babylon.d.txt 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vector3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param transform defines the transform (view x projection) matrix to use
  1851. * @returns the new Vector3
  1852. */
  1853. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param view defines the view matrix to use
  1861. * @param projection defines the projection matrix to use
  1862. * @returns the new Vector3
  1863. */
  1864. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1865. /**
  1866. * Unproject from screen space to object space
  1867. * @param source defines the screen space Vector3 to use
  1868. * @param viewportWidth defines the current width of the viewport
  1869. * @param viewportHeight defines the current height of the viewport
  1870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1871. * @param view defines the view matrix to use
  1872. * @param projection defines the projection matrix to use
  1873. * @param result defines the Vector3 where to store the result
  1874. */
  1875. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1876. /**
  1877. * Unproject from screen space to object space
  1878. * @param sourceX defines the screen space x coordinate to use
  1879. * @param sourceY defines the screen space y coordinate to use
  1880. * @param sourceZ defines the screen space z coordinate to use
  1881. * @param viewportWidth defines the current width of the viewport
  1882. * @param viewportHeight defines the current height of the viewport
  1883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1884. * @param view defines the view matrix to use
  1885. * @param projection defines the projection matrix to use
  1886. * @param result defines the Vector3 where to store the result
  1887. */
  1888. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1889. /**
  1890. * Gets the minimal coordinate values between two Vector3
  1891. * @param left defines the first operand
  1892. * @param right defines the second operand
  1893. * @returns the new Vector3
  1894. */
  1895. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1896. /**
  1897. * Gets the maximal coordinate values between two Vector3
  1898. * @param left defines the first operand
  1899. * @param right defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Returns the distance between the vectors "value1" and "value2"
  1905. * @param value1 defines the first operand
  1906. * @param value2 defines the second operand
  1907. * @returns the distance
  1908. */
  1909. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1910. /**
  1911. * Returns the squared distance between the vectors "value1" and "value2"
  1912. * @param value1 defines the first operand
  1913. * @param value2 defines the second operand
  1914. * @returns the squared distance
  1915. */
  1916. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1917. /**
  1918. * Returns a new Vector3 located at the center between "value1" and "value2"
  1919. * @param value1 defines the first operand
  1920. * @param value2 defines the second operand
  1921. * @returns the new Vector3
  1922. */
  1923. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1924. /**
  1925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1927. * to something in order to rotate it from its local system to the given target system
  1928. * Note: axis1, axis2 and axis3 are normalized during this operation
  1929. * @param axis1 defines the first axis
  1930. * @param axis2 defines the second axis
  1931. * @param axis3 defines the third axis
  1932. * @returns a new Vector3
  1933. */
  1934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1935. /**
  1936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1937. * @param axis1 defines the first axis
  1938. * @param axis2 defines the second axis
  1939. * @param axis3 defines the third axis
  1940. * @param ref defines the Vector3 where to store the result
  1941. */
  1942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1943. }
  1944. /**
  1945. * Vector4 class created for EulerAngle class conversion to Quaternion
  1946. */
  1947. export class Vector4 {
  1948. /** x value of the vector */
  1949. x: number;
  1950. /** y value of the vector */
  1951. y: number;
  1952. /** z value of the vector */
  1953. z: number;
  1954. /** w value of the vector */
  1955. w: number;
  1956. /**
  1957. * Creates a Vector4 object from the given floats.
  1958. * @param x x value of the vector
  1959. * @param y y value of the vector
  1960. * @param z z value of the vector
  1961. * @param w w value of the vector
  1962. */
  1963. constructor(
  1964. /** x value of the vector */
  1965. x: number,
  1966. /** y value of the vector */
  1967. y: number,
  1968. /** z value of the vector */
  1969. z: number,
  1970. /** w value of the vector */
  1971. w: number);
  1972. /**
  1973. * Returns the string with the Vector4 coordinates.
  1974. * @returns a string containing all the vector values
  1975. */
  1976. toString(): string;
  1977. /**
  1978. * Returns the string "Vector4".
  1979. * @returns "Vector4"
  1980. */
  1981. getClassName(): string;
  1982. /**
  1983. * Returns the Vector4 hash code.
  1984. * @returns a unique hash code
  1985. */
  1986. getHashCode(): number;
  1987. /**
  1988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1989. * @returns the resulting array
  1990. */
  1991. asArray(): number[];
  1992. /**
  1993. * Populates the given array from the given index with the Vector4 coordinates.
  1994. * @param array array to populate
  1995. * @param index index of the array to start at (default: 0)
  1996. * @returns the Vector4.
  1997. */
  1998. toArray(array: FloatArray, index?: number): Vector4;
  1999. /**
  2000. * Adds the given vector to the current Vector4.
  2001. * @param otherVector the vector to add
  2002. * @returns the updated Vector4.
  2003. */
  2004. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2005. /**
  2006. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2007. * @param otherVector the vector to add
  2008. * @returns the resulting vector
  2009. */
  2010. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2011. /**
  2012. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2013. * @param otherVector the vector to add
  2014. * @param result the vector to store the result
  2015. * @returns the current Vector4.
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2018. /**
  2019. * Subtract in place the given vector from the current Vector4.
  2020. * @param otherVector the vector to subtract
  2021. * @returns the updated Vector4.
  2022. */
  2023. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2024. /**
  2025. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2026. * @param otherVector the vector to add
  2027. * @returns the new vector with the result
  2028. */
  2029. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2030. /**
  2031. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2032. * @param otherVector the vector to subtract
  2033. * @param result the vector to store the result
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2039. */
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. * @param x value to subtract
  2043. * @param y value to subtract
  2044. * @param z value to subtract
  2045. * @param w value to subtract
  2046. * @returns new vector containing the result
  2047. */
  2048. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2049. /**
  2050. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2051. * @param x value to subtract
  2052. * @param y value to subtract
  2053. * @param z value to subtract
  2054. * @param w value to subtract
  2055. * @param result the vector to store the result in
  2056. * @returns the current Vector4.
  2057. */
  2058. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2059. /**
  2060. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2061. * @returns a new vector with the negated values
  2062. */
  2063. negate(): Vector4;
  2064. /**
  2065. * Multiplies the current Vector4 coordinates by scale (float).
  2066. * @param scale the number to scale with
  2067. * @returns the updated Vector4.
  2068. */
  2069. scaleInPlace(scale: number): Vector4;
  2070. /**
  2071. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2072. * @param scale the number to scale with
  2073. * @returns a new vector with the result
  2074. */
  2075. scale(scale: number): Vector4;
  2076. /**
  2077. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2078. * @param scale the number to scale with
  2079. * @param result a vector to store the result in
  2080. * @returns the current Vector4.
  2081. */
  2082. scaleToRef(scale: number, result: Vector4): Vector4;
  2083. /**
  2084. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2085. * @param scale defines the scale factor
  2086. * @param result defines the Vector4 object where to store the result
  2087. * @returns the unmodified current Vector4
  2088. */
  2089. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2090. /**
  2091. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2092. * @param otherVector the vector to compare against
  2093. * @returns true if they are equal
  2094. */
  2095. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2096. /**
  2097. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2098. * @param otherVector vector to compare against
  2099. * @param epsilon (Default: very small number)
  2100. * @returns true if they are equal
  2101. */
  2102. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2103. /**
  2104. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2105. * @param x x value to compare against
  2106. * @param y y value to compare against
  2107. * @param z z value to compare against
  2108. * @param w w value to compare against
  2109. * @returns true if equal
  2110. */
  2111. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2112. /**
  2113. * Multiplies in place the current Vector4 by the given one.
  2114. * @param otherVector vector to multiple with
  2115. * @returns the updated Vector4.
  2116. */
  2117. multiplyInPlace(otherVector: Vector4): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2120. * @param otherVector vector to multiple with
  2121. * @returns resulting new vector
  2122. */
  2123. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2126. * @param otherVector vector to multiple with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2133. * @param x x value multiply with
  2134. * @param y y value multiply with
  2135. * @param z z value multiply with
  2136. * @param w w value multiply with
  2137. * @returns resulting new vector
  2138. */
  2139. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2140. /**
  2141. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2142. * @param otherVector vector to devide with
  2143. * @returns resulting new vector
  2144. */
  2145. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2146. /**
  2147. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2148. * @param otherVector vector to devide with
  2149. * @param result vector to store the result
  2150. * @returns the current Vector4.
  2151. */
  2152. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2153. /**
  2154. * Divides the current Vector3 coordinates by the given ones.
  2155. * @param otherVector vector to devide with
  2156. * @returns the updated Vector3.
  2157. */
  2158. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2159. /**
  2160. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2161. * @param other defines the second operand
  2162. * @returns the current updated Vector4
  2163. */
  2164. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2165. /**
  2166. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2167. * @param other defines the second operand
  2168. * @returns the current updated Vector4
  2169. */
  2170. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2171. /**
  2172. * Gets a new Vector4 from current Vector4 floored values
  2173. * @returns a new Vector4
  2174. */
  2175. floor(): Vector4;
  2176. /**
  2177. * Gets a new Vector4 from current Vector3 floored values
  2178. * @returns a new Vector4
  2179. */
  2180. fract(): Vector4;
  2181. /**
  2182. * Returns the Vector4 length (float).
  2183. * @returns the length
  2184. */
  2185. length(): number;
  2186. /**
  2187. * Returns the Vector4 squared length (float).
  2188. * @returns the length squared
  2189. */
  2190. lengthSquared(): number;
  2191. /**
  2192. * Normalizes in place the Vector4.
  2193. * @returns the updated Vector4.
  2194. */
  2195. normalize(): Vector4;
  2196. /**
  2197. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2198. * @returns this converted to a new vector3
  2199. */
  2200. toVector3(): Vector3;
  2201. /**
  2202. * Returns a new Vector4 copied from the current one.
  2203. * @returns the new cloned vector
  2204. */
  2205. clone(): Vector4;
  2206. /**
  2207. * Updates the current Vector4 with the given one coordinates.
  2208. * @param source the source vector to copy from
  2209. * @returns the updated Vector4.
  2210. */
  2211. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2212. /**
  2213. * Updates the current Vector4 coordinates with the given floats.
  2214. * @param x float to copy from
  2215. * @param y float to copy from
  2216. * @param z float to copy from
  2217. * @param w float to copy from
  2218. * @returns the updated Vector4.
  2219. */
  2220. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2221. /**
  2222. * Updates the current Vector4 coordinates with the given floats.
  2223. * @param x float to set from
  2224. * @param y float to set from
  2225. * @param z float to set from
  2226. * @param w float to set from
  2227. * @returns the updated Vector4.
  2228. */
  2229. set(x: number, y: number, z: number, w: number): Vector4;
  2230. /**
  2231. * Copies the given float to the current Vector3 coordinates
  2232. * @param v defines the x, y, z and w coordinates of the operand
  2233. * @returns the current updated Vector3
  2234. */
  2235. setAll(v: number): Vector4;
  2236. /**
  2237. * Returns a new Vector4 set from the starting index of the given array.
  2238. * @param array the array to pull values from
  2239. * @param offset the offset into the array to start at
  2240. * @returns the new vector
  2241. */
  2242. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2243. /**
  2244. * Updates the given vector "result" from the starting index of the given array.
  2245. * @param array the array to pull values from
  2246. * @param offset the offset into the array to start at
  2247. * @param result the vector to store the result in
  2248. */
  2249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2250. /**
  2251. * Updates the given vector "result" from the starting index of the given Float32Array.
  2252. * @param array the array to pull values from
  2253. * @param offset the offset into the array to start at
  2254. * @param result the vector to store the result in
  2255. */
  2256. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2257. /**
  2258. * Updates the given vector "result" coordinates from the given floats.
  2259. * @param x float to set from
  2260. * @param y float to set from
  2261. * @param z float to set from
  2262. * @param w float to set from
  2263. * @param result the vector to the floats in
  2264. */
  2265. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2266. /**
  2267. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2268. * @returns the new vector
  2269. */
  2270. static Zero(): Vector4;
  2271. /**
  2272. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2273. * @returns the new vector
  2274. */
  2275. static One(): Vector4;
  2276. /**
  2277. * Returns a new normalized Vector4 from the given one.
  2278. * @param vector the vector to normalize
  2279. * @returns the vector
  2280. */
  2281. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Updates the given vector "result" from the normalization of the given one.
  2284. * @param vector the vector to normalize
  2285. * @param result the vector to store the result in
  2286. */
  2287. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2288. /**
  2289. * Returns a vector with the minimum values from the left and right vectors
  2290. * @param left left vector to minimize
  2291. * @param right right vector to minimize
  2292. * @returns a new vector with the minimum of the left and right vector values
  2293. */
  2294. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2295. /**
  2296. * Returns a vector with the maximum values from the left and right vectors
  2297. * @param left left vector to maximize
  2298. * @param right right vector to maximize
  2299. * @returns a new vector with the maximum of the left and right vector values
  2300. */
  2301. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns the distance (float) between the vectors "value1" and "value2".
  2304. * @param value1 value to calulate the distance between
  2305. * @param value2 value to calulate the distance between
  2306. * @return the distance between the two vectors
  2307. */
  2308. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2309. /**
  2310. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2311. * @param value1 value to calulate the distance between
  2312. * @param value2 value to calulate the distance between
  2313. * @return the distance between the two vectors squared
  2314. */
  2315. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2316. /**
  2317. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2318. * @param value1 value to calulate the center between
  2319. * @param value2 value to calulate the center between
  2320. * @return the center between the two vectors
  2321. */
  2322. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2323. /**
  2324. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2325. * This methods computes transformed normalized direction vectors only.
  2326. * @param vector the vector to transform
  2327. * @param transformation the transformation matrix to apply
  2328. * @returns the new vector
  2329. */
  2330. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2331. /**
  2332. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2333. * This methods computes transformed normalized direction vectors only.
  2334. * @param vector the vector to transform
  2335. * @param transformation the transformation matrix to apply
  2336. * @param result the vector to store the result in
  2337. */
  2338. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2339. /**
  2340. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2341. * This methods computes transformed normalized direction vectors only.
  2342. * @param x value to transform
  2343. * @param y value to transform
  2344. * @param z value to transform
  2345. * @param w value to transform
  2346. * @param transformation the transformation matrix to apply
  2347. * @param result the vector to store the results in
  2348. */
  2349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2350. /**
  2351. * Creates a new Vector4 from a Vector3
  2352. * @param source defines the source data
  2353. * @param w defines the 4th component (default is 0)
  2354. * @returns a new Vector4
  2355. */
  2356. static FromVector3(source: Vector3, w?: number): Vector4;
  2357. }
  2358. /**
  2359. * Interface for the size containing width and height
  2360. */
  2361. export interface ISize {
  2362. /**
  2363. * Width
  2364. */
  2365. width: number;
  2366. /**
  2367. * Heighht
  2368. */
  2369. height: number;
  2370. }
  2371. /**
  2372. * Size containing widht and height
  2373. */
  2374. export class Size implements ISize {
  2375. /**
  2376. * Width
  2377. */
  2378. width: number;
  2379. /**
  2380. * Height
  2381. */
  2382. height: number;
  2383. /**
  2384. * Creates a Size object from the given width and height (floats).
  2385. * @param width width of the new size
  2386. * @param height height of the new size
  2387. */
  2388. constructor(width: number, height: number);
  2389. /**
  2390. * Returns a string with the Size width and height
  2391. * @returns a string with the Size width and height
  2392. */
  2393. toString(): string;
  2394. /**
  2395. * "Size"
  2396. * @returns the string "Size"
  2397. */
  2398. getClassName(): string;
  2399. /**
  2400. * Returns the Size hash code.
  2401. * @returns a hash code for a unique width and height
  2402. */
  2403. getHashCode(): number;
  2404. /**
  2405. * Updates the current size from the given one.
  2406. * @param src the given size
  2407. */
  2408. copyFrom(src: Size): void;
  2409. /**
  2410. * Updates in place the current Size from the given floats.
  2411. * @param width width of the new size
  2412. * @param height height of the new size
  2413. * @returns the updated Size.
  2414. */
  2415. copyFromFloats(width: number, height: number): Size;
  2416. /**
  2417. * Updates in place the current Size from the given floats.
  2418. * @param width width to set
  2419. * @param height height to set
  2420. * @returns the updated Size.
  2421. */
  2422. set(width: number, height: number): Size;
  2423. /**
  2424. * Multiplies the width and height by numbers
  2425. * @param w factor to multiple the width by
  2426. * @param h factor to multiple the height by
  2427. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2428. */
  2429. multiplyByFloats(w: number, h: number): Size;
  2430. /**
  2431. * Clones the size
  2432. * @returns a new Size copied from the given one.
  2433. */
  2434. clone(): Size;
  2435. /**
  2436. * True if the current Size and the given one width and height are strictly equal.
  2437. * @param other the other size to compare against
  2438. * @returns True if the current Size and the given one width and height are strictly equal.
  2439. */
  2440. equals(other: Size): boolean;
  2441. /**
  2442. * The surface of the Size : width * height (float).
  2443. */
  2444. readonly surface: number;
  2445. /**
  2446. * Create a new size of zero
  2447. * @returns a new Size set to (0.0, 0.0)
  2448. */
  2449. static Zero(): Size;
  2450. /**
  2451. * Sums the width and height of two sizes
  2452. * @param otherSize size to add to this size
  2453. * @returns a new Size set as the addition result of the current Size and the given one.
  2454. */
  2455. add(otherSize: Size): Size;
  2456. /**
  2457. * Subtracts the width and height of two
  2458. * @param otherSize size to subtract to this size
  2459. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2460. */
  2461. subtract(otherSize: Size): Size;
  2462. /**
  2463. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2464. * @param start starting size to lerp between
  2465. * @param end end size to lerp between
  2466. * @param amount amount to lerp between the start and end values
  2467. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2468. */
  2469. static Lerp(start: Size, end: Size, amount: number): Size;
  2470. }
  2471. /**
  2472. * Class used to store quaternion data
  2473. * @see https://en.wikipedia.org/wiki/Quaternion
  2474. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2475. */
  2476. export class Quaternion {
  2477. /** defines the first component (0 by default) */
  2478. x: number;
  2479. /** defines the second component (0 by default) */
  2480. y: number;
  2481. /** defines the third component (0 by default) */
  2482. z: number;
  2483. /** defines the fourth component (1.0 by default) */
  2484. w: number;
  2485. /**
  2486. * Creates a new Quaternion from the given floats
  2487. * @param x defines the first component (0 by default)
  2488. * @param y defines the second component (0 by default)
  2489. * @param z defines the third component (0 by default)
  2490. * @param w defines the fourth component (1.0 by default)
  2491. */
  2492. constructor(
  2493. /** defines the first component (0 by default) */
  2494. x?: number,
  2495. /** defines the second component (0 by default) */
  2496. y?: number,
  2497. /** defines the third component (0 by default) */
  2498. z?: number,
  2499. /** defines the fourth component (1.0 by default) */
  2500. w?: number);
  2501. /**
  2502. * Gets a string representation for the current quaternion
  2503. * @returns a string with the Quaternion coordinates
  2504. */
  2505. toString(): string;
  2506. /**
  2507. * Gets the class name of the quaternion
  2508. * @returns the string "Quaternion"
  2509. */
  2510. getClassName(): string;
  2511. /**
  2512. * Gets a hash code for this quaternion
  2513. * @returns the quaternion hash code
  2514. */
  2515. getHashCode(): number;
  2516. /**
  2517. * Copy the quaternion to an array
  2518. * @returns a new array populated with 4 elements from the quaternion coordinates
  2519. */
  2520. asArray(): number[];
  2521. /**
  2522. * Check if two quaternions are equals
  2523. * @param otherQuaternion defines the second operand
  2524. * @return true if the current quaternion and the given one coordinates are strictly equals
  2525. */
  2526. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2527. /**
  2528. * Clone the current quaternion
  2529. * @returns a new quaternion copied from the current one
  2530. */
  2531. clone(): Quaternion;
  2532. /**
  2533. * Copy a quaternion to the current one
  2534. * @param other defines the other quaternion
  2535. * @returns the updated current quaternion
  2536. */
  2537. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2538. /**
  2539. * Updates the current quaternion with the given float coordinates
  2540. * @param x defines the x coordinate
  2541. * @param y defines the y coordinate
  2542. * @param z defines the z coordinate
  2543. * @param w defines the w coordinate
  2544. * @returns the updated current quaternion
  2545. */
  2546. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2547. /**
  2548. * Updates the current quaternion from the given float coordinates
  2549. * @param x defines the x coordinate
  2550. * @param y defines the y coordinate
  2551. * @param z defines the z coordinate
  2552. * @param w defines the w coordinate
  2553. * @returns the updated current quaternion
  2554. */
  2555. set(x: number, y: number, z: number, w: number): Quaternion;
  2556. /**
  2557. * Adds two quaternions
  2558. * @param other defines the second operand
  2559. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2560. */
  2561. add(other: DeepImmutable<Quaternion>): Quaternion;
  2562. /**
  2563. * Add a quaternion to the current one
  2564. * @param other defines the quaternion to add
  2565. * @returns the current quaternion
  2566. */
  2567. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2568. /**
  2569. * Subtract two quaternions
  2570. * @param other defines the second operand
  2571. * @returns a new quaternion as the subtraction result of the given one from the current one
  2572. */
  2573. subtract(other: Quaternion): Quaternion;
  2574. /**
  2575. * Multiplies the current quaternion by a scale factor
  2576. * @param value defines the scale factor
  2577. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2578. */
  2579. scale(value: number): Quaternion;
  2580. /**
  2581. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2582. * @param scale defines the scale factor
  2583. * @param result defines the Quaternion object where to store the result
  2584. * @returns the unmodified current quaternion
  2585. */
  2586. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2587. /**
  2588. * Multiplies in place the current quaternion by a scale factor
  2589. * @param value defines the scale factor
  2590. * @returns the current modified quaternion
  2591. */
  2592. scaleInPlace(value: number): Quaternion;
  2593. /**
  2594. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2595. * @param scale defines the scale factor
  2596. * @param result defines the Quaternion object where to store the result
  2597. * @returns the unmodified current quaternion
  2598. */
  2599. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2600. /**
  2601. * Multiplies two quaternions
  2602. * @param q1 defines the second operand
  2603. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2604. */
  2605. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2606. /**
  2607. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2608. * @param q1 defines the second operand
  2609. * @param result defines the target quaternion
  2610. * @returns the current quaternion
  2611. */
  2612. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2613. /**
  2614. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2615. * @param q1 defines the second operand
  2616. * @returns the currentupdated quaternion
  2617. */
  2618. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2619. /**
  2620. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2621. * @param ref defines the target quaternion
  2622. * @returns the current quaternion
  2623. */
  2624. conjugateToRef(ref: Quaternion): Quaternion;
  2625. /**
  2626. * Conjugates in place (1-q) the current quaternion
  2627. * @returns the current updated quaternion
  2628. */
  2629. conjugateInPlace(): Quaternion;
  2630. /**
  2631. * Conjugates in place (1-q) the current quaternion
  2632. * @returns a new quaternion
  2633. */
  2634. conjugate(): Quaternion;
  2635. /**
  2636. * Gets length of current quaternion
  2637. * @returns the quaternion length (float)
  2638. */
  2639. length(): number;
  2640. /**
  2641. * Normalize in place the current quaternion
  2642. * @returns the current updated quaternion
  2643. */
  2644. normalize(): Quaternion;
  2645. /**
  2646. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2647. * @param order is a reserved parameter and is ignore for now
  2648. * @returns a new Vector3 containing the Euler angles
  2649. */
  2650. toEulerAngles(order?: string): Vector3;
  2651. /**
  2652. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2653. * @param result defines the vector which will be filled with the Euler angles
  2654. * @param order is a reserved parameter and is ignore for now
  2655. * @returns the current unchanged quaternion
  2656. */
  2657. toEulerAnglesToRef(result: Vector3): Quaternion;
  2658. /**
  2659. * Updates the given rotation matrix with the current quaternion values
  2660. * @param result defines the target matrix
  2661. * @returns the current unchanged quaternion
  2662. */
  2663. toRotationMatrix(result: Matrix): Quaternion;
  2664. /**
  2665. * Updates the current quaternion from the given rotation matrix values
  2666. * @param matrix defines the source matrix
  2667. * @returns the current updated quaternion
  2668. */
  2669. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2670. /**
  2671. * Creates a new quaternion from a rotation matrix
  2672. * @param matrix defines the source matrix
  2673. * @returns a new quaternion created from the given rotation matrix values
  2674. */
  2675. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2676. /**
  2677. * Updates the given quaternion with the given rotation matrix values
  2678. * @param matrix defines the source matrix
  2679. * @param result defines the target quaternion
  2680. */
  2681. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2682. /**
  2683. * Returns the dot product (float) between the quaternions "left" and "right"
  2684. * @param left defines the left operand
  2685. * @param right defines the right operand
  2686. * @returns the dot product
  2687. */
  2688. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2689. /**
  2690. * Checks if the two quaternions are close to each other
  2691. * @param quat0 defines the first quaternion to check
  2692. * @param quat1 defines the second quaternion to check
  2693. * @returns true if the two quaternions are close to each other
  2694. */
  2695. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2696. /**
  2697. * Creates an empty quaternion
  2698. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2699. */
  2700. static Zero(): Quaternion;
  2701. /**
  2702. * Inverse a given quaternion
  2703. * @param q defines the source quaternion
  2704. * @returns a new quaternion as the inverted current quaternion
  2705. */
  2706. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2707. /**
  2708. * Inverse a given quaternion
  2709. * @param q defines the source quaternion
  2710. * @param result the quaternion the result will be stored in
  2711. * @returns the result quaternion
  2712. */
  2713. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2714. /**
  2715. * Creates an identity quaternion
  2716. * @returns the identity quaternion
  2717. */
  2718. static Identity(): Quaternion;
  2719. /**
  2720. * Gets a boolean indicating if the given quaternion is identity
  2721. * @param quaternion defines the quaternion to check
  2722. * @returns true if the quaternion is identity
  2723. */
  2724. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2725. /**
  2726. * Creates a quaternion from a rotation around an axis
  2727. * @param axis defines the axis to use
  2728. * @param angle defines the angle to use
  2729. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2730. */
  2731. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2732. /**
  2733. * Creates a rotation around an axis and stores it into the given quaternion
  2734. * @param axis defines the axis to use
  2735. * @param angle defines the angle to use
  2736. * @param result defines the target quaternion
  2737. * @returns the target quaternion
  2738. */
  2739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2740. /**
  2741. * Creates a new quaternion from data stored into an array
  2742. * @param array defines the data source
  2743. * @param offset defines the offset in the source array where the data starts
  2744. * @returns a new quaternion
  2745. */
  2746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2747. /**
  2748. * Create a quaternion from Euler rotation angles
  2749. * @param x Pitch
  2750. * @param y Yaw
  2751. * @param z Roll
  2752. * @returns the new Quaternion
  2753. */
  2754. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2755. /**
  2756. * Updates a quaternion from Euler rotation angles
  2757. * @param x Pitch
  2758. * @param y Yaw
  2759. * @param z Roll
  2760. * @param result the quaternion to store the result
  2761. * @returns the updated quaternion
  2762. */
  2763. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2764. /**
  2765. * Create a quaternion from Euler rotation vector
  2766. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2767. * @returns the new Quaternion
  2768. */
  2769. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2770. /**
  2771. * Updates a quaternion from Euler rotation vector
  2772. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2773. * @param result the quaternion to store the result
  2774. * @returns the updated quaternion
  2775. */
  2776. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2777. /**
  2778. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2779. * @param yaw defines the rotation around Y axis
  2780. * @param pitch defines the rotation around X axis
  2781. * @param roll defines the rotation around Z axis
  2782. * @returns the new quaternion
  2783. */
  2784. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2785. /**
  2786. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2787. * @param yaw defines the rotation around Y axis
  2788. * @param pitch defines the rotation around X axis
  2789. * @param roll defines the rotation around Z axis
  2790. * @param result defines the target quaternion
  2791. */
  2792. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2793. /**
  2794. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2795. * @param alpha defines the rotation around first axis
  2796. * @param beta defines the rotation around second axis
  2797. * @param gamma defines the rotation around third axis
  2798. * @returns the new quaternion
  2799. */
  2800. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2801. /**
  2802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2803. * @param alpha defines the rotation around first axis
  2804. * @param beta defines the rotation around second axis
  2805. * @param gamma defines the rotation around third axis
  2806. * @param result defines the target quaternion
  2807. */
  2808. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2809. /**
  2810. * 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)
  2811. * @param axis1 defines the first axis
  2812. * @param axis2 defines the second axis
  2813. * @param axis3 defines the third axis
  2814. * @returns the new quaternion
  2815. */
  2816. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2817. /**
  2818. * 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
  2819. * @param axis1 defines the first axis
  2820. * @param axis2 defines the second axis
  2821. * @param axis3 defines the third axis
  2822. * @param ref defines the target quaternion
  2823. */
  2824. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2825. /**
  2826. * Interpolates between two quaternions
  2827. * @param left defines first quaternion
  2828. * @param right defines second quaternion
  2829. * @param amount defines the gradient to use
  2830. * @returns the new interpolated quaternion
  2831. */
  2832. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2833. /**
  2834. * Interpolates between two quaternions and stores it into a target quaternion
  2835. * @param left defines first quaternion
  2836. * @param right defines second quaternion
  2837. * @param amount defines the gradient to use
  2838. * @param result defines the target quaternion
  2839. */
  2840. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2841. /**
  2842. * Interpolate between two quaternions using Hermite interpolation
  2843. * @param value1 defines first quaternion
  2844. * @param tangent1 defines the incoming tangent
  2845. * @param value2 defines second quaternion
  2846. * @param tangent2 defines the outgoing tangent
  2847. * @param amount defines the target quaternion
  2848. * @returns the new interpolated quaternion
  2849. */
  2850. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2851. }
  2852. /**
  2853. * Class used to store matrix data (4x4)
  2854. */
  2855. export class Matrix {
  2856. private static _updateFlagSeed;
  2857. private static _identityReadOnly;
  2858. private _isIdentity;
  2859. private _isIdentityDirty;
  2860. private _isIdentity3x2;
  2861. private _isIdentity3x2Dirty;
  2862. /**
  2863. * Gets the update flag of the matrix which is an unique number for the matrix.
  2864. * It will be incremented every time the matrix data change.
  2865. * You can use it to speed the comparison between two versions of the same matrix.
  2866. */
  2867. updateFlag: number;
  2868. private readonly _m;
  2869. /**
  2870. * Gets the internal data of the matrix
  2871. */
  2872. readonly m: DeepImmutable<Float32Array>;
  2873. /** @hidden */ private _markAsUpdated(): void;
  2874. /** @hidden */
  2875. private _updateIdentityStatus;
  2876. /**
  2877. * Creates an empty matrix (filled with zeros)
  2878. */
  2879. constructor();
  2880. /**
  2881. * Check if the current matrix is identity
  2882. * @returns true is the matrix is the identity matrix
  2883. */
  2884. isIdentity(): boolean;
  2885. /**
  2886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2887. * @returns true is the matrix is the identity matrix
  2888. */
  2889. isIdentityAs3x2(): boolean;
  2890. /**
  2891. * Gets the determinant of the matrix
  2892. * @returns the matrix determinant
  2893. */
  2894. determinant(): number;
  2895. /**
  2896. * Returns the matrix as a Float32Array
  2897. * @returns the matrix underlying array
  2898. */
  2899. toArray(): DeepImmutable<Float32Array>;
  2900. /**
  2901. * Returns the matrix as a Float32Array
  2902. * @returns the matrix underlying array.
  2903. */
  2904. asArray(): DeepImmutable<Float32Array>;
  2905. /**
  2906. * Inverts the current matrix in place
  2907. * @returns the current inverted matrix
  2908. */
  2909. invert(): Matrix;
  2910. /**
  2911. * Sets all the matrix elements to zero
  2912. * @returns the current matrix
  2913. */
  2914. reset(): Matrix;
  2915. /**
  2916. * Adds the current matrix with a second one
  2917. * @param other defines the matrix to add
  2918. * @returns a new matrix as the addition of the current matrix and the given one
  2919. */
  2920. add(other: DeepImmutable<Matrix>): Matrix;
  2921. /**
  2922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2923. * @param other defines the matrix to add
  2924. * @param result defines the target matrix
  2925. * @returns the current matrix
  2926. */
  2927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2928. /**
  2929. * Adds in place the given matrix to the current matrix
  2930. * @param other defines the second operand
  2931. * @returns the current updated matrix
  2932. */
  2933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2934. /**
  2935. * Sets the given matrix to the current inverted Matrix
  2936. * @param other defines the target matrix
  2937. * @returns the unmodified current matrix
  2938. */
  2939. invertToRef(other: Matrix): Matrix;
  2940. /**
  2941. * add a value at the specified position in the current Matrix
  2942. * @param index the index of the value within the matrix. between 0 and 15.
  2943. * @param value the value to be added
  2944. * @returns the current updated matrix
  2945. */
  2946. addAtIndex(index: number, value: number): Matrix;
  2947. /**
  2948. * mutiply the specified position in the current Matrix by a value
  2949. * @param index the index of the value within the matrix. between 0 and 15.
  2950. * @param value the value to be added
  2951. * @returns the current updated matrix
  2952. */
  2953. multiplyAtIndex(index: number, value: number): Matrix;
  2954. /**
  2955. * Inserts the translation vector (using 3 floats) in the current matrix
  2956. * @param x defines the 1st component of the translation
  2957. * @param y defines the 2nd component of the translation
  2958. * @param z defines the 3rd component of the translation
  2959. * @returns the current updated matrix
  2960. */
  2961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2962. /**
  2963. * Adds the translation vector (using 3 floats) in the current matrix
  2964. * @param x defines the 1st component of the translation
  2965. * @param y defines the 2nd component of the translation
  2966. * @param z defines the 3rd component of the translation
  2967. * @returns the current updated matrix
  2968. */
  2969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2970. /**
  2971. * Inserts the translation vector in the current matrix
  2972. * @param vector3 defines the translation to insert
  2973. * @returns the current updated matrix
  2974. */
  2975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2976. /**
  2977. * Gets the translation value of the current matrix
  2978. * @returns a new Vector3 as the extracted translation from the matrix
  2979. */
  2980. getTranslation(): Vector3;
  2981. /**
  2982. * Fill a Vector3 with the extracted translation from the matrix
  2983. * @param result defines the Vector3 where to store the translation
  2984. * @returns the current matrix
  2985. */
  2986. getTranslationToRef(result: Vector3): Matrix;
  2987. /**
  2988. * Remove rotation and scaling part from the matrix
  2989. * @returns the updated matrix
  2990. */
  2991. removeRotationAndScaling(): Matrix;
  2992. /**
  2993. * Multiply two matrices
  2994. * @param other defines the second operand
  2995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2996. */
  2997. multiply(other: DeepImmutable<Matrix>): Matrix;
  2998. /**
  2999. * Copy the current matrix from the given one
  3000. * @param other defines the source matrix
  3001. * @returns the current updated matrix
  3002. */
  3003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3004. /**
  3005. * Populates the given array from the starting index with the current matrix values
  3006. * @param array defines the target array
  3007. * @param offset defines the offset in the target array where to start storing values
  3008. * @returns the current matrix
  3009. */
  3010. copyToArray(array: Float32Array, offset?: number): Matrix;
  3011. /**
  3012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3013. * @param other defines the second operand
  3014. * @param result defines the matrix where to store the multiplication
  3015. * @returns the current matrix
  3016. */
  3017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3018. /**
  3019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3020. * @param other defines the second operand
  3021. * @param result defines the array where to store the multiplication
  3022. * @param offset defines the offset in the target array where to start storing values
  3023. * @returns the current matrix
  3024. */
  3025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3026. /**
  3027. * Check equality between this matrix and a second one
  3028. * @param value defines the second matrix to compare
  3029. * @returns true is the current matrix and the given one values are strictly equal
  3030. */
  3031. equals(value: DeepImmutable<Matrix>): boolean;
  3032. /**
  3033. * Clone the current matrix
  3034. * @returns a new matrix from the current matrix
  3035. */
  3036. clone(): Matrix;
  3037. /**
  3038. * Returns the name of the current matrix class
  3039. * @returns the string "Matrix"
  3040. */
  3041. getClassName(): string;
  3042. /**
  3043. * Gets the hash code of the current matrix
  3044. * @returns the hash code
  3045. */
  3046. getHashCode(): number;
  3047. /**
  3048. * Decomposes the current Matrix into a translation, rotation and scaling components
  3049. * @param scale defines the scale vector3 given as a reference to update
  3050. * @param rotation defines the rotation quaternion given as a reference to update
  3051. * @param translation defines the translation vector3 given as a reference to update
  3052. * @returns true if operation was successful
  3053. */
  3054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3055. /**
  3056. * Gets specific row of the matrix
  3057. * @param index defines the number of the row to get
  3058. * @returns the index-th row of the current matrix as a new Vector4
  3059. */
  3060. getRow(index: number): Nullable<Vector4>;
  3061. /**
  3062. * Sets the index-th row of the current matrix to the vector4 values
  3063. * @param index defines the number of the row to set
  3064. * @param row defines the target vector4
  3065. * @returns the updated current matrix
  3066. */
  3067. setRow(index: number, row: Vector4): Matrix;
  3068. /**
  3069. * Compute the transpose of the matrix
  3070. * @returns the new transposed matrix
  3071. */
  3072. transpose(): Matrix;
  3073. /**
  3074. * Compute the transpose of the matrix and store it in a given matrix
  3075. * @param result defines the target matrix
  3076. * @returns the current matrix
  3077. */
  3078. transposeToRef(result: Matrix): Matrix;
  3079. /**
  3080. * Sets the index-th row of the current matrix with the given 4 x float values
  3081. * @param index defines the row index
  3082. * @param x defines the x component to set
  3083. * @param y defines the y component to set
  3084. * @param z defines the z component to set
  3085. * @param w defines the w component to set
  3086. * @returns the updated current matrix
  3087. */
  3088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3089. /**
  3090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3091. * @param scale defines the scale factor
  3092. * @returns a new matrix
  3093. */
  3094. scale(scale: number): Matrix;
  3095. /**
  3096. * Scale the current matrix values by a factor to a given result matrix
  3097. * @param scale defines the scale factor
  3098. * @param result defines the matrix to store the result
  3099. * @returns the current matrix
  3100. */
  3101. scaleToRef(scale: number, result: Matrix): Matrix;
  3102. /**
  3103. * Scale the current matrix values by a factor and add the result to a given matrix
  3104. * @param scale defines the scale factor
  3105. * @param result defines the Matrix to store the result
  3106. * @returns the current matrix
  3107. */
  3108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3109. /**
  3110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3111. * @param ref matrix to store the result
  3112. */
  3113. toNormalMatrix(ref: Matrix): void;
  3114. /**
  3115. * Gets only rotation part of the current matrix
  3116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3117. */
  3118. getRotationMatrix(): Matrix;
  3119. /**
  3120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3121. * @param result defines the target matrix to store data to
  3122. * @returns the current matrix
  3123. */
  3124. getRotationMatrixToRef(result: Matrix): Matrix;
  3125. /**
  3126. * Toggles model matrix from being right handed to left handed in place and vice versa
  3127. */
  3128. toggleModelMatrixHandInPlace(): void;
  3129. /**
  3130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleProjectionMatrixHandInPlace(): void;
  3133. /**
  3134. * Creates a matrix from an array
  3135. * @param array defines the source array
  3136. * @param offset defines an offset in the source array
  3137. * @returns a new Matrix set from the starting index of the given array
  3138. */
  3139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3140. /**
  3141. * Copy the content of an array into a given matrix
  3142. * @param array defines the source array
  3143. * @param offset defines an offset in the source array
  3144. * @param result defines the target matrix
  3145. */
  3146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3147. /**
  3148. * Stores an array into a matrix after having multiplied each component by a given factor
  3149. * @param array defines the source array
  3150. * @param offset defines the offset in the source array
  3151. * @param scale defines the scaling factor
  3152. * @param result defines the target matrix
  3153. */
  3154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3155. /**
  3156. * Gets an identity matrix that must not be updated
  3157. */
  3158. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3159. /**
  3160. * Stores a list of values (16) inside a given matrix
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @param result defines the target matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates new matrix from a list of values (16)
  3182. * @param initialM11 defines 1st value of 1st row
  3183. * @param initialM12 defines 2nd value of 1st row
  3184. * @param initialM13 defines 3rd value of 1st row
  3185. * @param initialM14 defines 4th value of 1st row
  3186. * @param initialM21 defines 1st value of 2nd row
  3187. * @param initialM22 defines 2nd value of 2nd row
  3188. * @param initialM23 defines 3rd value of 2nd row
  3189. * @param initialM24 defines 4th value of 2nd row
  3190. * @param initialM31 defines 1st value of 3rd row
  3191. * @param initialM32 defines 2nd value of 3rd row
  3192. * @param initialM33 defines 3rd value of 3rd row
  3193. * @param initialM34 defines 4th value of 3rd row
  3194. * @param initialM41 defines 1st value of 4th row
  3195. * @param initialM42 defines 2nd value of 4th row
  3196. * @param initialM43 defines 3rd value of 4th row
  3197. * @param initialM44 defines 4th value of 4th row
  3198. * @returns the new matrix
  3199. */
  3200. 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;
  3201. /**
  3202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3203. * @param scale defines the scale vector3
  3204. * @param rotation defines the rotation quaternion
  3205. * @param translation defines the translation vector3
  3206. * @returns a new matrix
  3207. */
  3208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3209. /**
  3210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3211. * @param scale defines the scale vector3
  3212. * @param rotation defines the rotation quaternion
  3213. * @param translation defines the translation vector3
  3214. * @param result defines the target matrix
  3215. */
  3216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3217. /**
  3218. * Creates a new identity matrix
  3219. * @returns a new identity matrix
  3220. */
  3221. static Identity(): Matrix;
  3222. /**
  3223. * Creates a new identity matrix and stores the result in a given matrix
  3224. * @param result defines the target matrix
  3225. */
  3226. static IdentityToRef(result: Matrix): void;
  3227. /**
  3228. * Creates a new zero matrix
  3229. * @returns a new zero matrix
  3230. */
  3231. static Zero(): Matrix;
  3232. /**
  3233. * Creates a new rotation matrix for "angle" radians around the X axis
  3234. * @param angle defines the angle (in radians) to use
  3235. * @return the new matrix
  3236. */
  3237. static RotationX(angle: number): Matrix;
  3238. /**
  3239. * Creates a new matrix as the invert of a given matrix
  3240. * @param source defines the source matrix
  3241. * @returns the new matrix
  3242. */
  3243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3244. /**
  3245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3246. * @param angle defines the angle (in radians) to use
  3247. * @param result defines the target matrix
  3248. */
  3249. static RotationXToRef(angle: number, result: Matrix): void;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the Y axis
  3252. * @param angle defines the angle (in radians) to use
  3253. * @return the new matrix
  3254. */
  3255. static RotationY(angle: number): Matrix;
  3256. /**
  3257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3258. * @param angle defines the angle (in radians) to use
  3259. * @param result defines the target matrix
  3260. */
  3261. static RotationYToRef(angle: number, result: Matrix): void;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the Z axis
  3264. * @param angle defines the angle (in radians) to use
  3265. * @return the new matrix
  3266. */
  3267. static RotationZ(angle: number): Matrix;
  3268. /**
  3269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3270. * @param angle defines the angle (in radians) to use
  3271. * @param result defines the target matrix
  3272. */
  3273. static RotationZToRef(angle: number, result: Matrix): void;
  3274. /**
  3275. * Creates a new rotation matrix for "angle" radians around the given axis
  3276. * @param axis defines the axis to use
  3277. * @param angle defines the angle (in radians) to use
  3278. * @return the new matrix
  3279. */
  3280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3281. /**
  3282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3283. * @param axis defines the axis to use
  3284. * @param angle defines the angle (in radians) to use
  3285. * @param result defines the target matrix
  3286. */
  3287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3288. /**
  3289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3291. * @param from defines the vector to align
  3292. * @param to defines the vector to align to
  3293. * @param result defines the target matrix
  3294. */
  3295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3296. /**
  3297. * Creates a rotation matrix
  3298. * @param yaw defines the yaw angle in radians (Y axis)
  3299. * @param pitch defines the pitch angle in radians (X axis)
  3300. * @param roll defines the roll angle in radians (X axis)
  3301. * @returns the new rotation matrix
  3302. */
  3303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3304. /**
  3305. * Creates a rotation matrix and stores it in a given matrix
  3306. * @param yaw defines the yaw angle in radians (Y axis)
  3307. * @param pitch defines the pitch angle in radians (X axis)
  3308. * @param roll defines the roll angle in radians (X axis)
  3309. * @param result defines the target matrix
  3310. */
  3311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3312. /**
  3313. * Creates a scaling matrix
  3314. * @param x defines the scale factor on X axis
  3315. * @param y defines the scale factor on Y axis
  3316. * @param z defines the scale factor on Z axis
  3317. * @returns the new matrix
  3318. */
  3319. static Scaling(x: number, y: number, z: number): Matrix;
  3320. /**
  3321. * Creates a scaling matrix and stores it in a given matrix
  3322. * @param x defines the scale factor on X axis
  3323. * @param y defines the scale factor on Y axis
  3324. * @param z defines the scale factor on Z axis
  3325. * @param result defines the target matrix
  3326. */
  3327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3328. /**
  3329. * Creates a translation matrix
  3330. * @param x defines the translation on X axis
  3331. * @param y defines the translation on Y axis
  3332. * @param z defines the translationon Z axis
  3333. * @returns the new matrix
  3334. */
  3335. static Translation(x: number, y: number, z: number): Matrix;
  3336. /**
  3337. * Creates a translation matrix and stores it in a given matrix
  3338. * @param x defines the translation on X axis
  3339. * @param y defines the translation on Y axis
  3340. * @param z defines the translationon Z axis
  3341. * @param result defines the target matrix
  3342. */
  3343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3344. /**
  3345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3346. * @param startValue defines the start value
  3347. * @param endValue defines the end value
  3348. * @param gradient defines the gradient factor
  3349. * @returns the new matrix
  3350. */
  3351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3354. * @param startValue defines the start value
  3355. * @param endValue defines the end value
  3356. * @param gradient defines the gradient factor
  3357. * @param result defines the Matrix object where to store data
  3358. */
  3359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3360. /**
  3361. * Builds a new matrix whose values are computed by:
  3362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3365. * @param startValue defines the first matrix
  3366. * @param endValue defines the second matrix
  3367. * @param gradient defines the gradient between the two matrices
  3368. * @returns the new matrix
  3369. */
  3370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3371. /**
  3372. * Update a matrix to values which are computed by:
  3373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3376. * @param startValue defines the first matrix
  3377. * @param endValue defines the second matrix
  3378. * @param gradient defines the gradient between the two matrices
  3379. * @param result defines the target matrix
  3380. */
  3381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3382. /**
  3383. * 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"
  3384. * This function works in left handed mode
  3385. * @param eye defines the final position of the entity
  3386. * @param target defines where the entity should look at
  3387. * @param up defines the up vector for the entity
  3388. * @returns the new matrix
  3389. */
  3390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3391. /**
  3392. * 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".
  3393. * This function works in left handed mode
  3394. * @param eye defines the final position of the entity
  3395. * @param target defines where the entity should look at
  3396. * @param up defines the up vector for the entity
  3397. * @param result defines the target matrix
  3398. */
  3399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3400. /**
  3401. * 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"
  3402. * This function works in right handed mode
  3403. * @param eye defines the final position of the entity
  3404. * @param target defines where the entity should look at
  3405. * @param up defines the up vector for the entity
  3406. * @returns the new matrix
  3407. */
  3408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3409. /**
  3410. * 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".
  3411. * This function works in right handed mode
  3412. * @param eye defines the final position of the entity
  3413. * @param target defines where the entity should look at
  3414. * @param up defines the up vector for the entity
  3415. * @param result defines the target matrix
  3416. */
  3417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3418. /**
  3419. * Create a left-handed orthographic projection matrix
  3420. * @param width defines the viewport width
  3421. * @param height defines the viewport height
  3422. * @param znear defines the near clip plane
  3423. * @param zfar defines the far clip plane
  3424. * @returns a new matrix as a left-handed orthographic projection matrix
  3425. */
  3426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3427. /**
  3428. * Store a left-handed orthographic projection to a given matrix
  3429. * @param width defines the viewport width
  3430. * @param height defines the viewport height
  3431. * @param znear defines the near clip plane
  3432. * @param zfar defines the far clip plane
  3433. * @param result defines the target matrix
  3434. */
  3435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3436. /**
  3437. * Create a left-handed orthographic projection matrix
  3438. * @param left defines the viewport left coordinate
  3439. * @param right defines the viewport right coordinate
  3440. * @param bottom defines the viewport bottom coordinate
  3441. * @param top defines the viewport top coordinate
  3442. * @param znear defines the near clip plane
  3443. * @param zfar defines the far clip plane
  3444. * @returns a new matrix as a left-handed orthographic projection matrix
  3445. */
  3446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3447. /**
  3448. * Stores a left-handed orthographic projection into a given matrix
  3449. * @param left defines the viewport left coordinate
  3450. * @param right defines the viewport right coordinate
  3451. * @param bottom defines the viewport bottom coordinate
  3452. * @param top defines the viewport top coordinate
  3453. * @param znear defines the near clip plane
  3454. * @param zfar defines the far clip plane
  3455. * @param result defines the target matrix
  3456. */
  3457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3458. /**
  3459. * Creates a right-handed orthographic projection matrix
  3460. * @param left defines the viewport left coordinate
  3461. * @param right defines the viewport right coordinate
  3462. * @param bottom defines the viewport bottom coordinate
  3463. * @param top defines the viewport top coordinate
  3464. * @param znear defines the near clip plane
  3465. * @param zfar defines the far clip plane
  3466. * @returns a new matrix as a right-handed orthographic projection matrix
  3467. */
  3468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3469. /**
  3470. * Stores a right-handed orthographic projection into a given matrix
  3471. * @param left defines the viewport left coordinate
  3472. * @param right defines the viewport right coordinate
  3473. * @param bottom defines the viewport bottom coordinate
  3474. * @param top defines the viewport top coordinate
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @param result defines the target matrix
  3478. */
  3479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3480. /**
  3481. * Creates a left-handed perspective projection matrix
  3482. * @param width defines the viewport width
  3483. * @param height defines the viewport height
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @returns a new matrix as a left-handed perspective projection matrix
  3487. */
  3488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3489. /**
  3490. * Creates a left-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a left-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a left-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Creates a right-handed perspective projection matrix
  3510. * @param fov defines the horizontal field of view
  3511. * @param aspect defines the aspect ratio
  3512. * @param znear defines the near clip plane
  3513. * @param zfar defines the far clip plane
  3514. * @returns a new matrix as a right-handed perspective projection matrix
  3515. */
  3516. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3517. /**
  3518. * Stores a right-handed perspective projection into a given matrix
  3519. * @param fov defines the horizontal field of view
  3520. * @param aspect defines the aspect ratio
  3521. * @param znear defines the near clip plane
  3522. * @param zfar defines the far clip plane
  3523. * @param result defines the target matrix
  3524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3525. */
  3526. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3527. /**
  3528. * Stores a perspective projection for WebVR info a given matrix
  3529. * @param fov defines the field of view
  3530. * @param znear defines the near clip plane
  3531. * @param zfar defines the far clip plane
  3532. * @param result defines the target matrix
  3533. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3534. */
  3535. static PerspectiveFovWebVRToRef(fov: {
  3536. upDegrees: number;
  3537. downDegrees: number;
  3538. leftDegrees: number;
  3539. rightDegrees: number;
  3540. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3541. /**
  3542. * Computes a complete transformation matrix
  3543. * @param viewport defines the viewport to use
  3544. * @param world defines the world matrix
  3545. * @param view defines the view matrix
  3546. * @param projection defines the projection matrix
  3547. * @param zmin defines the near clip plane
  3548. * @param zmax defines the far clip plane
  3549. * @returns the transformation matrix
  3550. */
  3551. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3552. /**
  3553. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3554. * @param matrix defines the matrix to use
  3555. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3556. */
  3557. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3558. /**
  3559. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3560. * @param matrix defines the matrix to use
  3561. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3562. */
  3563. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3564. /**
  3565. * Compute the transpose of a given matrix
  3566. * @param matrix defines the matrix to transpose
  3567. * @returns the new matrix
  3568. */
  3569. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3570. /**
  3571. * Compute the transpose of a matrix and store it in a target matrix
  3572. * @param matrix defines the matrix to transpose
  3573. * @param result defines the target matrix
  3574. */
  3575. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3576. /**
  3577. * Computes a reflection matrix from a plane
  3578. * @param plane defines the reflection plane
  3579. * @returns a new matrix
  3580. */
  3581. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3582. /**
  3583. * Computes a reflection matrix from a plane
  3584. * @param plane defines the reflection plane
  3585. * @param result defines the target matrix
  3586. */
  3587. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3588. /**
  3589. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3590. * @param xaxis defines the value of the 1st axis
  3591. * @param yaxis defines the value of the 2nd axis
  3592. * @param zaxis defines the value of the 3rd axis
  3593. * @param result defines the target matrix
  3594. */
  3595. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3596. /**
  3597. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3598. * @param quat defines the quaternion to use
  3599. * @param result defines the target matrix
  3600. */
  3601. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3602. }
  3603. /**
  3604. * Represens a plane by the equation ax + by + cz + d = 0
  3605. */
  3606. export class Plane {
  3607. /**
  3608. * Normal of the plane (a,b,c)
  3609. */
  3610. normal: Vector3;
  3611. /**
  3612. * d component of the plane
  3613. */
  3614. d: number;
  3615. /**
  3616. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3617. * @param a a component of the plane
  3618. * @param b b component of the plane
  3619. * @param c c component of the plane
  3620. * @param d d component of the plane
  3621. */
  3622. constructor(a: number, b: number, c: number, d: number);
  3623. /**
  3624. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3625. */
  3626. asArray(): number[];
  3627. /**
  3628. * @returns a new plane copied from the current Plane.
  3629. */
  3630. clone(): Plane;
  3631. /**
  3632. * @returns the string "Plane".
  3633. */
  3634. getClassName(): string;
  3635. /**
  3636. * @returns the Plane hash code.
  3637. */
  3638. getHashCode(): number;
  3639. /**
  3640. * Normalize the current Plane in place.
  3641. * @returns the updated Plane.
  3642. */
  3643. normalize(): Plane;
  3644. /**
  3645. * Applies a transformation the plane and returns the result
  3646. * @param transformation the transformation matrix to be applied to the plane
  3647. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3648. */
  3649. transform(transformation: DeepImmutable<Matrix>): Plane;
  3650. /**
  3651. * Calcualtte the dot product between the point and the plane normal
  3652. * @param point point to calculate the dot product with
  3653. * @returns the dot product (float) of the point coordinates and the plane normal.
  3654. */
  3655. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Updates the current Plane from the plane defined by the three given points.
  3658. * @param point1 one of the points used to contruct the plane
  3659. * @param point2 one of the points used to contruct the plane
  3660. * @param point3 one of the points used to contruct the plane
  3661. * @returns the updated Plane.
  3662. */
  3663. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3664. /**
  3665. * Checks if the plane is facing a given direction
  3666. * @param direction the direction to check if the plane is facing
  3667. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3668. * @returns True is the vector "direction" is the same side than the plane normal.
  3669. */
  3670. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3671. /**
  3672. * Calculates the distance to a point
  3673. * @param point point to calculate distance to
  3674. * @returns the signed distance (float) from the given point to the Plane.
  3675. */
  3676. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3677. /**
  3678. * Creates a plane from an array
  3679. * @param array the array to create a plane from
  3680. * @returns a new Plane from the given array.
  3681. */
  3682. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3683. /**
  3684. * Creates a plane from three points
  3685. * @param point1 point used to create the plane
  3686. * @param point2 point used to create the plane
  3687. * @param point3 point used to create the plane
  3688. * @returns a new Plane defined by the three given points.
  3689. */
  3690. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3691. /**
  3692. * Creates a plane from an origin point and a normal
  3693. * @param origin origin of the plane to be constructed
  3694. * @param normal normal of the plane to be constructed
  3695. * @returns a new Plane the normal vector to this plane at the given origin point.
  3696. * Note : the vector "normal" is updated because normalized.
  3697. */
  3698. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3699. /**
  3700. * Calculates the distance from a plane and a point
  3701. * @param origin origin of the plane to be constructed
  3702. * @param normal normal of the plane to be constructed
  3703. * @param point point to calculate distance to
  3704. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3705. */
  3706. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3707. }
  3708. /**
  3709. * Class used to represent a viewport on screen
  3710. */
  3711. export class Viewport {
  3712. /** viewport left coordinate */
  3713. x: number;
  3714. /** viewport top coordinate */
  3715. y: number;
  3716. /**viewport width */
  3717. width: number;
  3718. /** viewport height */
  3719. height: number;
  3720. /**
  3721. * Creates a Viewport object located at (x, y) and sized (width, height)
  3722. * @param x defines viewport left coordinate
  3723. * @param y defines viewport top coordinate
  3724. * @param width defines the viewport width
  3725. * @param height defines the viewport height
  3726. */
  3727. constructor(
  3728. /** viewport left coordinate */
  3729. x: number,
  3730. /** viewport top coordinate */
  3731. y: number,
  3732. /**viewport width */
  3733. width: number,
  3734. /** viewport height */
  3735. height: number);
  3736. /**
  3737. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3738. * @param renderWidth defines the rendering width
  3739. * @param renderHeight defines the rendering height
  3740. * @returns a new Viewport
  3741. */
  3742. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3743. /**
  3744. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3745. * @param renderWidth defines the rendering width
  3746. * @param renderHeight defines the rendering height
  3747. * @param ref defines the target viewport
  3748. * @returns the current viewport
  3749. */
  3750. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3751. /**
  3752. * Returns a new Viewport copied from the current one
  3753. * @returns a new Viewport
  3754. */
  3755. clone(): Viewport;
  3756. }
  3757. /**
  3758. * Reprasents a camera frustum
  3759. */
  3760. export class Frustum {
  3761. /**
  3762. * Gets the planes representing the frustum
  3763. * @param transform matrix to be applied to the returned planes
  3764. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3765. */
  3766. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3767. /**
  3768. * Gets the near frustum plane transformed by the transform matrix
  3769. * @param transform transformation matrix to be applied to the resulting frustum plane
  3770. * @param frustumPlane the resuling frustum plane
  3771. */
  3772. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3773. /**
  3774. * Gets the far frustum plane transformed by the transform matrix
  3775. * @param transform transformation matrix to be applied to the resulting frustum plane
  3776. * @param frustumPlane the resuling frustum plane
  3777. */
  3778. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3779. /**
  3780. * Gets the left frustum plane transformed by the transform matrix
  3781. * @param transform transformation matrix to be applied to the resulting frustum plane
  3782. * @param frustumPlane the resuling frustum plane
  3783. */
  3784. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3785. /**
  3786. * Gets the right frustum plane transformed by the transform matrix
  3787. * @param transform transformation matrix to be applied to the resulting frustum plane
  3788. * @param frustumPlane the resuling frustum plane
  3789. */
  3790. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3791. /**
  3792. * Gets the top frustum plane transformed by the transform matrix
  3793. * @param transform transformation matrix to be applied to the resulting frustum plane
  3794. * @param frustumPlane the resuling frustum plane
  3795. */
  3796. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3797. /**
  3798. * Gets the bottom frustum plane transformed by the transform matrix
  3799. * @param transform transformation matrix to be applied to the resulting frustum plane
  3800. * @param frustumPlane the resuling frustum plane
  3801. */
  3802. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3803. /**
  3804. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3805. * @param transform transformation matrix to be applied to the resulting frustum planes
  3806. * @param frustumPlanes the resuling frustum planes
  3807. */
  3808. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3809. }
  3810. /** Defines supported spaces */
  3811. export enum Space {
  3812. /** Local (object) space */
  3813. LOCAL = 0,
  3814. /** World space */
  3815. WORLD = 1,
  3816. /** Bone space */
  3817. BONE = 2
  3818. }
  3819. /** Defines the 3 main axes */
  3820. export class Axis {
  3821. /** X axis */
  3822. static X: Vector3;
  3823. /** Y axis */
  3824. static Y: Vector3;
  3825. /** Z axis */
  3826. static Z: Vector3;
  3827. }
  3828. /** Class used to represent a Bezier curve */
  3829. export class BezierCurve {
  3830. /**
  3831. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3832. * @param t defines the time
  3833. * @param x1 defines the left coordinate on X axis
  3834. * @param y1 defines the left coordinate on Y axis
  3835. * @param x2 defines the right coordinate on X axis
  3836. * @param y2 defines the right coordinate on Y axis
  3837. * @returns the interpolated value
  3838. */
  3839. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3840. }
  3841. /**
  3842. * Defines potential orientation for back face culling
  3843. */
  3844. export enum Orientation {
  3845. /**
  3846. * Clockwise
  3847. */
  3848. CW = 0,
  3849. /** Counter clockwise */
  3850. CCW = 1
  3851. }
  3852. /**
  3853. * Defines angle representation
  3854. */
  3855. export class Angle {
  3856. private _radians;
  3857. /**
  3858. * Creates an Angle object of "radians" radians (float).
  3859. * @param radians the angle in radians
  3860. */
  3861. constructor(radians: number);
  3862. /**
  3863. * Get value in degrees
  3864. * @returns the Angle value in degrees (float)
  3865. */
  3866. degrees(): number;
  3867. /**
  3868. * Get value in radians
  3869. * @returns the Angle value in radians (float)
  3870. */
  3871. radians(): number;
  3872. /**
  3873. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3874. * @param a defines first vector
  3875. * @param b defines second vector
  3876. * @returns a new Angle
  3877. */
  3878. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3879. /**
  3880. * Gets a new Angle object from the given float in radians
  3881. * @param radians defines the angle value in radians
  3882. * @returns a new Angle
  3883. */
  3884. static FromRadians(radians: number): Angle;
  3885. /**
  3886. * Gets a new Angle object from the given float in degrees
  3887. * @param degrees defines the angle value in degrees
  3888. * @returns a new Angle
  3889. */
  3890. static FromDegrees(degrees: number): Angle;
  3891. }
  3892. /**
  3893. * This represents an arc in a 2d space.
  3894. */
  3895. export class Arc2 {
  3896. /** Defines the start point of the arc */
  3897. startPoint: Vector2;
  3898. /** Defines the mid point of the arc */
  3899. midPoint: Vector2;
  3900. /** Defines the end point of the arc */
  3901. endPoint: Vector2;
  3902. /**
  3903. * Defines the center point of the arc.
  3904. */
  3905. centerPoint: Vector2;
  3906. /**
  3907. * Defines the radius of the arc.
  3908. */
  3909. radius: number;
  3910. /**
  3911. * Defines the angle of the arc (from mid point to end point).
  3912. */
  3913. angle: Angle;
  3914. /**
  3915. * Defines the start angle of the arc (from start point to middle point).
  3916. */
  3917. startAngle: Angle;
  3918. /**
  3919. * Defines the orientation of the arc (clock wise/counter clock wise).
  3920. */
  3921. orientation: Orientation;
  3922. /**
  3923. * Creates an Arc object from the three given points : start, middle and end.
  3924. * @param startPoint Defines the start point of the arc
  3925. * @param midPoint Defines the midlle point of the arc
  3926. * @param endPoint Defines the end point of the arc
  3927. */
  3928. constructor(
  3929. /** Defines the start point of the arc */
  3930. startPoint: Vector2,
  3931. /** Defines the mid point of the arc */
  3932. midPoint: Vector2,
  3933. /** Defines the end point of the arc */
  3934. endPoint: Vector2);
  3935. }
  3936. /**
  3937. * Represents a 2D path made up of multiple 2D points
  3938. */
  3939. export class Path2 {
  3940. private _points;
  3941. private _length;
  3942. /**
  3943. * If the path start and end point are the same
  3944. */
  3945. closed: boolean;
  3946. /**
  3947. * Creates a Path2 object from the starting 2D coordinates x and y.
  3948. * @param x the starting points x value
  3949. * @param y the starting points y value
  3950. */
  3951. constructor(x: number, y: number);
  3952. /**
  3953. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3954. * @param x the added points x value
  3955. * @param y the added points y value
  3956. * @returns the updated Path2.
  3957. */
  3958. addLineTo(x: number, y: number): Path2;
  3959. /**
  3960. * 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.
  3961. * @param midX middle point x value
  3962. * @param midY middle point y value
  3963. * @param endX end point x value
  3964. * @param endY end point y value
  3965. * @param numberOfSegments (default: 36)
  3966. * @returns the updated Path2.
  3967. */
  3968. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3969. /**
  3970. * Closes the Path2.
  3971. * @returns the Path2.
  3972. */
  3973. close(): Path2;
  3974. /**
  3975. * Gets the sum of the distance between each sequential point in the path
  3976. * @returns the Path2 total length (float).
  3977. */
  3978. length(): number;
  3979. /**
  3980. * Gets the points which construct the path
  3981. * @returns the Path2 internal array of points.
  3982. */
  3983. getPoints(): Vector2[];
  3984. /**
  3985. * Retreives the point at the distance aways from the starting point
  3986. * @param normalizedLengthPosition the length along the path to retreive the point from
  3987. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3988. */
  3989. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3990. /**
  3991. * Creates a new path starting from an x and y position
  3992. * @param x starting x value
  3993. * @param y starting y value
  3994. * @returns a new Path2 starting at the coordinates (x, y).
  3995. */
  3996. static StartingAt(x: number, y: number): Path2;
  3997. }
  3998. /**
  3999. * Represents a 3D path made up of multiple 3D points
  4000. */
  4001. export class Path3D {
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[];
  4006. private _curve;
  4007. private _distances;
  4008. private _tangents;
  4009. private _normals;
  4010. private _binormals;
  4011. private _raw;
  4012. /**
  4013. * new Path3D(path, normal, raw)
  4014. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4015. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4016. * @param path an array of Vector3, the curve axis of the Path3D
  4017. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4018. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4019. */
  4020. constructor(
  4021. /**
  4022. * an array of Vector3, the curve axis of the Path3D
  4023. */
  4024. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4025. /**
  4026. * Returns the Path3D array of successive Vector3 designing its curve.
  4027. * @returns the Path3D array of successive Vector3 designing its curve.
  4028. */
  4029. getCurve(): Vector3[];
  4030. /**
  4031. * Returns an array populated with tangent vectors on each Path3D curve point.
  4032. * @returns an array populated with tangent vectors on each Path3D curve point.
  4033. */
  4034. getTangents(): Vector3[];
  4035. /**
  4036. * Returns an array populated with normal vectors on each Path3D curve point.
  4037. * @returns an array populated with normal vectors on each Path3D curve point.
  4038. */
  4039. getNormals(): Vector3[];
  4040. /**
  4041. * Returns an array populated with binormal vectors on each Path3D curve point.
  4042. * @returns an array populated with binormal vectors on each Path3D curve point.
  4043. */
  4044. getBinormals(): Vector3[];
  4045. /**
  4046. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4047. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4048. */
  4049. getDistances(): number[];
  4050. /**
  4051. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4052. * @param path path which all values are copied into the curves points
  4053. * @param firstNormal which should be projected onto the curve
  4054. * @returns the same object updated.
  4055. */
  4056. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4057. private _compute;
  4058. private _getFirstNonNullVector;
  4059. private _getLastNonNullVector;
  4060. private _normalVector;
  4061. }
  4062. /**
  4063. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4064. * A Curve3 is designed from a series of successive Vector3.
  4065. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4066. */
  4067. export class Curve3 {
  4068. private _points;
  4069. private _length;
  4070. /**
  4071. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4072. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4073. * @param v1 (Vector3) the control point
  4074. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4075. * @param nbPoints (integer) the wanted number of points in the curve
  4076. * @returns the created Curve3
  4077. */
  4078. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4079. /**
  4080. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4081. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4082. * @param v1 (Vector3) the first control point
  4083. * @param v2 (Vector3) the second control point
  4084. * @param v3 (Vector3) the end point of the Cubic Bezier
  4085. * @param nbPoints (integer) the wanted number of points in the curve
  4086. * @returns the created Curve3
  4087. */
  4088. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4089. /**
  4090. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4091. * @param p1 (Vector3) the origin point of the Hermite Spline
  4092. * @param t1 (Vector3) the tangent vector at the origin point
  4093. * @param p2 (Vector3) the end point of the Hermite Spline
  4094. * @param t2 (Vector3) the tangent vector at the end point
  4095. * @param nbPoints (integer) the wanted number of points in the curve
  4096. * @returns the created Curve3
  4097. */
  4098. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4099. /**
  4100. * Returns a Curve3 object along a CatmullRom Spline curve :
  4101. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4102. * @param nbPoints (integer) the wanted number of points between each curve control points
  4103. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4104. * @returns the created Curve3
  4105. */
  4106. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4107. /**
  4108. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4109. * A Curve3 is designed from a series of successive Vector3.
  4110. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4111. * @param points points which make up the curve
  4112. */
  4113. constructor(points: Vector3[]);
  4114. /**
  4115. * @returns the Curve3 stored array of successive Vector3
  4116. */
  4117. getPoints(): Vector3[];
  4118. /**
  4119. * @returns the computed length (float) of the curve.
  4120. */
  4121. length(): number;
  4122. /**
  4123. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4124. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4125. * curveA and curveB keep unchanged.
  4126. * @param curve the curve to continue from this curve
  4127. * @returns the newly constructed curve
  4128. */
  4129. continue(curve: DeepImmutable<Curve3>): Curve3;
  4130. private _computeLength;
  4131. }
  4132. /**
  4133. * Contains position and normal vectors for a vertex
  4134. */
  4135. export class PositionNormalVertex {
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position: Vector3;
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal: Vector3;
  4140. /**
  4141. * Creates a PositionNormalVertex
  4142. * @param position the position of the vertex (defaut: 0,0,0)
  4143. * @param normal the normal of the vertex (defaut: 0,1,0)
  4144. */
  4145. constructor(
  4146. /** the position of the vertex (defaut: 0,0,0) */
  4147. position?: Vector3,
  4148. /** the normal of the vertex (defaut: 0,1,0) */
  4149. normal?: Vector3);
  4150. /**
  4151. * Clones the PositionNormalVertex
  4152. * @returns the cloned PositionNormalVertex
  4153. */
  4154. clone(): PositionNormalVertex;
  4155. }
  4156. /**
  4157. * Contains position, normal and uv vectors for a vertex
  4158. */
  4159. export class PositionNormalTextureVertex {
  4160. /** the position of the vertex (defaut: 0,0,0) */
  4161. position: Vector3;
  4162. /** the normal of the vertex (defaut: 0,1,0) */
  4163. normal: Vector3;
  4164. /** the uv of the vertex (default: 0,0) */
  4165. uv: Vector2;
  4166. /**
  4167. * Creates a PositionNormalTextureVertex
  4168. * @param position the position of the vertex (defaut: 0,0,0)
  4169. * @param normal the normal of the vertex (defaut: 0,1,0)
  4170. * @param uv the uv of the vertex (default: 0,0)
  4171. */
  4172. constructor(
  4173. /** the position of the vertex (defaut: 0,0,0) */
  4174. position?: Vector3,
  4175. /** the normal of the vertex (defaut: 0,1,0) */
  4176. normal?: Vector3,
  4177. /** the uv of the vertex (default: 0,0) */
  4178. uv?: Vector2);
  4179. /**
  4180. * Clones the PositionNormalTextureVertex
  4181. * @returns the cloned PositionNormalTextureVertex
  4182. */
  4183. clone(): PositionNormalTextureVertex;
  4184. }
  4185. /**
  4186. * @hidden
  4187. */
  4188. export class Tmp {
  4189. static Color3: Color3[];
  4190. static Color4: Color4[];
  4191. static Vector2: Vector2[];
  4192. static Vector3: Vector3[];
  4193. static Vector4: Vector4[];
  4194. static Quaternion: Quaternion[];
  4195. static Matrix: Matrix[];
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * Class used to enable access to offline support
  4201. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4202. */
  4203. export interface IOfflineProvider {
  4204. /**
  4205. * Gets a boolean indicating if scene must be saved in the database
  4206. */
  4207. enableSceneOffline: boolean;
  4208. /**
  4209. * Gets a boolean indicating if textures must be saved in the database
  4210. */
  4211. enableTexturesOffline: boolean;
  4212. /**
  4213. * Open the offline support and make it available
  4214. * @param successCallback defines the callback to call on success
  4215. * @param errorCallback defines the callback to call on error
  4216. */
  4217. open(successCallback: () => void, errorCallback: () => void): void;
  4218. /**
  4219. * Loads an image from the offline support
  4220. * @param url defines the url to load from
  4221. * @param image defines the target DOM image
  4222. */
  4223. loadImage(url: string, image: HTMLImageElement): void;
  4224. /**
  4225. * Loads a file from offline support
  4226. * @param url defines the URL to load from
  4227. * @param sceneLoaded defines a callback to call on success
  4228. * @param progressCallBack defines a callback to call when progress changed
  4229. * @param errorCallback defines a callback to call on error
  4230. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4231. */
  4232. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4233. }
  4234. }
  4235. declare module BABYLON {
  4236. /**
  4237. * A class serves as a medium between the observable and its observers
  4238. */
  4239. export class EventState {
  4240. /**
  4241. * Create a new EventState
  4242. * @param mask defines the mask associated with this state
  4243. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4244. * @param target defines the original target of the state
  4245. * @param currentTarget defines the current target of the state
  4246. */
  4247. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4248. /**
  4249. * Initialize the current event state
  4250. * @param mask defines the mask associated with this state
  4251. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4252. * @param target defines the original target of the state
  4253. * @param currentTarget defines the current target of the state
  4254. * @returns the current event state
  4255. */
  4256. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4257. /**
  4258. * An Observer can set this property to true to prevent subsequent observers of being notified
  4259. */
  4260. skipNextObservers: boolean;
  4261. /**
  4262. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4263. */
  4264. mask: number;
  4265. /**
  4266. * The object that originally notified the event
  4267. */
  4268. target?: any;
  4269. /**
  4270. * The current object in the bubbling phase
  4271. */
  4272. currentTarget?: any;
  4273. /**
  4274. * This will be populated with the return value of the last function that was executed.
  4275. * If it is the first function in the callback chain it will be the event data.
  4276. */
  4277. lastReturnValue?: any;
  4278. }
  4279. /**
  4280. * Represent an Observer registered to a given Observable object.
  4281. */
  4282. export class Observer<T> {
  4283. /**
  4284. * Defines the callback to call when the observer is notified
  4285. */
  4286. callback: (eventData: T, eventState: EventState) => void;
  4287. /**
  4288. * Defines the mask of the observer (used to filter notifications)
  4289. */
  4290. mask: number;
  4291. /**
  4292. * Defines the current scope used to restore the JS context
  4293. */
  4294. scope: any;
  4295. /** @hidden */ private _willBeUnregistered: boolean;
  4296. /**
  4297. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4298. */
  4299. unregisterOnNextCall: boolean;
  4300. /**
  4301. * Creates a new observer
  4302. * @param callback defines the callback to call when the observer is notified
  4303. * @param mask defines the mask of the observer (used to filter notifications)
  4304. * @param scope defines the current scope used to restore the JS context
  4305. */
  4306. constructor(
  4307. /**
  4308. * Defines the callback to call when the observer is notified
  4309. */
  4310. callback: (eventData: T, eventState: EventState) => void,
  4311. /**
  4312. * Defines the mask of the observer (used to filter notifications)
  4313. */
  4314. mask: number,
  4315. /**
  4316. * Defines the current scope used to restore the JS context
  4317. */
  4318. scope?: any);
  4319. }
  4320. /**
  4321. * Represent a list of observers registered to multiple Observables object.
  4322. */
  4323. export class MultiObserver<T> {
  4324. private _observers;
  4325. private _observables;
  4326. /**
  4327. * Release associated resources
  4328. */
  4329. dispose(): void;
  4330. /**
  4331. * Raise a callback when one of the observable will notify
  4332. * @param observables defines a list of observables to watch
  4333. * @param callback defines the callback to call on notification
  4334. * @param mask defines the mask used to filter notifications
  4335. * @param scope defines the current scope used to restore the JS context
  4336. * @returns the new MultiObserver
  4337. */
  4338. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4339. }
  4340. /**
  4341. * The Observable class is a simple implementation of the Observable pattern.
  4342. *
  4343. * 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.
  4344. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4345. * 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).
  4346. * 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.
  4347. */
  4348. export class Observable<T> {
  4349. private _observers;
  4350. private _eventState;
  4351. private _onObserverAdded;
  4352. /**
  4353. * Gets the list of observers
  4354. */
  4355. readonly observers: Array<Observer<T>>;
  4356. /**
  4357. * Creates a new observable
  4358. * @param onObserverAdded defines a callback to call when a new observer is added
  4359. */
  4360. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4361. /**
  4362. * Create a new Observer with the specified callback
  4363. * @param callback the callback that will be executed for that Observer
  4364. * @param mask the mask used to filter observers
  4365. * @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.
  4366. * @param scope optional scope for the callback to be called from
  4367. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4368. * @returns the new observer created for the callback
  4369. */
  4370. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4371. /**
  4372. * Create a new Observer with the specified callback and unregisters after the next notification
  4373. * @param callback the callback that will be executed for that Observer
  4374. * @returns the new observer created for the callback
  4375. */
  4376. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4377. /**
  4378. * Remove an Observer from the Observable object
  4379. * @param observer the instance of the Observer to remove
  4380. * @returns false if it doesn't belong to this Observable
  4381. */
  4382. remove(observer: Nullable<Observer<T>>): boolean;
  4383. /**
  4384. * Remove a callback from the Observable object
  4385. * @param callback the callback to remove
  4386. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4387. * @returns false if it doesn't belong to this Observable
  4388. */
  4389. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4390. private _deferUnregister;
  4391. private _remove;
  4392. /**
  4393. * Moves the observable to the top of the observer list making it get called first when notified
  4394. * @param observer the observer to move
  4395. */
  4396. makeObserverTopPriority(observer: Observer<T>): void;
  4397. /**
  4398. * Moves the observable to the bottom of the observer list making it get called last when notified
  4399. * @param observer the observer to move
  4400. */
  4401. makeObserverBottomPriority(observer: Observer<T>): void;
  4402. /**
  4403. * Notify all Observers by calling their respective callback with the given data
  4404. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4405. * @param eventData defines the data to send to all observers
  4406. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4407. * @param target defines the original target of the state
  4408. * @param currentTarget defines the current target of the state
  4409. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4410. */
  4411. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4412. /**
  4413. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4414. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4415. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4416. * and it is crucial that all callbacks will be executed.
  4417. * The order of the callbacks is kept, callbacks are not executed parallel.
  4418. *
  4419. * @param eventData The data to be sent to each callback
  4420. * @param mask is used to filter observers defaults to -1
  4421. * @param target defines the callback target (see EventState)
  4422. * @param currentTarget defines he current object in the bubbling phase
  4423. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4424. */
  4425. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4426. /**
  4427. * Notify a specific observer
  4428. * @param observer defines the observer to notify
  4429. * @param eventData defines the data to be sent to each callback
  4430. * @param mask is used to filter observers defaults to -1
  4431. */
  4432. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4433. /**
  4434. * Gets a boolean indicating if the observable has at least one observer
  4435. * @returns true is the Observable has at least one Observer registered
  4436. */
  4437. hasObservers(): boolean;
  4438. /**
  4439. * Clear the list of observers
  4440. */
  4441. clear(): void;
  4442. /**
  4443. * Clone the current observable
  4444. * @returns a new observable
  4445. */
  4446. clone(): Observable<T>;
  4447. /**
  4448. * Does this observable handles observer registered with a given mask
  4449. * @param mask defines the mask to be tested
  4450. * @return whether or not one observer registered with the given mask is handeled
  4451. **/
  4452. hasSpecificMask(mask?: number): boolean;
  4453. }
  4454. }
  4455. declare module BABYLON {
  4456. /**
  4457. * Class used to help managing file picking and drag'n'drop
  4458. * File Storage
  4459. */
  4460. export class FilesInputStore {
  4461. /**
  4462. * List of files ready to be loaded
  4463. */
  4464. static FilesToLoad: {
  4465. [key: string]: File;
  4466. };
  4467. }
  4468. }
  4469. declare module BABYLON {
  4470. /** Defines the cross module used constants to avoid circular dependncies */
  4471. export class Constants {
  4472. /** Defines that alpha blending is disabled */
  4473. static readonly ALPHA_DISABLE: number;
  4474. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4475. static readonly ALPHA_ADD: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4477. static readonly ALPHA_COMBINE: number;
  4478. /** Defines that alpha blending to DEST - SRC * DEST */
  4479. static readonly ALPHA_SUBTRACT: number;
  4480. /** Defines that alpha blending to SRC * DEST */
  4481. static readonly ALPHA_MULTIPLY: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4483. static readonly ALPHA_MAXIMIZED: number;
  4484. /** Defines that alpha blending to SRC + DEST */
  4485. static readonly ALPHA_ONEONE: number;
  4486. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4487. static readonly ALPHA_PREMULTIPLIED: number;
  4488. /**
  4489. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4490. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4491. */
  4492. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4493. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4494. static readonly ALPHA_INTERPOLATE: number;
  4495. /**
  4496. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4497. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4498. */
  4499. static readonly ALPHA_SCREENMODE: number;
  4500. /** Defines that the ressource is not delayed*/
  4501. static readonly DELAYLOADSTATE_NONE: number;
  4502. /** Defines that the ressource was successfully delay loaded */
  4503. static readonly DELAYLOADSTATE_LOADED: number;
  4504. /** Defines that the ressource is currently delay loading */
  4505. static readonly DELAYLOADSTATE_LOADING: number;
  4506. /** Defines that the ressource is delayed and has not started loading */
  4507. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4509. static readonly NEVER: number;
  4510. /** 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 */
  4511. static readonly ALWAYS: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4513. static readonly LESS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4515. static readonly EQUAL: number;
  4516. /** 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 */
  4517. static readonly LEQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4519. static readonly GREATER: number;
  4520. /** 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 */
  4521. static readonly GEQUAL: number;
  4522. /** 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 */
  4523. static readonly NOTEQUAL: number;
  4524. /** Passed to stencilOperation to specify that stencil value must be kept */
  4525. static readonly KEEP: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4527. static readonly REPLACE: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4529. static readonly INCR: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4531. static readonly DECR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4533. static readonly INVERT: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4535. static readonly INCR_WRAP: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4537. static readonly DECR_WRAP: number;
  4538. /** Texture is not repeating outside of 0..1 UVs */
  4539. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4540. /** Texture is repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4542. /** Texture is repeating and mirrored */
  4543. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4544. /** ALPHA */
  4545. static readonly TEXTUREFORMAT_ALPHA: number;
  4546. /** LUMINANCE */
  4547. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4548. /** LUMINANCE_ALPHA */
  4549. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4550. /** RGB */
  4551. static readonly TEXTUREFORMAT_RGB: number;
  4552. /** RGBA */
  4553. static readonly TEXTUREFORMAT_RGBA: number;
  4554. /** RED */
  4555. static readonly TEXTUREFORMAT_RED: number;
  4556. /** RED (2nd reference) */
  4557. static readonly TEXTUREFORMAT_R: number;
  4558. /** RG */
  4559. static readonly TEXTUREFORMAT_RG: number;
  4560. /** RED_INTEGER */
  4561. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4562. /** RED_INTEGER (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4564. /** RG_INTEGER */
  4565. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4566. /** RGB_INTEGER */
  4567. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4568. /** RGBA_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4570. /** UNSIGNED_BYTE */
  4571. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4572. /** UNSIGNED_BYTE (2nd reference) */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4574. /** FLOAT */
  4575. static readonly TEXTURETYPE_FLOAT: number;
  4576. /** HALF_FLOAT */
  4577. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4578. /** BYTE */
  4579. static readonly TEXTURETYPE_BYTE: number;
  4580. /** SHORT */
  4581. static readonly TEXTURETYPE_SHORT: number;
  4582. /** UNSIGNED_SHORT */
  4583. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4584. /** INT */
  4585. static readonly TEXTURETYPE_INT: number;
  4586. /** UNSIGNED_INT */
  4587. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4588. /** UNSIGNED_SHORT_4_4_4_4 */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4590. /** UNSIGNED_SHORT_5_5_5_1 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4592. /** UNSIGNED_SHORT_5_6_5 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4594. /** UNSIGNED_INT_2_10_10_10_REV */
  4595. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4596. /** UNSIGNED_INT_24_8 */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4598. /** UNSIGNED_INT_10F_11F_11F_REV */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4600. /** UNSIGNED_INT_5_9_9_9_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4602. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4603. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4604. /** nearest is mag = nearest and min = nearest and mip = linear */
  4605. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4606. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4607. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4608. /** Trilinear is mag = linear and min = linear and mip = linear */
  4609. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4616. /** mag = nearest and min = nearest and mip = nearest */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4618. /** mag = nearest and min = linear and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = linear */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = linear and mip = none */
  4623. static readonly TEXTURE_NEAREST_LINEAR: number;
  4624. /** mag = nearest and min = nearest and mip = none */
  4625. static readonly TEXTURE_NEAREST_NEAREST: number;
  4626. /** mag = linear and min = nearest and mip = nearest */
  4627. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4628. /** mag = linear and min = nearest and mip = linear */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4630. /** mag = linear and min = linear and mip = none */
  4631. static readonly TEXTURE_LINEAR_LINEAR: number;
  4632. /** mag = linear and min = nearest and mip = none */
  4633. static readonly TEXTURE_LINEAR_NEAREST: number;
  4634. /** Explicit coordinates mode */
  4635. static readonly TEXTURE_EXPLICIT_MODE: number;
  4636. /** Spherical coordinates mode */
  4637. static readonly TEXTURE_SPHERICAL_MODE: number;
  4638. /** Planar coordinates mode */
  4639. static readonly TEXTURE_PLANAR_MODE: number;
  4640. /** Cubic coordinates mode */
  4641. static readonly TEXTURE_CUBIC_MODE: number;
  4642. /** Projection coordinates mode */
  4643. static readonly TEXTURE_PROJECTION_MODE: number;
  4644. /** Skybox coordinates mode */
  4645. static readonly TEXTURE_SKYBOX_MODE: number;
  4646. /** Inverse Cubic coordinates mode */
  4647. static readonly TEXTURE_INVCUBIC_MODE: number;
  4648. /** Equirectangular coordinates mode */
  4649. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4650. /** Equirectangular Fixed coordinates mode */
  4651. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed Mirrored coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4654. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4655. static readonly SCALEMODE_FLOOR: number;
  4656. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4657. static readonly SCALEMODE_NEAREST: number;
  4658. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4659. static readonly SCALEMODE_CEILING: number;
  4660. /**
  4661. * The dirty texture flag value
  4662. */
  4663. static readonly MATERIAL_TextureDirtyFlag: number;
  4664. /**
  4665. * The dirty light flag value
  4666. */
  4667. static readonly MATERIAL_LightDirtyFlag: number;
  4668. /**
  4669. * The dirty fresnel flag value
  4670. */
  4671. static readonly MATERIAL_FresnelDirtyFlag: number;
  4672. /**
  4673. * The dirty attribute flag value
  4674. */
  4675. static readonly MATERIAL_AttributesDirtyFlag: number;
  4676. /**
  4677. * The dirty misc flag value
  4678. */
  4679. static readonly MATERIAL_MiscDirtyFlag: number;
  4680. /**
  4681. * The all dirty flag value
  4682. */
  4683. static readonly MATERIAL_AllDirtyFlag: number;
  4684. /**
  4685. * Returns the triangle fill mode
  4686. */
  4687. static readonly MATERIAL_TriangleFillMode: number;
  4688. /**
  4689. * Returns the wireframe mode
  4690. */
  4691. static readonly MATERIAL_WireFrameFillMode: number;
  4692. /**
  4693. * Returns the point fill mode
  4694. */
  4695. static readonly MATERIAL_PointFillMode: number;
  4696. /**
  4697. * Returns the point list draw mode
  4698. */
  4699. static readonly MATERIAL_PointListDrawMode: number;
  4700. /**
  4701. * Returns the line list draw mode
  4702. */
  4703. static readonly MATERIAL_LineListDrawMode: number;
  4704. /**
  4705. * Returns the line loop draw mode
  4706. */
  4707. static readonly MATERIAL_LineLoopDrawMode: number;
  4708. /**
  4709. * Returns the line strip draw mode
  4710. */
  4711. static readonly MATERIAL_LineStripDrawMode: number;
  4712. /**
  4713. * Returns the triangle strip draw mode
  4714. */
  4715. static readonly MATERIAL_TriangleStripDrawMode: number;
  4716. /**
  4717. * Returns the triangle fan draw mode
  4718. */
  4719. static readonly MATERIAL_TriangleFanDrawMode: number;
  4720. /**
  4721. * Stores the clock-wise side orientation
  4722. */
  4723. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4724. /**
  4725. * Stores the counter clock-wise side orientation
  4726. */
  4727. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4728. /**
  4729. * Nothing
  4730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4731. */
  4732. static readonly ACTION_NothingTrigger: number;
  4733. /**
  4734. * On pick
  4735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4736. */
  4737. static readonly ACTION_OnPickTrigger: number;
  4738. /**
  4739. * On left pick
  4740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4741. */
  4742. static readonly ACTION_OnLeftPickTrigger: number;
  4743. /**
  4744. * On right pick
  4745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4746. */
  4747. static readonly ACTION_OnRightPickTrigger: number;
  4748. /**
  4749. * On center pick
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnCenterPickTrigger: number;
  4753. /**
  4754. * On pick down
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnPickDownTrigger: number;
  4758. /**
  4759. * On double pick
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnDoublePickTrigger: number;
  4763. /**
  4764. * On pick up
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPickUpTrigger: number;
  4768. /**
  4769. * On pick out.
  4770. * This trigger will only be raised if you also declared a OnPickDown
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickOutTrigger: number;
  4774. /**
  4775. * On long press
  4776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4777. */
  4778. static readonly ACTION_OnLongPressTrigger: number;
  4779. /**
  4780. * On pointer over
  4781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4782. */
  4783. static readonly ACTION_OnPointerOverTrigger: number;
  4784. /**
  4785. * On pointer out
  4786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4787. */
  4788. static readonly ACTION_OnPointerOutTrigger: number;
  4789. /**
  4790. * On every frame
  4791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4792. */
  4793. static readonly ACTION_OnEveryFrameTrigger: number;
  4794. /**
  4795. * On intersection enter
  4796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4797. */
  4798. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4799. /**
  4800. * On intersection exit
  4801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4802. */
  4803. static readonly ACTION_OnIntersectionExitTrigger: number;
  4804. /**
  4805. * On key down
  4806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4807. */
  4808. static readonly ACTION_OnKeyDownTrigger: number;
  4809. /**
  4810. * On key up
  4811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4812. */
  4813. static readonly ACTION_OnKeyUpTrigger: number;
  4814. /**
  4815. * Billboard mode will only apply to Y axis
  4816. */
  4817. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4818. /**
  4819. * Billboard mode will apply to all axes
  4820. */
  4821. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4822. /**
  4823. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4824. */
  4825. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4826. /**
  4827. * Gets or sets base Assets URL
  4828. */
  4829. static PARTICLES_BaseAssetsUrl: string;
  4830. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4831. * Test order :
  4832. * Is the bounding sphere outside the frustum ?
  4833. * If not, are the bounding box vertices outside the frustum ?
  4834. * It not, then the cullable object is in the frustum.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4837. /** Culling strategy : Bounding Sphere Only.
  4838. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4839. * It's also less accurate than the standard because some not visible objects can still be selected.
  4840. * Test : is the bounding sphere outside the frustum ?
  4841. * If not, then the cullable object is in the frustum.
  4842. */
  4843. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4844. /** Culling strategy : Optimistic Inclusion.
  4845. * This in an inclusion test first, then the standard exclusion test.
  4846. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4847. * 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.
  4848. * Anyway, it's as accurate as the standard strategy.
  4849. * Test :
  4850. * Is the cullable object bounding sphere center in the frustum ?
  4851. * If not, apply the default culling strategy.
  4852. */
  4853. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4854. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4855. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4856. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4857. * 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.
  4858. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4859. * Test :
  4860. * Is the cullable object bounding sphere center in the frustum ?
  4861. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4862. */
  4863. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4864. /**
  4865. * No logging while loading
  4866. */
  4867. static readonly SCENELOADER_NO_LOGGING: number;
  4868. /**
  4869. * Minimal logging while loading
  4870. */
  4871. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4872. /**
  4873. * Summary logging while loading
  4874. */
  4875. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4876. /**
  4877. * Detailled logging while loading
  4878. */
  4879. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4880. }
  4881. }
  4882. declare module BABYLON {
  4883. /**
  4884. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4885. * Babylon.js
  4886. */
  4887. export class DomManagement {
  4888. /**
  4889. * Checks if the window object exists
  4890. * @returns true if the window object exists
  4891. */
  4892. static IsWindowObjectExist(): boolean;
  4893. /**
  4894. * Extracts text content from a DOM element hierarchy
  4895. * @param element defines the root element
  4896. * @returns a string
  4897. */
  4898. static GetDOMTextContent(element: HTMLElement): string;
  4899. }
  4900. }
  4901. declare module BABYLON {
  4902. /**
  4903. * Logger used througouht the application to allow configuration of
  4904. * the log level required for the messages.
  4905. */
  4906. export class Logger {
  4907. /**
  4908. * No log
  4909. */
  4910. static readonly NoneLogLevel: number;
  4911. /**
  4912. * Only message logs
  4913. */
  4914. static readonly MessageLogLevel: number;
  4915. /**
  4916. * Only warning logs
  4917. */
  4918. static readonly WarningLogLevel: number;
  4919. /**
  4920. * Only error logs
  4921. */
  4922. static readonly ErrorLogLevel: number;
  4923. /**
  4924. * All logs
  4925. */
  4926. static readonly AllLogLevel: number;
  4927. private static _LogCache;
  4928. /**
  4929. * Gets a value indicating the number of loading errors
  4930. * @ignorenaming
  4931. */
  4932. static errorsCount: number;
  4933. /**
  4934. * Callback called when a new log is added
  4935. */
  4936. static OnNewCacheEntry: (entry: string) => void;
  4937. private static _AddLogEntry;
  4938. private static _FormatMessage;
  4939. private static _LogDisabled;
  4940. private static _LogEnabled;
  4941. private static _WarnDisabled;
  4942. private static _WarnEnabled;
  4943. private static _ErrorDisabled;
  4944. private static _ErrorEnabled;
  4945. /**
  4946. * Log a message to the console
  4947. */
  4948. static Log: (message: string) => void;
  4949. /**
  4950. * Write a warning message to the console
  4951. */
  4952. static Warn: (message: string) => void;
  4953. /**
  4954. * Write an error message to the console
  4955. */
  4956. static Error: (message: string) => void;
  4957. /**
  4958. * Gets current log cache (list of logs)
  4959. */
  4960. static readonly LogCache: string;
  4961. /**
  4962. * Clears the log cache
  4963. */
  4964. static ClearLogCache(): void;
  4965. /**
  4966. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4967. */
  4968. static LogLevels: number;
  4969. }
  4970. }
  4971. declare module BABYLON {
  4972. /** @hidden */
  4973. export class _TypeStore {
  4974. /** @hidden */
  4975. static RegisteredTypes: {
  4976. [key: string]: Object;
  4977. };
  4978. /** @hidden */
  4979. static GetClass(fqdn: string): any;
  4980. }
  4981. }
  4982. declare module BABYLON {
  4983. /**
  4984. * Class containing a set of static utilities functions for deep copy.
  4985. */
  4986. export class DeepCopier {
  4987. /**
  4988. * Tries to copy an object by duplicating every property
  4989. * @param source defines the source object
  4990. * @param destination defines the target object
  4991. * @param doNotCopyList defines a list of properties to avoid
  4992. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4993. */
  4994. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /**
  4999. * Class containing a set of static utilities functions for precision date
  5000. */
  5001. export class PrecisionDate {
  5002. /**
  5003. * Gets either window.performance.now() if supported or Date.now() else
  5004. */
  5005. static readonly Now: number;
  5006. }
  5007. }
  5008. declare module BABYLON {
  5009. /** @hidden */
  5010. export class _DevTools {
  5011. static WarnImport(name: string): string;
  5012. }
  5013. }
  5014. declare module BABYLON {
  5015. /**
  5016. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5017. */
  5018. export class WebRequest {
  5019. private _xhr;
  5020. /**
  5021. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5022. * i.e. when loading files, where the server/service expects an Authorization header
  5023. */
  5024. static CustomRequestHeaders: {
  5025. [key: string]: string;
  5026. };
  5027. /**
  5028. * Add callback functions in this array to update all the requests before they get sent to the network
  5029. */
  5030. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5031. private _injectCustomRequestHeaders;
  5032. /**
  5033. * Gets or sets a function to be called when loading progress changes
  5034. */
  5035. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5036. /**
  5037. * Returns client's state
  5038. */
  5039. readonly readyState: number;
  5040. /**
  5041. * Returns client's status
  5042. */
  5043. readonly status: number;
  5044. /**
  5045. * Returns client's status as a text
  5046. */
  5047. readonly statusText: string;
  5048. /**
  5049. * Returns client's response
  5050. */
  5051. readonly response: any;
  5052. /**
  5053. * Returns client's response url
  5054. */
  5055. readonly responseURL: string;
  5056. /**
  5057. * Returns client's response as text
  5058. */
  5059. readonly responseText: string;
  5060. /**
  5061. * Gets or sets the expected response type
  5062. */
  5063. responseType: XMLHttpRequestResponseType;
  5064. /** @hidden */
  5065. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5066. /** @hidden */
  5067. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5068. /**
  5069. * Cancels any network activity
  5070. */
  5071. abort(): void;
  5072. /**
  5073. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5074. * @param body defines an optional request body
  5075. */
  5076. send(body?: Document | BodyInit | null): void;
  5077. /**
  5078. * Sets the request method, request URL
  5079. * @param method defines the method to use (GET, POST, etc..)
  5080. * @param url defines the url to connect with
  5081. */
  5082. open(method: string, url: string): void;
  5083. }
  5084. }
  5085. declare module BABYLON {
  5086. /**
  5087. * Class used to evalaute queries containing `and` and `or` operators
  5088. */
  5089. export class AndOrNotEvaluator {
  5090. /**
  5091. * Evaluate a query
  5092. * @param query defines the query to evaluate
  5093. * @param evaluateCallback defines the callback used to filter result
  5094. * @returns true if the query matches
  5095. */
  5096. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5097. private static _HandleParenthesisContent;
  5098. private static _SimplifyNegation;
  5099. }
  5100. }
  5101. declare module BABYLON {
  5102. /**
  5103. * Class used to store custom tags
  5104. */
  5105. export class Tags {
  5106. /**
  5107. * Adds support for tags on the given object
  5108. * @param obj defines the object to use
  5109. */
  5110. static EnableFor(obj: any): void;
  5111. /**
  5112. * Removes tags support
  5113. * @param obj defines the object to use
  5114. */
  5115. static DisableFor(obj: any): void;
  5116. /**
  5117. * Gets a boolean indicating if the given object has tags
  5118. * @param obj defines the object to use
  5119. * @returns a boolean
  5120. */
  5121. static HasTags(obj: any): boolean;
  5122. /**
  5123. * Gets the tags available on a given object
  5124. * @param obj defines the object to use
  5125. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5126. * @returns the tags
  5127. */
  5128. static GetTags(obj: any, asString?: boolean): any;
  5129. /**
  5130. * Adds tags to an object
  5131. * @param obj defines the object to use
  5132. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5133. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5134. */
  5135. static AddTagsTo(obj: any, tagsString: string): void;
  5136. /**
  5137. * @hidden
  5138. */ private static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5148. /**
  5149. * Defines if tags hosted on an object match a given query
  5150. * @param obj defines the object to use
  5151. * @param tagsQuery defines the tag query
  5152. * @returns a boolean
  5153. */
  5154. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5155. }
  5156. }
  5157. declare module BABYLON {
  5158. /**
  5159. * Manages the defines for the Material
  5160. */
  5161. export class MaterialDefines {
  5162. /** @hidden */
  5163. protected _keys: string[];
  5164. private _isDirty;
  5165. /** @hidden */ private _renderId: number;
  5166. /** @hidden */ private _areLightsDirty: boolean;
  5167. /** @hidden */ private _areAttributesDirty: boolean;
  5168. /** @hidden */ private _areTexturesDirty: boolean;
  5169. /** @hidden */ private _areFresnelDirty: boolean;
  5170. /** @hidden */ private _areMiscDirty: boolean;
  5171. /** @hidden */ private _areImageProcessingDirty: boolean;
  5172. /** @hidden */ private _normals: boolean;
  5173. /** @hidden */ private _uvs: boolean;
  5174. /** @hidden */ private _needNormals: boolean;
  5175. /** @hidden */ private _needUVs: boolean;
  5176. [id: string]: any;
  5177. /**
  5178. * Specifies if the material needs to be re-calculated
  5179. */
  5180. readonly isDirty: boolean;
  5181. /**
  5182. * Marks the material to indicate that it has been re-calculated
  5183. */
  5184. markAsProcessed(): void;
  5185. /**
  5186. * Marks the material to indicate that it needs to be re-calculated
  5187. */
  5188. markAsUnprocessed(): void;
  5189. /**
  5190. * Marks the material to indicate all of its defines need to be re-calculated
  5191. */
  5192. markAllAsDirty(): void;
  5193. /**
  5194. * Marks the material to indicate that image processing needs to be re-calculated
  5195. */
  5196. markAsImageProcessingDirty(): void;
  5197. /**
  5198. * Marks the material to indicate the lights need to be re-calculated
  5199. */
  5200. markAsLightDirty(): void;
  5201. /**
  5202. * Marks the attribute state as changed
  5203. */
  5204. markAsAttributesDirty(): void;
  5205. /**
  5206. * Marks the texture state as changed
  5207. */
  5208. markAsTexturesDirty(): void;
  5209. /**
  5210. * Marks the fresnel state as changed
  5211. */
  5212. markAsFresnelDirty(): void;
  5213. /**
  5214. * Marks the misc state as changed
  5215. */
  5216. markAsMiscDirty(): void;
  5217. /**
  5218. * Rebuilds the material defines
  5219. */
  5220. rebuild(): void;
  5221. /**
  5222. * Specifies if two material defines are equal
  5223. * @param other - A material define instance to compare to
  5224. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5225. */
  5226. isEqual(other: MaterialDefines): boolean;
  5227. /**
  5228. * Clones this instance's defines to another instance
  5229. * @param other - material defines to clone values to
  5230. */
  5231. cloneTo(other: MaterialDefines): void;
  5232. /**
  5233. * Resets the material define values
  5234. */
  5235. reset(): void;
  5236. /**
  5237. * Converts the material define values to a string
  5238. * @returns - String of material define information
  5239. */
  5240. toString(): string;
  5241. }
  5242. }
  5243. declare module BABYLON {
  5244. /**
  5245. * Class used to store and describe the pipeline context associated with an effect
  5246. */
  5247. export interface IPipelineContext {
  5248. /**
  5249. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5250. */
  5251. isAsync: boolean;
  5252. /**
  5253. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5254. */
  5255. isReady: boolean;
  5256. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5257. }
  5258. }
  5259. declare module BABYLON {
  5260. /**
  5261. * Class used to store gfx data (like WebGLBuffer)
  5262. */
  5263. export class DataBuffer {
  5264. /**
  5265. * Gets or sets the number of objects referencing this buffer
  5266. */
  5267. references: number;
  5268. /** Gets or sets the size of the underlying buffer */
  5269. capacity: number;
  5270. /**
  5271. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5272. */
  5273. is32Bits: boolean;
  5274. /**
  5275. * Gets the underlying buffer
  5276. */
  5277. readonly underlyingResource: any;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /** @hidden */
  5282. export interface IShaderProcessor {
  5283. attributeProcessor?: (attribute: string) => string;
  5284. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5285. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5286. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5287. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5288. lineProcessor?: (line: string, isFragment: boolean) => string;
  5289. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5290. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /** @hidden */
  5295. export interface ProcessingOptions {
  5296. defines: string[];
  5297. indexParameters: any;
  5298. isFragment: boolean;
  5299. shouldUseHighPrecisionShader: boolean;
  5300. supportsUniformBuffers: boolean;
  5301. shadersRepository: string;
  5302. includesShadersStore: {
  5303. [key: string]: string;
  5304. };
  5305. processor?: IShaderProcessor;
  5306. version: string;
  5307. platformName: string;
  5308. lookForClosingBracketForUniformBuffer?: boolean;
  5309. }
  5310. }
  5311. declare module BABYLON {
  5312. /** @hidden */
  5313. export class ShaderCodeNode {
  5314. line: string;
  5315. children: ShaderCodeNode[];
  5316. additionalDefineKey?: string;
  5317. additionalDefineValue?: string;
  5318. isValid(preprocessors: {
  5319. [key: string]: string;
  5320. }): boolean;
  5321. process(preprocessors: {
  5322. [key: string]: string;
  5323. }, options: ProcessingOptions): string;
  5324. }
  5325. }
  5326. declare module BABYLON {
  5327. /** @hidden */
  5328. export class ShaderCodeCursor {
  5329. private _lines;
  5330. lineIndex: number;
  5331. readonly currentLine: string;
  5332. readonly canRead: boolean;
  5333. lines: string[];
  5334. }
  5335. }
  5336. declare module BABYLON {
  5337. /** @hidden */
  5338. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module BABYLON {
  5345. /** @hidden */
  5346. export class ShaderDefineExpression {
  5347. isTrue(preprocessors: {
  5348. [key: string]: string;
  5349. }): boolean;
  5350. }
  5351. }
  5352. declare module BABYLON {
  5353. /** @hidden */
  5354. export class ShaderCodeTestNode extends ShaderCodeNode {
  5355. testExpression: ShaderDefineExpression;
  5356. isValid(preprocessors: {
  5357. [key: string]: string;
  5358. }): boolean;
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. /** @hidden */
  5363. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5364. define: string;
  5365. not: boolean;
  5366. constructor(define: string, not?: boolean);
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /** @hidden */
  5374. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5375. leftOperand: ShaderDefineExpression;
  5376. rightOperand: ShaderDefineExpression;
  5377. isTrue(preprocessors: {
  5378. [key: string]: string;
  5379. }): boolean;
  5380. }
  5381. }
  5382. declare module BABYLON {
  5383. /** @hidden */
  5384. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5385. leftOperand: ShaderDefineExpression;
  5386. rightOperand: ShaderDefineExpression;
  5387. isTrue(preprocessors: {
  5388. [key: string]: string;
  5389. }): boolean;
  5390. }
  5391. }
  5392. declare module BABYLON {
  5393. /** @hidden */
  5394. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5395. define: string;
  5396. operand: string;
  5397. testValue: string;
  5398. constructor(define: string, operand: string, testValue: string);
  5399. isTrue(preprocessors: {
  5400. [key: string]: string;
  5401. }): boolean;
  5402. }
  5403. }
  5404. declare module BABYLON {
  5405. /** @hidden */
  5406. export class ShaderProcessor {
  5407. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5408. private static _ProcessPrecision;
  5409. private static _ExtractOperation;
  5410. private static _BuildSubExpression;
  5411. private static _BuildExpression;
  5412. private static _MoveCursorWithinIf;
  5413. private static _MoveCursor;
  5414. private static _EvaluatePreProcessors;
  5415. private static _PreparePreProcessors;
  5416. private static _ProcessShaderConversion;
  5417. private static _ProcessIncludes;
  5418. }
  5419. }
  5420. declare module BABYLON {
  5421. /**
  5422. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5423. */
  5424. export class PerformanceMonitor {
  5425. private _enabled;
  5426. private _rollingFrameTime;
  5427. private _lastFrameTimeMs;
  5428. /**
  5429. * constructor
  5430. * @param frameSampleSize The number of samples required to saturate the sliding window
  5431. */
  5432. constructor(frameSampleSize?: number);
  5433. /**
  5434. * Samples current frame
  5435. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5436. */
  5437. sampleFrame(timeMs?: number): void;
  5438. /**
  5439. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5440. */
  5441. readonly averageFrameTime: number;
  5442. /**
  5443. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5444. */
  5445. readonly averageFrameTimeVariance: number;
  5446. /**
  5447. * Returns the frame time of the most recent frame
  5448. */
  5449. readonly instantaneousFrameTime: number;
  5450. /**
  5451. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5452. */
  5453. readonly averageFPS: number;
  5454. /**
  5455. * Returns the average framerate in frames per second using the most recent frame time
  5456. */
  5457. readonly instantaneousFPS: number;
  5458. /**
  5459. * Returns true if enough samples have been taken to completely fill the sliding window
  5460. */
  5461. readonly isSaturated: boolean;
  5462. /**
  5463. * Enables contributions to the sliding window sample set
  5464. */
  5465. enable(): void;
  5466. /**
  5467. * Disables contributions to the sliding window sample set
  5468. * Samples will not be interpolated over the disabled period
  5469. */
  5470. disable(): void;
  5471. /**
  5472. * Returns true if sampling is enabled
  5473. */
  5474. readonly isEnabled: boolean;
  5475. /**
  5476. * Resets performance monitor
  5477. */
  5478. reset(): void;
  5479. }
  5480. /**
  5481. * RollingAverage
  5482. *
  5483. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5484. */
  5485. export class RollingAverage {
  5486. /**
  5487. * Current average
  5488. */
  5489. average: number;
  5490. /**
  5491. * Current variance
  5492. */
  5493. variance: number;
  5494. protected _samples: Array<number>;
  5495. protected _sampleCount: number;
  5496. protected _pos: number;
  5497. protected _m2: number;
  5498. /**
  5499. * constructor
  5500. * @param length The number of samples required to saturate the sliding window
  5501. */
  5502. constructor(length: number);
  5503. /**
  5504. * Adds a sample to the sample set
  5505. * @param v The sample value
  5506. */
  5507. add(v: number): void;
  5508. /**
  5509. * Returns previously added values or null if outside of history or outside the sliding window domain
  5510. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5511. * @return Value previously recorded with add() or null if outside of range
  5512. */
  5513. history(i: number): number;
  5514. /**
  5515. * Returns true if enough samples have been taken to completely fill the sliding window
  5516. * @return true if sample-set saturated
  5517. */
  5518. isSaturated(): boolean;
  5519. /**
  5520. * Resets the rolling average (equivalent to 0 samples taken so far)
  5521. */
  5522. reset(): void;
  5523. /**
  5524. * Wraps a value around the sample range boundaries
  5525. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5526. * @return Wrapped position in sample range
  5527. */
  5528. protected _wrapPosition(i: number): number;
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5534. * The underlying implementation relies on an associative array to ensure the best performances.
  5535. * The value can be anything including 'null' but except 'undefined'
  5536. */
  5537. export class StringDictionary<T> {
  5538. /**
  5539. * This will clear this dictionary and copy the content from the 'source' one.
  5540. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5541. * @param source the dictionary to take the content from and copy to this dictionary
  5542. */
  5543. copyFrom(source: StringDictionary<T>): void;
  5544. /**
  5545. * Get a value based from its key
  5546. * @param key the given key to get the matching value from
  5547. * @return the value if found, otherwise undefined is returned
  5548. */
  5549. get(key: string): T | undefined;
  5550. /**
  5551. * Get a value from its key or add it if it doesn't exist.
  5552. * This method will ensure you that a given key/data will be present in the dictionary.
  5553. * @param key the given key to get the matching value from
  5554. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5555. * The factory will only be invoked if there's no data for the given key.
  5556. * @return the value corresponding to the key.
  5557. */
  5558. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5559. /**
  5560. * Get a value from its key if present in the dictionary otherwise add it
  5561. * @param key the key to get the value from
  5562. * @param val if there's no such key/value pair in the dictionary add it with this value
  5563. * @return the value corresponding to the key
  5564. */
  5565. getOrAdd(key: string, val: T): T;
  5566. /**
  5567. * Check if there's a given key in the dictionary
  5568. * @param key the key to check for
  5569. * @return true if the key is present, false otherwise
  5570. */
  5571. contains(key: string): boolean;
  5572. /**
  5573. * Add a new key and its corresponding value
  5574. * @param key the key to add
  5575. * @param value the value corresponding to the key
  5576. * @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
  5577. */
  5578. add(key: string, value: T): boolean;
  5579. /**
  5580. * Update a specific value associated to a key
  5581. * @param key defines the key to use
  5582. * @param value defines the value to store
  5583. * @returns true if the value was updated (or false if the key was not found)
  5584. */
  5585. set(key: string, value: T): boolean;
  5586. /**
  5587. * Get the element of the given key and remove it from the dictionary
  5588. * @param key defines the key to search
  5589. * @returns the value associated with the key or null if not found
  5590. */
  5591. getAndRemove(key: string): Nullable<T>;
  5592. /**
  5593. * Remove a key/value from the dictionary.
  5594. * @param key the key to remove
  5595. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5596. */
  5597. remove(key: string): boolean;
  5598. /**
  5599. * Clear the whole content of the dictionary
  5600. */
  5601. clear(): void;
  5602. /**
  5603. * Gets the current count
  5604. */
  5605. readonly count: number;
  5606. /**
  5607. * Execute a callback on each key/val of the dictionary.
  5608. * Note that you can remove any element in this dictionary in the callback implementation
  5609. * @param callback the callback to execute on a given key/value pair
  5610. */
  5611. forEach(callback: (key: string, val: T) => void): void;
  5612. /**
  5613. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5614. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5615. * Note that you can remove any element in this dictionary in the callback implementation
  5616. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5617. * @returns the first item
  5618. */
  5619. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5620. private _count;
  5621. private _data;
  5622. }
  5623. }
  5624. declare module BABYLON {
  5625. /**
  5626. * Helper class that provides a small promise polyfill
  5627. */
  5628. export class PromisePolyfill {
  5629. /**
  5630. * Static function used to check if the polyfill is required
  5631. * If this is the case then the function will inject the polyfill to window.Promise
  5632. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5633. */
  5634. static Apply(force?: boolean): void;
  5635. }
  5636. }
  5637. declare module BABYLON {
  5638. /**
  5639. * Class used to store data that will be store in GPU memory
  5640. */
  5641. export class Buffer {
  5642. private _engine;
  5643. private _buffer;
  5644. /** @hidden */ private _data: Nullable<DataArray>;
  5645. private _updatable;
  5646. private _instanced;
  5647. /**
  5648. * Gets the byte stride.
  5649. */
  5650. readonly byteStride: number;
  5651. /**
  5652. * Constructor
  5653. * @param engine the engine
  5654. * @param data the data to use for this buffer
  5655. * @param updatable whether the data is updatable
  5656. * @param stride the stride (optional)
  5657. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5658. * @param instanced whether the buffer is instanced (optional)
  5659. * @param useBytes set to true if the stride in in bytes (optional)
  5660. */
  5661. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5662. /**
  5663. * Create a new VertexBuffer based on the current buffer
  5664. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5665. * @param offset defines offset in the buffer (0 by default)
  5666. * @param size defines the size in floats of attributes (position is 3 for instance)
  5667. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5668. * @param instanced defines if the vertex buffer contains indexed data
  5669. * @param useBytes defines if the offset and stride are in bytes
  5670. * @returns the new vertex buffer
  5671. */
  5672. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5673. /**
  5674. * Gets a boolean indicating if the Buffer is updatable?
  5675. * @returns true if the buffer is updatable
  5676. */
  5677. isUpdatable(): boolean;
  5678. /**
  5679. * Gets current buffer's data
  5680. * @returns a DataArray or null
  5681. */
  5682. getData(): Nullable<DataArray>;
  5683. /**
  5684. * Gets underlying native buffer
  5685. * @returns underlying native buffer
  5686. */
  5687. getBuffer(): Nullable<DataBuffer>;
  5688. /**
  5689. * Gets the stride in float32 units (i.e. byte stride / 4).
  5690. * May not be an integer if the byte stride is not divisible by 4.
  5691. * DEPRECATED. Use byteStride instead.
  5692. * @returns the stride in float32 units
  5693. */
  5694. getStrideSize(): number;
  5695. /**
  5696. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5697. * @param data defines the data to store
  5698. */
  5699. create(data?: Nullable<DataArray>): void;
  5700. /** @hidden */ private _rebuild(): void;
  5701. /**
  5702. * Update current buffer data
  5703. * @param data defines the data to store
  5704. */
  5705. update(data: DataArray): void;
  5706. /**
  5707. * Updates the data directly.
  5708. * @param data the new data
  5709. * @param offset the new offset
  5710. * @param vertexCount the vertex count (optional)
  5711. * @param useBytes set to true if the offset is in bytes
  5712. */
  5713. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5714. /**
  5715. * Release all resources
  5716. */
  5717. dispose(): void;
  5718. }
  5719. /**
  5720. * Specialized buffer used to store vertex data
  5721. */
  5722. export class VertexBuffer {
  5723. /** @hidden */ private _buffer: Buffer;
  5724. private _kind;
  5725. private _size;
  5726. private _ownsBuffer;
  5727. private _instanced;
  5728. private _instanceDivisor;
  5729. /**
  5730. * The byte type.
  5731. */
  5732. static readonly BYTE: number;
  5733. /**
  5734. * The unsigned byte type.
  5735. */
  5736. static readonly UNSIGNED_BYTE: number;
  5737. /**
  5738. * The short type.
  5739. */
  5740. static readonly SHORT: number;
  5741. /**
  5742. * The unsigned short type.
  5743. */
  5744. static readonly UNSIGNED_SHORT: number;
  5745. /**
  5746. * The integer type.
  5747. */
  5748. static readonly INT: number;
  5749. /**
  5750. * The unsigned integer type.
  5751. */
  5752. static readonly UNSIGNED_INT: number;
  5753. /**
  5754. * The float type.
  5755. */
  5756. static readonly FLOAT: number;
  5757. /**
  5758. * Gets or sets the instance divisor when in instanced mode
  5759. */
  5760. instanceDivisor: number;
  5761. /**
  5762. * Gets the byte stride.
  5763. */
  5764. readonly byteStride: number;
  5765. /**
  5766. * Gets the byte offset.
  5767. */
  5768. readonly byteOffset: number;
  5769. /**
  5770. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5771. */
  5772. readonly normalized: boolean;
  5773. /**
  5774. * Gets the data type of each component in the array.
  5775. */
  5776. readonly type: number;
  5777. /**
  5778. * Constructor
  5779. * @param engine the engine
  5780. * @param data the data to use for this vertex buffer
  5781. * @param kind the vertex buffer kind
  5782. * @param updatable whether the data is updatable
  5783. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5784. * @param stride the stride (optional)
  5785. * @param instanced whether the buffer is instanced (optional)
  5786. * @param offset the offset of the data (optional)
  5787. * @param size the number of components (optional)
  5788. * @param type the type of the component (optional)
  5789. * @param normalized whether the data contains normalized data (optional)
  5790. * @param useBytes set to true if stride and offset are in bytes (optional)
  5791. */
  5792. 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);
  5793. /** @hidden */ private _rebuild(): void;
  5794. /**
  5795. * Returns the kind of the VertexBuffer (string)
  5796. * @returns a string
  5797. */
  5798. getKind(): string;
  5799. /**
  5800. * Gets a boolean indicating if the VertexBuffer is updatable?
  5801. * @returns true if the buffer is updatable
  5802. */
  5803. isUpdatable(): boolean;
  5804. /**
  5805. * Gets current buffer's data
  5806. * @returns a DataArray or null
  5807. */
  5808. getData(): Nullable<DataArray>;
  5809. /**
  5810. * Gets underlying native buffer
  5811. * @returns underlying native buffer
  5812. */
  5813. getBuffer(): Nullable<DataBuffer>;
  5814. /**
  5815. * Gets the stride in float32 units (i.e. byte stride / 4).
  5816. * May not be an integer if the byte stride is not divisible by 4.
  5817. * DEPRECATED. Use byteStride instead.
  5818. * @returns the stride in float32 units
  5819. */
  5820. getStrideSize(): number;
  5821. /**
  5822. * Returns the offset as a multiple of the type byte length.
  5823. * DEPRECATED. Use byteOffset instead.
  5824. * @returns the offset in bytes
  5825. */
  5826. getOffset(): number;
  5827. /**
  5828. * Returns the number of components per vertex attribute (integer)
  5829. * @returns the size in float
  5830. */
  5831. getSize(): number;
  5832. /**
  5833. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5834. * @returns true if this buffer is instanced
  5835. */
  5836. getIsInstanced(): boolean;
  5837. /**
  5838. * Returns the instancing divisor, zero for non-instanced (integer).
  5839. * @returns a number
  5840. */
  5841. getInstanceDivisor(): number;
  5842. /**
  5843. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5844. * @param data defines the data to store
  5845. */
  5846. create(data?: DataArray): void;
  5847. /**
  5848. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5849. * This function will create a new buffer if the current one is not updatable
  5850. * @param data defines the data to store
  5851. */
  5852. update(data: DataArray): void;
  5853. /**
  5854. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5855. * Returns the directly updated WebGLBuffer.
  5856. * @param data the new data
  5857. * @param offset the new offset
  5858. * @param useBytes set to true if the offset is in bytes
  5859. */
  5860. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5861. /**
  5862. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5863. */
  5864. dispose(): void;
  5865. /**
  5866. * Enumerates each value of this vertex buffer as numbers.
  5867. * @param count the number of values to enumerate
  5868. * @param callback the callback function called for each value
  5869. */
  5870. forEach(count: number, callback: (value: number, index: number) => void): void;
  5871. /**
  5872. * Positions
  5873. */
  5874. static readonly PositionKind: string;
  5875. /**
  5876. * Normals
  5877. */
  5878. static readonly NormalKind: string;
  5879. /**
  5880. * Tangents
  5881. */
  5882. static readonly TangentKind: string;
  5883. /**
  5884. * Texture coordinates
  5885. */
  5886. static readonly UVKind: string;
  5887. /**
  5888. * Texture coordinates 2
  5889. */
  5890. static readonly UV2Kind: string;
  5891. /**
  5892. * Texture coordinates 3
  5893. */
  5894. static readonly UV3Kind: string;
  5895. /**
  5896. * Texture coordinates 4
  5897. */
  5898. static readonly UV4Kind: string;
  5899. /**
  5900. * Texture coordinates 5
  5901. */
  5902. static readonly UV5Kind: string;
  5903. /**
  5904. * Texture coordinates 6
  5905. */
  5906. static readonly UV6Kind: string;
  5907. /**
  5908. * Colors
  5909. */
  5910. static readonly ColorKind: string;
  5911. /**
  5912. * Matrix indices (for bones)
  5913. */
  5914. static readonly MatricesIndicesKind: string;
  5915. /**
  5916. * Matrix weights (for bones)
  5917. */
  5918. static readonly MatricesWeightsKind: string;
  5919. /**
  5920. * Additional matrix indices (for bones)
  5921. */
  5922. static readonly MatricesIndicesExtraKind: string;
  5923. /**
  5924. * Additional matrix weights (for bones)
  5925. */
  5926. static readonly MatricesWeightsExtraKind: string;
  5927. /**
  5928. * Deduces the stride given a kind.
  5929. * @param kind The kind string to deduce
  5930. * @returns The deduced stride
  5931. */
  5932. static DeduceStride(kind: string): number;
  5933. /**
  5934. * Gets the byte length of the given type.
  5935. * @param type the type
  5936. * @returns the number of bytes
  5937. */
  5938. static GetTypeByteLength(type: number): number;
  5939. /**
  5940. * Enumerates each value of the given parameters as numbers.
  5941. * @param data the data to enumerate
  5942. * @param byteOffset the byte offset of the data
  5943. * @param byteStride the byte stride of the data
  5944. * @param componentCount the number of components per element
  5945. * @param componentType the type of the component
  5946. * @param count the number of values to enumerate
  5947. * @param normalized whether the data is normalized
  5948. * @param callback the callback function called for each value
  5949. */
  5950. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5951. private static _GetFloatValue;
  5952. }
  5953. }
  5954. declare module BABYLON {
  5955. /**
  5956. * Class representing spherical harmonics coefficients to the 3rd degree
  5957. */
  5958. export class SphericalHarmonics {
  5959. /**
  5960. * Defines whether or not the harmonics have been prescaled for rendering.
  5961. */
  5962. preScaled: boolean;
  5963. /**
  5964. * The l0,0 coefficients of the spherical harmonics
  5965. */
  5966. l00: Vector3;
  5967. /**
  5968. * The l1,-1 coefficients of the spherical harmonics
  5969. */
  5970. l1_1: Vector3;
  5971. /**
  5972. * The l1,0 coefficients of the spherical harmonics
  5973. */
  5974. l10: Vector3;
  5975. /**
  5976. * The l1,1 coefficients of the spherical harmonics
  5977. */
  5978. l11: Vector3;
  5979. /**
  5980. * The l2,-2 coefficients of the spherical harmonics
  5981. */
  5982. l2_2: Vector3;
  5983. /**
  5984. * The l2,-1 coefficients of the spherical harmonics
  5985. */
  5986. l2_1: Vector3;
  5987. /**
  5988. * The l2,0 coefficients of the spherical harmonics
  5989. */
  5990. l20: Vector3;
  5991. /**
  5992. * The l2,1 coefficients of the spherical harmonics
  5993. */
  5994. l21: Vector3;
  5995. /**
  5996. * The l2,2 coefficients of the spherical harmonics
  5997. */
  5998. l22: Vector3;
  5999. /**
  6000. * Adds a light to the spherical harmonics
  6001. * @param direction the direction of the light
  6002. * @param color the color of the light
  6003. * @param deltaSolidAngle the delta solid angle of the light
  6004. */
  6005. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6006. /**
  6007. * Scales the spherical harmonics by the given amount
  6008. * @param scale the amount to scale
  6009. */
  6010. scaleInPlace(scale: number): void;
  6011. /**
  6012. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6013. *
  6014. * ```
  6015. * E_lm = A_l * L_lm
  6016. * ```
  6017. *
  6018. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6019. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6020. * the scaling factors are given in equation 9.
  6021. */
  6022. convertIncidentRadianceToIrradiance(): void;
  6023. /**
  6024. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6025. *
  6026. * ```
  6027. * L = (1/pi) * E * rho
  6028. * ```
  6029. *
  6030. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6031. */
  6032. convertIrradianceToLambertianRadiance(): void;
  6033. /**
  6034. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6035. * required operations at run time.
  6036. *
  6037. * This is simply done by scaling back the SH with Ylm constants parameter.
  6038. * The trigonometric part being applied by the shader at run time.
  6039. */
  6040. preScaleForRendering(): void;
  6041. /**
  6042. * Constructs a spherical harmonics from an array.
  6043. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6044. * @returns the spherical harmonics
  6045. */
  6046. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6047. /**
  6048. * Gets the spherical harmonics from polynomial
  6049. * @param polynomial the spherical polynomial
  6050. * @returns the spherical harmonics
  6051. */
  6052. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6053. }
  6054. /**
  6055. * Class representing spherical polynomial coefficients to the 3rd degree
  6056. */
  6057. export class SphericalPolynomial {
  6058. private _harmonics;
  6059. /**
  6060. * The spherical harmonics used to create the polynomials.
  6061. */
  6062. readonly preScaledHarmonics: SphericalHarmonics;
  6063. /**
  6064. * The x coefficients of the spherical polynomial
  6065. */
  6066. x: Vector3;
  6067. /**
  6068. * The y coefficients of the spherical polynomial
  6069. */
  6070. y: Vector3;
  6071. /**
  6072. * The z coefficients of the spherical polynomial
  6073. */
  6074. z: Vector3;
  6075. /**
  6076. * The xx coefficients of the spherical polynomial
  6077. */
  6078. xx: Vector3;
  6079. /**
  6080. * The yy coefficients of the spherical polynomial
  6081. */
  6082. yy: Vector3;
  6083. /**
  6084. * The zz coefficients of the spherical polynomial
  6085. */
  6086. zz: Vector3;
  6087. /**
  6088. * The xy coefficients of the spherical polynomial
  6089. */
  6090. xy: Vector3;
  6091. /**
  6092. * The yz coefficients of the spherical polynomial
  6093. */
  6094. yz: Vector3;
  6095. /**
  6096. * The zx coefficients of the spherical polynomial
  6097. */
  6098. zx: Vector3;
  6099. /**
  6100. * Adds an ambient color to the spherical polynomial
  6101. * @param color the color to add
  6102. */
  6103. addAmbient(color: Color3): void;
  6104. /**
  6105. * Scales the spherical polynomial by the given amount
  6106. * @param scale the amount to scale
  6107. */
  6108. scaleInPlace(scale: number): void;
  6109. /**
  6110. * Gets the spherical polynomial from harmonics
  6111. * @param harmonics the spherical harmonics
  6112. * @returns the spherical polynomial
  6113. */
  6114. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6115. /**
  6116. * Constructs a spherical polynomial from an array.
  6117. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6118. * @returns the spherical polynomial
  6119. */
  6120. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6126. */
  6127. export interface CubeMapInfo {
  6128. /**
  6129. * The pixel array for the front face.
  6130. * This is stored in format, left to right, up to down format.
  6131. */
  6132. front: Nullable<ArrayBufferView>;
  6133. /**
  6134. * The pixel array for the back face.
  6135. * This is stored in format, left to right, up to down format.
  6136. */
  6137. back: Nullable<ArrayBufferView>;
  6138. /**
  6139. * The pixel array for the left face.
  6140. * This is stored in format, left to right, up to down format.
  6141. */
  6142. left: Nullable<ArrayBufferView>;
  6143. /**
  6144. * The pixel array for the right face.
  6145. * This is stored in format, left to right, up to down format.
  6146. */
  6147. right: Nullable<ArrayBufferView>;
  6148. /**
  6149. * The pixel array for the up face.
  6150. * This is stored in format, left to right, up to down format.
  6151. */
  6152. up: Nullable<ArrayBufferView>;
  6153. /**
  6154. * The pixel array for the down face.
  6155. * This is stored in format, left to right, up to down format.
  6156. */
  6157. down: Nullable<ArrayBufferView>;
  6158. /**
  6159. * The size of the cubemap stored.
  6160. *
  6161. * Each faces will be size * size pixels.
  6162. */
  6163. size: number;
  6164. /**
  6165. * The format of the texture.
  6166. *
  6167. * RGBA, RGB.
  6168. */
  6169. format: number;
  6170. /**
  6171. * The type of the texture data.
  6172. *
  6173. * UNSIGNED_INT, FLOAT.
  6174. */
  6175. type: number;
  6176. /**
  6177. * Specifies whether the texture is in gamma space.
  6178. */
  6179. gammaSpace: boolean;
  6180. }
  6181. /**
  6182. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6183. */
  6184. export class PanoramaToCubeMapTools {
  6185. private static FACE_FRONT;
  6186. private static FACE_BACK;
  6187. private static FACE_RIGHT;
  6188. private static FACE_LEFT;
  6189. private static FACE_DOWN;
  6190. private static FACE_UP;
  6191. /**
  6192. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6193. *
  6194. * @param float32Array The source data.
  6195. * @param inputWidth The width of the input panorama.
  6196. * @param inputHeight The height of the input panorama.
  6197. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6198. * @return The cubemap data
  6199. */
  6200. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6201. private static CreateCubemapTexture;
  6202. private static CalcProjectionSpherical;
  6203. }
  6204. }
  6205. declare module BABYLON {
  6206. /**
  6207. * Helper class dealing with the extraction of spherical polynomial dataArray
  6208. * from a cube map.
  6209. */
  6210. export class CubeMapToSphericalPolynomialTools {
  6211. private static FileFaces;
  6212. /**
  6213. * Converts a texture to the according Spherical Polynomial data.
  6214. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6215. *
  6216. * @param texture The texture to extract the information from.
  6217. * @return The Spherical Polynomial data.
  6218. */
  6219. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6220. /**
  6221. * Converts a cubemap to the according Spherical Polynomial data.
  6222. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6223. *
  6224. * @param cubeInfo The Cube map to extract the information from.
  6225. * @return The Spherical Polynomial data.
  6226. */
  6227. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6228. }
  6229. }
  6230. declare module BABYLON {
  6231. /**
  6232. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6233. * during the life time of the application.
  6234. */
  6235. export class EngineStore {
  6236. /** Gets the list of created engines */
  6237. static Instances: Engine[];
  6238. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  6239. /**
  6240. * Gets the latest created engine
  6241. */
  6242. static readonly LastCreatedEngine: Nullable<Engine>;
  6243. /**
  6244. * Gets the latest created scene
  6245. */
  6246. static readonly LastCreatedScene: Nullable<Scene>;
  6247. }
  6248. }
  6249. declare module BABYLON {
  6250. /**
  6251. * Define options used to create a render target texture
  6252. */
  6253. export class RenderTargetCreationOptions {
  6254. /**
  6255. * Specifies is mipmaps must be generated
  6256. */
  6257. generateMipMaps?: boolean;
  6258. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6259. generateDepthBuffer?: boolean;
  6260. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6261. generateStencilBuffer?: boolean;
  6262. /** Defines texture type (int by default) */
  6263. type?: number;
  6264. /** Defines sampling mode (trilinear by default) */
  6265. samplingMode?: number;
  6266. /** Defines format (RGBA by default) */
  6267. format?: number;
  6268. }
  6269. }
  6270. declare module BABYLON {
  6271. /**
  6272. * @hidden
  6273. **/
  6274. export class _AlphaState {
  6275. private _isAlphaBlendDirty;
  6276. private _isBlendFunctionParametersDirty;
  6277. private _isBlendEquationParametersDirty;
  6278. private _isBlendConstantsDirty;
  6279. private _alphaBlend;
  6280. private _blendFunctionParameters;
  6281. private _blendEquationParameters;
  6282. private _blendConstants;
  6283. /**
  6284. * Initializes the state.
  6285. */
  6286. constructor();
  6287. readonly isDirty: boolean;
  6288. alphaBlend: boolean;
  6289. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6290. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6291. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6292. reset(): void;
  6293. apply(gl: WebGLRenderingContext): void;
  6294. }
  6295. }
  6296. declare module BABYLON {
  6297. /**
  6298. * @hidden
  6299. **/
  6300. export class _DepthCullingState {
  6301. private _isDepthTestDirty;
  6302. private _isDepthMaskDirty;
  6303. private _isDepthFuncDirty;
  6304. private _isCullFaceDirty;
  6305. private _isCullDirty;
  6306. private _isZOffsetDirty;
  6307. private _isFrontFaceDirty;
  6308. private _depthTest;
  6309. private _depthMask;
  6310. private _depthFunc;
  6311. private _cull;
  6312. private _cullFace;
  6313. private _zOffset;
  6314. private _frontFace;
  6315. /**
  6316. * Initializes the state.
  6317. */
  6318. constructor();
  6319. readonly isDirty: boolean;
  6320. zOffset: number;
  6321. cullFace: Nullable<number>;
  6322. cull: Nullable<boolean>;
  6323. depthFunc: Nullable<number>;
  6324. depthMask: boolean;
  6325. depthTest: boolean;
  6326. frontFace: Nullable<number>;
  6327. reset(): void;
  6328. apply(gl: WebGLRenderingContext): void;
  6329. }
  6330. }
  6331. declare module BABYLON {
  6332. /**
  6333. * @hidden
  6334. **/
  6335. export class _StencilState {
  6336. /** 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 */
  6337. static readonly ALWAYS: number;
  6338. /** Passed to stencilOperation to specify that stencil value must be kept */
  6339. static readonly KEEP: number;
  6340. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6341. static readonly REPLACE: number;
  6342. private _isStencilTestDirty;
  6343. private _isStencilMaskDirty;
  6344. private _isStencilFuncDirty;
  6345. private _isStencilOpDirty;
  6346. private _stencilTest;
  6347. private _stencilMask;
  6348. private _stencilFunc;
  6349. private _stencilFuncRef;
  6350. private _stencilFuncMask;
  6351. private _stencilOpStencilFail;
  6352. private _stencilOpDepthFail;
  6353. private _stencilOpStencilDepthPass;
  6354. readonly isDirty: boolean;
  6355. stencilFunc: number;
  6356. stencilFuncRef: number;
  6357. stencilFuncMask: number;
  6358. stencilOpStencilFail: number;
  6359. stencilOpDepthFail: number;
  6360. stencilOpStencilDepthPass: number;
  6361. stencilMask: number;
  6362. stencilTest: boolean;
  6363. constructor();
  6364. reset(): void;
  6365. apply(gl: WebGLRenderingContext): void;
  6366. }
  6367. }
  6368. declare module BABYLON {
  6369. /**
  6370. * @hidden
  6371. **/
  6372. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  6373. }
  6374. }
  6375. declare module BABYLON {
  6376. /**
  6377. * Class used to store data associated with WebGL texture data for the engine
  6378. * This class should not be used directly
  6379. */
  6380. export class InternalTexture {
  6381. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6382. /**
  6383. * The source of the texture data is unknown
  6384. */
  6385. static DATASOURCE_UNKNOWN: number;
  6386. /**
  6387. * Texture data comes from an URL
  6388. */
  6389. static DATASOURCE_URL: number;
  6390. /**
  6391. * Texture data is only used for temporary storage
  6392. */
  6393. static DATASOURCE_TEMP: number;
  6394. /**
  6395. * Texture data comes from raw data (ArrayBuffer)
  6396. */
  6397. static DATASOURCE_RAW: number;
  6398. /**
  6399. * Texture content is dynamic (video or dynamic texture)
  6400. */
  6401. static DATASOURCE_DYNAMIC: number;
  6402. /**
  6403. * Texture content is generated by rendering to it
  6404. */
  6405. static DATASOURCE_RENDERTARGET: number;
  6406. /**
  6407. * Texture content is part of a multi render target process
  6408. */
  6409. static DATASOURCE_MULTIRENDERTARGET: number;
  6410. /**
  6411. * Texture data comes from a cube data file
  6412. */
  6413. static DATASOURCE_CUBE: number;
  6414. /**
  6415. * Texture data comes from a raw cube data
  6416. */
  6417. static DATASOURCE_CUBERAW: number;
  6418. /**
  6419. * Texture data come from a prefiltered cube data file
  6420. */
  6421. static DATASOURCE_CUBEPREFILTERED: number;
  6422. /**
  6423. * Texture content is raw 3D data
  6424. */
  6425. static DATASOURCE_RAW3D: number;
  6426. /**
  6427. * Texture content is a depth texture
  6428. */
  6429. static DATASOURCE_DEPTHTEXTURE: number;
  6430. /**
  6431. * Texture data comes from a raw cube data encoded with RGBD
  6432. */
  6433. static DATASOURCE_CUBERAW_RGBD: number;
  6434. /**
  6435. * Defines if the texture is ready
  6436. */
  6437. isReady: boolean;
  6438. /**
  6439. * Defines if the texture is a cube texture
  6440. */
  6441. isCube: boolean;
  6442. /**
  6443. * Defines if the texture contains 3D data
  6444. */
  6445. is3D: boolean;
  6446. /**
  6447. * Defines if the texture contains multiview data
  6448. */
  6449. isMultiview: boolean;
  6450. /**
  6451. * Gets the URL used to load this texture
  6452. */
  6453. url: string;
  6454. /**
  6455. * Gets the sampling mode of the texture
  6456. */
  6457. samplingMode: number;
  6458. /**
  6459. * Gets a boolean indicating if the texture needs mipmaps generation
  6460. */
  6461. generateMipMaps: boolean;
  6462. /**
  6463. * Gets the number of samples used by the texture (WebGL2+ only)
  6464. */
  6465. samples: number;
  6466. /**
  6467. * Gets the type of the texture (int, float...)
  6468. */
  6469. type: number;
  6470. /**
  6471. * Gets the format of the texture (RGB, RGBA...)
  6472. */
  6473. format: number;
  6474. /**
  6475. * Observable called when the texture is loaded
  6476. */
  6477. onLoadedObservable: Observable<InternalTexture>;
  6478. /**
  6479. * Gets the width of the texture
  6480. */
  6481. width: number;
  6482. /**
  6483. * Gets the height of the texture
  6484. */
  6485. height: number;
  6486. /**
  6487. * Gets the depth of the texture
  6488. */
  6489. depth: number;
  6490. /**
  6491. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6492. */
  6493. baseWidth: number;
  6494. /**
  6495. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6496. */
  6497. baseHeight: number;
  6498. /**
  6499. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6500. */
  6501. baseDepth: number;
  6502. /**
  6503. * Gets a boolean indicating if the texture is inverted on Y axis
  6504. */
  6505. invertY: boolean;
  6506. /** @hidden */ private _invertVScale: boolean;
  6507. /** @hidden */ private _associatedChannel: number;
  6508. /** @hidden */ private _dataSource: number;
  6509. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6510. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  6511. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  6512. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6513. /** @hidden */ private _size: number;
  6514. /** @hidden */ private _extension: string;
  6515. /** @hidden */ private _files: Nullable<string[]>;
  6516. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  6517. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  6518. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  6519. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6520. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6521. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6522. /** @hidden */ private _attachments: Nullable<number[]>;
  6523. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  6524. /** @hidden */ private _cachedWrapU: Nullable<number>;
  6525. /** @hidden */ private _cachedWrapV: Nullable<number>;
  6526. /** @hidden */ private _cachedWrapR: Nullable<number>;
  6527. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  6528. /** @hidden */ private _isDisabled: boolean;
  6529. /** @hidden */ private _compression: Nullable<string>;
  6530. /** @hidden */ private _generateStencilBuffer: boolean;
  6531. /** @hidden */ private _generateDepthBuffer: boolean;
  6532. /** @hidden */ private _comparisonFunction: number;
  6533. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6534. /** @hidden */ private _lodGenerationScale: number;
  6535. /** @hidden */ private _lodGenerationOffset: number;
  6536. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  6537. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  6538. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  6539. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  6540. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  6541. /** @hidden */ private _isRGBD: boolean;
  6542. /** @hidden */ private _linearSpecularLOD: boolean;
  6543. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  6544. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  6545. /** @hidden */ private _references: number;
  6546. private _engine;
  6547. /**
  6548. * Gets the Engine the texture belongs to.
  6549. * @returns The babylon engine
  6550. */
  6551. getEngine(): Engine;
  6552. /**
  6553. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6554. */
  6555. readonly dataSource: number;
  6556. /**
  6557. * Creates a new InternalTexture
  6558. * @param engine defines the engine to use
  6559. * @param dataSource defines the type of data that will be used
  6560. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6561. */
  6562. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6563. /**
  6564. * Increments the number of references (ie. the number of Texture that point to it)
  6565. */
  6566. incrementReferences(): void;
  6567. /**
  6568. * Change the size of the texture (not the size of the content)
  6569. * @param width defines the new width
  6570. * @param height defines the new height
  6571. * @param depth defines the new depth (1 by default)
  6572. */
  6573. updateSize(width: int, height: int, depth?: int): void;
  6574. /** @hidden */ private _rebuild(): void;
  6575. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  6576. /**
  6577. * Dispose the current allocated resources
  6578. */
  6579. dispose(): void;
  6580. }
  6581. }
  6582. declare module BABYLON {
  6583. /**
  6584. * This represents the main contract an easing function should follow.
  6585. * Easing functions are used throughout the animation system.
  6586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6587. */
  6588. export interface IEasingFunction {
  6589. /**
  6590. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6591. * of the easing function.
  6592. * The link below provides some of the most common examples of easing functions.
  6593. * @see https://easings.net/
  6594. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6595. * @returns the corresponding value on the curve defined by the easing function
  6596. */
  6597. ease(gradient: number): number;
  6598. }
  6599. /**
  6600. * Base class used for every default easing function.
  6601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6602. */
  6603. export class EasingFunction implements IEasingFunction {
  6604. /**
  6605. * Interpolation follows the mathematical formula associated with the easing function.
  6606. */
  6607. static readonly EASINGMODE_EASEIN: number;
  6608. /**
  6609. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6610. */
  6611. static readonly EASINGMODE_EASEOUT: number;
  6612. /**
  6613. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6614. */
  6615. static readonly EASINGMODE_EASEINOUT: number;
  6616. private _easingMode;
  6617. /**
  6618. * Sets the easing mode of the current function.
  6619. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6620. */
  6621. setEasingMode(easingMode: number): void;
  6622. /**
  6623. * Gets the current easing mode.
  6624. * @returns the easing mode
  6625. */
  6626. getEasingMode(): number;
  6627. /**
  6628. * @hidden
  6629. */
  6630. easeInCore(gradient: number): number;
  6631. /**
  6632. * Given an input gradient between 0 and 1, this returns the corresponding value
  6633. * of the easing function.
  6634. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6635. * @returns the corresponding value on the curve defined by the easing function
  6636. */
  6637. ease(gradient: number): number;
  6638. }
  6639. /**
  6640. * Easing function with a circle shape (see link below).
  6641. * @see https://easings.net/#easeInCirc
  6642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6643. */
  6644. export class CircleEase extends EasingFunction implements IEasingFunction {
  6645. /** @hidden */
  6646. easeInCore(gradient: number): number;
  6647. }
  6648. /**
  6649. * Easing function with a ease back shape (see link below).
  6650. * @see https://easings.net/#easeInBack
  6651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6652. */
  6653. export class BackEase extends EasingFunction implements IEasingFunction {
  6654. /** Defines the amplitude of the function */
  6655. amplitude: number;
  6656. /**
  6657. * Instantiates a back ease easing
  6658. * @see https://easings.net/#easeInBack
  6659. * @param amplitude Defines the amplitude of the function
  6660. */
  6661. constructor(
  6662. /** Defines the amplitude of the function */
  6663. amplitude?: number);
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a bouncing shape (see link below).
  6669. * @see https://easings.net/#easeInBounce
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class BounceEase extends EasingFunction implements IEasingFunction {
  6673. /** Defines the number of bounces */
  6674. bounces: number;
  6675. /** Defines the amplitude of the bounce */
  6676. bounciness: number;
  6677. /**
  6678. * Instantiates a bounce easing
  6679. * @see https://easings.net/#easeInBounce
  6680. * @param bounces Defines the number of bounces
  6681. * @param bounciness Defines the amplitude of the bounce
  6682. */
  6683. constructor(
  6684. /** Defines the number of bounces */
  6685. bounces?: number,
  6686. /** Defines the amplitude of the bounce */
  6687. bounciness?: number);
  6688. /** @hidden */
  6689. easeInCore(gradient: number): number;
  6690. }
  6691. /**
  6692. * Easing function with a power of 3 shape (see link below).
  6693. * @see https://easings.net/#easeInCubic
  6694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6695. */
  6696. export class CubicEase extends EasingFunction implements IEasingFunction {
  6697. /** @hidden */
  6698. easeInCore(gradient: number): number;
  6699. }
  6700. /**
  6701. * Easing function with an elastic shape (see link below).
  6702. * @see https://easings.net/#easeInElastic
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6706. /** Defines the number of oscillations*/
  6707. oscillations: number;
  6708. /** Defines the amplitude of the oscillations*/
  6709. springiness: number;
  6710. /**
  6711. * Instantiates an elastic easing function
  6712. * @see https://easings.net/#easeInElastic
  6713. * @param oscillations Defines the number of oscillations
  6714. * @param springiness Defines the amplitude of the oscillations
  6715. */
  6716. constructor(
  6717. /** Defines the number of oscillations*/
  6718. oscillations?: number,
  6719. /** Defines the amplitude of the oscillations*/
  6720. springiness?: number);
  6721. /** @hidden */
  6722. easeInCore(gradient: number): number;
  6723. }
  6724. /**
  6725. * Easing function with an exponential shape (see link below).
  6726. * @see https://easings.net/#easeInExpo
  6727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6728. */
  6729. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6730. /** Defines the exponent of the function */
  6731. exponent: number;
  6732. /**
  6733. * Instantiates an exponential easing function
  6734. * @see https://easings.net/#easeInExpo
  6735. * @param exponent Defines the exponent of the function
  6736. */
  6737. constructor(
  6738. /** Defines the exponent of the function */
  6739. exponent?: number);
  6740. /** @hidden */
  6741. easeInCore(gradient: number): number;
  6742. }
  6743. /**
  6744. * Easing function with a power shape (see link below).
  6745. * @see https://easings.net/#easeInQuad
  6746. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6747. */
  6748. export class PowerEase extends EasingFunction implements IEasingFunction {
  6749. /** Defines the power of the function */
  6750. power: number;
  6751. /**
  6752. * Instantiates an power base easing function
  6753. * @see https://easings.net/#easeInQuad
  6754. * @param power Defines the power of the function
  6755. */
  6756. constructor(
  6757. /** Defines the power of the function */
  6758. power?: number);
  6759. /** @hidden */
  6760. easeInCore(gradient: number): number;
  6761. }
  6762. /**
  6763. * Easing function with a power of 2 shape (see link below).
  6764. * @see https://easings.net/#easeInQuad
  6765. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6766. */
  6767. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6768. /** @hidden */
  6769. easeInCore(gradient: number): number;
  6770. }
  6771. /**
  6772. * Easing function with a power of 4 shape (see link below).
  6773. * @see https://easings.net/#easeInQuart
  6774. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6775. */
  6776. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6777. /** @hidden */
  6778. easeInCore(gradient: number): number;
  6779. }
  6780. /**
  6781. * Easing function with a power of 5 shape (see link below).
  6782. * @see https://easings.net/#easeInQuint
  6783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6784. */
  6785. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6786. /** @hidden */
  6787. easeInCore(gradient: number): number;
  6788. }
  6789. /**
  6790. * Easing function with a sin shape (see link below).
  6791. * @see https://easings.net/#easeInSine
  6792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6793. */
  6794. export class SineEase extends EasingFunction implements IEasingFunction {
  6795. /** @hidden */
  6796. easeInCore(gradient: number): number;
  6797. }
  6798. /**
  6799. * Easing function with a bezier shape (see link below).
  6800. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6801. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6802. */
  6803. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6804. /** Defines the x component of the start tangent in the bezier curve */
  6805. x1: number;
  6806. /** Defines the y component of the start tangent in the bezier curve */
  6807. y1: number;
  6808. /** Defines the x component of the end tangent in the bezier curve */
  6809. x2: number;
  6810. /** Defines the y component of the end tangent in the bezier curve */
  6811. y2: number;
  6812. /**
  6813. * Instantiates a bezier function
  6814. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6815. * @param x1 Defines the x component of the start tangent in the bezier curve
  6816. * @param y1 Defines the y component of the start tangent in the bezier curve
  6817. * @param x2 Defines the x component of the end tangent in the bezier curve
  6818. * @param y2 Defines the y component of the end tangent in the bezier curve
  6819. */
  6820. constructor(
  6821. /** Defines the x component of the start tangent in the bezier curve */
  6822. x1?: number,
  6823. /** Defines the y component of the start tangent in the bezier curve */
  6824. y1?: number,
  6825. /** Defines the x component of the end tangent in the bezier curve */
  6826. x2?: number,
  6827. /** Defines the y component of the end tangent in the bezier curve */
  6828. y2?: number);
  6829. /** @hidden */
  6830. easeInCore(gradient: number): number;
  6831. }
  6832. }
  6833. declare module BABYLON {
  6834. /**
  6835. * Defines an interface which represents an animation key frame
  6836. */
  6837. export interface IAnimationKey {
  6838. /**
  6839. * Frame of the key frame
  6840. */
  6841. frame: number;
  6842. /**
  6843. * Value at the specifies key frame
  6844. */
  6845. value: any;
  6846. /**
  6847. * The input tangent for the cubic hermite spline
  6848. */
  6849. inTangent?: any;
  6850. /**
  6851. * The output tangent for the cubic hermite spline
  6852. */
  6853. outTangent?: any;
  6854. /**
  6855. * The animation interpolation type
  6856. */
  6857. interpolation?: AnimationKeyInterpolation;
  6858. }
  6859. /**
  6860. * Enum for the animation key frame interpolation type
  6861. */
  6862. export enum AnimationKeyInterpolation {
  6863. /**
  6864. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6865. */
  6866. STEP = 1
  6867. }
  6868. }
  6869. declare module BABYLON {
  6870. /**
  6871. * Represents the range of an animation
  6872. */
  6873. export class AnimationRange {
  6874. /**The name of the animation range**/
  6875. name: string;
  6876. /**The starting frame of the animation */
  6877. from: number;
  6878. /**The ending frame of the animation*/
  6879. to: number;
  6880. /**
  6881. * Initializes the range of an animation
  6882. * @param name The name of the animation range
  6883. * @param from The starting frame of the animation
  6884. * @param to The ending frame of the animation
  6885. */
  6886. constructor(
  6887. /**The name of the animation range**/
  6888. name: string,
  6889. /**The starting frame of the animation */
  6890. from: number,
  6891. /**The ending frame of the animation*/
  6892. to: number);
  6893. /**
  6894. * Makes a copy of the animation range
  6895. * @returns A copy of the animation range
  6896. */
  6897. clone(): AnimationRange;
  6898. }
  6899. }
  6900. declare module BABYLON {
  6901. /**
  6902. * Composed of a frame, and an action function
  6903. */
  6904. export class AnimationEvent {
  6905. /** The frame for which the event is triggered **/
  6906. frame: number;
  6907. /** The event to perform when triggered **/
  6908. action: (currentFrame: number) => void;
  6909. /** Specifies if the event should be triggered only once**/
  6910. onlyOnce?: boolean | undefined;
  6911. /**
  6912. * Specifies if the animation event is done
  6913. */
  6914. isDone: boolean;
  6915. /**
  6916. * Initializes the animation event
  6917. * @param frame The frame for which the event is triggered
  6918. * @param action The event to perform when triggered
  6919. * @param onlyOnce Specifies if the event should be triggered only once
  6920. */
  6921. constructor(
  6922. /** The frame for which the event is triggered **/
  6923. frame: number,
  6924. /** The event to perform when triggered **/
  6925. action: (currentFrame: number) => void,
  6926. /** Specifies if the event should be triggered only once**/
  6927. onlyOnce?: boolean | undefined);
  6928. /** @hidden */ private _clone(): AnimationEvent;
  6929. }
  6930. }
  6931. declare module BABYLON {
  6932. /**
  6933. * Interface used to define a behavior
  6934. */
  6935. export interface Behavior<T> {
  6936. /** gets or sets behavior's name */
  6937. name: string;
  6938. /**
  6939. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6940. */
  6941. init(): void;
  6942. /**
  6943. * Called when the behavior is attached to a target
  6944. * @param target defines the target where the behavior is attached to
  6945. */
  6946. attach(target: T): void;
  6947. /**
  6948. * Called when the behavior is detached from its target
  6949. */
  6950. detach(): void;
  6951. }
  6952. /**
  6953. * Interface implemented by classes supporting behaviors
  6954. */
  6955. export interface IBehaviorAware<T> {
  6956. /**
  6957. * Attach a behavior
  6958. * @param behavior defines the behavior to attach
  6959. * @returns the current host
  6960. */
  6961. addBehavior(behavior: Behavior<T>): T;
  6962. /**
  6963. * Remove a behavior from the current object
  6964. * @param behavior defines the behavior to detach
  6965. * @returns the current host
  6966. */
  6967. removeBehavior(behavior: Behavior<T>): T;
  6968. /**
  6969. * Gets a behavior using its name to search
  6970. * @param name defines the name to search
  6971. * @returns the behavior or null if not found
  6972. */
  6973. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6974. }
  6975. }
  6976. declare module BABYLON {
  6977. /**
  6978. * @hidden
  6979. */
  6980. export class IntersectionInfo {
  6981. bu: Nullable<number>;
  6982. bv: Nullable<number>;
  6983. distance: number;
  6984. faceId: number;
  6985. subMeshId: number;
  6986. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Class used to store bounding sphere information
  6992. */
  6993. export class BoundingSphere {
  6994. /**
  6995. * Gets the center of the bounding sphere in local space
  6996. */
  6997. readonly center: Vector3;
  6998. /**
  6999. * Radius of the bounding sphere in local space
  7000. */
  7001. radius: number;
  7002. /**
  7003. * Gets the center of the bounding sphere in world space
  7004. */
  7005. readonly centerWorld: Vector3;
  7006. /**
  7007. * Radius of the bounding sphere in world space
  7008. */
  7009. radiusWorld: number;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * Creates a new bounding sphere
  7022. * @param min defines the minimum vector (in local space)
  7023. * @param max defines the maximum vector (in local space)
  7024. * @param worldMatrix defines the new world matrix
  7025. */
  7026. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7027. /**
  7028. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7029. * @param min defines the new minimum vector (in local space)
  7030. * @param max defines the new maximum vector (in local space)
  7031. * @param worldMatrix defines the new world matrix
  7032. */
  7033. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7034. /**
  7035. * Scale the current bounding sphere by applying a scale factor
  7036. * @param factor defines the scale factor to apply
  7037. * @returns the current bounding box
  7038. */
  7039. scale(factor: number): BoundingSphere;
  7040. /**
  7041. * Gets the world matrix of the bounding box
  7042. * @returns a matrix
  7043. */
  7044. getWorldMatrix(): DeepImmutable<Matrix>;
  7045. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  7046. /**
  7047. * Tests if the bounding sphere is intersecting the frustum planes
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @returns true if there is an intersection
  7050. */
  7051. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if the bounding sphere center is in between the frustum planes.
  7054. * Used for optimistic fast inclusion.
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if the sphere center is in between the frustum planes
  7057. */
  7058. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if a point is inside the bounding sphere
  7061. * @param point defines the point to test
  7062. * @returns true if the point is inside the bounding sphere
  7063. */
  7064. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7065. /**
  7066. * Checks if two sphere intersct
  7067. * @param sphere0 sphere 0
  7068. * @param sphere1 sphere 1
  7069. * @returns true if the speres intersect
  7070. */
  7071. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7072. }
  7073. }
  7074. declare module BABYLON {
  7075. /**
  7076. * Class used to store bounding box information
  7077. */
  7078. export class BoundingBox implements ICullable {
  7079. /**
  7080. * Gets the 8 vectors representing the bounding box in local space
  7081. */
  7082. readonly vectors: Vector3[];
  7083. /**
  7084. * Gets the center of the bounding box in local space
  7085. */
  7086. readonly center: Vector3;
  7087. /**
  7088. * Gets the center of the bounding box in world space
  7089. */
  7090. readonly centerWorld: Vector3;
  7091. /**
  7092. * Gets the extend size in local space
  7093. */
  7094. readonly extendSize: Vector3;
  7095. /**
  7096. * Gets the extend size in world space
  7097. */
  7098. readonly extendSizeWorld: Vector3;
  7099. /**
  7100. * Gets the OBB (object bounding box) directions
  7101. */
  7102. readonly directions: Vector3[];
  7103. /**
  7104. * Gets the 8 vectors representing the bounding box in world space
  7105. */
  7106. readonly vectorsWorld: Vector3[];
  7107. /**
  7108. * Gets the minimum vector in world space
  7109. */
  7110. readonly minimumWorld: Vector3;
  7111. /**
  7112. * Gets the maximum vector in world space
  7113. */
  7114. readonly maximumWorld: Vector3;
  7115. /**
  7116. * Gets the minimum vector in local space
  7117. */
  7118. readonly minimum: Vector3;
  7119. /**
  7120. * Gets the maximum vector in local space
  7121. */
  7122. readonly maximum: Vector3;
  7123. private _worldMatrix;
  7124. private static readonly TmpVector3;
  7125. /**
  7126. * @hidden
  7127. */ private _tag: number;
  7128. /**
  7129. * Creates a new bounding box
  7130. * @param min defines the minimum vector (in local space)
  7131. * @param max defines the maximum vector (in local space)
  7132. * @param worldMatrix defines the new world matrix
  7133. */
  7134. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7135. /**
  7136. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7137. * @param min defines the new minimum vector (in local space)
  7138. * @param max defines the new maximum vector (in local space)
  7139. * @param worldMatrix defines the new world matrix
  7140. */
  7141. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7142. /**
  7143. * Scale the current bounding box by applying a scale factor
  7144. * @param factor defines the scale factor to apply
  7145. * @returns the current bounding box
  7146. */
  7147. scale(factor: number): BoundingBox;
  7148. /**
  7149. * Gets the world matrix of the bounding box
  7150. * @returns a matrix
  7151. */
  7152. getWorldMatrix(): DeepImmutable<Matrix>;
  7153. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding box is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding box is entirely inside the frustum planes
  7162. * @param frustumPlanes defines the frustum planes to test
  7163. * @returns true if there is an inclusion
  7164. */
  7165. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7166. /**
  7167. * Tests if a point is inside the bounding box
  7168. * @param point defines the point to test
  7169. * @returns true if the point is inside the bounding box
  7170. */
  7171. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7172. /**
  7173. * Tests if the bounding box intersects with a bounding sphere
  7174. * @param sphere defines the sphere to test
  7175. * @returns true if there is an intersection
  7176. */
  7177. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7178. /**
  7179. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7180. * @param min defines the min vector to use
  7181. * @param max defines the max vector to use
  7182. * @returns true if there is an intersection
  7183. */
  7184. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7185. /**
  7186. * Tests if two bounding boxes are intersections
  7187. * @param box0 defines the first box to test
  7188. * @param box1 defines the second box to test
  7189. * @returns true if there is an intersection
  7190. */
  7191. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7192. /**
  7193. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7194. * @param minPoint defines the minimum vector of the bounding box
  7195. * @param maxPoint defines the maximum vector of the bounding box
  7196. * @param sphereCenter defines the sphere center
  7197. * @param sphereRadius defines the sphere radius
  7198. * @returns true if there is an intersection
  7199. */
  7200. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7201. /**
  7202. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7203. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7204. * @param frustumPlanes defines the frustum planes to test
  7205. * @return true if there is an inclusion
  7206. */
  7207. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7208. /**
  7209. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7210. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7211. * @param frustumPlanes defines the frustum planes to test
  7212. * @return true if there is an intersection
  7213. */
  7214. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7215. }
  7216. }
  7217. declare module BABYLON {
  7218. /** @hidden */
  7219. export class Collider {
  7220. /** Define if a collision was found */
  7221. collisionFound: boolean;
  7222. /**
  7223. * Define last intersection point in local space
  7224. */
  7225. intersectionPoint: Vector3;
  7226. /**
  7227. * Define last collided mesh
  7228. */
  7229. collidedMesh: Nullable<AbstractMesh>;
  7230. private _collisionPoint;
  7231. private _planeIntersectionPoint;
  7232. private _tempVector;
  7233. private _tempVector2;
  7234. private _tempVector3;
  7235. private _tempVector4;
  7236. private _edge;
  7237. private _baseToVertex;
  7238. private _destinationPoint;
  7239. private _slidePlaneNormal;
  7240. private _displacementVector;
  7241. /** @hidden */ private _radius: Vector3;
  7242. /** @hidden */ private _retry: number;
  7243. private _velocity;
  7244. private _basePoint;
  7245. private _epsilon;
  7246. /** @hidden */ private _velocityWorldLength: number;
  7247. /** @hidden */ private _basePointWorld: Vector3;
  7248. private _velocityWorld;
  7249. private _normalizedVelocity;
  7250. /** @hidden */ private _initialVelocity: Vector3;
  7251. /** @hidden */ private _initialPosition: Vector3;
  7252. private _nearestDistance;
  7253. private _collisionMask;
  7254. collisionMask: number;
  7255. /**
  7256. * Gets the plane normal used to compute the sliding response (in local space)
  7257. */
  7258. readonly slidePlaneNormal: Vector3;
  7259. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7260. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7261. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7262. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7263. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7264. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7265. }
  7266. }
  7267. declare module BABYLON {
  7268. /**
  7269. * Interface for cullable objects
  7270. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7271. */
  7272. export interface ICullable {
  7273. /**
  7274. * Checks if the object or part of the object is in the frustum
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isInFrustum(frustumPlanes: Plane[]): boolean;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7286. }
  7287. /**
  7288. * Info for a bounding data of a mesh
  7289. */
  7290. export class BoundingInfo implements ICullable {
  7291. /**
  7292. * Bounding box for the mesh
  7293. */
  7294. readonly boundingBox: BoundingBox;
  7295. /**
  7296. * Bounding sphere for the mesh
  7297. */
  7298. readonly boundingSphere: BoundingSphere;
  7299. private _isLocked;
  7300. private static readonly TmpVector3;
  7301. /**
  7302. * Constructs bounding info
  7303. * @param minimum min vector of the bounding box/sphere
  7304. * @param maximum max vector of the bounding box/sphere
  7305. * @param worldMatrix defines the new world matrix
  7306. */
  7307. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7308. /**
  7309. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7310. * @param min defines the new minimum vector (in local space)
  7311. * @param max defines the new maximum vector (in local space)
  7312. * @param worldMatrix defines the new world matrix
  7313. */
  7314. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7315. /**
  7316. * min vector of the bounding box/sphere
  7317. */
  7318. readonly minimum: Vector3;
  7319. /**
  7320. * max vector of the bounding box/sphere
  7321. */
  7322. readonly maximum: Vector3;
  7323. /**
  7324. * If the info is locked and won't be updated to avoid perf overhead
  7325. */
  7326. isLocked: boolean;
  7327. /**
  7328. * Updates the bounding sphere and box
  7329. * @param world world matrix to be used to update
  7330. */
  7331. update(world: DeepImmutable<Matrix>): void;
  7332. /**
  7333. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7334. * @param center New center of the bounding info
  7335. * @param extend New extend of the bounding info
  7336. * @returns the current bounding info
  7337. */
  7338. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7339. /**
  7340. * Scale the current bounding info by applying a scale factor
  7341. * @param factor defines the scale factor to apply
  7342. * @returns the current bounding info
  7343. */
  7344. scale(factor: number): BoundingInfo;
  7345. /**
  7346. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7347. * @param frustumPlanes defines the frustum to test
  7348. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7349. * @returns true if the bounding info is in the frustum planes
  7350. */
  7351. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7352. /**
  7353. * Gets the world distance between the min and max points of the bounding box
  7354. */
  7355. readonly diagonalLength: number;
  7356. /**
  7357. * Checks if a cullable object (mesh...) is in the camera frustum
  7358. * Unlike isInFrustum this cheks the full bounding box
  7359. * @param frustumPlanes Camera near/planes
  7360. * @returns true if the object is in frustum otherwise false
  7361. */
  7362. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7363. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7364. /**
  7365. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7366. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7367. * @param point the point to check intersection with
  7368. * @returns if the point intersects
  7369. */
  7370. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7371. /**
  7372. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7373. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7374. * @param boundingInfo the bounding info to check intersection with
  7375. * @param precise if the intersection should be done using OBB
  7376. * @returns if the bounding info intersects
  7377. */
  7378. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7379. }
  7380. }
  7381. declare module BABYLON {
  7382. /**
  7383. * Defines an array and its length.
  7384. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7385. */
  7386. export interface ISmartArrayLike<T> {
  7387. /**
  7388. * The data of the array.
  7389. */
  7390. data: Array<T>;
  7391. /**
  7392. * The active length of the array.
  7393. */
  7394. length: number;
  7395. }
  7396. /**
  7397. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7398. */
  7399. export class SmartArray<T> implements ISmartArrayLike<T> {
  7400. /**
  7401. * The full set of data from the array.
  7402. */
  7403. data: Array<T>;
  7404. /**
  7405. * The active length of the array.
  7406. */
  7407. length: number;
  7408. protected _id: number;
  7409. /**
  7410. * Instantiates a Smart Array.
  7411. * @param capacity defines the default capacity of the array.
  7412. */
  7413. constructor(capacity: number);
  7414. /**
  7415. * Pushes a value at the end of the active data.
  7416. * @param value defines the object to push in the array.
  7417. */
  7418. push(value: T): void;
  7419. /**
  7420. * Iterates over the active data and apply the lambda to them.
  7421. * @param func defines the action to apply on each value.
  7422. */
  7423. forEach(func: (content: T) => void): void;
  7424. /**
  7425. * Sorts the full sets of data.
  7426. * @param compareFn defines the comparison function to apply.
  7427. */
  7428. sort(compareFn: (a: T, b: T) => number): void;
  7429. /**
  7430. * Resets the active data to an empty array.
  7431. */
  7432. reset(): void;
  7433. /**
  7434. * Releases all the data from the array as well as the array.
  7435. */
  7436. dispose(): void;
  7437. /**
  7438. * Concats the active data with a given array.
  7439. * @param array defines the data to concatenate with.
  7440. */
  7441. concat(array: any): void;
  7442. /**
  7443. * Returns the position of a value in the active data.
  7444. * @param value defines the value to find the index for
  7445. * @returns the index if found in the active data otherwise -1
  7446. */
  7447. indexOf(value: T): number;
  7448. /**
  7449. * Returns whether an element is part of the active data.
  7450. * @param value defines the value to look for
  7451. * @returns true if found in the active data otherwise false
  7452. */
  7453. contains(value: T): boolean;
  7454. private static _GlobalId;
  7455. }
  7456. /**
  7457. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7458. * The data in this array can only be present once
  7459. */
  7460. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7461. private _duplicateId;
  7462. /**
  7463. * Pushes a value at the end of the active data.
  7464. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7465. * @param value defines the object to push in the array.
  7466. */
  7467. push(value: T): void;
  7468. /**
  7469. * Pushes a value at the end of the active data.
  7470. * If the data is already present, it won t be added again
  7471. * @param value defines the object to push in the array.
  7472. * @returns true if added false if it was already present
  7473. */
  7474. pushNoDuplicate(value: T): boolean;
  7475. /**
  7476. * Resets the active data to an empty array.
  7477. */
  7478. reset(): void;
  7479. /**
  7480. * Concats the active data with a given array.
  7481. * This ensures no dupplicate will be present in the result.
  7482. * @param array defines the data to concatenate with.
  7483. */
  7484. concatWithNoDuplicate(array: any): void;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Enum that determines the text-wrapping mode to use.
  7490. */
  7491. export enum InspectableType {
  7492. /**
  7493. * Checkbox for booleans
  7494. */
  7495. Checkbox = 0,
  7496. /**
  7497. * Sliders for numbers
  7498. */
  7499. Slider = 1,
  7500. /**
  7501. * Vector3
  7502. */
  7503. Vector3 = 2,
  7504. /**
  7505. * Quaternions
  7506. */
  7507. Quaternion = 3,
  7508. /**
  7509. * Color3
  7510. */
  7511. Color3 = 4
  7512. }
  7513. /**
  7514. * Interface used to define custom inspectable properties.
  7515. * This interface is used by the inspector to display custom property grids
  7516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7517. */
  7518. export interface IInspectable {
  7519. /**
  7520. * Gets the label to display
  7521. */
  7522. label: string;
  7523. /**
  7524. * Gets the name of the property to edit
  7525. */
  7526. propertyName: string;
  7527. /**
  7528. * Gets the type of the editor to use
  7529. */
  7530. type: InspectableType;
  7531. /**
  7532. * Gets the minimum value of the property when using in "slider" mode
  7533. */
  7534. min?: number;
  7535. /**
  7536. * Gets the maximum value of the property when using in "slider" mode
  7537. */
  7538. max?: number;
  7539. /**
  7540. * Gets the setp to use when using in "slider" mode
  7541. */
  7542. step?: number;
  7543. }
  7544. }
  7545. declare module BABYLON {
  7546. /**
  7547. * This represents the required contract to create a new type of texture loader.
  7548. */
  7549. export interface IInternalTextureLoader {
  7550. /**
  7551. * Defines wether the loader supports cascade loading the different faces.
  7552. */
  7553. supportCascades: boolean;
  7554. /**
  7555. * This returns if the loader support the current file information.
  7556. * @param extension defines the file extension of the file being loaded
  7557. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7558. * @param fallback defines the fallback internal texture if any
  7559. * @param isBase64 defines whether the texture is encoded as a base64
  7560. * @param isBuffer defines whether the texture data are stored as a buffer
  7561. * @returns true if the loader can load the specified file
  7562. */
  7563. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7564. /**
  7565. * Transform the url before loading if required.
  7566. * @param rootUrl the url of the texture
  7567. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7568. * @returns the transformed texture
  7569. */
  7570. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7571. /**
  7572. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7573. * @param rootUrl the url of the texture
  7574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7575. * @returns the fallback texture
  7576. */
  7577. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7578. /**
  7579. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7580. * @param data contains the texture data
  7581. * @param texture defines the BabylonJS internal texture
  7582. * @param createPolynomials will be true if polynomials have been requested
  7583. * @param onLoad defines the callback to trigger once the texture is ready
  7584. * @param onError defines the callback to trigger in case of error
  7585. */
  7586. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7587. /**
  7588. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7589. * @param data contains the texture data
  7590. * @param texture defines the BabylonJS internal texture
  7591. * @param callback defines the method to call once ready to upload
  7592. */
  7593. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7594. }
  7595. }
  7596. declare module BABYLON {
  7597. interface Engine {
  7598. /**
  7599. * Creates a depth stencil cube texture.
  7600. * This is only available in WebGL 2.
  7601. * @param size The size of face edge in the cube texture.
  7602. * @param options The options defining the cube texture.
  7603. * @returns The cube texture
  7604. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7605. /**
  7606. * Creates a cube texture
  7607. * @param rootUrl defines the url where the files to load is located
  7608. * @param scene defines the current scene
  7609. * @param files defines the list of files to load (1 per face)
  7610. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7611. * @param onLoad defines an optional callback raised when the texture is loaded
  7612. * @param onError defines an optional callback raised if there is an issue to load the texture
  7613. * @param format defines the format of the data
  7614. * @param forcedExtension defines the extension to use to pick the right loader
  7615. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7616. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7617. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7618. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7619. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7620. * @returns the cube texture as an InternalTexture
  7621. */
  7622. 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;
  7623. /**
  7624. * Creates a cube texture
  7625. * @param rootUrl defines the url where the files to load is located
  7626. * @param scene defines the current scene
  7627. * @param files defines the list of files to load (1 per face)
  7628. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7629. * @param onLoad defines an optional callback raised when the texture is loaded
  7630. * @param onError defines an optional callback raised if there is an issue to load the texture
  7631. * @param format defines the format of the data
  7632. * @param forcedExtension defines the extension to use to pick the right loader
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. 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;
  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. * @returns the cube texture as an InternalTexture
  7650. */
  7651. 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;
  7652. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7653. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7654. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7655. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7656. }
  7657. }
  7658. declare module BABYLON {
  7659. /**
  7660. * Class for creating a cube texture
  7661. */
  7662. export class CubeTexture extends BaseTexture {
  7663. private _delayedOnLoad;
  7664. /**
  7665. * The url of the texture
  7666. */
  7667. url: string;
  7668. /**
  7669. * Gets or sets the center of the bounding box associated with the cube texture.
  7670. * It must define where the camera used to render the texture was set
  7671. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7672. */
  7673. boundingBoxPosition: Vector3;
  7674. private _boundingBoxSize;
  7675. /**
  7676. * Gets or sets the size of the bounding box associated with the cube texture
  7677. * When defined, the cubemap will switch to local mode
  7678. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7679. * @example https://www.babylonjs-playground.com/#RNASML
  7680. */
  7681. /**
  7682. * Returns the bounding box size
  7683. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7684. */
  7685. boundingBoxSize: Vector3;
  7686. protected _rotationY: number;
  7687. /**
  7688. * Sets texture matrix rotation angle around Y axis in radians.
  7689. */
  7690. /**
  7691. * Gets texture matrix rotation angle around Y axis radians.
  7692. */
  7693. rotationY: number;
  7694. /**
  7695. * Are mip maps generated for this texture or not.
  7696. */
  7697. readonly noMipmap: boolean;
  7698. private _noMipmap;
  7699. private _files;
  7700. private _extensions;
  7701. private _textureMatrix;
  7702. private _format;
  7703. private _createPolynomials;
  7704. /** @hidden */ private _prefiltered: boolean;
  7705. /**
  7706. * Creates a cube texture from an array of image urls
  7707. * @param files defines an array of image urls
  7708. * @param scene defines the hosting scene
  7709. * @param noMipmap specifies if mip maps are not used
  7710. * @returns a cube texture
  7711. */
  7712. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7713. /**
  7714. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7715. * @param url defines the url of the prefiltered texture
  7716. * @param scene defines the scene the texture is attached to
  7717. * @param forcedExtension defines the extension of the file if different from the url
  7718. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7719. * @return the prefiltered texture
  7720. */
  7721. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7722. /**
  7723. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7724. * as prefiltered data.
  7725. * @param rootUrl defines the url of the texture or the root name of the six images
  7726. * @param scene defines the scene the texture is attached to
  7727. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7728. * @param noMipmap defines if mipmaps should be created or not
  7729. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7730. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7731. * @param onError defines a callback triggered in case of error during load
  7732. * @param format defines the internal format to use for the texture once loaded
  7733. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7734. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7735. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @return the cube texture
  7739. */
  7740. 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);
  7741. /**
  7742. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7743. */
  7744. readonly isPrefiltered: boolean;
  7745. /**
  7746. * Get the current class name of the texture useful for serialization or dynamic coding.
  7747. * @returns "CubeTexture"
  7748. */
  7749. getClassName(): string;
  7750. /**
  7751. * Update the url (and optional buffer) of this texture if url was null during construction.
  7752. * @param url the url of the texture
  7753. * @param forcedExtension defines the extension to use
  7754. * @param onLoad callback called when the texture is loaded (defaults to null)
  7755. */
  7756. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7757. /**
  7758. * Delays loading of the cube texture
  7759. * @param forcedExtension defines the extension to use
  7760. */
  7761. delayLoad(forcedExtension?: string): void;
  7762. /**
  7763. * Returns the reflection texture matrix
  7764. * @returns the reflection texture matrix
  7765. */
  7766. getReflectionTextureMatrix(): Matrix;
  7767. /**
  7768. * Sets the reflection texture matrix
  7769. * @param value Reflection texture matrix
  7770. */
  7771. setReflectionTextureMatrix(value: Matrix): void;
  7772. /**
  7773. * Parses text to create a cube texture
  7774. * @param parsedTexture define the serialized text to read from
  7775. * @param scene defines the hosting scene
  7776. * @param rootUrl defines the root url of the cube texture
  7777. * @returns a cube texture
  7778. */
  7779. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7780. /**
  7781. * Makes a clone, or deep copy, of the cube texture
  7782. * @returns a new cube texture
  7783. */
  7784. clone(): CubeTexture;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /** @hidden */
  7789. export var postprocessVertexShader: {
  7790. name: string;
  7791. shader: string;
  7792. };
  7793. }
  7794. declare module BABYLON {
  7795. /**
  7796. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7797. * This is the base of the follow, arc rotate cameras and Free camera
  7798. * @see http://doc.babylonjs.com/features/cameras
  7799. */
  7800. export class TargetCamera extends Camera {
  7801. private static _RigCamTransformMatrix;
  7802. private static _TargetTransformMatrix;
  7803. private static _TargetFocalPoint;
  7804. /**
  7805. * Define the current direction the camera is moving to
  7806. */
  7807. cameraDirection: Vector3;
  7808. /**
  7809. * Define the current rotation the camera is rotating to
  7810. */
  7811. cameraRotation: Vector2;
  7812. /**
  7813. * When set, the up vector of the camera will be updated by the rotation of the camera
  7814. */
  7815. updateUpVectorFromRotation: boolean;
  7816. private _tmpQuaternion;
  7817. /**
  7818. * Define the current rotation of the camera
  7819. */
  7820. rotation: Vector3;
  7821. /**
  7822. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7823. */
  7824. rotationQuaternion: Quaternion;
  7825. /**
  7826. * Define the current speed of the camera
  7827. */
  7828. speed: number;
  7829. /**
  7830. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7831. * around all axis.
  7832. */
  7833. noRotationConstraint: boolean;
  7834. /**
  7835. * Define the current target of the camera as an object or a position.
  7836. */
  7837. lockedTarget: any;
  7838. /** @hidden */ private _currentTarget: Vector3;
  7839. /** @hidden */ private _initialFocalDistance: number;
  7840. /** @hidden */ private _viewMatrix: Matrix;
  7841. /** @hidden */ private _camMatrix: Matrix;
  7842. /** @hidden */ private _cameraTransformMatrix: Matrix;
  7843. /** @hidden */ private _cameraRotationMatrix: Matrix;
  7844. /** @hidden */ private _referencePoint: Vector3;
  7845. /** @hidden */ private _transformedReferencePoint: Vector3;
  7846. protected _globalCurrentTarget: Vector3;
  7847. protected _globalCurrentUpVector: Vector3;
  7848. /** @hidden */ private _reset: () => void;
  7849. private _defaultUp;
  7850. /**
  7851. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7852. * This is the base of the follow, arc rotate cameras and Free camera
  7853. * @see http://doc.babylonjs.com/features/cameras
  7854. * @param name Defines the name of the camera in the scene
  7855. * @param position Defines the start position of the camera in the scene
  7856. * @param scene Defines the scene the camera belongs to
  7857. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7858. */
  7859. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7860. /**
  7861. * Gets the position in front of the camera at a given distance.
  7862. * @param distance The distance from the camera we want the position to be
  7863. * @returns the position
  7864. */
  7865. getFrontPosition(distance: number): Vector3;
  7866. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  7867. private _storedPosition;
  7868. private _storedRotation;
  7869. private _storedRotationQuaternion;
  7870. /**
  7871. * Store current camera state of the camera (fov, position, rotation, etc..)
  7872. * @returns the camera
  7873. */
  7874. storeState(): Camera;
  7875. /**
  7876. * Restored camera state. You must call storeState() first
  7877. * @returns whether it was successful or not
  7878. * @hidden
  7879. */ private _restoreStateValues(): boolean;
  7880. /** @hidden */ private _initCache(): void;
  7881. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  7882. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  7883. /** @hidden */ private _computeLocalCameraSpeed(): number;
  7884. /**
  7885. * Defines the target the camera should look at.
  7886. * @param target Defines the new target as a Vector or a mesh
  7887. */
  7888. setTarget(target: Vector3): void;
  7889. /**
  7890. * Return the current target position of the camera. This value is expressed in local space.
  7891. * @returns the target position
  7892. */
  7893. getTarget(): Vector3;
  7894. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  7895. /** @hidden */ private _updatePosition(): void;
  7896. /** @hidden */ private _checkInputs(): void;
  7897. protected _updateCameraRotationMatrix(): void;
  7898. /**
  7899. * 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)
  7900. * @returns the current camera
  7901. */
  7902. private _rotateUpVectorWithCameraRotationMatrix;
  7903. private _cachedRotationZ;
  7904. private _cachedQuaternionRotationZ;
  7905. /** @hidden */ private _getViewMatrix(): Matrix;
  7906. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7907. /**
  7908. * @hidden
  7909. */
  7910. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7911. /**
  7912. * @hidden
  7913. */ private _updateRigCameras(): void;
  7914. private _getRigCamPositionAndTarget;
  7915. /**
  7916. * Gets the current object class name.
  7917. * @return the class name
  7918. */
  7919. getClassName(): string;
  7920. }
  7921. }
  7922. declare module BABYLON {
  7923. /**
  7924. * @ignore
  7925. * This is a list of all the different input types that are available in the application.
  7926. * Fo instance: ArcRotateCameraGamepadInput...
  7927. */
  7928. export var CameraInputTypes: {};
  7929. /**
  7930. * This is the contract to implement in order to create a new input class.
  7931. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7932. */
  7933. export interface ICameraInput<TCamera extends Camera> {
  7934. /**
  7935. * Defines the camera the input is attached to.
  7936. */
  7937. camera: Nullable<TCamera>;
  7938. /**
  7939. * Gets the class name of the current intput.
  7940. * @returns the class name
  7941. */
  7942. getClassName(): string;
  7943. /**
  7944. * Get the friendly name associated with the input class.
  7945. * @returns the input friendly name
  7946. */
  7947. getSimpleName(): string;
  7948. /**
  7949. * Attach the input controls to a specific dom element to get the input from.
  7950. * @param element Defines the element the controls should be listened from
  7951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7952. */
  7953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7954. /**
  7955. * Detach the current controls from the specified dom element.
  7956. * @param element Defines the element to stop listening the inputs from
  7957. */
  7958. detachControl(element: Nullable<HTMLElement>): void;
  7959. /**
  7960. * Update the current camera state depending on the inputs that have been used this frame.
  7961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7962. */
  7963. checkInputs?: () => void;
  7964. }
  7965. /**
  7966. * Represents a map of input types to input instance or input index to input instance.
  7967. */
  7968. export interface CameraInputsMap<TCamera extends Camera> {
  7969. /**
  7970. * Accessor to the input by input type.
  7971. */
  7972. [name: string]: ICameraInput<TCamera>;
  7973. /**
  7974. * Accessor to the input by input index.
  7975. */
  7976. [idx: number]: ICameraInput<TCamera>;
  7977. }
  7978. /**
  7979. * This represents the input manager used within a camera.
  7980. * It helps dealing with all the different kind of input attached to a camera.
  7981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7982. */
  7983. export class CameraInputsManager<TCamera extends Camera> {
  7984. /**
  7985. * Defines the list of inputs attahed to the camera.
  7986. */
  7987. attached: CameraInputsMap<TCamera>;
  7988. /**
  7989. * Defines the dom element the camera is collecting inputs from.
  7990. * This is null if the controls have not been attached.
  7991. */
  7992. attachedElement: Nullable<HTMLElement>;
  7993. /**
  7994. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7995. */
  7996. noPreventDefault: boolean;
  7997. /**
  7998. * Defined the camera the input manager belongs to.
  7999. */
  8000. camera: TCamera;
  8001. /**
  8002. * Update the current camera state depending on the inputs that have been used this frame.
  8003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8004. */
  8005. checkInputs: () => void;
  8006. /**
  8007. * Instantiate a new Camera Input Manager.
  8008. * @param camera Defines the camera the input manager blongs to
  8009. */
  8010. constructor(camera: TCamera);
  8011. /**
  8012. * Add an input method to a camera
  8013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8014. * @param input camera input method
  8015. */
  8016. add(input: ICameraInput<TCamera>): void;
  8017. /**
  8018. * Remove a specific input method from a camera
  8019. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8020. * @param inputToRemove camera input method
  8021. */
  8022. remove(inputToRemove: ICameraInput<TCamera>): void;
  8023. /**
  8024. * Remove a specific input type from a camera
  8025. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8026. * @param inputType the type of the input to remove
  8027. */
  8028. removeByType(inputType: string): void;
  8029. private _addCheckInputs;
  8030. /**
  8031. * Attach the input controls to the currently attached dom element to listen the events from.
  8032. * @param input Defines the input to attach
  8033. */
  8034. attachInput(input: ICameraInput<TCamera>): void;
  8035. /**
  8036. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8037. * @param element Defines the dom element to collect the events from
  8038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8039. */
  8040. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8041. /**
  8042. * Detach the current manager inputs controls from a specific dom element.
  8043. * @param element Defines the dom element to collect the events from
  8044. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8045. */
  8046. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8047. /**
  8048. * Rebuild the dynamic inputCheck function from the current list of
  8049. * defined inputs in the manager.
  8050. */
  8051. rebuildInputCheck(): void;
  8052. /**
  8053. * Remove all attached input methods from a camera
  8054. */
  8055. clear(): void;
  8056. /**
  8057. * Serialize the current input manager attached to a camera.
  8058. * This ensures than once parsed,
  8059. * the input associated to the camera will be identical to the current ones
  8060. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8061. */
  8062. serialize(serializedCamera: any): void;
  8063. /**
  8064. * Parses an input manager serialized JSON to restore the previous list of inputs
  8065. * and states associated to a camera.
  8066. * @param parsedCamera Defines the JSON to parse
  8067. */
  8068. parse(parsedCamera: any): void;
  8069. }
  8070. }
  8071. declare module BABYLON {
  8072. /**
  8073. * Gather the list of keyboard event types as constants.
  8074. */
  8075. export class KeyboardEventTypes {
  8076. /**
  8077. * The keydown event is fired when a key becomes active (pressed).
  8078. */
  8079. static readonly KEYDOWN: number;
  8080. /**
  8081. * The keyup event is fired when a key has been released.
  8082. */
  8083. static readonly KEYUP: number;
  8084. }
  8085. /**
  8086. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8087. */
  8088. export class KeyboardInfo {
  8089. /**
  8090. * Defines the type of event (KeyboardEventTypes)
  8091. */
  8092. type: number;
  8093. /**
  8094. * Defines the related dom event
  8095. */
  8096. event: KeyboardEvent;
  8097. /**
  8098. * Instantiates a new keyboard info.
  8099. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8100. * @param type Defines the type of event (KeyboardEventTypes)
  8101. * @param event Defines the related dom event
  8102. */
  8103. constructor(
  8104. /**
  8105. * Defines the type of event (KeyboardEventTypes)
  8106. */
  8107. type: number,
  8108. /**
  8109. * Defines the related dom event
  8110. */
  8111. event: KeyboardEvent);
  8112. }
  8113. /**
  8114. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8115. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8116. */
  8117. export class KeyboardInfoPre extends KeyboardInfo {
  8118. /**
  8119. * Defines the type of event (KeyboardEventTypes)
  8120. */
  8121. type: number;
  8122. /**
  8123. * Defines the related dom event
  8124. */
  8125. event: KeyboardEvent;
  8126. /**
  8127. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8128. */
  8129. skipOnPointerObservable: boolean;
  8130. /**
  8131. * Instantiates a new keyboard pre info.
  8132. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8133. * @param type Defines the type of event (KeyboardEventTypes)
  8134. * @param event Defines the related dom event
  8135. */
  8136. constructor(
  8137. /**
  8138. * Defines the type of event (KeyboardEventTypes)
  8139. */
  8140. type: number,
  8141. /**
  8142. * Defines the related dom event
  8143. */
  8144. event: KeyboardEvent);
  8145. }
  8146. }
  8147. declare module BABYLON {
  8148. /**
  8149. * Manage the keyboard inputs to control the movement of a free camera.
  8150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8151. */
  8152. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8153. /**
  8154. * Defines the camera the input is attached to.
  8155. */
  8156. camera: FreeCamera;
  8157. /**
  8158. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8159. */
  8160. keysUp: number[];
  8161. /**
  8162. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8163. */
  8164. keysDown: number[];
  8165. /**
  8166. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8167. */
  8168. keysLeft: number[];
  8169. /**
  8170. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8171. */
  8172. keysRight: number[];
  8173. private _keys;
  8174. private _onCanvasBlurObserver;
  8175. private _onKeyboardObserver;
  8176. private _engine;
  8177. private _scene;
  8178. /**
  8179. * Attach the input controls to a specific dom element to get the input from.
  8180. * @param element Defines the element the controls should be listened from
  8181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8182. */
  8183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8184. /**
  8185. * Detach the current controls from the specified dom element.
  8186. * @param element Defines the element to stop listening the inputs from
  8187. */
  8188. detachControl(element: Nullable<HTMLElement>): void;
  8189. /**
  8190. * Update the current camera state depending on the inputs that have been used this frame.
  8191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8192. */
  8193. checkInputs(): void;
  8194. /**
  8195. * Gets the class name of the current intput.
  8196. * @returns the class name
  8197. */
  8198. getClassName(): string;
  8199. /** @hidden */ private _onLostFocus(): void;
  8200. /**
  8201. * Get the friendly name associated with the input class.
  8202. * @returns the input friendly name
  8203. */
  8204. getSimpleName(): string;
  8205. }
  8206. }
  8207. declare module BABYLON {
  8208. /**
  8209. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8210. * separate meshes. This can be use to improve performances.
  8211. * @see http://doc.babylonjs.com/how_to/multi_materials
  8212. */
  8213. export class MultiMaterial extends Material {
  8214. private _subMaterials;
  8215. /**
  8216. * Gets or Sets the list of Materials used within the multi material.
  8217. * They need to be ordered according to the submeshes order in the associated mesh
  8218. */
  8219. subMaterials: Nullable<Material>[];
  8220. /**
  8221. * Function used to align with Node.getChildren()
  8222. * @returns the list of Materials used within the multi material
  8223. */
  8224. getChildren(): Nullable<Material>[];
  8225. /**
  8226. * Instantiates a new Multi Material
  8227. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8228. * separate meshes. This can be use to improve performances.
  8229. * @see http://doc.babylonjs.com/how_to/multi_materials
  8230. * @param name Define the name in the scene
  8231. * @param scene Define the scene the material belongs to
  8232. */
  8233. constructor(name: string, scene: Scene);
  8234. private _hookArray;
  8235. /**
  8236. * Get one of the submaterial by its index in the submaterials array
  8237. * @param index The index to look the sub material at
  8238. * @returns The Material if the index has been defined
  8239. */
  8240. getSubMaterial(index: number): Nullable<Material>;
  8241. /**
  8242. * Get the list of active textures for the whole sub materials list.
  8243. * @returns All the textures that will be used during the rendering
  8244. */
  8245. getActiveTextures(): BaseTexture[];
  8246. /**
  8247. * Gets the current class name of the material e.g. "MultiMaterial"
  8248. * Mainly use in serialization.
  8249. * @returns the class name
  8250. */
  8251. getClassName(): string;
  8252. /**
  8253. * Checks if the material is ready to render the requested sub mesh
  8254. * @param mesh Define the mesh the submesh belongs to
  8255. * @param subMesh Define the sub mesh to look readyness for
  8256. * @param useInstances Define whether or not the material is used with instances
  8257. * @returns true if ready, otherwise false
  8258. */
  8259. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8260. /**
  8261. * Clones the current material and its related sub materials
  8262. * @param name Define the name of the newly cloned material
  8263. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8264. * @returns the cloned material
  8265. */
  8266. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8267. /**
  8268. * Serializes the materials into a JSON representation.
  8269. * @returns the JSON representation
  8270. */
  8271. serialize(): any;
  8272. /**
  8273. * Dispose the material and release its associated resources
  8274. * @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)
  8275. * @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)
  8276. * @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)
  8277. */
  8278. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8279. /**
  8280. * Creates a MultiMaterial from parsed MultiMaterial data.
  8281. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8282. * @param scene defines the hosting scene
  8283. * @returns a new MultiMaterial
  8284. */
  8285. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8286. }
  8287. }
  8288. declare module BABYLON {
  8289. /**
  8290. * Class used to represent data loading progression
  8291. */
  8292. export class SceneLoaderFlags {
  8293. private static _ForceFullSceneLoadingForIncremental;
  8294. private static _ShowLoadingScreen;
  8295. private static _CleanBoneMatrixWeights;
  8296. private static _loggingLevel;
  8297. /**
  8298. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8299. */
  8300. static ForceFullSceneLoadingForIncremental: boolean;
  8301. /**
  8302. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8303. */
  8304. static ShowLoadingScreen: boolean;
  8305. /**
  8306. * Defines the current logging level (while loading the scene)
  8307. * @ignorenaming
  8308. */
  8309. static loggingLevel: number;
  8310. /**
  8311. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8312. */
  8313. static CleanBoneMatrixWeights: boolean;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * 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.
  8319. * @see https://doc.babylonjs.com/how_to/transformnode
  8320. */
  8321. export class TransformNode extends Node {
  8322. /**
  8323. * Object will not rotate to face the camera
  8324. */
  8325. static BILLBOARDMODE_NONE: number;
  8326. /**
  8327. * Object will rotate to face the camera but only on the x axis
  8328. */
  8329. static BILLBOARDMODE_X: number;
  8330. /**
  8331. * Object will rotate to face the camera but only on the y axis
  8332. */
  8333. static BILLBOARDMODE_Y: number;
  8334. /**
  8335. * Object will rotate to face the camera but only on the z axis
  8336. */
  8337. static BILLBOARDMODE_Z: number;
  8338. /**
  8339. * Object will rotate to face the camera
  8340. */
  8341. static BILLBOARDMODE_ALL: number;
  8342. private _forward;
  8343. private _forwardInverted;
  8344. private _up;
  8345. private _right;
  8346. private _rightInverted;
  8347. private _position;
  8348. private _rotation;
  8349. private _rotationQuaternion;
  8350. protected _scaling: Vector3;
  8351. protected _isDirty: boolean;
  8352. private _transformToBoneReferal;
  8353. private _billboardMode;
  8354. /**
  8355. * Gets or sets the billboard mode. Default is 0.
  8356. *
  8357. * | Value | Type | Description |
  8358. * | --- | --- | --- |
  8359. * | 0 | BILLBOARDMODE_NONE | |
  8360. * | 1 | BILLBOARDMODE_X | |
  8361. * | 2 | BILLBOARDMODE_Y | |
  8362. * | 4 | BILLBOARDMODE_Z | |
  8363. * | 7 | BILLBOARDMODE_ALL | |
  8364. *
  8365. */
  8366. billboardMode: number;
  8367. private _preserveParentRotationForBillboard;
  8368. /**
  8369. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8370. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8371. */
  8372. preserveParentRotationForBillboard: boolean;
  8373. /**
  8374. * 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
  8375. */
  8376. scalingDeterminant: number;
  8377. private _infiniteDistance;
  8378. /**
  8379. * Gets or sets the distance of the object to max, often used by skybox
  8380. */
  8381. infiniteDistance: boolean;
  8382. /**
  8383. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8384. * By default the system will update normals to compensate
  8385. */
  8386. ignoreNonUniformScaling: boolean;
  8387. /**
  8388. * 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
  8389. */
  8390. reIntegrateRotationIntoRotationQuaternion: boolean;
  8391. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  8392. /** @hidden */ private _localMatrix: Matrix;
  8393. private _usePivotMatrix;
  8394. private _absolutePosition;
  8395. private _pivotMatrix;
  8396. private _pivotMatrixInverse;
  8397. protected _postMultiplyPivotMatrix: boolean;
  8398. protected _isWorldMatrixFrozen: boolean;
  8399. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  8400. /**
  8401. * An event triggered after the world matrix is updated
  8402. */
  8403. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8404. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8405. /**
  8406. * Gets a string identifying the name of the class
  8407. * @returns "TransformNode" string
  8408. */
  8409. getClassName(): string;
  8410. /**
  8411. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8412. */
  8413. position: Vector3;
  8414. /**
  8415. * 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)).
  8416. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8417. */
  8418. rotation: Vector3;
  8419. /**
  8420. * 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)).
  8421. */
  8422. scaling: Vector3;
  8423. /**
  8424. * 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).
  8425. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8426. */
  8427. rotationQuaternion: Nullable<Quaternion>;
  8428. /**
  8429. * The forward direction of that transform in world space.
  8430. */
  8431. readonly forward: Vector3;
  8432. /**
  8433. * The up direction of that transform in world space.
  8434. */
  8435. readonly up: Vector3;
  8436. /**
  8437. * The right direction of that transform in world space.
  8438. */
  8439. readonly right: Vector3;
  8440. /**
  8441. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8442. * @param matrix the matrix to copy the pose from
  8443. * @returns this TransformNode.
  8444. */
  8445. updatePoseMatrix(matrix: Matrix): TransformNode;
  8446. /**
  8447. * Returns the mesh Pose matrix.
  8448. * @returns the pose matrix
  8449. */
  8450. getPoseMatrix(): Matrix;
  8451. /** @hidden */ private _isSynchronized(): boolean;
  8452. /** @hidden */ private _initCache(): void;
  8453. /**
  8454. * Flag the transform node as dirty (Forcing it to update everything)
  8455. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8456. * @returns this transform node
  8457. */
  8458. markAsDirty(property: string): TransformNode;
  8459. /**
  8460. * Returns the current mesh absolute position.
  8461. * Returns a Vector3.
  8462. */
  8463. readonly absolutePosition: Vector3;
  8464. /**
  8465. * Sets a new matrix to apply before all other transformation
  8466. * @param matrix defines the transform matrix
  8467. * @returns the current TransformNode
  8468. */
  8469. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8470. /**
  8471. * Sets a new pivot matrix to the current node
  8472. * @param matrix defines the new pivot matrix to use
  8473. * @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
  8474. * @returns the current TransformNode
  8475. */
  8476. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8477. /**
  8478. * Returns the mesh pivot matrix.
  8479. * Default : Identity.
  8480. * @returns the matrix
  8481. */
  8482. getPivotMatrix(): Matrix;
  8483. /**
  8484. * Prevents the World matrix to be computed any longer.
  8485. * @returns the TransformNode.
  8486. */
  8487. freezeWorldMatrix(): TransformNode;
  8488. /**
  8489. * Allows back the World matrix computation.
  8490. * @returns the TransformNode.
  8491. */
  8492. unfreezeWorldMatrix(): this;
  8493. /**
  8494. * True if the World matrix has been frozen.
  8495. */
  8496. readonly isWorldMatrixFrozen: boolean;
  8497. /**
  8498. * Retuns the mesh absolute position in the World.
  8499. * @returns a Vector3.
  8500. */
  8501. getAbsolutePosition(): Vector3;
  8502. /**
  8503. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8504. * @param absolutePosition the absolute position to set
  8505. * @returns the TransformNode.
  8506. */
  8507. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8508. /**
  8509. * Sets the mesh position in its local space.
  8510. * @param vector3 the position to set in localspace
  8511. * @returns the TransformNode.
  8512. */
  8513. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8514. /**
  8515. * Returns the mesh position in the local space from the current World matrix values.
  8516. * @returns a new Vector3.
  8517. */
  8518. getPositionExpressedInLocalSpace(): Vector3;
  8519. /**
  8520. * Translates the mesh along the passed Vector3 in its local space.
  8521. * @param vector3 the distance to translate in localspace
  8522. * @returns the TransformNode.
  8523. */
  8524. locallyTranslate(vector3: Vector3): TransformNode;
  8525. private static _lookAtVectorCache;
  8526. /**
  8527. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8528. * @param targetPoint the position (must be in same space as current mesh) to look at
  8529. * @param yawCor optional yaw (y-axis) correction in radians
  8530. * @param pitchCor optional pitch (x-axis) correction in radians
  8531. * @param rollCor optional roll (z-axis) correction in radians
  8532. * @param space the choosen space of the target
  8533. * @returns the TransformNode.
  8534. */
  8535. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8536. /**
  8537. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8538. * This Vector3 is expressed in the World space.
  8539. * @param localAxis axis to rotate
  8540. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8541. */
  8542. getDirection(localAxis: Vector3): Vector3;
  8543. /**
  8544. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8545. * localAxis is expressed in the mesh local space.
  8546. * result is computed in the Wordl space from the mesh World matrix.
  8547. * @param localAxis axis to rotate
  8548. * @param result the resulting transformnode
  8549. * @returns this TransformNode.
  8550. */
  8551. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8552. /**
  8553. * Sets this transform node rotation to the given local axis.
  8554. * @param localAxis the axis in local space
  8555. * @param yawCor optional yaw (y-axis) correction in radians
  8556. * @param pitchCor optional pitch (x-axis) correction in radians
  8557. * @param rollCor optional roll (z-axis) correction in radians
  8558. * @returns this TransformNode
  8559. */
  8560. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8561. /**
  8562. * Sets a new pivot point to the current node
  8563. * @param point defines the new pivot point to use
  8564. * @param space defines if the point is in world or local space (local by default)
  8565. * @returns the current TransformNode
  8566. */
  8567. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8568. /**
  8569. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8570. * @returns the pivot point
  8571. */
  8572. getPivotPoint(): Vector3;
  8573. /**
  8574. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8575. * @param result the vector3 to store the result
  8576. * @returns this TransformNode.
  8577. */
  8578. getPivotPointToRef(result: Vector3): TransformNode;
  8579. /**
  8580. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8581. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8582. */
  8583. getAbsolutePivotPoint(): Vector3;
  8584. /**
  8585. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8586. * @param result vector3 to store the result
  8587. * @returns this TransformNode.
  8588. */
  8589. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8590. /**
  8591. * Defines the passed node as the parent of the current node.
  8592. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8593. * @see https://doc.babylonjs.com/how_to/parenting
  8594. * @param node the node ot set as the parent
  8595. * @returns this TransformNode.
  8596. */
  8597. setParent(node: Nullable<Node>): TransformNode;
  8598. private _nonUniformScaling;
  8599. /**
  8600. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8601. */
  8602. readonly nonUniformScaling: boolean;
  8603. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  8604. /**
  8605. * Attach the current TransformNode to another TransformNode associated with a bone
  8606. * @param bone Bone affecting the TransformNode
  8607. * @param affectedTransformNode TransformNode associated with the bone
  8608. * @returns this object
  8609. */
  8610. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8611. /**
  8612. * Detach the transform node if its associated with a bone
  8613. * @returns this object
  8614. */
  8615. detachFromBone(): TransformNode;
  8616. private static _rotationAxisCache;
  8617. /**
  8618. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8619. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8620. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8621. * The passed axis is also normalized.
  8622. * @param axis the axis to rotate around
  8623. * @param amount the amount to rotate in radians
  8624. * @param space Space to rotate in (Default: local)
  8625. * @returns the TransformNode.
  8626. */
  8627. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8628. /**
  8629. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8630. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8631. * The passed axis is also normalized. .
  8632. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8633. * @param point the point to rotate around
  8634. * @param axis the axis to rotate around
  8635. * @param amount the amount to rotate in radians
  8636. * @returns the TransformNode
  8637. */
  8638. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8639. /**
  8640. * Translates the mesh along the axis vector for the passed distance in the given space.
  8641. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8642. * @param axis the axis to translate in
  8643. * @param distance the distance to translate
  8644. * @param space Space to rotate in (Default: local)
  8645. * @returns the TransformNode.
  8646. */
  8647. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8648. /**
  8649. * Adds a rotation step to the mesh current rotation.
  8650. * x, y, z are Euler angles expressed in radians.
  8651. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8652. * This means this rotation is made in the mesh local space only.
  8653. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8654. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8655. * ```javascript
  8656. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8657. * ```
  8658. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8659. * 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.
  8660. * @param x Rotation to add
  8661. * @param y Rotation to add
  8662. * @param z Rotation to add
  8663. * @returns the TransformNode.
  8664. */
  8665. addRotation(x: number, y: number, z: number): TransformNode;
  8666. /**
  8667. * @hidden
  8668. */
  8669. protected _getEffectiveParent(): Nullable<Node>;
  8670. /**
  8671. * Computes the world matrix of the node
  8672. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8673. * @returns the world matrix
  8674. */
  8675. computeWorldMatrix(force?: boolean): Matrix;
  8676. protected _afterComputeWorldMatrix(): void;
  8677. /**
  8678. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8679. * @param func callback function to add
  8680. *
  8681. * @returns the TransformNode.
  8682. */
  8683. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8684. /**
  8685. * Removes a registered callback function.
  8686. * @param func callback function to remove
  8687. * @returns the TransformNode.
  8688. */
  8689. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8690. /**
  8691. * Gets the position of the current mesh in camera space
  8692. * @param camera defines the camera to use
  8693. * @returns a position
  8694. */
  8695. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8696. /**
  8697. * Returns the distance from the mesh to the active camera
  8698. * @param camera defines the camera to use
  8699. * @returns the distance
  8700. */
  8701. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8702. /**
  8703. * Clone the current transform node
  8704. * @param name Name of the new clone
  8705. * @param newParent New parent for the clone
  8706. * @param doNotCloneChildren Do not clone children hierarchy
  8707. * @returns the new transform node
  8708. */
  8709. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8710. /**
  8711. * Serializes the objects information.
  8712. * @param currentSerializationObject defines the object to serialize in
  8713. * @returns the serialized object
  8714. */
  8715. serialize(currentSerializationObject?: any): any;
  8716. /**
  8717. * Returns a new TransformNode object parsed from the source provided.
  8718. * @param parsedTransformNode is the source.
  8719. * @param scene the scne the object belongs to
  8720. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8721. * @returns a new TransformNode object parsed from the source provided.
  8722. */
  8723. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8724. /**
  8725. * Get all child-transformNodes of this node
  8726. * @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
  8727. * @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
  8728. * @returns an array of TransformNode
  8729. */
  8730. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8731. /**
  8732. * Releases resources associated with this transform node.
  8733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8735. */
  8736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8737. /**
  8738. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8739. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8740. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8741. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8742. * @returns the current mesh
  8743. */
  8744. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8745. }
  8746. }
  8747. declare module BABYLON {
  8748. /**
  8749. * Class used to override all child animations of a given target
  8750. */
  8751. export class AnimationPropertiesOverride {
  8752. /**
  8753. * Gets or sets a value indicating if animation blending must be used
  8754. */
  8755. enableBlending: boolean;
  8756. /**
  8757. * Gets or sets the blending speed to use when enableBlending is true
  8758. */
  8759. blendingSpeed: number;
  8760. /**
  8761. * Gets or sets the default loop mode to use
  8762. */
  8763. loopMode: number;
  8764. }
  8765. }
  8766. declare module BABYLON {
  8767. /**
  8768. * Class used to store bone information
  8769. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8770. */
  8771. export class Bone extends Node {
  8772. /**
  8773. * defines the bone name
  8774. */
  8775. name: string;
  8776. private static _tmpVecs;
  8777. private static _tmpQuat;
  8778. private static _tmpMats;
  8779. /**
  8780. * Gets the list of child bones
  8781. */
  8782. children: Bone[];
  8783. /** Gets the animations associated with this bone */
  8784. animations: Animation[];
  8785. /**
  8786. * Gets or sets bone length
  8787. */
  8788. length: number;
  8789. /**
  8790. * @hidden Internal only
  8791. * Set this value to map this bone to a different index in the transform matrices
  8792. * Set this value to -1 to exclude the bone from the transform matrices
  8793. */ private _index: Nullable<number>;
  8794. private _skeleton;
  8795. private _localMatrix;
  8796. private _restPose;
  8797. private _baseMatrix;
  8798. private _absoluteTransform;
  8799. private _invertedAbsoluteTransform;
  8800. private _parent;
  8801. private _scalingDeterminant;
  8802. private _worldTransform;
  8803. private _localScaling;
  8804. private _localRotation;
  8805. private _localPosition;
  8806. private _needToDecompose;
  8807. private _needToCompose;
  8808. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  8809. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  8810. /** @hidden */
  8811. /** @hidden */ private _matrix: Matrix;
  8812. /**
  8813. * Create a new bone
  8814. * @param name defines the bone name
  8815. * @param skeleton defines the parent skeleton
  8816. * @param parentBone defines the parent (can be null if the bone is the root)
  8817. * @param localMatrix defines the local matrix
  8818. * @param restPose defines the rest pose matrix
  8819. * @param baseMatrix defines the base matrix
  8820. * @param index defines index of the bone in the hiearchy
  8821. */
  8822. constructor(
  8823. /**
  8824. * defines the bone name
  8825. */
  8826. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8827. /**
  8828. * Gets the current object class name.
  8829. * @return the class name
  8830. */
  8831. getClassName(): string;
  8832. /**
  8833. * Gets the parent skeleton
  8834. * @returns a skeleton
  8835. */
  8836. getSkeleton(): Skeleton;
  8837. /**
  8838. * Gets parent bone
  8839. * @returns a bone or null if the bone is the root of the bone hierarchy
  8840. */
  8841. getParent(): Nullable<Bone>;
  8842. /**
  8843. * Returns an array containing the root bones
  8844. * @returns an array containing the root bones
  8845. */
  8846. getChildren(): Array<Bone>;
  8847. /**
  8848. * Sets the parent bone
  8849. * @param parent defines the parent (can be null if the bone is the root)
  8850. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8851. */
  8852. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8853. /**
  8854. * Gets the local matrix
  8855. * @returns a matrix
  8856. */
  8857. getLocalMatrix(): Matrix;
  8858. /**
  8859. * Gets the base matrix (initial matrix which remains unchanged)
  8860. * @returns a matrix
  8861. */
  8862. getBaseMatrix(): Matrix;
  8863. /**
  8864. * Gets the rest pose matrix
  8865. * @returns a matrix
  8866. */
  8867. getRestPose(): Matrix;
  8868. /**
  8869. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8870. */
  8871. getWorldMatrix(): Matrix;
  8872. /**
  8873. * Sets the local matrix to rest pose matrix
  8874. */
  8875. returnToRest(): void;
  8876. /**
  8877. * Gets the inverse of the absolute transform matrix.
  8878. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8879. * @returns a matrix
  8880. */
  8881. getInvertedAbsoluteTransform(): Matrix;
  8882. /**
  8883. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8884. * @returns a matrix
  8885. */
  8886. getAbsoluteTransform(): Matrix;
  8887. /**
  8888. * Links with the given transform node.
  8889. * The local matrix of this bone is copied from the transform node every frame.
  8890. * @param transformNode defines the transform node to link to
  8891. */
  8892. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8893. /** Gets or sets current position (in local space) */
  8894. position: Vector3;
  8895. /** Gets or sets current rotation (in local space) */
  8896. rotation: Vector3;
  8897. /** Gets or sets current rotation quaternion (in local space) */
  8898. rotationQuaternion: Quaternion;
  8899. /** Gets or sets current scaling (in local space) */
  8900. scaling: Vector3;
  8901. /**
  8902. * Gets the animation properties override
  8903. */
  8904. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8905. private _decompose;
  8906. private _compose;
  8907. /**
  8908. * Update the base and local matrices
  8909. * @param matrix defines the new base or local matrix
  8910. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8911. * @param updateLocalMatrix defines if the local matrix should be updated
  8912. */
  8913. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8914. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8915. /**
  8916. * Flag the bone as dirty (Forcing it to update everything)
  8917. */
  8918. markAsDirty(): void;
  8919. /** @hidden */ private _markAsDirtyAndCompose(): void;
  8920. private _markAsDirtyAndDecompose;
  8921. /**
  8922. * Translate the bone in local or world space
  8923. * @param vec The amount to translate the bone
  8924. * @param space The space that the translation is in
  8925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8926. */
  8927. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8928. /**
  8929. * Set the postion of the bone in local or world space
  8930. * @param position The position to set the bone
  8931. * @param space The space that the position is in
  8932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8933. */
  8934. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8935. /**
  8936. * Set the absolute position of the bone (world space)
  8937. * @param position The position to set the bone
  8938. * @param mesh The mesh that this bone is attached to
  8939. */
  8940. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8941. /**
  8942. * Scale the bone on the x, y and z axes (in local space)
  8943. * @param x The amount to scale the bone on the x axis
  8944. * @param y The amount to scale the bone on the y axis
  8945. * @param z The amount to scale the bone on the z axis
  8946. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8947. */
  8948. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8949. /**
  8950. * Set the bone scaling in local space
  8951. * @param scale defines the scaling vector
  8952. */
  8953. setScale(scale: Vector3): void;
  8954. /**
  8955. * Gets the current scaling in local space
  8956. * @returns the current scaling vector
  8957. */
  8958. getScale(): Vector3;
  8959. /**
  8960. * Gets the current scaling in local space and stores it in a target vector
  8961. * @param result defines the target vector
  8962. */
  8963. getScaleToRef(result: Vector3): void;
  8964. /**
  8965. * Set the yaw, pitch, and roll of the bone in local or world space
  8966. * @param yaw The rotation of the bone on the y axis
  8967. * @param pitch The rotation of the bone on the x axis
  8968. * @param roll The rotation of the bone on the z axis
  8969. * @param space The space that the axes of rotation are in
  8970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8971. */
  8972. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8973. /**
  8974. * Add a rotation to the bone on an axis in local or world space
  8975. * @param axis The axis to rotate the bone on
  8976. * @param amount The amount to rotate the bone
  8977. * @param space The space that the axis is in
  8978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8979. */
  8980. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8981. /**
  8982. * Set the rotation of the bone to a particular axis angle in local or world space
  8983. * @param axis The axis to rotate the bone on
  8984. * @param angle The angle that the bone should be rotated to
  8985. * @param space The space that the axis is in
  8986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8987. */
  8988. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8989. /**
  8990. * Set the euler rotation of the bone in local of world space
  8991. * @param rotation The euler rotation that the bone should be set to
  8992. * @param space The space that the rotation is in
  8993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8994. */
  8995. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8996. /**
  8997. * Set the quaternion rotation of the bone in local of world space
  8998. * @param quat The quaternion rotation that the bone should be set to
  8999. * @param space The space that the rotation is in
  9000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9001. */
  9002. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9003. /**
  9004. * Set the rotation matrix of the bone in local of world space
  9005. * @param rotMat The rotation matrix that the bone should be set to
  9006. * @param space The space that the rotation is in
  9007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9008. */
  9009. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9010. private _rotateWithMatrix;
  9011. private _getNegativeRotationToRef;
  9012. /**
  9013. * Get the position of the bone in local or world space
  9014. * @param space The space that the returned position is in
  9015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9016. * @returns The position of the bone
  9017. */
  9018. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9019. /**
  9020. * Copy the position of the bone to a vector3 in local or world space
  9021. * @param space The space that the returned position is in
  9022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9023. * @param result The vector3 to copy the position to
  9024. */
  9025. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9026. /**
  9027. * Get the absolute position of the bone (world space)
  9028. * @param mesh The mesh that this bone is attached to
  9029. * @returns The absolute position of the bone
  9030. */
  9031. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9032. /**
  9033. * Copy the absolute position of the bone (world space) to the result param
  9034. * @param mesh The mesh that this bone is attached to
  9035. * @param result The vector3 to copy the absolute position to
  9036. */
  9037. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9038. /**
  9039. * Compute the absolute transforms of this bone and its children
  9040. */
  9041. computeAbsoluteTransforms(): void;
  9042. /**
  9043. * Get the world direction from an axis that is in the local space of the bone
  9044. * @param localAxis The local direction that is used to compute the world direction
  9045. * @param mesh The mesh that this bone is attached to
  9046. * @returns The world direction
  9047. */
  9048. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9049. /**
  9050. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9051. * @param localAxis The local direction that is used to compute the world direction
  9052. * @param mesh The mesh that this bone is attached to
  9053. * @param result The vector3 that the world direction will be copied to
  9054. */
  9055. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9056. /**
  9057. * Get the euler rotation of the bone in local or world space
  9058. * @param space The space that the rotation should be in
  9059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9060. * @returns The euler rotation
  9061. */
  9062. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9063. /**
  9064. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9065. * @param space The space that the rotation should be in
  9066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9067. * @param result The vector3 that the rotation should be copied to
  9068. */
  9069. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9070. /**
  9071. * Get the quaternion rotation of the bone in either local or world space
  9072. * @param space The space that the rotation should be in
  9073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9074. * @returns The quaternion rotation
  9075. */
  9076. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9077. /**
  9078. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9079. * @param space The space that the rotation should be in
  9080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9081. * @param result The quaternion that the rotation should be copied to
  9082. */
  9083. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9084. /**
  9085. * Get the rotation matrix of the bone in local or world space
  9086. * @param space The space that the rotation should be in
  9087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9088. * @returns The rotation matrix
  9089. */
  9090. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9091. /**
  9092. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9093. * @param space The space that the rotation should be in
  9094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9095. * @param result The quaternion that the rotation should be copied to
  9096. */
  9097. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9098. /**
  9099. * Get the world position of a point that is in the local space of the bone
  9100. * @param position The local position
  9101. * @param mesh The mesh that this bone is attached to
  9102. * @returns The world position
  9103. */
  9104. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9105. /**
  9106. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9107. * @param position The local position
  9108. * @param mesh The mesh that this bone is attached to
  9109. * @param result The vector3 that the world position should be copied to
  9110. */
  9111. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9112. /**
  9113. * Get the local position of a point that is in world space
  9114. * @param position The world position
  9115. * @param mesh The mesh that this bone is attached to
  9116. * @returns The local position
  9117. */
  9118. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9119. /**
  9120. * Get the local position of a point that is in world space and copy it to the result param
  9121. * @param position The world position
  9122. * @param mesh The mesh that this bone is attached to
  9123. * @param result The vector3 that the local position should be copied to
  9124. */
  9125. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9126. }
  9127. }
  9128. declare module BABYLON {
  9129. interface Engine {
  9130. /**
  9131. * Creates a raw texture
  9132. * @param data defines the data to store in the texture
  9133. * @param width defines the width of the texture
  9134. * @param height defines the height of the texture
  9135. * @param format defines the format of the data
  9136. * @param generateMipMaps defines if the engine should generate the mip levels
  9137. * @param invertY defines if data must be stored with Y axis inverted
  9138. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9139. * @param compression defines the compression used (null by default)
  9140. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9141. * @returns the raw texture inside an InternalTexture
  9142. */
  9143. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9144. /**
  9145. * Update a raw texture
  9146. * @param texture defines the texture to update
  9147. * @param data defines the data to store in the texture
  9148. * @param format defines the format of the data
  9149. * @param invertY defines if data must be stored with Y axis inverted
  9150. */
  9151. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9152. /**
  9153. * Update a raw texture
  9154. * @param texture defines the texture to update
  9155. * @param data defines the data to store in the texture
  9156. * @param format defines the format of the data
  9157. * @param invertY defines if data must be stored with Y axis inverted
  9158. * @param compression defines the compression used (null by default)
  9159. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9160. */
  9161. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9162. /**
  9163. * Creates a new raw cube texture
  9164. * @param data defines the array of data to use to create each face
  9165. * @param size defines the size of the textures
  9166. * @param format defines the format of the data
  9167. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9168. * @param generateMipMaps defines if the engine should generate the mip levels
  9169. * @param invertY defines if data must be stored with Y axis inverted
  9170. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9171. * @param compression defines the compression used (null by default)
  9172. * @returns the cube texture as an InternalTexture
  9173. */
  9174. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9175. /**
  9176. * Update a raw cube texture
  9177. * @param texture defines the texture to udpdate
  9178. * @param data defines the data to store
  9179. * @param format defines the data format
  9180. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9181. * @param invertY defines if data must be stored with Y axis inverted
  9182. */
  9183. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9184. /**
  9185. * Update a raw cube texture
  9186. * @param texture defines the texture to udpdate
  9187. * @param data defines the data to store
  9188. * @param format defines the data format
  9189. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9190. * @param invertY defines if data must be stored with Y axis inverted
  9191. * @param compression defines the compression used (null by default)
  9192. */
  9193. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9194. /**
  9195. * Update a raw cube texture
  9196. * @param texture defines the texture to udpdate
  9197. * @param data defines the data to store
  9198. * @param format defines the data format
  9199. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9200. * @param invertY defines if data must be stored with Y axis inverted
  9201. * @param compression defines the compression used (null by default)
  9202. * @param level defines which level of the texture to update
  9203. */
  9204. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9205. /**
  9206. * Creates a new raw cube texture from a specified url
  9207. * @param url defines the url where the data is located
  9208. * @param scene defines the current scene
  9209. * @param size defines the size of the textures
  9210. * @param format defines the format of the data
  9211. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9212. * @param noMipmap defines if the engine should avoid generating the mip levels
  9213. * @param callback defines a callback used to extract texture data from loaded data
  9214. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9215. * @param onLoad defines a callback called when texture is loaded
  9216. * @param onError defines a callback called if there is an error
  9217. * @returns the cube texture as an InternalTexture
  9218. */
  9219. 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;
  9220. /**
  9221. * Creates a new raw cube texture from a specified url
  9222. * @param url defines the url where the data is located
  9223. * @param scene defines the current scene
  9224. * @param size defines the size of the textures
  9225. * @param format defines the format of the data
  9226. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9227. * @param noMipmap defines if the engine should avoid generating the mip levels
  9228. * @param callback defines a callback used to extract texture data from loaded data
  9229. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9230. * @param onLoad defines a callback called when texture is loaded
  9231. * @param onError defines a callback called if there is an error
  9232. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9233. * @param invertY defines if data must be stored with Y axis inverted
  9234. * @returns the cube texture as an InternalTexture
  9235. */
  9236. 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;
  9237. /**
  9238. * Creates a new raw 3D texture
  9239. * @param data defines the data used to create the texture
  9240. * @param width defines the width of the texture
  9241. * @param height defines the height of the texture
  9242. * @param depth defines the depth of the texture
  9243. * @param format defines the format of the texture
  9244. * @param generateMipMaps defines if the engine must generate mip levels
  9245. * @param invertY defines if data must be stored with Y axis inverted
  9246. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9247. * @param compression defines the compressed used (can be null)
  9248. * @param textureType defines the compressed used (can be null)
  9249. * @returns a new raw 3D texture (stored in an InternalTexture)
  9250. */
  9251. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9252. /**
  9253. * Update a raw 3D texture
  9254. * @param texture defines the texture to update
  9255. * @param data defines the data to store
  9256. * @param format defines the data format
  9257. * @param invertY defines if data must be stored with Y axis inverted
  9258. */
  9259. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9260. /**
  9261. * Update a raw 3D texture
  9262. * @param texture defines the texture to update
  9263. * @param data defines the data to store
  9264. * @param format defines the data format
  9265. * @param invertY defines if data must be stored with Y axis inverted
  9266. * @param compression defines the used compression (can be null)
  9267. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9268. */
  9269. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9270. }
  9271. }
  9272. declare module BABYLON {
  9273. /**
  9274. * Raw texture can help creating a texture directly from an array of data.
  9275. * This can be super useful if you either get the data from an uncompressed source or
  9276. * if you wish to create your texture pixel by pixel.
  9277. */
  9278. export class RawTexture extends Texture {
  9279. /**
  9280. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9281. */
  9282. format: number;
  9283. private _engine;
  9284. /**
  9285. * Instantiates a new RawTexture.
  9286. * Raw texture can help creating a texture directly from an array of data.
  9287. * This can be super useful if you either get the data from an uncompressed source or
  9288. * if you wish to create your texture pixel by pixel.
  9289. * @param data define the array of data to use to create the texture
  9290. * @param width define the width of the texture
  9291. * @param height define the height of the texture
  9292. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9293. * @param scene define the scene the texture belongs to
  9294. * @param generateMipMaps define whether mip maps should be generated or not
  9295. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9296. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9297. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9298. */
  9299. constructor(data: ArrayBufferView, width: number, height: number,
  9300. /**
  9301. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9302. */
  9303. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9304. /**
  9305. * Updates the texture underlying data.
  9306. * @param data Define the new data of the texture
  9307. */
  9308. update(data: ArrayBufferView): void;
  9309. /**
  9310. * Creates a luminance texture from some data.
  9311. * @param data Define the texture data
  9312. * @param width Define the width of the texture
  9313. * @param height Define the height of the texture
  9314. * @param scene Define the scene the texture belongs to
  9315. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9316. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9317. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9318. * @returns the luminance texture
  9319. */
  9320. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9321. /**
  9322. * Creates a luminance alpha texture from some data.
  9323. * @param data Define the texture data
  9324. * @param width Define the width of the texture
  9325. * @param height Define the height of the texture
  9326. * @param scene Define the scene the texture belongs to
  9327. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9328. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9329. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9330. * @returns the luminance alpha texture
  9331. */
  9332. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9333. /**
  9334. * Creates an alpha texture from some data.
  9335. * @param data Define the texture data
  9336. * @param width Define the width of the texture
  9337. * @param height Define the height of the texture
  9338. * @param scene Define the scene the texture belongs to
  9339. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9340. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9341. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9342. * @returns the alpha texture
  9343. */
  9344. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9345. /**
  9346. * Creates a RGB texture from some data.
  9347. * @param data Define the texture data
  9348. * @param width Define the width of the texture
  9349. * @param height Define the height of the texture
  9350. * @param scene Define the scene the texture belongs to
  9351. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9352. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9353. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9354. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9355. * @returns the RGB alpha texture
  9356. */
  9357. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9358. /**
  9359. * Creates a RGBA texture from some data.
  9360. * @param data Define the texture data
  9361. * @param width Define the width of the texture
  9362. * @param height Define the height of the texture
  9363. * @param scene Define the scene the texture belongs to
  9364. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9365. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9366. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9367. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9368. * @returns the RGBA texture
  9369. */
  9370. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9371. /**
  9372. * Creates a R texture from some data.
  9373. * @param data Define the texture data
  9374. * @param width Define the width of the texture
  9375. * @param height Define the height of the texture
  9376. * @param scene Define the scene the texture belongs to
  9377. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9378. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9379. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9380. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9381. * @returns the R texture
  9382. */
  9383. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9384. }
  9385. }
  9386. declare module BABYLON {
  9387. /**
  9388. * Defines a runtime animation
  9389. */
  9390. export class RuntimeAnimation {
  9391. private _events;
  9392. /**
  9393. * The current frame of the runtime animation
  9394. */
  9395. private _currentFrame;
  9396. /**
  9397. * The animation used by the runtime animation
  9398. */
  9399. private _animation;
  9400. /**
  9401. * The target of the runtime animation
  9402. */
  9403. private _target;
  9404. /**
  9405. * The initiating animatable
  9406. */
  9407. private _host;
  9408. /**
  9409. * The original value of the runtime animation
  9410. */
  9411. private _originalValue;
  9412. /**
  9413. * The original blend value of the runtime animation
  9414. */
  9415. private _originalBlendValue;
  9416. /**
  9417. * The offsets cache of the runtime animation
  9418. */
  9419. private _offsetsCache;
  9420. /**
  9421. * The high limits cache of the runtime animation
  9422. */
  9423. private _highLimitsCache;
  9424. /**
  9425. * Specifies if the runtime animation has been stopped
  9426. */
  9427. private _stopped;
  9428. /**
  9429. * The blending factor of the runtime animation
  9430. */
  9431. private _blendingFactor;
  9432. /**
  9433. * The BabylonJS scene
  9434. */
  9435. private _scene;
  9436. /**
  9437. * The current value of the runtime animation
  9438. */
  9439. private _currentValue;
  9440. /** @hidden */ private _animationState: _IAnimationState;
  9441. /**
  9442. * The active target of the runtime animation
  9443. */
  9444. private _activeTargets;
  9445. private _currentActiveTarget;
  9446. private _directTarget;
  9447. /**
  9448. * The target path of the runtime animation
  9449. */
  9450. private _targetPath;
  9451. /**
  9452. * The weight of the runtime animation
  9453. */
  9454. private _weight;
  9455. /**
  9456. * The ratio offset of the runtime animation
  9457. */
  9458. private _ratioOffset;
  9459. /**
  9460. * The previous delay of the runtime animation
  9461. */
  9462. private _previousDelay;
  9463. /**
  9464. * The previous ratio of the runtime animation
  9465. */
  9466. private _previousRatio;
  9467. private _enableBlending;
  9468. private _keys;
  9469. private _minFrame;
  9470. private _maxFrame;
  9471. private _minValue;
  9472. private _maxValue;
  9473. private _targetIsArray;
  9474. /**
  9475. * Gets the current frame of the runtime animation
  9476. */
  9477. readonly currentFrame: number;
  9478. /**
  9479. * Gets the weight of the runtime animation
  9480. */
  9481. readonly weight: number;
  9482. /**
  9483. * Gets the current value of the runtime animation
  9484. */
  9485. readonly currentValue: any;
  9486. /**
  9487. * Gets the target path of the runtime animation
  9488. */
  9489. readonly targetPath: string;
  9490. /**
  9491. * Gets the actual target of the runtime animation
  9492. */
  9493. readonly target: any;
  9494. /** @hidden */ private _onLoop: () => void;
  9495. /**
  9496. * Create a new RuntimeAnimation object
  9497. * @param target defines the target of the animation
  9498. * @param animation defines the source animation object
  9499. * @param scene defines the hosting scene
  9500. * @param host defines the initiating Animatable
  9501. */
  9502. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9503. private _preparePath;
  9504. /**
  9505. * Gets the animation from the runtime animation
  9506. */
  9507. readonly animation: Animation;
  9508. /**
  9509. * Resets the runtime animation to the beginning
  9510. * @param restoreOriginal defines whether to restore the target property to the original value
  9511. */
  9512. reset(restoreOriginal?: boolean): void;
  9513. /**
  9514. * Specifies if the runtime animation is stopped
  9515. * @returns Boolean specifying if the runtime animation is stopped
  9516. */
  9517. isStopped(): boolean;
  9518. /**
  9519. * Disposes of the runtime animation
  9520. */
  9521. dispose(): void;
  9522. /**
  9523. * Apply the interpolated value to the target
  9524. * @param currentValue defines the value computed by the animation
  9525. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9526. */
  9527. setValue(currentValue: any, weight: number): void;
  9528. private _getOriginalValues;
  9529. private _setValue;
  9530. /**
  9531. * Gets the loop pmode of the runtime animation
  9532. * @returns Loop Mode
  9533. */
  9534. private _getCorrectLoopMode;
  9535. /**
  9536. * Move the current animation to a given frame
  9537. * @param frame defines the frame to move to
  9538. */
  9539. goToFrame(frame: number): void;
  9540. /**
  9541. * @hidden Internal use only
  9542. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9543. /**
  9544. * Execute the current animation
  9545. * @param delay defines the delay to add to the current frame
  9546. * @param from defines the lower bound of the animation range
  9547. * @param to defines the upper bound of the animation range
  9548. * @param loop defines if the current animation must loop
  9549. * @param speedRatio defines the current speed ratio
  9550. * @param weight defines the weight of the animation (default is -1 so no weight)
  9551. * @param onLoop optional callback called when animation loops
  9552. * @returns a boolean indicating if the animation is running
  9553. */
  9554. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9555. }
  9556. }
  9557. declare module BABYLON {
  9558. /**
  9559. * Class used to store an actual running animation
  9560. */
  9561. export class Animatable {
  9562. /** defines the target object */
  9563. target: any;
  9564. /** defines the starting frame number (default is 0) */
  9565. fromFrame: number;
  9566. /** defines the ending frame number (default is 100) */
  9567. toFrame: number;
  9568. /** defines if the animation must loop (default is false) */
  9569. loopAnimation: boolean;
  9570. /** defines a callback to call when animation ends if it is not looping */
  9571. onAnimationEnd?: (() => void) | null | undefined;
  9572. /** defines a callback to call when animation loops */
  9573. onAnimationLoop?: (() => void) | null | undefined;
  9574. private _localDelayOffset;
  9575. private _pausedDelay;
  9576. private _runtimeAnimations;
  9577. private _paused;
  9578. private _scene;
  9579. private _speedRatio;
  9580. private _weight;
  9581. private _syncRoot;
  9582. /**
  9583. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9584. * This will only apply for non looping animation (default is true)
  9585. */
  9586. disposeOnEnd: boolean;
  9587. /**
  9588. * Gets a boolean indicating if the animation has started
  9589. */
  9590. animationStarted: boolean;
  9591. /**
  9592. * Observer raised when the animation ends
  9593. */
  9594. onAnimationEndObservable: Observable<Animatable>;
  9595. /**
  9596. * Observer raised when the animation loops
  9597. */
  9598. onAnimationLoopObservable: Observable<Animatable>;
  9599. /**
  9600. * Gets the root Animatable used to synchronize and normalize animations
  9601. */
  9602. readonly syncRoot: Nullable<Animatable>;
  9603. /**
  9604. * Gets the current frame of the first RuntimeAnimation
  9605. * Used to synchronize Animatables
  9606. */
  9607. readonly masterFrame: number;
  9608. /**
  9609. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9610. */
  9611. weight: number;
  9612. /**
  9613. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9614. */
  9615. speedRatio: number;
  9616. /**
  9617. * Creates a new Animatable
  9618. * @param scene defines the hosting scene
  9619. * @param target defines the target object
  9620. * @param fromFrame defines the starting frame number (default is 0)
  9621. * @param toFrame defines the ending frame number (default is 100)
  9622. * @param loopAnimation defines if the animation must loop (default is false)
  9623. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9624. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9625. * @param animations defines a group of animation to add to the new Animatable
  9626. * @param onAnimationLoop defines a callback to call when animation loops
  9627. */
  9628. constructor(scene: Scene,
  9629. /** defines the target object */
  9630. target: any,
  9631. /** defines the starting frame number (default is 0) */
  9632. fromFrame?: number,
  9633. /** defines the ending frame number (default is 100) */
  9634. toFrame?: number,
  9635. /** defines if the animation must loop (default is false) */
  9636. loopAnimation?: boolean, speedRatio?: number,
  9637. /** defines a callback to call when animation ends if it is not looping */
  9638. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9639. /** defines a callback to call when animation loops */
  9640. onAnimationLoop?: (() => void) | null | undefined);
  9641. /**
  9642. * Synchronize and normalize current Animatable with a source Animatable
  9643. * This is useful when using animation weights and when animations are not of the same length
  9644. * @param root defines the root Animatable to synchronize with
  9645. * @returns the current Animatable
  9646. */
  9647. syncWith(root: Animatable): Animatable;
  9648. /**
  9649. * Gets the list of runtime animations
  9650. * @returns an array of RuntimeAnimation
  9651. */
  9652. getAnimations(): RuntimeAnimation[];
  9653. /**
  9654. * Adds more animations to the current animatable
  9655. * @param target defines the target of the animations
  9656. * @param animations defines the new animations to add
  9657. */
  9658. appendAnimations(target: any, animations: Animation[]): void;
  9659. /**
  9660. * Gets the source animation for a specific property
  9661. * @param property defines the propertyu to look for
  9662. * @returns null or the source animation for the given property
  9663. */
  9664. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9665. /**
  9666. * Gets the runtime animation for a specific property
  9667. * @param property defines the propertyu to look for
  9668. * @returns null or the runtime animation for the given property
  9669. */
  9670. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9671. /**
  9672. * Resets the animatable to its original state
  9673. */
  9674. reset(): void;
  9675. /**
  9676. * Allows the animatable to blend with current running animations
  9677. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9678. * @param blendingSpeed defines the blending speed to use
  9679. */
  9680. enableBlending(blendingSpeed: number): void;
  9681. /**
  9682. * Disable animation blending
  9683. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9684. */
  9685. disableBlending(): void;
  9686. /**
  9687. * Jump directly to a given frame
  9688. * @param frame defines the frame to jump to
  9689. */
  9690. goToFrame(frame: number): void;
  9691. /**
  9692. * Pause the animation
  9693. */
  9694. pause(): void;
  9695. /**
  9696. * Restart the animation
  9697. */
  9698. restart(): void;
  9699. private _raiseOnAnimationEnd;
  9700. /**
  9701. * Stop and delete the current animation
  9702. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9703. * @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)
  9704. */
  9705. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9706. /**
  9707. * Wait asynchronously for the animation to end
  9708. * @returns a promise which will be fullfilled when the animation ends
  9709. */
  9710. waitAsync(): Promise<Animatable>;
  9711. /** @hidden */ private _animate(delay: number): boolean;
  9712. }
  9713. interface Scene {
  9714. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9715. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  9716. totalWeight: number;
  9717. animations: RuntimeAnimation[];
  9718. originalValue: Matrix;
  9719. }): any;
  9720. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  9721. totalWeight: number;
  9722. animations: RuntimeAnimation[];
  9723. originalValue: Quaternion;
  9724. }, refQuaternion: Quaternion): Quaternion;
  9725. /** @hidden */ private _processLateAnimationBindings(): void;
  9726. /**
  9727. * Will start the animation sequence of a given target
  9728. * @param target defines the target
  9729. * @param from defines from which frame should animation start
  9730. * @param to defines until which frame should animation run.
  9731. * @param weight defines the weight to apply to the animation (1.0 by default)
  9732. * @param loop defines if the animation loops
  9733. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9734. * @param onAnimationEnd defines the function to be executed when the animation ends
  9735. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9736. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9737. * @param onAnimationLoop defines the callback to call when an animation loops
  9738. * @returns the animatable object created for this animation
  9739. */
  9740. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9741. /**
  9742. * Will start the animation sequence of a given target
  9743. * @param target defines the target
  9744. * @param from defines from which frame should animation start
  9745. * @param to defines until which frame should animation run.
  9746. * @param loop defines if the animation loops
  9747. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9748. * @param onAnimationEnd defines the function to be executed when the animation ends
  9749. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9750. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9751. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9752. * @param onAnimationLoop defines the callback to call when an animation loops
  9753. * @returns the animatable object created for this animation
  9754. */
  9755. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9756. /**
  9757. * Will start the animation sequence of a given target and its hierarchy
  9758. * @param target defines the target
  9759. * @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.
  9760. * @param from defines from which frame should animation start
  9761. * @param to defines until which frame should animation run.
  9762. * @param loop defines if the animation loops
  9763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9764. * @param onAnimationEnd defines the function to be executed when the animation ends
  9765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9766. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9767. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9768. * @param onAnimationLoop defines the callback to call when an animation loops
  9769. * @returns the list of created animatables
  9770. */
  9771. 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[];
  9772. /**
  9773. * Begin a new animation on a given node
  9774. * @param target defines the target where the animation will take place
  9775. * @param animations defines the list of animations to start
  9776. * @param from defines the initial value
  9777. * @param to defines the final value
  9778. * @param loop defines if you want animation to loop (off by default)
  9779. * @param speedRatio defines the speed ratio to apply to all animations
  9780. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9781. * @param onAnimationLoop defines the callback to call when an animation loops
  9782. * @returns the list of created animatables
  9783. */
  9784. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9785. /**
  9786. * Begin a new animation on a given node and its hierarchy
  9787. * @param target defines the root node where the animation will take place
  9788. * @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.
  9789. * @param animations defines the list of animations to start
  9790. * @param from defines the initial value
  9791. * @param to defines the final value
  9792. * @param loop defines if you want animation to loop (off by default)
  9793. * @param speedRatio defines the speed ratio to apply to all animations
  9794. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9795. * @param onAnimationLoop defines the callback to call when an animation loops
  9796. * @returns the list of animatables created for all nodes
  9797. */
  9798. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9799. /**
  9800. * Gets the animatable associated with a specific target
  9801. * @param target defines the target of the animatable
  9802. * @returns the required animatable if found
  9803. */
  9804. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9805. /**
  9806. * Gets all animatables associated with a given target
  9807. * @param target defines the target to look animatables for
  9808. * @returns an array of Animatables
  9809. */
  9810. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9811. /**
  9812. * Stops and removes all animations that have been applied to the scene
  9813. */
  9814. stopAllAnimations(): void;
  9815. }
  9816. interface Bone {
  9817. /**
  9818. * Copy an animation range from another bone
  9819. * @param source defines the source bone
  9820. * @param rangeName defines the range name to copy
  9821. * @param frameOffset defines the frame offset
  9822. * @param rescaleAsRequired defines if rescaling must be applied if required
  9823. * @param skelDimensionsRatio defines the scaling ratio
  9824. * @returns true if operation was successful
  9825. */
  9826. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9827. }
  9828. }
  9829. declare module BABYLON {
  9830. /**
  9831. * Class used to handle skinning animations
  9832. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9833. */
  9834. export class Skeleton implements IAnimatable {
  9835. /** defines the skeleton name */
  9836. name: string;
  9837. /** defines the skeleton Id */
  9838. id: string;
  9839. /**
  9840. * Defines the list of child bones
  9841. */
  9842. bones: Bone[];
  9843. /**
  9844. * Defines an estimate of the dimension of the skeleton at rest
  9845. */
  9846. dimensionsAtRest: Vector3;
  9847. /**
  9848. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9849. */
  9850. needInitialSkinMatrix: boolean;
  9851. /**
  9852. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9853. */
  9854. overrideMesh: Nullable<AbstractMesh>;
  9855. /**
  9856. * Gets the list of animations attached to this skeleton
  9857. */
  9858. animations: Array<Animation>;
  9859. private _scene;
  9860. private _isDirty;
  9861. private _transformMatrices;
  9862. private _transformMatrixTexture;
  9863. private _meshesWithPoseMatrix;
  9864. private _animatables;
  9865. private _identity;
  9866. private _synchronizedWithMesh;
  9867. private _ranges;
  9868. private _lastAbsoluteTransformsUpdateId;
  9869. private _canUseTextureForBones;
  9870. private _uniqueId;
  9871. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  9872. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  9873. /**
  9874. * Specifies if the skeleton should be serialized
  9875. */
  9876. doNotSerialize: boolean;
  9877. private _useTextureToStoreBoneMatrices;
  9878. /**
  9879. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  9880. * Please note that this option is not available if the hardware does not support it
  9881. */
  9882. useTextureToStoreBoneMatrices: boolean;
  9883. private _animationPropertiesOverride;
  9884. /**
  9885. * Gets or sets the animation properties override
  9886. */
  9887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9888. /**
  9889. * List of inspectable custom properties (used by the Inspector)
  9890. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  9891. */
  9892. inspectableCustomProperties: IInspectable[];
  9893. /**
  9894. * An observable triggered before computing the skeleton's matrices
  9895. */
  9896. onBeforeComputeObservable: Observable<Skeleton>;
  9897. /**
  9898. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  9899. */
  9900. readonly isUsingTextureForMatrices: boolean;
  9901. /**
  9902. * Gets the unique ID of this skeleton
  9903. */
  9904. readonly uniqueId: number;
  9905. /**
  9906. * Creates a new skeleton
  9907. * @param name defines the skeleton name
  9908. * @param id defines the skeleton Id
  9909. * @param scene defines the hosting scene
  9910. */
  9911. constructor(
  9912. /** defines the skeleton name */
  9913. name: string,
  9914. /** defines the skeleton Id */
  9915. id: string, scene: Scene);
  9916. /**
  9917. * Gets the current object class name.
  9918. * @return the class name
  9919. */
  9920. getClassName(): string;
  9921. /**
  9922. * Returns an array containing the root bones
  9923. * @returns an array containing the root bones
  9924. */
  9925. getChildren(): Array<Bone>;
  9926. /**
  9927. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9928. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9929. * @returns a Float32Array containing matrices data
  9930. */
  9931. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9932. /**
  9933. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  9934. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9935. * @returns a raw texture containing the data
  9936. */
  9937. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  9938. /**
  9939. * Gets the current hosting scene
  9940. * @returns a scene object
  9941. */
  9942. getScene(): Scene;
  9943. /**
  9944. * Gets a string representing the current skeleton data
  9945. * @param fullDetails defines a boolean indicating if we want a verbose version
  9946. * @returns a string representing the current skeleton data
  9947. */
  9948. toString(fullDetails?: boolean): string;
  9949. /**
  9950. * Get bone's index searching by name
  9951. * @param name defines bone's name to search for
  9952. * @return the indice of the bone. Returns -1 if not found
  9953. */
  9954. getBoneIndexByName(name: string): number;
  9955. /**
  9956. * Creater a new animation range
  9957. * @param name defines the name of the range
  9958. * @param from defines the start key
  9959. * @param to defines the end key
  9960. */
  9961. createAnimationRange(name: string, from: number, to: number): void;
  9962. /**
  9963. * Delete a specific animation range
  9964. * @param name defines the name of the range
  9965. * @param deleteFrames defines if frames must be removed as well
  9966. */
  9967. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9968. /**
  9969. * Gets a specific animation range
  9970. * @param name defines the name of the range to look for
  9971. * @returns the requested animation range or null if not found
  9972. */
  9973. getAnimationRange(name: string): Nullable<AnimationRange>;
  9974. /**
  9975. * Gets the list of all animation ranges defined on this skeleton
  9976. * @returns an array
  9977. */
  9978. getAnimationRanges(): Nullable<AnimationRange>[];
  9979. /**
  9980. * Copy animation range from a source skeleton.
  9981. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9982. * @param source defines the source skeleton
  9983. * @param name defines the name of the range to copy
  9984. * @param rescaleAsRequired defines if rescaling must be applied if required
  9985. * @returns true if operation was successful
  9986. */
  9987. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9988. /**
  9989. * Forces the skeleton to go to rest pose
  9990. */
  9991. returnToRest(): void;
  9992. private _getHighestAnimationFrame;
  9993. /**
  9994. * Begin a specific animation range
  9995. * @param name defines the name of the range to start
  9996. * @param loop defines if looping must be turned on (false by default)
  9997. * @param speedRatio defines the speed ratio to apply (1 by default)
  9998. * @param onAnimationEnd defines a callback which will be called when animation will end
  9999. * @returns a new animatable
  10000. */
  10001. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10002. /** @hidden */ private _markAsDirty(): void;
  10003. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10004. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10005. private _computeTransformMatrices;
  10006. /**
  10007. * Build all resources required to render a skeleton
  10008. */
  10009. prepare(): void;
  10010. /**
  10011. * Gets the list of animatables currently running for this skeleton
  10012. * @returns an array of animatables
  10013. */
  10014. getAnimatables(): IAnimatable[];
  10015. /**
  10016. * Clone the current skeleton
  10017. * @param name defines the name of the new skeleton
  10018. * @param id defines the id of the new skeleton
  10019. * @returns the new skeleton
  10020. */
  10021. clone(name: string, id: string): Skeleton;
  10022. /**
  10023. * Enable animation blending for this skeleton
  10024. * @param blendingSpeed defines the blending speed to apply
  10025. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10026. */
  10027. enableBlending(blendingSpeed?: number): void;
  10028. /**
  10029. * Releases all resources associated with the current skeleton
  10030. */
  10031. dispose(): void;
  10032. /**
  10033. * Serialize the skeleton in a JSON object
  10034. * @returns a JSON object
  10035. */
  10036. serialize(): any;
  10037. /**
  10038. * Creates a new skeleton from serialized data
  10039. * @param parsedSkeleton defines the serialized data
  10040. * @param scene defines the hosting scene
  10041. * @returns a new skeleton
  10042. */
  10043. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10044. /**
  10045. * Compute all node absolute transforms
  10046. * @param forceUpdate defines if computation must be done even if cache is up to date
  10047. */
  10048. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10049. /**
  10050. * Gets the root pose matrix
  10051. * @returns a matrix
  10052. */
  10053. getPoseMatrix(): Nullable<Matrix>;
  10054. /**
  10055. * Sorts bones per internal index
  10056. */
  10057. sortBones(): void;
  10058. private _sortBones;
  10059. }
  10060. }
  10061. declare module BABYLON {
  10062. /**
  10063. * Defines a target to use with MorphTargetManager
  10064. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10065. */
  10066. export class MorphTarget implements IAnimatable {
  10067. /** defines the name of the target */
  10068. name: string;
  10069. /**
  10070. * Gets or sets the list of animations
  10071. */
  10072. animations: Animation[];
  10073. private _scene;
  10074. private _positions;
  10075. private _normals;
  10076. private _tangents;
  10077. private _uvs;
  10078. private _influence;
  10079. /**
  10080. * Observable raised when the influence changes
  10081. */
  10082. onInfluenceChanged: Observable<boolean>;
  10083. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  10084. /**
  10085. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10086. */
  10087. influence: number;
  10088. /**
  10089. * Gets or sets the id of the morph Target
  10090. */
  10091. id: string;
  10092. private _animationPropertiesOverride;
  10093. /**
  10094. * Gets or sets the animation properties override
  10095. */
  10096. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10097. /**
  10098. * Creates a new MorphTarget
  10099. * @param name defines the name of the target
  10100. * @param influence defines the influence to use
  10101. * @param scene defines the scene the morphtarget belongs to
  10102. */
  10103. constructor(
  10104. /** defines the name of the target */
  10105. name: string, influence?: number, scene?: Nullable<Scene>);
  10106. /**
  10107. * Gets a boolean defining if the target contains position data
  10108. */
  10109. readonly hasPositions: boolean;
  10110. /**
  10111. * Gets a boolean defining if the target contains normal data
  10112. */
  10113. readonly hasNormals: boolean;
  10114. /**
  10115. * Gets a boolean defining if the target contains tangent data
  10116. */
  10117. readonly hasTangents: boolean;
  10118. /**
  10119. * Gets a boolean defining if the target contains texture coordinates data
  10120. */
  10121. readonly hasUVs: boolean;
  10122. /**
  10123. * Affects position data to this target
  10124. * @param data defines the position data to use
  10125. */
  10126. setPositions(data: Nullable<FloatArray>): void;
  10127. /**
  10128. * Gets the position data stored in this target
  10129. * @returns a FloatArray containing the position data (or null if not present)
  10130. */
  10131. getPositions(): Nullable<FloatArray>;
  10132. /**
  10133. * Affects normal data to this target
  10134. * @param data defines the normal data to use
  10135. */
  10136. setNormals(data: Nullable<FloatArray>): void;
  10137. /**
  10138. * Gets the normal data stored in this target
  10139. * @returns a FloatArray containing the normal data (or null if not present)
  10140. */
  10141. getNormals(): Nullable<FloatArray>;
  10142. /**
  10143. * Affects tangent data to this target
  10144. * @param data defines the tangent data to use
  10145. */
  10146. setTangents(data: Nullable<FloatArray>): void;
  10147. /**
  10148. * Gets the tangent data stored in this target
  10149. * @returns a FloatArray containing the tangent data (or null if not present)
  10150. */
  10151. getTangents(): Nullable<FloatArray>;
  10152. /**
  10153. * Affects texture coordinates data to this target
  10154. * @param data defines the texture coordinates data to use
  10155. */
  10156. setUVs(data: Nullable<FloatArray>): void;
  10157. /**
  10158. * Gets the texture coordinates data stored in this target
  10159. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10160. */
  10161. getUVs(): Nullable<FloatArray>;
  10162. /**
  10163. * Serializes the current target into a Serialization object
  10164. * @returns the serialized object
  10165. */
  10166. serialize(): any;
  10167. /**
  10168. * Returns the string "MorphTarget"
  10169. * @returns "MorphTarget"
  10170. */
  10171. getClassName(): string;
  10172. /**
  10173. * Creates a new target from serialized data
  10174. * @param serializationObject defines the serialized data to use
  10175. * @returns a new MorphTarget
  10176. */
  10177. static Parse(serializationObject: any): MorphTarget;
  10178. /**
  10179. * Creates a MorphTarget from mesh data
  10180. * @param mesh defines the source mesh
  10181. * @param name defines the name to use for the new target
  10182. * @param influence defines the influence to attach to the target
  10183. * @returns a new MorphTarget
  10184. */
  10185. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10186. }
  10187. }
  10188. declare module BABYLON {
  10189. /**
  10190. * This class is used to deform meshes using morphing between different targets
  10191. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10192. */
  10193. export class MorphTargetManager {
  10194. private _targets;
  10195. private _targetInfluenceChangedObservers;
  10196. private _targetDataLayoutChangedObservers;
  10197. private _activeTargets;
  10198. private _scene;
  10199. private _influences;
  10200. private _supportsNormals;
  10201. private _supportsTangents;
  10202. private _supportsUVs;
  10203. private _vertexCount;
  10204. private _uniqueId;
  10205. private _tempInfluences;
  10206. /**
  10207. * Gets or sets a boolean indicating if normals must be morphed
  10208. */
  10209. enableNormalMorphing: boolean;
  10210. /**
  10211. * Gets or sets a boolean indicating if tangents must be morphed
  10212. */
  10213. enableTangentMorphing: boolean;
  10214. /**
  10215. * Gets or sets a boolean indicating if UV must be morphed
  10216. */
  10217. enableUVMorphing: boolean;
  10218. /**
  10219. * Creates a new MorphTargetManager
  10220. * @param scene defines the current scene
  10221. */
  10222. constructor(scene?: Nullable<Scene>);
  10223. /**
  10224. * Gets the unique ID of this manager
  10225. */
  10226. readonly uniqueId: number;
  10227. /**
  10228. * Gets the number of vertices handled by this manager
  10229. */
  10230. readonly vertexCount: number;
  10231. /**
  10232. * Gets a boolean indicating if this manager supports morphing of normals
  10233. */
  10234. readonly supportsNormals: boolean;
  10235. /**
  10236. * Gets a boolean indicating if this manager supports morphing of tangents
  10237. */
  10238. readonly supportsTangents: boolean;
  10239. /**
  10240. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10241. */
  10242. readonly supportsUVs: boolean;
  10243. /**
  10244. * Gets the number of targets stored in this manager
  10245. */
  10246. readonly numTargets: number;
  10247. /**
  10248. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10249. */
  10250. readonly numInfluencers: number;
  10251. /**
  10252. * Gets the list of influences (one per target)
  10253. */
  10254. readonly influences: Float32Array;
  10255. /**
  10256. * Gets the active target at specified index. An active target is a target with an influence > 0
  10257. * @param index defines the index to check
  10258. * @returns the requested target
  10259. */
  10260. getActiveTarget(index: number): MorphTarget;
  10261. /**
  10262. * Gets the target at specified index
  10263. * @param index defines the index to check
  10264. * @returns the requested target
  10265. */
  10266. getTarget(index: number): MorphTarget;
  10267. /**
  10268. * Add a new target to this manager
  10269. * @param target defines the target to add
  10270. */
  10271. addTarget(target: MorphTarget): void;
  10272. /**
  10273. * Removes a target from the manager
  10274. * @param target defines the target to remove
  10275. */
  10276. removeTarget(target: MorphTarget): void;
  10277. /**
  10278. * Serializes the current manager into a Serialization object
  10279. * @returns the serialized object
  10280. */
  10281. serialize(): any;
  10282. private _syncActiveTargets;
  10283. /**
  10284. * Syncrhonize the targets with all the meshes using this morph target manager
  10285. */
  10286. synchronize(): void;
  10287. /**
  10288. * Creates a new MorphTargetManager from serialized data
  10289. * @param serializationObject defines the serialized data
  10290. * @param scene defines the hosting scene
  10291. * @returns the new MorphTargetManager
  10292. */
  10293. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10294. }
  10295. }
  10296. declare module BABYLON {
  10297. /**
  10298. * Groups all the scene component constants in one place to ease maintenance.
  10299. * @hidden
  10300. */
  10301. export class SceneComponentConstants {
  10302. static readonly NAME_EFFECTLAYER: string;
  10303. static readonly NAME_LAYER: string;
  10304. static readonly NAME_LENSFLARESYSTEM: string;
  10305. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10306. static readonly NAME_PARTICLESYSTEM: string;
  10307. static readonly NAME_GAMEPAD: string;
  10308. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10309. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10310. static readonly NAME_DEPTHRENDERER: string;
  10311. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10312. static readonly NAME_SPRITE: string;
  10313. static readonly NAME_OUTLINERENDERER: string;
  10314. static readonly NAME_PROCEDURALTEXTURE: string;
  10315. static readonly NAME_SHADOWGENERATOR: string;
  10316. static readonly NAME_OCTREE: string;
  10317. static readonly NAME_PHYSICSENGINE: string;
  10318. static readonly NAME_AUDIO: string;
  10319. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10320. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10321. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10322. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10323. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10324. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10325. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10326. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10327. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10328. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10329. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10330. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10331. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10332. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10333. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10334. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10335. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10336. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10337. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10338. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10339. static readonly STEP_AFTERRENDER_AUDIO: number;
  10340. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10341. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10342. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10343. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10344. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10345. static readonly STEP_POINTERMOVE_SPRITE: number;
  10346. static readonly STEP_POINTERDOWN_SPRITE: number;
  10347. static readonly STEP_POINTERUP_SPRITE: number;
  10348. }
  10349. /**
  10350. * This represents a scene component.
  10351. *
  10352. * This is used to decouple the dependency the scene is having on the different workloads like
  10353. * layers, post processes...
  10354. */
  10355. export interface ISceneComponent {
  10356. /**
  10357. * The name of the component. Each component must have a unique name.
  10358. */
  10359. name: string;
  10360. /**
  10361. * The scene the component belongs to.
  10362. */
  10363. scene: Scene;
  10364. /**
  10365. * Register the component to one instance of a scene.
  10366. */
  10367. register(): void;
  10368. /**
  10369. * Rebuilds the elements related to this component in case of
  10370. * context lost for instance.
  10371. */
  10372. rebuild(): void;
  10373. /**
  10374. * Disposes the component and the associated ressources.
  10375. */
  10376. dispose(): void;
  10377. }
  10378. /**
  10379. * This represents a SERIALIZABLE scene component.
  10380. *
  10381. * This extends Scene Component to add Serialization methods on top.
  10382. */
  10383. export interface ISceneSerializableComponent extends ISceneComponent {
  10384. /**
  10385. * Adds all the elements from the container to the scene
  10386. * @param container the container holding the elements
  10387. */
  10388. addFromContainer(container: AbstractScene): void;
  10389. /**
  10390. * Removes all the elements in the container from the scene
  10391. * @param container contains the elements to remove
  10392. * @param dispose if the removed element should be disposed (default: false)
  10393. */
  10394. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10395. /**
  10396. * Serializes the component data to the specified json object
  10397. * @param serializationObject The object to serialize to
  10398. */
  10399. serialize(serializationObject: any): void;
  10400. }
  10401. /**
  10402. * Strong typing of a Mesh related stage step action
  10403. */
  10404. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10405. /**
  10406. * Strong typing of a Evaluate Sub Mesh related stage step action
  10407. */
  10408. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10409. /**
  10410. * Strong typing of a Active Mesh related stage step action
  10411. */
  10412. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10413. /**
  10414. * Strong typing of a Camera related stage step action
  10415. */
  10416. export type CameraStageAction = (camera: Camera) => void;
  10417. /**
  10418. * Strong typing of a Camera Frame buffer related stage step action
  10419. */
  10420. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10421. /**
  10422. * Strong typing of a Render Target related stage step action
  10423. */
  10424. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10425. /**
  10426. * Strong typing of a RenderingGroup related stage step action
  10427. */
  10428. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10429. /**
  10430. * Strong typing of a Mesh Render related stage step action
  10431. */
  10432. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10433. /**
  10434. * Strong typing of a simple stage step action
  10435. */
  10436. export type SimpleStageAction = () => void;
  10437. /**
  10438. * Strong typing of a render target action.
  10439. */
  10440. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10441. /**
  10442. * Strong typing of a pointer move action.
  10443. */
  10444. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10445. /**
  10446. * Strong typing of a pointer up/down action.
  10447. */
  10448. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10449. /**
  10450. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10451. * @hidden
  10452. */
  10453. export class Stage<T extends Function> extends Array<{
  10454. index: number;
  10455. component: ISceneComponent;
  10456. action: T;
  10457. }> {
  10458. /**
  10459. * Hide ctor from the rest of the world.
  10460. * @param items The items to add.
  10461. */
  10462. private constructor();
  10463. /**
  10464. * Creates a new Stage.
  10465. * @returns A new instance of a Stage
  10466. */
  10467. static Create<T extends Function>(): Stage<T>;
  10468. /**
  10469. * Registers a step in an ordered way in the targeted stage.
  10470. * @param index Defines the position to register the step in
  10471. * @param component Defines the component attached to the step
  10472. * @param action Defines the action to launch during the step
  10473. */
  10474. registerStep(index: number, component: ISceneComponent, action: T): void;
  10475. /**
  10476. * Clears all the steps from the stage.
  10477. */
  10478. clear(): void;
  10479. }
  10480. }
  10481. declare module BABYLON {
  10482. /**
  10483. * Class used to represent a specific level of detail of a mesh
  10484. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10485. */
  10486. export class MeshLODLevel {
  10487. /** Defines the distance where this level should star being displayed */
  10488. distance: number;
  10489. /** Defines the mesh to use to render this level */
  10490. mesh: Nullable<Mesh>;
  10491. /**
  10492. * Creates a new LOD level
  10493. * @param distance defines the distance where this level should star being displayed
  10494. * @param mesh defines the mesh to use to render this level
  10495. */
  10496. constructor(
  10497. /** Defines the distance where this level should star being displayed */
  10498. distance: number,
  10499. /** Defines the mesh to use to render this level */
  10500. mesh: Nullable<Mesh>);
  10501. }
  10502. }
  10503. declare module BABYLON {
  10504. /**
  10505. * Interface describing all the common properties and methods a shadow light needs to implement.
  10506. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10507. * as well as binding the different shadow properties to the effects.
  10508. */
  10509. export interface IShadowLight extends Light {
  10510. /**
  10511. * The light id in the scene (used in scene.findLighById for instance)
  10512. */
  10513. id: string;
  10514. /**
  10515. * The position the shdow will be casted from.
  10516. */
  10517. position: Vector3;
  10518. /**
  10519. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10520. */
  10521. direction: Vector3;
  10522. /**
  10523. * The transformed position. Position of the light in world space taking parenting in account.
  10524. */
  10525. transformedPosition: Vector3;
  10526. /**
  10527. * The transformed direction. Direction of the light in world space taking parenting in account.
  10528. */
  10529. transformedDirection: Vector3;
  10530. /**
  10531. * The friendly name of the light in the scene.
  10532. */
  10533. name: string;
  10534. /**
  10535. * Defines the shadow projection clipping minimum z value.
  10536. */
  10537. shadowMinZ: number;
  10538. /**
  10539. * Defines the shadow projection clipping maximum z value.
  10540. */
  10541. shadowMaxZ: number;
  10542. /**
  10543. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10544. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10545. */
  10546. computeTransformedInformation(): boolean;
  10547. /**
  10548. * Gets the scene the light belongs to.
  10549. * @returns The scene
  10550. */
  10551. getScene(): Scene;
  10552. /**
  10553. * Callback defining a custom Projection Matrix Builder.
  10554. * This can be used to override the default projection matrix computation.
  10555. */
  10556. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10557. /**
  10558. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10559. * @param matrix The materix to updated with the projection information
  10560. * @param viewMatrix The transform matrix of the light
  10561. * @param renderList The list of mesh to render in the map
  10562. * @returns The current light
  10563. */
  10564. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10565. /**
  10566. * Gets the current depth scale used in ESM.
  10567. * @returns The scale
  10568. */
  10569. getDepthScale(): number;
  10570. /**
  10571. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10572. * @returns true if a cube texture needs to be use
  10573. */
  10574. needCube(): boolean;
  10575. /**
  10576. * Detects if the projection matrix requires to be recomputed this frame.
  10577. * @returns true if it requires to be recomputed otherwise, false.
  10578. */
  10579. needProjectionMatrixCompute(): boolean;
  10580. /**
  10581. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10582. */
  10583. forceProjectionMatrixCompute(): void;
  10584. /**
  10585. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10586. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10587. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10588. */
  10589. getShadowDirection(faceIndex?: number): Vector3;
  10590. /**
  10591. * Gets the minZ used for shadow according to both the scene and the light.
  10592. * @param activeCamera The camera we are returning the min for
  10593. * @returns the depth min z
  10594. */
  10595. getDepthMinZ(activeCamera: Camera): number;
  10596. /**
  10597. * Gets the maxZ used for shadow according to both the scene and the light.
  10598. * @param activeCamera The camera we are returning the max for
  10599. * @returns the depth max z
  10600. */
  10601. getDepthMaxZ(activeCamera: Camera): number;
  10602. }
  10603. /**
  10604. * Base implementation IShadowLight
  10605. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10606. */
  10607. export abstract class ShadowLight extends Light implements IShadowLight {
  10608. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10609. protected _position: Vector3;
  10610. protected _setPosition(value: Vector3): void;
  10611. /**
  10612. * Sets the position the shadow will be casted from. Also use as the light position for both
  10613. * point and spot lights.
  10614. */
  10615. /**
  10616. * Sets the position the shadow will be casted from. Also use as the light position for both
  10617. * point and spot lights.
  10618. */
  10619. position: Vector3;
  10620. protected _direction: Vector3;
  10621. protected _setDirection(value: Vector3): void;
  10622. /**
  10623. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10624. * Also use as the light direction on spot and directional lights.
  10625. */
  10626. /**
  10627. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10628. * Also use as the light direction on spot and directional lights.
  10629. */
  10630. direction: Vector3;
  10631. private _shadowMinZ;
  10632. /**
  10633. * Gets the shadow projection clipping minimum z value.
  10634. */
  10635. /**
  10636. * Sets the shadow projection clipping minimum z value.
  10637. */
  10638. shadowMinZ: number;
  10639. private _shadowMaxZ;
  10640. /**
  10641. * Sets the shadow projection clipping maximum z value.
  10642. */
  10643. /**
  10644. * Gets the shadow projection clipping maximum z value.
  10645. */
  10646. shadowMaxZ: number;
  10647. /**
  10648. * Callback defining a custom Projection Matrix Builder.
  10649. * This can be used to override the default projection matrix computation.
  10650. */
  10651. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10652. /**
  10653. * The transformed position. Position of the light in world space taking parenting in account.
  10654. */
  10655. transformedPosition: Vector3;
  10656. /**
  10657. * The transformed direction. Direction of the light in world space taking parenting in account.
  10658. */
  10659. transformedDirection: Vector3;
  10660. private _needProjectionMatrixCompute;
  10661. /**
  10662. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10663. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10664. */
  10665. computeTransformedInformation(): boolean;
  10666. /**
  10667. * Return the depth scale used for the shadow map.
  10668. * @returns the depth scale.
  10669. */
  10670. getDepthScale(): number;
  10671. /**
  10672. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10673. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10674. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10675. */
  10676. getShadowDirection(faceIndex?: number): Vector3;
  10677. /**
  10678. * Returns the ShadowLight absolute position in the World.
  10679. * @returns the position vector in world space
  10680. */
  10681. getAbsolutePosition(): Vector3;
  10682. /**
  10683. * Sets the ShadowLight direction toward the passed target.
  10684. * @param target The point to target in local space
  10685. * @returns the updated ShadowLight direction
  10686. */
  10687. setDirectionToTarget(target: Vector3): Vector3;
  10688. /**
  10689. * Returns the light rotation in euler definition.
  10690. * @returns the x y z rotation in local space.
  10691. */
  10692. getRotation(): Vector3;
  10693. /**
  10694. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10695. * @returns true if a cube texture needs to be use
  10696. */
  10697. needCube(): boolean;
  10698. /**
  10699. * Detects if the projection matrix requires to be recomputed this frame.
  10700. * @returns true if it requires to be recomputed otherwise, false.
  10701. */
  10702. needProjectionMatrixCompute(): boolean;
  10703. /**
  10704. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10705. */
  10706. forceProjectionMatrixCompute(): void;
  10707. /** @hidden */ private _initCache(): void;
  10708. /** @hidden */ private _isSynchronized(): boolean;
  10709. /**
  10710. * Computes the world matrix of the node
  10711. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10712. * @returns the world matrix
  10713. */
  10714. computeWorldMatrix(force?: boolean): Matrix;
  10715. /**
  10716. * Gets the minZ used for shadow according to both the scene and the light.
  10717. * @param activeCamera The camera we are returning the min for
  10718. * @returns the depth min z
  10719. */
  10720. getDepthMinZ(activeCamera: Camera): number;
  10721. /**
  10722. * Gets the maxZ used for shadow according to both the scene and the light.
  10723. * @param activeCamera The camera we are returning the max for
  10724. * @returns the depth max z
  10725. */
  10726. getDepthMaxZ(activeCamera: Camera): number;
  10727. /**
  10728. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10729. * @param matrix The materix to updated with the projection information
  10730. * @param viewMatrix The transform matrix of the light
  10731. * @param renderList The list of mesh to render in the map
  10732. * @returns The current light
  10733. */
  10734. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10735. }
  10736. }
  10737. declare module BABYLON {
  10738. /**
  10739. * "Static Class" containing the most commonly used helper while dealing with material for
  10740. * rendering purpose.
  10741. *
  10742. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10743. *
  10744. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10745. */
  10746. export class MaterialHelper {
  10747. /**
  10748. * Bind the current view position to an effect.
  10749. * @param effect The effect to be bound
  10750. * @param scene The scene the eyes position is used from
  10751. */
  10752. static BindEyePosition(effect: Effect, scene: Scene): void;
  10753. /**
  10754. * Helps preparing the defines values about the UVs in used in the effect.
  10755. * UVs are shared as much as we can accross channels in the shaders.
  10756. * @param texture The texture we are preparing the UVs for
  10757. * @param defines The defines to update
  10758. * @param key The channel key "diffuse", "specular"... used in the shader
  10759. */
  10760. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10761. /**
  10762. * Binds a texture matrix value to its corrsponding uniform
  10763. * @param texture The texture to bind the matrix for
  10764. * @param uniformBuffer The uniform buffer receivin the data
  10765. * @param key The channel key "diffuse", "specular"... used in the shader
  10766. */
  10767. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10768. /**
  10769. * Gets the current status of the fog (should it be enabled?)
  10770. * @param mesh defines the mesh to evaluate for fog support
  10771. * @param scene defines the hosting scene
  10772. * @returns true if fog must be enabled
  10773. */
  10774. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10775. /**
  10776. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10777. * @param mesh defines the current mesh
  10778. * @param scene defines the current scene
  10779. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10780. * @param pointsCloud defines if point cloud rendering has to be turned on
  10781. * @param fogEnabled defines if fog has to be turned on
  10782. * @param alphaTest defines if alpha testing has to be turned on
  10783. * @param defines defines the current list of defines
  10784. */
  10785. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10786. /**
  10787. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10788. * @param scene defines the current scene
  10789. * @param engine defines the current engine
  10790. * @param defines specifies the list of active defines
  10791. * @param useInstances defines if instances have to be turned on
  10792. * @param useClipPlane defines if clip plane have to be turned on
  10793. */
  10794. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10795. /**
  10796. * Prepares the defines for bones
  10797. * @param mesh The mesh containing the geometry data we will draw
  10798. * @param defines The defines to update
  10799. */
  10800. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10801. /**
  10802. * Prepares the defines for morph targets
  10803. * @param mesh The mesh containing the geometry data we will draw
  10804. * @param defines The defines to update
  10805. */
  10806. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10807. /**
  10808. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10809. * @param mesh The mesh containing the geometry data we will draw
  10810. * @param defines The defines to update
  10811. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10812. * @param useBones Precise whether bones should be used or not (override mesh info)
  10813. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10814. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10815. * @returns false if defines are considered not dirty and have not been checked
  10816. */
  10817. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10818. /**
  10819. * Prepares the defines related to multiview
  10820. * @param scene The scene we are intending to draw
  10821. * @param defines The defines to update
  10822. */
  10823. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10824. /**
  10825. * Prepares the defines related to the light information passed in parameter
  10826. * @param scene The scene we are intending to draw
  10827. * @param mesh The mesh the effect is compiling for
  10828. * @param light The light the effect is compiling for
  10829. * @param lightIndex The index of the light
  10830. * @param defines The defines to update
  10831. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10832. * @param state Defines the current state regarding what is needed (normals, etc...)
  10833. */
  10834. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10835. needNormals: boolean;
  10836. needRebuild: boolean;
  10837. shadowEnabled: boolean;
  10838. specularEnabled: boolean;
  10839. lightmapMode: boolean;
  10840. }): void;
  10841. /**
  10842. * Prepares the defines related to the light information passed in parameter
  10843. * @param scene The scene we are intending to draw
  10844. * @param mesh The mesh the effect is compiling for
  10845. * @param defines The defines to update
  10846. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10847. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10848. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10849. * @returns true if normals will be required for the rest of the effect
  10850. */
  10851. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10852. /**
  10853. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10854. * @param lightIndex defines the light index
  10855. * @param uniformsList The uniform list
  10856. * @param samplersList The sampler list
  10857. * @param projectedLightTexture defines if projected texture must be used
  10858. * @param uniformBuffersList defines an optional list of uniform buffers
  10859. */
  10860. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  10861. /**
  10862. * Prepares the uniforms and samplers list to be used in the effect
  10863. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10864. * @param samplersList The sampler list
  10865. * @param defines The defines helping in the list generation
  10866. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10867. */
  10868. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10869. /**
  10870. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10871. * @param defines The defines to update while falling back
  10872. * @param fallbacks The authorized effect fallbacks
  10873. * @param maxSimultaneousLights The maximum number of lights allowed
  10874. * @param rank the current rank of the Effect
  10875. * @returns The newly affected rank
  10876. */
  10877. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10878. private static _TmpMorphInfluencers;
  10879. /**
  10880. * Prepares the list of attributes required for morph targets according to the effect defines.
  10881. * @param attribs The current list of supported attribs
  10882. * @param mesh The mesh to prepare the morph targets attributes for
  10883. * @param influencers The number of influencers
  10884. */
  10885. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  10886. /**
  10887. * Prepares the list of attributes required for morph targets according to the effect defines.
  10888. * @param attribs The current list of supported attribs
  10889. * @param mesh The mesh to prepare the morph targets attributes for
  10890. * @param defines The current Defines of the effect
  10891. */
  10892. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10893. /**
  10894. * Prepares the list of attributes required for bones according to the effect defines.
  10895. * @param attribs The current list of supported attribs
  10896. * @param mesh The mesh to prepare the bones attributes for
  10897. * @param defines The current Defines of the effect
  10898. * @param fallbacks The current efffect fallback strategy
  10899. */
  10900. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10901. /**
  10902. * Check and prepare the list of attributes required for instances according to the effect defines.
  10903. * @param attribs The current list of supported attribs
  10904. * @param defines The current MaterialDefines of the effect
  10905. */
  10906. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  10907. /**
  10908. * Add the list of attributes required for instances to the attribs array.
  10909. * @param attribs The current list of supported attribs
  10910. */
  10911. static PushAttributesForInstances(attribs: string[]): void;
  10912. /**
  10913. * Binds the light shadow information to the effect for the given mesh.
  10914. * @param light The light containing the generator
  10915. * @param scene The scene the lights belongs to
  10916. * @param mesh The mesh we are binding the information to render
  10917. * @param lightIndex The light index in the effect used to render the mesh
  10918. * @param effect The effect we are binding the data to
  10919. */
  10920. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10921. /**
  10922. * Binds the light information to the effect.
  10923. * @param light The light containing the generator
  10924. * @param effect The effect we are binding the data to
  10925. * @param lightIndex The light index in the effect used to render
  10926. */
  10927. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10928. /**
  10929. * Binds the lights information from the scene to the effect for the given mesh.
  10930. * @param light Light to bind
  10931. * @param lightIndex Light index
  10932. * @param scene The scene where the light belongs to
  10933. * @param mesh The mesh we are binding the information to render
  10934. * @param effect The effect we are binding the data to
  10935. * @param useSpecular Defines if specular is supported
  10936. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10937. */
  10938. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  10939. /**
  10940. * Binds the lights information from the scene to the effect for the given mesh.
  10941. * @param scene The scene the lights belongs to
  10942. * @param mesh The mesh we are binding the information to render
  10943. * @param effect The effect we are binding the data to
  10944. * @param defines The generated defines for the effect
  10945. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10946. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10947. */
  10948. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10949. private static _tempFogColor;
  10950. /**
  10951. * Binds the fog information from the scene to the effect for the given mesh.
  10952. * @param scene The scene the lights belongs to
  10953. * @param mesh The mesh we are binding the information to render
  10954. * @param effect The effect we are binding the data to
  10955. * @param linearSpace Defines if the fog effect is applied in linear space
  10956. */
  10957. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10958. /**
  10959. * Binds the bones information from the mesh to the effect.
  10960. * @param mesh The mesh we are binding the information to render
  10961. * @param effect The effect we are binding the data to
  10962. */
  10963. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10964. /**
  10965. * Binds the morph targets information from the mesh to the effect.
  10966. * @param abstractMesh The mesh we are binding the information to render
  10967. * @param effect The effect we are binding the data to
  10968. */
  10969. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10970. /**
  10971. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10972. * @param defines The generated defines used in the effect
  10973. * @param effect The effect we are binding the data to
  10974. * @param scene The scene we are willing to render with logarithmic scale for
  10975. */
  10976. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10977. /**
  10978. * Binds the clip plane information from the scene to the effect.
  10979. * @param scene The scene the clip plane information are extracted from
  10980. * @param effect The effect we are binding the data to
  10981. */
  10982. static BindClipPlane(effect: Effect, scene: Scene): void;
  10983. }
  10984. }
  10985. declare module BABYLON {
  10986. /** @hidden */
  10987. export var shadowMapPixelShader: {
  10988. name: string;
  10989. shader: string;
  10990. };
  10991. }
  10992. declare module BABYLON {
  10993. /** @hidden */
  10994. export var bonesDeclaration: {
  10995. name: string;
  10996. shader: string;
  10997. };
  10998. }
  10999. declare module BABYLON {
  11000. /** @hidden */
  11001. export var morphTargetsVertexGlobalDeclaration: {
  11002. name: string;
  11003. shader: string;
  11004. };
  11005. }
  11006. declare module BABYLON {
  11007. /** @hidden */
  11008. export var morphTargetsVertexDeclaration: {
  11009. name: string;
  11010. shader: string;
  11011. };
  11012. }
  11013. declare module BABYLON {
  11014. /** @hidden */
  11015. export var instancesDeclaration: {
  11016. name: string;
  11017. shader: string;
  11018. };
  11019. }
  11020. declare module BABYLON {
  11021. /** @hidden */
  11022. export var helperFunctions: {
  11023. name: string;
  11024. shader: string;
  11025. };
  11026. }
  11027. declare module BABYLON {
  11028. /** @hidden */
  11029. export var morphTargetsVertex: {
  11030. name: string;
  11031. shader: string;
  11032. };
  11033. }
  11034. declare module BABYLON {
  11035. /** @hidden */
  11036. export var instancesVertex: {
  11037. name: string;
  11038. shader: string;
  11039. };
  11040. }
  11041. declare module BABYLON {
  11042. /** @hidden */
  11043. export var bonesVertex: {
  11044. name: string;
  11045. shader: string;
  11046. };
  11047. }
  11048. declare module BABYLON {
  11049. /** @hidden */
  11050. export var shadowMapVertexShader: {
  11051. name: string;
  11052. shader: string;
  11053. };
  11054. }
  11055. declare module BABYLON {
  11056. /** @hidden */
  11057. export var depthBoxBlurPixelShader: {
  11058. name: string;
  11059. shader: string;
  11060. };
  11061. }
  11062. declare module BABYLON {
  11063. /**
  11064. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11065. */
  11066. export interface ICustomShaderOptions {
  11067. /**
  11068. * Gets or sets the custom shader name to use
  11069. */
  11070. shaderName: string;
  11071. /**
  11072. * The list of attribute names used in the shader
  11073. */
  11074. attributes?: string[];
  11075. /**
  11076. * The list of unifrom names used in the shader
  11077. */
  11078. uniforms?: string[];
  11079. /**
  11080. * The list of sampler names used in the shader
  11081. */
  11082. samplers?: string[];
  11083. /**
  11084. * The list of defines used in the shader
  11085. */
  11086. defines?: string[];
  11087. }
  11088. /**
  11089. * Interface to implement to create a shadow generator compatible with BJS.
  11090. */
  11091. export interface IShadowGenerator {
  11092. /**
  11093. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11094. * @returns The render target texture if present otherwise, null
  11095. */
  11096. getShadowMap(): Nullable<RenderTargetTexture>;
  11097. /**
  11098. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11099. * @returns The render target texture if the shadow map is present otherwise, null
  11100. */
  11101. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11102. /**
  11103. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11104. * @param subMesh The submesh we want to render in the shadow map
  11105. * @param useInstances Defines wether will draw in the map using instances
  11106. * @returns true if ready otherwise, false
  11107. */
  11108. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11109. /**
  11110. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11111. * @param defines Defines of the material we want to update
  11112. * @param lightIndex Index of the light in the enabled light list of the material
  11113. */
  11114. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11115. /**
  11116. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11117. * defined in the generator but impacting the effect).
  11118. * It implies the unifroms available on the materials are the standard BJS ones.
  11119. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11120. * @param effect The effect we are binfing the information for
  11121. */
  11122. bindShadowLight(lightIndex: string, effect: Effect): void;
  11123. /**
  11124. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11125. * (eq to shadow prjection matrix * light transform matrix)
  11126. * @returns The transform matrix used to create the shadow map
  11127. */
  11128. getTransformMatrix(): Matrix;
  11129. /**
  11130. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11131. * Cube and 2D textures for instance.
  11132. */
  11133. recreateShadowMap(): void;
  11134. /**
  11135. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11136. * @param onCompiled Callback triggered at the and of the effects compilation
  11137. * @param options Sets of optional options forcing the compilation with different modes
  11138. */
  11139. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11140. useInstances: boolean;
  11141. }>): void;
  11142. /**
  11143. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11144. * @param options Sets of optional options forcing the compilation with different modes
  11145. * @returns A promise that resolves when the compilation completes
  11146. */
  11147. forceCompilationAsync(options?: Partial<{
  11148. useInstances: boolean;
  11149. }>): Promise<void>;
  11150. /**
  11151. * Serializes the shadow generator setup to a json object.
  11152. * @returns The serialized JSON object
  11153. */
  11154. serialize(): any;
  11155. /**
  11156. * Disposes the Shadow map and related Textures and effects.
  11157. */
  11158. dispose(): void;
  11159. }
  11160. /**
  11161. * Default implementation IShadowGenerator.
  11162. * This is the main object responsible of generating shadows in the framework.
  11163. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11164. */
  11165. export class ShadowGenerator implements IShadowGenerator {
  11166. /**
  11167. * Shadow generator mode None: no filtering applied.
  11168. */
  11169. static readonly FILTER_NONE: number;
  11170. /**
  11171. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11172. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11173. */
  11174. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11175. /**
  11176. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11177. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11178. */
  11179. static readonly FILTER_POISSONSAMPLING: number;
  11180. /**
  11181. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11182. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11183. */
  11184. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11185. /**
  11186. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11187. * edge artifacts on steep falloff.
  11188. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11189. */
  11190. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11191. /**
  11192. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11193. * edge artifacts on steep falloff.
  11194. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11195. */
  11196. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11197. /**
  11198. * Shadow generator mode PCF: Percentage Closer Filtering
  11199. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11200. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11201. */
  11202. static readonly FILTER_PCF: number;
  11203. /**
  11204. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11205. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11206. * Contact Hardening
  11207. */
  11208. static readonly FILTER_PCSS: number;
  11209. /**
  11210. * Reserved for PCF and PCSS
  11211. * Highest Quality.
  11212. *
  11213. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11214. *
  11215. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11216. */
  11217. static readonly QUALITY_HIGH: number;
  11218. /**
  11219. * Reserved for PCF and PCSS
  11220. * Good tradeoff for quality/perf cross devices
  11221. *
  11222. * Execute PCF on a 3*3 kernel.
  11223. *
  11224. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11225. */
  11226. static readonly QUALITY_MEDIUM: number;
  11227. /**
  11228. * Reserved for PCF and PCSS
  11229. * The lowest quality but the fastest.
  11230. *
  11231. * Execute PCF on a 1*1 kernel.
  11232. *
  11233. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11234. */
  11235. static readonly QUALITY_LOW: number;
  11236. /** Gets or sets the custom shader name to use */
  11237. customShaderOptions: ICustomShaderOptions;
  11238. /**
  11239. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11240. */
  11241. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11242. /**
  11243. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11244. */
  11245. onAfterShadowMapRenderObservable: Observable<Effect>;
  11246. /**
  11247. * Observable triggered before a mesh is rendered in the shadow map.
  11248. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11249. */
  11250. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11251. /**
  11252. * Observable triggered after a mesh is rendered in the shadow map.
  11253. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11254. */
  11255. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11256. private _bias;
  11257. /**
  11258. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11259. */
  11260. /**
  11261. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11262. */
  11263. bias: number;
  11264. private _normalBias;
  11265. /**
  11266. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11267. */
  11268. /**
  11269. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11270. */
  11271. normalBias: number;
  11272. private _blurBoxOffset;
  11273. /**
  11274. * Gets the blur box offset: offset applied during the blur pass.
  11275. * Only useful if useKernelBlur = false
  11276. */
  11277. /**
  11278. * Sets the blur box offset: offset applied during the blur pass.
  11279. * Only useful if useKernelBlur = false
  11280. */
  11281. blurBoxOffset: number;
  11282. private _blurScale;
  11283. /**
  11284. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11285. * 2 means half of the size.
  11286. */
  11287. /**
  11288. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11289. * 2 means half of the size.
  11290. */
  11291. blurScale: number;
  11292. private _blurKernel;
  11293. /**
  11294. * Gets the blur kernel: kernel size of the blur pass.
  11295. * Only useful if useKernelBlur = true
  11296. */
  11297. /**
  11298. * Sets the blur kernel: kernel size of the blur pass.
  11299. * Only useful if useKernelBlur = true
  11300. */
  11301. blurKernel: number;
  11302. private _useKernelBlur;
  11303. /**
  11304. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11305. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11306. */
  11307. /**
  11308. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11309. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11310. */
  11311. useKernelBlur: boolean;
  11312. private _depthScale;
  11313. /**
  11314. * Gets the depth scale used in ESM mode.
  11315. */
  11316. /**
  11317. * Sets the depth scale used in ESM mode.
  11318. * This can override the scale stored on the light.
  11319. */
  11320. depthScale: number;
  11321. private _filter;
  11322. /**
  11323. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11324. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11325. */
  11326. /**
  11327. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11328. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11329. */
  11330. filter: number;
  11331. /**
  11332. * Gets if the current filter is set to Poisson Sampling.
  11333. */
  11334. /**
  11335. * Sets the current filter to Poisson Sampling.
  11336. */
  11337. usePoissonSampling: boolean;
  11338. /**
  11339. * Gets if the current filter is set to ESM.
  11340. */
  11341. /**
  11342. * Sets the current filter is to ESM.
  11343. */
  11344. useExponentialShadowMap: boolean;
  11345. /**
  11346. * Gets if the current filter is set to filtered ESM.
  11347. */
  11348. /**
  11349. * Gets if the current filter is set to filtered ESM.
  11350. */
  11351. useBlurExponentialShadowMap: boolean;
  11352. /**
  11353. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11354. * exponential to prevent steep falloff artifacts).
  11355. */
  11356. /**
  11357. * Sets the current filter to "close ESM" (using the inverse of the
  11358. * exponential to prevent steep falloff artifacts).
  11359. */
  11360. useCloseExponentialShadowMap: boolean;
  11361. /**
  11362. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11363. * exponential to prevent steep falloff artifacts).
  11364. */
  11365. /**
  11366. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11367. * exponential to prevent steep falloff artifacts).
  11368. */
  11369. useBlurCloseExponentialShadowMap: boolean;
  11370. /**
  11371. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11372. */
  11373. /**
  11374. * Sets the current filter to "PCF" (percentage closer filtering).
  11375. */
  11376. usePercentageCloserFiltering: boolean;
  11377. private _filteringQuality;
  11378. /**
  11379. * Gets the PCF or PCSS Quality.
  11380. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11381. */
  11382. /**
  11383. * Sets the PCF or PCSS Quality.
  11384. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11385. */
  11386. filteringQuality: number;
  11387. /**
  11388. * Gets if the current filter is set to "PCSS" (contact hardening).
  11389. */
  11390. /**
  11391. * Sets the current filter to "PCSS" (contact hardening).
  11392. */
  11393. useContactHardeningShadow: boolean;
  11394. private _contactHardeningLightSizeUVRatio;
  11395. /**
  11396. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11397. * Using a ratio helps keeping shape stability independently of the map size.
  11398. *
  11399. * It does not account for the light projection as it was having too much
  11400. * instability during the light setup or during light position changes.
  11401. *
  11402. * Only valid if useContactHardeningShadow is true.
  11403. */
  11404. /**
  11405. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11406. * Using a ratio helps keeping shape stability independently of the map size.
  11407. *
  11408. * It does not account for the light projection as it was having too much
  11409. * instability during the light setup or during light position changes.
  11410. *
  11411. * Only valid if useContactHardeningShadow is true.
  11412. */
  11413. contactHardeningLightSizeUVRatio: number;
  11414. private _darkness;
  11415. /** Gets or sets the actual darkness of a shadow */
  11416. darkness: number;
  11417. /**
  11418. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11419. * 0 means strongest and 1 would means no shadow.
  11420. * @returns the darkness.
  11421. */
  11422. getDarkness(): number;
  11423. /**
  11424. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11425. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11426. * @returns the shadow generator allowing fluent coding.
  11427. */
  11428. setDarkness(darkness: number): ShadowGenerator;
  11429. private _transparencyShadow;
  11430. /** Gets or sets the ability to have transparent shadow */
  11431. transparencyShadow: boolean;
  11432. /**
  11433. * Sets the ability to have transparent shadow (boolean).
  11434. * @param transparent True if transparent else False
  11435. * @returns the shadow generator allowing fluent coding
  11436. */
  11437. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11438. private _shadowMap;
  11439. private _shadowMap2;
  11440. /**
  11441. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11442. * @returns The render target texture if present otherwise, null
  11443. */
  11444. getShadowMap(): Nullable<RenderTargetTexture>;
  11445. /**
  11446. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11447. * @returns The render target texture if the shadow map is present otherwise, null
  11448. */
  11449. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11450. /**
  11451. * Gets the class name of that object
  11452. * @returns "ShadowGenerator"
  11453. */
  11454. getClassName(): string;
  11455. /**
  11456. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11457. * @param mesh Mesh to add
  11458. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11459. * @returns the Shadow Generator itself
  11460. */
  11461. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11462. /**
  11463. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11464. * @param mesh Mesh to remove
  11465. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11466. * @returns the Shadow Generator itself
  11467. */
  11468. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11469. /**
  11470. * Controls the extent to which the shadows fade out at the edge of the frustum
  11471. * Used only by directionals and spots
  11472. */
  11473. frustumEdgeFalloff: number;
  11474. private _light;
  11475. /**
  11476. * Returns the associated light object.
  11477. * @returns the light generating the shadow
  11478. */
  11479. getLight(): IShadowLight;
  11480. /**
  11481. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11482. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11483. * It might on the other hand introduce peter panning.
  11484. */
  11485. forceBackFacesOnly: boolean;
  11486. private _scene;
  11487. private _lightDirection;
  11488. private _effect;
  11489. private _viewMatrix;
  11490. private _projectionMatrix;
  11491. private _transformMatrix;
  11492. private _cachedPosition;
  11493. private _cachedDirection;
  11494. private _cachedDefines;
  11495. private _currentRenderID;
  11496. private _boxBlurPostprocess;
  11497. private _kernelBlurXPostprocess;
  11498. private _kernelBlurYPostprocess;
  11499. private _blurPostProcesses;
  11500. private _mapSize;
  11501. private _currentFaceIndex;
  11502. private _currentFaceIndexCache;
  11503. private _textureType;
  11504. private _defaultTextureMatrix;
  11505. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  11506. /**
  11507. * Creates a ShadowGenerator object.
  11508. * A ShadowGenerator is the required tool to use the shadows.
  11509. * Each light casting shadows needs to use its own ShadowGenerator.
  11510. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11511. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11512. * @param light The light object generating the shadows.
  11513. * @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.
  11514. */
  11515. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11516. private _initializeGenerator;
  11517. private _initializeShadowMap;
  11518. private _initializeBlurRTTAndPostProcesses;
  11519. private _renderForShadowMap;
  11520. private _renderSubMeshForShadowMap;
  11521. private _applyFilterValues;
  11522. /**
  11523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11524. * @param onCompiled Callback triggered at the and of the effects compilation
  11525. * @param options Sets of optional options forcing the compilation with different modes
  11526. */
  11527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11528. useInstances: boolean;
  11529. }>): void;
  11530. /**
  11531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11532. * @param options Sets of optional options forcing the compilation with different modes
  11533. * @returns A promise that resolves when the compilation completes
  11534. */
  11535. forceCompilationAsync(options?: Partial<{
  11536. useInstances: boolean;
  11537. }>): Promise<void>;
  11538. /**
  11539. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11540. * @param subMesh The submesh we want to render in the shadow map
  11541. * @param useInstances Defines wether will draw in the map using instances
  11542. * @returns true if ready otherwise, false
  11543. */
  11544. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11545. /**
  11546. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11547. * @param defines Defines of the material we want to update
  11548. * @param lightIndex Index of the light in the enabled light list of the material
  11549. */
  11550. prepareDefines(defines: any, lightIndex: number): void;
  11551. /**
  11552. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11553. * defined in the generator but impacting the effect).
  11554. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11555. * @param effect The effect we are binfing the information for
  11556. */
  11557. bindShadowLight(lightIndex: string, effect: Effect): void;
  11558. /**
  11559. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11560. * (eq to shadow prjection matrix * light transform matrix)
  11561. * @returns The transform matrix used to create the shadow map
  11562. */
  11563. getTransformMatrix(): Matrix;
  11564. /**
  11565. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11566. * Cube and 2D textures for instance.
  11567. */
  11568. recreateShadowMap(): void;
  11569. private _disposeBlurPostProcesses;
  11570. private _disposeRTTandPostProcesses;
  11571. /**
  11572. * Disposes the ShadowGenerator.
  11573. * Returns nothing.
  11574. */
  11575. dispose(): void;
  11576. /**
  11577. * Serializes the shadow generator setup to a json object.
  11578. * @returns The serialized JSON object
  11579. */
  11580. serialize(): any;
  11581. /**
  11582. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11583. * @param parsedShadowGenerator The JSON object to parse
  11584. * @param scene The scene to create the shadow map for
  11585. * @returns The parsed shadow generator
  11586. */
  11587. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11588. }
  11589. }
  11590. declare module BABYLON {
  11591. /**
  11592. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11593. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11594. * 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.
  11595. */
  11596. export abstract class Light extends Node {
  11597. /**
  11598. * Falloff Default: light is falling off following the material specification:
  11599. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11600. */
  11601. static readonly FALLOFF_DEFAULT: number;
  11602. /**
  11603. * Falloff Physical: light is falling off following the inverse squared distance law.
  11604. */
  11605. static readonly FALLOFF_PHYSICAL: number;
  11606. /**
  11607. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11608. * to enhance interoperability with other engines.
  11609. */
  11610. static readonly FALLOFF_GLTF: number;
  11611. /**
  11612. * Falloff Standard: light is falling off like in the standard material
  11613. * to enhance interoperability with other materials.
  11614. */
  11615. static readonly FALLOFF_STANDARD: number;
  11616. /**
  11617. * If every light affecting the material is in this lightmapMode,
  11618. * material.lightmapTexture adds or multiplies
  11619. * (depends on material.useLightmapAsShadowmap)
  11620. * after every other light calculations.
  11621. */
  11622. static readonly LIGHTMAP_DEFAULT: number;
  11623. /**
  11624. * material.lightmapTexture as only diffuse lighting from this light
  11625. * adds only specular lighting from this light
  11626. * adds dynamic shadows
  11627. */
  11628. static readonly LIGHTMAP_SPECULAR: number;
  11629. /**
  11630. * material.lightmapTexture as only lighting
  11631. * no light calculation from this light
  11632. * only adds dynamic shadows from this light
  11633. */
  11634. static readonly LIGHTMAP_SHADOWSONLY: number;
  11635. /**
  11636. * Each light type uses the default quantity according to its type:
  11637. * point/spot lights use luminous intensity
  11638. * directional lights use illuminance
  11639. */
  11640. static readonly INTENSITYMODE_AUTOMATIC: number;
  11641. /**
  11642. * lumen (lm)
  11643. */
  11644. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11645. /**
  11646. * candela (lm/sr)
  11647. */
  11648. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11649. /**
  11650. * lux (lm/m^2)
  11651. */
  11652. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11653. /**
  11654. * nit (cd/m^2)
  11655. */
  11656. static readonly INTENSITYMODE_LUMINANCE: number;
  11657. /**
  11658. * Light type const id of the point light.
  11659. */
  11660. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11661. /**
  11662. * Light type const id of the directional light.
  11663. */
  11664. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11665. /**
  11666. * Light type const id of the spot light.
  11667. */
  11668. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11669. /**
  11670. * Light type const id of the hemispheric light.
  11671. */
  11672. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11673. /**
  11674. * Diffuse gives the basic color to an object.
  11675. */
  11676. diffuse: Color3;
  11677. /**
  11678. * Specular produces a highlight color on an object.
  11679. * Note: This is note affecting PBR materials.
  11680. */
  11681. specular: Color3;
  11682. /**
  11683. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11684. * falling off base on range or angle.
  11685. * This can be set to any values in Light.FALLOFF_x.
  11686. *
  11687. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11688. * other types of materials.
  11689. */
  11690. falloffType: number;
  11691. /**
  11692. * Strength of the light.
  11693. * Note: By default it is define in the framework own unit.
  11694. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11695. */
  11696. intensity: number;
  11697. private _range;
  11698. protected _inverseSquaredRange: number;
  11699. /**
  11700. * Defines how far from the source the light is impacting in scene units.
  11701. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11702. */
  11703. /**
  11704. * Defines how far from the source the light is impacting in scene units.
  11705. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11706. */
  11707. range: number;
  11708. /**
  11709. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11710. * of light.
  11711. */
  11712. private _photometricScale;
  11713. private _intensityMode;
  11714. /**
  11715. * Gets the photometric scale used to interpret the intensity.
  11716. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11717. */
  11718. /**
  11719. * Sets the photometric scale used to interpret the intensity.
  11720. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11721. */
  11722. intensityMode: number;
  11723. private _radius;
  11724. /**
  11725. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11726. */
  11727. /**
  11728. * sets the light radius used by PBR Materials to simulate soft area lights.
  11729. */
  11730. radius: number;
  11731. private _renderPriority;
  11732. /**
  11733. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11734. * exceeding the number allowed of the materials.
  11735. */
  11736. renderPriority: number;
  11737. private _shadowEnabled;
  11738. /**
  11739. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11740. * the current shadow generator.
  11741. */
  11742. /**
  11743. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11744. * the current shadow generator.
  11745. */
  11746. shadowEnabled: boolean;
  11747. private _includedOnlyMeshes;
  11748. /**
  11749. * Gets the only meshes impacted by this light.
  11750. */
  11751. /**
  11752. * Sets the only meshes impacted by this light.
  11753. */
  11754. includedOnlyMeshes: AbstractMesh[];
  11755. private _excludedMeshes;
  11756. /**
  11757. * Gets the meshes not impacted by this light.
  11758. */
  11759. /**
  11760. * Sets the meshes not impacted by this light.
  11761. */
  11762. excludedMeshes: AbstractMesh[];
  11763. private _excludeWithLayerMask;
  11764. /**
  11765. * Gets the layer id use to find what meshes are not impacted by the light.
  11766. * Inactive if 0
  11767. */
  11768. /**
  11769. * Sets the layer id use to find what meshes are not impacted by the light.
  11770. * Inactive if 0
  11771. */
  11772. excludeWithLayerMask: number;
  11773. private _includeOnlyWithLayerMask;
  11774. /**
  11775. * Gets the layer id use to find what meshes are impacted by the light.
  11776. * Inactive if 0
  11777. */
  11778. /**
  11779. * Sets the layer id use to find what meshes are impacted by the light.
  11780. * Inactive if 0
  11781. */
  11782. includeOnlyWithLayerMask: number;
  11783. private _lightmapMode;
  11784. /**
  11785. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11786. */
  11787. /**
  11788. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11789. */
  11790. lightmapMode: number;
  11791. /**
  11792. * Shadow generator associted to the light.
  11793. * @hidden Internal use only.
  11794. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  11795. /**
  11796. * @hidden Internal use only.
  11797. */ private _excludedMeshesIds: string[];
  11798. /**
  11799. * @hidden Internal use only.
  11800. */ private _includedOnlyMeshesIds: string[];
  11801. /**
  11802. * The current light unifom buffer.
  11803. * @hidden Internal use only.
  11804. */ private _uniformBuffer: UniformBuffer;
  11805. /**
  11806. * Creates a Light object in the scene.
  11807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11808. * @param name The firendly name of the light
  11809. * @param scene The scene the light belongs too
  11810. */
  11811. constructor(name: string, scene: Scene);
  11812. protected abstract _buildUniformLayout(): void;
  11813. /**
  11814. * Sets the passed Effect "effect" with the Light information.
  11815. * @param effect The effect to update
  11816. * @param lightIndex The index of the light in the effect to update
  11817. * @returns The light
  11818. */
  11819. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11820. /**
  11821. * Returns the string "Light".
  11822. * @returns the class name
  11823. */
  11824. getClassName(): string;
  11825. /** @hidden */ protected readonly _isLight: boolean;
  11826. /**
  11827. * Converts the light information to a readable string for debug purpose.
  11828. * @param fullDetails Supports for multiple levels of logging within scene loading
  11829. * @returns the human readable light info
  11830. */
  11831. toString(fullDetails?: boolean): string;
  11832. /** @hidden */
  11833. protected _syncParentEnabledState(): void;
  11834. /**
  11835. * Set the enabled state of this node.
  11836. * @param value - the new enabled state
  11837. */
  11838. setEnabled(value: boolean): void;
  11839. /**
  11840. * Returns the Light associated shadow generator if any.
  11841. * @return the associated shadow generator.
  11842. */
  11843. getShadowGenerator(): Nullable<IShadowGenerator>;
  11844. /**
  11845. * Returns a Vector3, the absolute light position in the World.
  11846. * @returns the world space position of the light
  11847. */
  11848. getAbsolutePosition(): Vector3;
  11849. /**
  11850. * Specifies if the light will affect the passed mesh.
  11851. * @param mesh The mesh to test against the light
  11852. * @return true the mesh is affected otherwise, false.
  11853. */
  11854. canAffectMesh(mesh: AbstractMesh): boolean;
  11855. /**
  11856. * Sort function to order lights for rendering.
  11857. * @param a First Light object to compare to second.
  11858. * @param b Second Light object to compare first.
  11859. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11860. */
  11861. static CompareLightsPriority(a: Light, b: Light): number;
  11862. /**
  11863. * Releases resources associated with this node.
  11864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11866. */
  11867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11868. /**
  11869. * Returns the light type ID (integer).
  11870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11871. */
  11872. getTypeID(): number;
  11873. /**
  11874. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11875. * @returns the scaled intensity in intensity mode unit
  11876. */
  11877. getScaledIntensity(): number;
  11878. /**
  11879. * Returns a new Light object, named "name", from the current one.
  11880. * @param name The name of the cloned light
  11881. * @returns the new created light
  11882. */
  11883. clone(name: string): Nullable<Light>;
  11884. /**
  11885. * Serializes the current light into a Serialization object.
  11886. * @returns the serialized object.
  11887. */
  11888. serialize(): any;
  11889. /**
  11890. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11891. * This new light is named "name" and added to the passed scene.
  11892. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11893. * @param name The friendly name of the light
  11894. * @param scene The scene the new light will belong to
  11895. * @returns the constructor function
  11896. */
  11897. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11898. /**
  11899. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11900. * @param parsedLight The JSON representation of the light
  11901. * @param scene The scene to create the parsed light in
  11902. * @returns the created light after parsing
  11903. */
  11904. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11905. private _hookArrayForExcluded;
  11906. private _hookArrayForIncludedOnly;
  11907. private _resyncMeshes;
  11908. /**
  11909. * Forces the meshes to update their light related information in their rendering used effects
  11910. * @hidden Internal Use Only
  11911. */ private _markMeshesAsLightDirty(): void;
  11912. /**
  11913. * Recomputes the cached photometric scale if needed.
  11914. */
  11915. private _computePhotometricScale;
  11916. /**
  11917. * Returns the Photometric Scale according to the light type and intensity mode.
  11918. */
  11919. private _getPhotometricScale;
  11920. /**
  11921. * Reorder the light in the scene according to their defined priority.
  11922. * @hidden Internal Use Only
  11923. */ private _reorderLightsInScene(): void;
  11924. /**
  11925. * Prepares the list of defines specific to the light type.
  11926. * @param defines the list of defines
  11927. * @param lightIndex defines the index of the light for the effect
  11928. */
  11929. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11930. }
  11931. }
  11932. declare module BABYLON {
  11933. /**
  11934. * Creates an instance based on a source mesh.
  11935. */
  11936. export class InstancedMesh extends AbstractMesh {
  11937. private _sourceMesh;
  11938. private _currentLOD;
  11939. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  11940. constructor(name: string, source: Mesh);
  11941. /**
  11942. * Returns the string "InstancedMesh".
  11943. */
  11944. getClassName(): string;
  11945. /** Gets the list of lights affecting that mesh */
  11946. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  11947. /**
  11948. * If the source mesh receives shadows
  11949. */
  11950. readonly receiveShadows: boolean;
  11951. /**
  11952. * The material of the source mesh
  11953. */
  11954. readonly material: Nullable<Material>;
  11955. /**
  11956. * Visibility of the source mesh
  11957. */
  11958. readonly visibility: number;
  11959. /**
  11960. * Skeleton of the source mesh
  11961. */
  11962. readonly skeleton: Nullable<Skeleton>;
  11963. /**
  11964. * Rendering ground id of the source mesh
  11965. */
  11966. renderingGroupId: number;
  11967. /**
  11968. * Returns the total number of vertices (integer).
  11969. */
  11970. getTotalVertices(): number;
  11971. /**
  11972. * Returns a positive integer : the total number of indices in this mesh geometry.
  11973. * @returns the numner of indices or zero if the mesh has no geometry.
  11974. */
  11975. getTotalIndices(): number;
  11976. /**
  11977. * The source mesh of the instance
  11978. */
  11979. readonly sourceMesh: Mesh;
  11980. /**
  11981. * Is this node ready to be used/rendered
  11982. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  11983. * @return {boolean} is it ready
  11984. */
  11985. isReady(completeCheck?: boolean): boolean;
  11986. /**
  11987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  11988. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  11989. * @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.
  11990. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  11991. */
  11992. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  11993. /**
  11994. * Sets the vertex data of the mesh geometry for the requested `kind`.
  11995. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  11996. * The `data` are either a numeric array either a Float32Array.
  11997. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  11998. * 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).
  11999. * Note that a new underlying VertexBuffer object is created each call.
  12000. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12001. *
  12002. * Possible `kind` values :
  12003. * - VertexBuffer.PositionKind
  12004. * - VertexBuffer.UVKind
  12005. * - VertexBuffer.UV2Kind
  12006. * - VertexBuffer.UV3Kind
  12007. * - VertexBuffer.UV4Kind
  12008. * - VertexBuffer.UV5Kind
  12009. * - VertexBuffer.UV6Kind
  12010. * - VertexBuffer.ColorKind
  12011. * - VertexBuffer.MatricesIndicesKind
  12012. * - VertexBuffer.MatricesIndicesExtraKind
  12013. * - VertexBuffer.MatricesWeightsKind
  12014. * - VertexBuffer.MatricesWeightsExtraKind
  12015. *
  12016. * Returns the Mesh.
  12017. */
  12018. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12019. /**
  12020. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12021. * If the mesh has no geometry, it is simply returned as it is.
  12022. * The `data` are either a numeric array either a Float32Array.
  12023. * No new underlying VertexBuffer object is created.
  12024. * 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.
  12025. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12026. *
  12027. * Possible `kind` values :
  12028. * - VertexBuffer.PositionKind
  12029. * - VertexBuffer.UVKind
  12030. * - VertexBuffer.UV2Kind
  12031. * - VertexBuffer.UV3Kind
  12032. * - VertexBuffer.UV4Kind
  12033. * - VertexBuffer.UV5Kind
  12034. * - VertexBuffer.UV6Kind
  12035. * - VertexBuffer.ColorKind
  12036. * - VertexBuffer.MatricesIndicesKind
  12037. * - VertexBuffer.MatricesIndicesExtraKind
  12038. * - VertexBuffer.MatricesWeightsKind
  12039. * - VertexBuffer.MatricesWeightsExtraKind
  12040. *
  12041. * Returns the Mesh.
  12042. */
  12043. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12044. /**
  12045. * Sets the mesh indices.
  12046. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12047. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12048. * This method creates a new index buffer each call.
  12049. * Returns the Mesh.
  12050. */
  12051. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12052. /**
  12053. * Boolean : True if the mesh owns the requested kind of data.
  12054. */
  12055. isVerticesDataPresent(kind: string): boolean;
  12056. /**
  12057. * Returns an array of indices (IndicesArray).
  12058. */
  12059. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  12060. /**
  12061. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12062. * This means the mesh underlying bounding box and sphere are recomputed.
  12063. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12064. * @returns the current mesh
  12065. */
  12066. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12067. /** @hidden */ private _preActivate(): InstancedMesh;
  12068. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  12069. /** @hidden */ private _postActivate(): void;
  12070. getWorldMatrix(): Matrix;
  12071. readonly isAnInstance: boolean;
  12072. /**
  12073. * Returns the current associated LOD AbstractMesh.
  12074. */
  12075. getLOD(camera: Camera): AbstractMesh;
  12076. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  12077. /** @hidden */ private _generatePointsArray(): boolean;
  12078. /**
  12079. * Creates a new InstancedMesh from the current mesh.
  12080. * - name (string) : the cloned mesh name
  12081. * - newParent (optional Node) : the optional Node to parent the clone to.
  12082. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12083. *
  12084. * Returns the clone.
  12085. */
  12086. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12087. /**
  12088. * Disposes the InstancedMesh.
  12089. * Returns nothing.
  12090. */
  12091. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12092. }
  12093. }
  12094. declare module BABYLON {
  12095. /**
  12096. * Defines the options associated with the creation of a shader material.
  12097. */
  12098. export interface IShaderMaterialOptions {
  12099. /**
  12100. * Does the material work in alpha blend mode
  12101. */
  12102. needAlphaBlending: boolean;
  12103. /**
  12104. * Does the material work in alpha test mode
  12105. */
  12106. needAlphaTesting: boolean;
  12107. /**
  12108. * The list of attribute names used in the shader
  12109. */
  12110. attributes: string[];
  12111. /**
  12112. * The list of unifrom names used in the shader
  12113. */
  12114. uniforms: string[];
  12115. /**
  12116. * The list of UBO names used in the shader
  12117. */
  12118. uniformBuffers: string[];
  12119. /**
  12120. * The list of sampler names used in the shader
  12121. */
  12122. samplers: string[];
  12123. /**
  12124. * The list of defines used in the shader
  12125. */
  12126. defines: string[];
  12127. }
  12128. /**
  12129. * 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.
  12130. *
  12131. * This returned material effects how the mesh will look based on the code in the shaders.
  12132. *
  12133. * @see http://doc.babylonjs.com/how_to/shader_material
  12134. */
  12135. export class ShaderMaterial extends Material {
  12136. private _shaderPath;
  12137. private _options;
  12138. private _textures;
  12139. private _textureArrays;
  12140. private _floats;
  12141. private _ints;
  12142. private _floatsArrays;
  12143. private _colors3;
  12144. private _colors3Arrays;
  12145. private _colors4;
  12146. private _colors4Arrays;
  12147. private _vectors2;
  12148. private _vectors3;
  12149. private _vectors4;
  12150. private _matrices;
  12151. private _matrices3x3;
  12152. private _matrices2x2;
  12153. private _vectors2Arrays;
  12154. private _vectors3Arrays;
  12155. private _vectors4Arrays;
  12156. private _cachedWorldViewMatrix;
  12157. private _cachedWorldViewProjectionMatrix;
  12158. private _renderId;
  12159. /**
  12160. * Instantiate a new shader material.
  12161. * 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.
  12162. * This returned material effects how the mesh will look based on the code in the shaders.
  12163. * @see http://doc.babylonjs.com/how_to/shader_material
  12164. * @param name Define the name of the material in the scene
  12165. * @param scene Define the scene the material belongs to
  12166. * @param shaderPath Defines the route to the shader code in one of three ways:
  12167. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12168. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12169. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12170. * @param options Define the options used to create the shader
  12171. */
  12172. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12173. /**
  12174. * Gets the options used to compile the shader.
  12175. * They can be modified to trigger a new compilation
  12176. */
  12177. readonly options: IShaderMaterialOptions;
  12178. /**
  12179. * Gets the current class name of the material e.g. "ShaderMaterial"
  12180. * Mainly use in serialization.
  12181. * @returns the class name
  12182. */
  12183. getClassName(): string;
  12184. /**
  12185. * Specifies if the material will require alpha blending
  12186. * @returns a boolean specifying if alpha blending is needed
  12187. */
  12188. needAlphaBlending(): boolean;
  12189. /**
  12190. * Specifies if this material should be rendered in alpha test mode
  12191. * @returns a boolean specifying if an alpha test is needed.
  12192. */
  12193. needAlphaTesting(): boolean;
  12194. private _checkUniform;
  12195. /**
  12196. * Set a texture in the shader.
  12197. * @param name Define the name of the uniform samplers as defined in the shader
  12198. * @param texture Define the texture to bind to this sampler
  12199. * @return the material itself allowing "fluent" like uniform updates
  12200. */
  12201. setTexture(name: string, texture: Texture): ShaderMaterial;
  12202. /**
  12203. * Set a texture array in the shader.
  12204. * @param name Define the name of the uniform sampler array as defined in the shader
  12205. * @param textures Define the list of textures to bind to this sampler
  12206. * @return the material itself allowing "fluent" like uniform updates
  12207. */
  12208. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12209. /**
  12210. * Set a float in the shader.
  12211. * @param name Define the name of the uniform as defined in the shader
  12212. * @param value Define the value to give to the uniform
  12213. * @return the material itself allowing "fluent" like uniform updates
  12214. */
  12215. setFloat(name: string, value: number): ShaderMaterial;
  12216. /**
  12217. * Set a int in the shader.
  12218. * @param name Define the name of the uniform as defined in the shader
  12219. * @param value Define the value to give to the uniform
  12220. * @return the material itself allowing "fluent" like uniform updates
  12221. */
  12222. setInt(name: string, value: number): ShaderMaterial;
  12223. /**
  12224. * Set an array of floats in the shader.
  12225. * @param name Define the name of the uniform as defined in the shader
  12226. * @param value Define the value to give to the uniform
  12227. * @return the material itself allowing "fluent" like uniform updates
  12228. */
  12229. setFloats(name: string, value: number[]): ShaderMaterial;
  12230. /**
  12231. * Set a vec3 in the shader from a Color3.
  12232. * @param name Define the name of the uniform as defined in the shader
  12233. * @param value Define the value to give to the uniform
  12234. * @return the material itself allowing "fluent" like uniform updates
  12235. */
  12236. setColor3(name: string, value: Color3): ShaderMaterial;
  12237. /**
  12238. * Set a vec3 array in the shader from a Color3 array.
  12239. * @param name Define the name of the uniform as defined in the shader
  12240. * @param value Define the value to give to the uniform
  12241. * @return the material itself allowing "fluent" like uniform updates
  12242. */
  12243. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12244. /**
  12245. * Set a vec4 in the shader from a Color4.
  12246. * @param name Define the name of the uniform as defined in the shader
  12247. * @param value Define the value to give to the uniform
  12248. * @return the material itself allowing "fluent" like uniform updates
  12249. */
  12250. setColor4(name: string, value: Color4): ShaderMaterial;
  12251. /**
  12252. * Set a vec4 array in the shader from a Color4 array.
  12253. * @param name Define the name of the uniform as defined in the shader
  12254. * @param value Define the value to give to the uniform
  12255. * @return the material itself allowing "fluent" like uniform updates
  12256. */
  12257. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12258. /**
  12259. * Set a vec2 in the shader from a Vector2.
  12260. * @param name Define the name of the uniform as defined in the shader
  12261. * @param value Define the value to give to the uniform
  12262. * @return the material itself allowing "fluent" like uniform updates
  12263. */
  12264. setVector2(name: string, value: Vector2): ShaderMaterial;
  12265. /**
  12266. * Set a vec3 in the shader from a Vector3.
  12267. * @param name Define the name of the uniform as defined in the shader
  12268. * @param value Define the value to give to the uniform
  12269. * @return the material itself allowing "fluent" like uniform updates
  12270. */
  12271. setVector3(name: string, value: Vector3): ShaderMaterial;
  12272. /**
  12273. * Set a vec4 in the shader from a Vector4.
  12274. * @param name Define the name of the uniform as defined in the shader
  12275. * @param value Define the value to give to the uniform
  12276. * @return the material itself allowing "fluent" like uniform updates
  12277. */
  12278. setVector4(name: string, value: Vector4): ShaderMaterial;
  12279. /**
  12280. * Set a mat4 in the shader from a Matrix.
  12281. * @param name Define the name of the uniform as defined in the shader
  12282. * @param value Define the value to give to the uniform
  12283. * @return the material itself allowing "fluent" like uniform updates
  12284. */
  12285. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12286. /**
  12287. * Set a mat3 in the shader from a Float32Array.
  12288. * @param name Define the name of the uniform as defined in the shader
  12289. * @param value Define the value to give to the uniform
  12290. * @return the material itself allowing "fluent" like uniform updates
  12291. */
  12292. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12293. /**
  12294. * Set a mat2 in the shader from a Float32Array.
  12295. * @param name Define the name of the uniform as defined in the shader
  12296. * @param value Define the value to give to the uniform
  12297. * @return the material itself allowing "fluent" like uniform updates
  12298. */
  12299. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12300. /**
  12301. * Set a vec2 array in the shader from a number array.
  12302. * @param name Define the name of the uniform as defined in the shader
  12303. * @param value Define the value to give to the uniform
  12304. * @return the material itself allowing "fluent" like uniform updates
  12305. */
  12306. setArray2(name: string, value: number[]): ShaderMaterial;
  12307. /**
  12308. * Set a vec3 array in the shader from a number array.
  12309. * @param name Define the name of the uniform as defined in the shader
  12310. * @param value Define the value to give to the uniform
  12311. * @return the material itself allowing "fluent" like uniform updates
  12312. */
  12313. setArray3(name: string, value: number[]): ShaderMaterial;
  12314. /**
  12315. * Set a vec4 array in the shader from a number array.
  12316. * @param name Define the name of the uniform as defined in the shader
  12317. * @param value Define the value to give to the uniform
  12318. * @return the material itself allowing "fluent" like uniform updates
  12319. */
  12320. setArray4(name: string, value: number[]): ShaderMaterial;
  12321. private _checkCache;
  12322. /**
  12323. * Specifies that the submesh is ready to be used
  12324. * @param mesh defines the mesh to check
  12325. * @param subMesh defines which submesh to check
  12326. * @param useInstances specifies that instances should be used
  12327. * @returns a boolean indicating that the submesh is ready or not
  12328. */
  12329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12330. /**
  12331. * Checks if the material is ready to render the requested mesh
  12332. * @param mesh Define the mesh to render
  12333. * @param useInstances Define whether or not the material is used with instances
  12334. * @returns true if ready, otherwise false
  12335. */
  12336. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12337. /**
  12338. * Binds the world matrix to the material
  12339. * @param world defines the world transformation matrix
  12340. */
  12341. bindOnlyWorldMatrix(world: Matrix): void;
  12342. /**
  12343. * Binds the material to the mesh
  12344. * @param world defines the world transformation matrix
  12345. * @param mesh defines the mesh to bind the material to
  12346. */
  12347. bind(world: Matrix, mesh?: Mesh): void;
  12348. /**
  12349. * Gets the active textures from the material
  12350. * @returns an array of textures
  12351. */
  12352. getActiveTextures(): BaseTexture[];
  12353. /**
  12354. * Specifies if the material uses a texture
  12355. * @param texture defines the texture to check against the material
  12356. * @returns a boolean specifying if the material uses the texture
  12357. */
  12358. hasTexture(texture: BaseTexture): boolean;
  12359. /**
  12360. * Makes a duplicate of the material, and gives it a new name
  12361. * @param name defines the new name for the duplicated material
  12362. * @returns the cloned material
  12363. */
  12364. clone(name: string): ShaderMaterial;
  12365. /**
  12366. * Disposes the material
  12367. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12368. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12369. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12370. */
  12371. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12372. /**
  12373. * Serializes this material in a JSON representation
  12374. * @returns the serialized material object
  12375. */
  12376. serialize(): any;
  12377. /**
  12378. * Creates a shader material from parsed shader material data
  12379. * @param source defines the JSON represnetation of the material
  12380. * @param scene defines the hosting scene
  12381. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12382. * @returns a new material
  12383. */
  12384. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12385. }
  12386. }
  12387. declare module BABYLON {
  12388. /** @hidden */
  12389. export var clipPlaneFragmentDeclaration: {
  12390. name: string;
  12391. shader: string;
  12392. };
  12393. }
  12394. declare module BABYLON {
  12395. /** @hidden */
  12396. export var clipPlaneFragment: {
  12397. name: string;
  12398. shader: string;
  12399. };
  12400. }
  12401. declare module BABYLON {
  12402. /** @hidden */
  12403. export var colorPixelShader: {
  12404. name: string;
  12405. shader: string;
  12406. };
  12407. }
  12408. declare module BABYLON {
  12409. /** @hidden */
  12410. export var clipPlaneVertexDeclaration: {
  12411. name: string;
  12412. shader: string;
  12413. };
  12414. }
  12415. declare module BABYLON {
  12416. /** @hidden */
  12417. export var clipPlaneVertex: {
  12418. name: string;
  12419. shader: string;
  12420. };
  12421. }
  12422. declare module BABYLON {
  12423. /** @hidden */
  12424. export var colorVertexShader: {
  12425. name: string;
  12426. shader: string;
  12427. };
  12428. }
  12429. declare module BABYLON {
  12430. /**
  12431. * Line mesh
  12432. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12433. */
  12434. export class LinesMesh extends Mesh {
  12435. /**
  12436. * If vertex color should be applied to the mesh
  12437. */
  12438. readonly useVertexColor?: boolean | undefined;
  12439. /**
  12440. * If vertex alpha should be applied to the mesh
  12441. */
  12442. readonly useVertexAlpha?: boolean | undefined;
  12443. /**
  12444. * Color of the line (Default: White)
  12445. */
  12446. color: Color3;
  12447. /**
  12448. * Alpha of the line (Default: 1)
  12449. */
  12450. alpha: number;
  12451. /**
  12452. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12453. * This margin is expressed in world space coordinates, so its value may vary.
  12454. * Default value is 0.1
  12455. */
  12456. intersectionThreshold: number;
  12457. private _colorShader;
  12458. private color4;
  12459. /**
  12460. * Creates a new LinesMesh
  12461. * @param name defines the name
  12462. * @param scene defines the hosting scene
  12463. * @param parent defines the parent mesh if any
  12464. * @param source defines the optional source LinesMesh used to clone data from
  12465. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12466. * When false, achieved by calling a clone(), also passing False.
  12467. * This will make creation of children, recursive.
  12468. * @param useVertexColor defines if this LinesMesh supports vertex color
  12469. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12470. */
  12471. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12472. /**
  12473. * If vertex color should be applied to the mesh
  12474. */
  12475. useVertexColor?: boolean | undefined,
  12476. /**
  12477. * If vertex alpha should be applied to the mesh
  12478. */
  12479. useVertexAlpha?: boolean | undefined);
  12480. private _addClipPlaneDefine;
  12481. private _removeClipPlaneDefine;
  12482. isReady(): boolean;
  12483. /**
  12484. * Returns the string "LineMesh"
  12485. */
  12486. getClassName(): string;
  12487. /**
  12488. * @hidden
  12489. */
  12490. /**
  12491. * @hidden
  12492. */
  12493. material: Material;
  12494. /**
  12495. * @hidden
  12496. */
  12497. readonly checkCollisions: boolean;
  12498. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12499. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12500. /**
  12501. * Disposes of the line mesh
  12502. * @param doNotRecurse If children should be disposed
  12503. */
  12504. dispose(doNotRecurse?: boolean): void;
  12505. /**
  12506. * Returns a new LineMesh object cloned from the current one.
  12507. */
  12508. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12509. /**
  12510. * Creates a new InstancedLinesMesh object from the mesh model.
  12511. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12512. * @param name defines the name of the new instance
  12513. * @returns a new InstancedLinesMesh
  12514. */
  12515. createInstance(name: string): InstancedLinesMesh;
  12516. }
  12517. /**
  12518. * Creates an instance based on a source LinesMesh
  12519. */
  12520. export class InstancedLinesMesh extends InstancedMesh {
  12521. /**
  12522. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12523. * This margin is expressed in world space coordinates, so its value may vary.
  12524. * Initilized with the intersectionThreshold value of the source LinesMesh
  12525. */
  12526. intersectionThreshold: number;
  12527. constructor(name: string, source: LinesMesh);
  12528. /**
  12529. * Returns the string "InstancedLinesMesh".
  12530. */
  12531. getClassName(): string;
  12532. }
  12533. }
  12534. declare module BABYLON {
  12535. /**
  12536. * Mesh representing the gorund
  12537. */
  12538. export class GroundMesh extends Mesh {
  12539. /** If octree should be generated */
  12540. generateOctree: boolean;
  12541. private _heightQuads;
  12542. /** @hidden */ private _subdivisionsX: number;
  12543. /** @hidden */ private _subdivisionsY: number;
  12544. /** @hidden */ private _width: number;
  12545. /** @hidden */ private _height: number;
  12546. /** @hidden */ private _minX: number;
  12547. /** @hidden */ private _maxX: number;
  12548. /** @hidden */ private _minZ: number;
  12549. /** @hidden */ private _maxZ: number;
  12550. constructor(name: string, scene: Scene);
  12551. /**
  12552. * "GroundMesh"
  12553. * @returns "GroundMesh"
  12554. */
  12555. getClassName(): string;
  12556. /**
  12557. * The minimum of x and y subdivisions
  12558. */
  12559. readonly subdivisions: number;
  12560. /**
  12561. * X subdivisions
  12562. */
  12563. readonly subdivisionsX: number;
  12564. /**
  12565. * Y subdivisions
  12566. */
  12567. readonly subdivisionsY: number;
  12568. /**
  12569. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12570. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12571. * @param chunksCount the number of subdivisions for x and y
  12572. * @param octreeBlocksSize (Default: 32)
  12573. */
  12574. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12575. /**
  12576. * Returns a height (y) value in the Worl system :
  12577. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12578. * @param x x coordinate
  12579. * @param z z coordinate
  12580. * @returns the ground y position if (x, z) are outside the ground surface.
  12581. */
  12582. getHeightAtCoordinates(x: number, z: number): number;
  12583. /**
  12584. * Returns a normalized vector (Vector3) orthogonal to the ground
  12585. * at the ground coordinates (x, z) expressed in the World system.
  12586. * @param x x coordinate
  12587. * @param z z coordinate
  12588. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12589. */
  12590. getNormalAtCoordinates(x: number, z: number): Vector3;
  12591. /**
  12592. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12593. * at the ground coordinates (x, z) expressed in the World system.
  12594. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12595. * @param x x coordinate
  12596. * @param z z coordinate
  12597. * @param ref vector to store the result
  12598. * @returns the GroundMesh.
  12599. */
  12600. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12601. /**
  12602. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12603. * if the ground has been updated.
  12604. * This can be used in the render loop.
  12605. * @returns the GroundMesh.
  12606. */
  12607. updateCoordinateHeights(): GroundMesh;
  12608. private _getFacetAt;
  12609. private _initHeightQuads;
  12610. private _computeHeightQuads;
  12611. /**
  12612. * Serializes this ground mesh
  12613. * @param serializationObject object to write serialization to
  12614. */
  12615. serialize(serializationObject: any): void;
  12616. /**
  12617. * Parses a serialized ground mesh
  12618. * @param parsedMesh the serialized mesh
  12619. * @param scene the scene to create the ground mesh in
  12620. * @returns the created ground mesh
  12621. */
  12622. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12623. }
  12624. }
  12625. declare module BABYLON {
  12626. /**
  12627. * Interface for Physics-Joint data
  12628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12629. */
  12630. export interface PhysicsJointData {
  12631. /**
  12632. * The main pivot of the joint
  12633. */
  12634. mainPivot?: Vector3;
  12635. /**
  12636. * The connected pivot of the joint
  12637. */
  12638. connectedPivot?: Vector3;
  12639. /**
  12640. * The main axis of the joint
  12641. */
  12642. mainAxis?: Vector3;
  12643. /**
  12644. * The connected axis of the joint
  12645. */
  12646. connectedAxis?: Vector3;
  12647. /**
  12648. * The collision of the joint
  12649. */
  12650. collision?: boolean;
  12651. /**
  12652. * Native Oimo/Cannon/Energy data
  12653. */
  12654. nativeParams?: any;
  12655. }
  12656. /**
  12657. * This is a holder class for the physics joint created by the physics plugin
  12658. * It holds a set of functions to control the underlying joint
  12659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12660. */
  12661. export class PhysicsJoint {
  12662. /**
  12663. * The type of the physics joint
  12664. */
  12665. type: number;
  12666. /**
  12667. * The data for the physics joint
  12668. */
  12669. jointData: PhysicsJointData;
  12670. private _physicsJoint;
  12671. protected _physicsPlugin: IPhysicsEnginePlugin;
  12672. /**
  12673. * Initializes the physics joint
  12674. * @param type The type of the physics joint
  12675. * @param jointData The data for the physics joint
  12676. */
  12677. constructor(
  12678. /**
  12679. * The type of the physics joint
  12680. */
  12681. type: number,
  12682. /**
  12683. * The data for the physics joint
  12684. */
  12685. jointData: PhysicsJointData);
  12686. /**
  12687. * Gets the physics joint
  12688. */
  12689. /**
  12690. * Sets the physics joint
  12691. */
  12692. physicsJoint: any;
  12693. /**
  12694. * Sets the physics plugin
  12695. */
  12696. physicsPlugin: IPhysicsEnginePlugin;
  12697. /**
  12698. * Execute a function that is physics-plugin specific.
  12699. * @param {Function} func the function that will be executed.
  12700. * It accepts two parameters: the physics world and the physics joint
  12701. */
  12702. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12703. /**
  12704. * Distance-Joint type
  12705. */
  12706. static DistanceJoint: number;
  12707. /**
  12708. * Hinge-Joint type
  12709. */
  12710. static HingeJoint: number;
  12711. /**
  12712. * Ball-and-Socket joint type
  12713. */
  12714. static BallAndSocketJoint: number;
  12715. /**
  12716. * Wheel-Joint type
  12717. */
  12718. static WheelJoint: number;
  12719. /**
  12720. * Slider-Joint type
  12721. */
  12722. static SliderJoint: number;
  12723. /**
  12724. * Prismatic-Joint type
  12725. */
  12726. static PrismaticJoint: number;
  12727. /**
  12728. * Universal-Joint type
  12729. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12730. */
  12731. static UniversalJoint: number;
  12732. /**
  12733. * Hinge-Joint 2 type
  12734. */
  12735. static Hinge2Joint: number;
  12736. /**
  12737. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12738. */
  12739. static PointToPointJoint: number;
  12740. /**
  12741. * Spring-Joint type
  12742. */
  12743. static SpringJoint: number;
  12744. /**
  12745. * Lock-Joint type
  12746. */
  12747. static LockJoint: number;
  12748. }
  12749. /**
  12750. * A class representing a physics distance joint
  12751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12752. */
  12753. export class DistanceJoint extends PhysicsJoint {
  12754. /**
  12755. *
  12756. * @param jointData The data for the Distance-Joint
  12757. */
  12758. constructor(jointData: DistanceJointData);
  12759. /**
  12760. * Update the predefined distance.
  12761. * @param maxDistance The maximum preferred distance
  12762. * @param minDistance The minimum preferred distance
  12763. */
  12764. updateDistance(maxDistance: number, minDistance?: number): void;
  12765. }
  12766. /**
  12767. * Represents a Motor-Enabled Joint
  12768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12769. */
  12770. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12771. /**
  12772. * Initializes the Motor-Enabled Joint
  12773. * @param type The type of the joint
  12774. * @param jointData The physica joint data for the joint
  12775. */
  12776. constructor(type: number, jointData: PhysicsJointData);
  12777. /**
  12778. * Set the motor values.
  12779. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12780. * @param force the force to apply
  12781. * @param maxForce max force for this motor.
  12782. */
  12783. setMotor(force?: number, maxForce?: number): void;
  12784. /**
  12785. * Set the motor's limits.
  12786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12787. * @param upperLimit The upper limit of the motor
  12788. * @param lowerLimit The lower limit of the motor
  12789. */
  12790. setLimit(upperLimit: number, lowerLimit?: number): void;
  12791. }
  12792. /**
  12793. * This class represents a single physics Hinge-Joint
  12794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12795. */
  12796. export class HingeJoint extends MotorEnabledJoint {
  12797. /**
  12798. * Initializes the Hinge-Joint
  12799. * @param jointData The joint data for the Hinge-Joint
  12800. */
  12801. constructor(jointData: PhysicsJointData);
  12802. /**
  12803. * Set the motor values.
  12804. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12805. * @param {number} force the force to apply
  12806. * @param {number} maxForce max force for this motor.
  12807. */
  12808. setMotor(force?: number, maxForce?: number): void;
  12809. /**
  12810. * Set the motor's limits.
  12811. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12812. * @param upperLimit The upper limit of the motor
  12813. * @param lowerLimit The lower limit of the motor
  12814. */
  12815. setLimit(upperLimit: number, lowerLimit?: number): void;
  12816. }
  12817. /**
  12818. * This class represents a dual hinge physics joint (same as wheel joint)
  12819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12820. */
  12821. export class Hinge2Joint extends MotorEnabledJoint {
  12822. /**
  12823. * Initializes the Hinge2-Joint
  12824. * @param jointData The joint data for the Hinge2-Joint
  12825. */
  12826. constructor(jointData: PhysicsJointData);
  12827. /**
  12828. * Set the motor values.
  12829. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12830. * @param {number} targetSpeed the speed the motor is to reach
  12831. * @param {number} maxForce max force for this motor.
  12832. * @param {motorIndex} the motor's index, 0 or 1.
  12833. */
  12834. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  12835. /**
  12836. * Set the motor limits.
  12837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12838. * @param {number} upperLimit the upper limit
  12839. * @param {number} lowerLimit lower limit
  12840. * @param {motorIndex} the motor's index, 0 or 1.
  12841. */
  12842. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12843. }
  12844. /**
  12845. * Interface for a motor enabled joint
  12846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12847. */
  12848. export interface IMotorEnabledJoint {
  12849. /**
  12850. * Physics joint
  12851. */
  12852. physicsJoint: any;
  12853. /**
  12854. * Sets the motor of the motor-enabled joint
  12855. * @param force The force of the motor
  12856. * @param maxForce The maximum force of the motor
  12857. * @param motorIndex The index of the motor
  12858. */
  12859. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  12860. /**
  12861. * Sets the limit of the motor
  12862. * @param upperLimit The upper limit of the motor
  12863. * @param lowerLimit The lower limit of the motor
  12864. * @param motorIndex The index of the motor
  12865. */
  12866. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12867. }
  12868. /**
  12869. * Joint data for a Distance-Joint
  12870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12871. */
  12872. export interface DistanceJointData extends PhysicsJointData {
  12873. /**
  12874. * Max distance the 2 joint objects can be apart
  12875. */
  12876. maxDistance: number;
  12877. }
  12878. /**
  12879. * Joint data from a spring joint
  12880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12881. */
  12882. export interface SpringJointData extends PhysicsJointData {
  12883. /**
  12884. * Length of the spring
  12885. */
  12886. length: number;
  12887. /**
  12888. * Stiffness of the spring
  12889. */
  12890. stiffness: number;
  12891. /**
  12892. * Damping of the spring
  12893. */
  12894. damping: number;
  12895. /** this callback will be called when applying the force to the impostors. */
  12896. forceApplicationCallback: () => void;
  12897. }
  12898. }
  12899. declare module BABYLON {
  12900. /**
  12901. * Holds the data for the raycast result
  12902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12903. */
  12904. export class PhysicsRaycastResult {
  12905. private _hasHit;
  12906. private _hitDistance;
  12907. private _hitNormalWorld;
  12908. private _hitPointWorld;
  12909. private _rayFromWorld;
  12910. private _rayToWorld;
  12911. /**
  12912. * Gets if there was a hit
  12913. */
  12914. readonly hasHit: boolean;
  12915. /**
  12916. * Gets the distance from the hit
  12917. */
  12918. readonly hitDistance: number;
  12919. /**
  12920. * Gets the hit normal/direction in the world
  12921. */
  12922. readonly hitNormalWorld: Vector3;
  12923. /**
  12924. * Gets the hit point in the world
  12925. */
  12926. readonly hitPointWorld: Vector3;
  12927. /**
  12928. * Gets the ray "start point" of the ray in the world
  12929. */
  12930. readonly rayFromWorld: Vector3;
  12931. /**
  12932. * Gets the ray "end point" of the ray in the world
  12933. */
  12934. readonly rayToWorld: Vector3;
  12935. /**
  12936. * Sets the hit data (normal & point in world space)
  12937. * @param hitNormalWorld defines the normal in world space
  12938. * @param hitPointWorld defines the point in world space
  12939. */
  12940. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  12941. /**
  12942. * Sets the distance from the start point to the hit point
  12943. * @param distance
  12944. */
  12945. setHitDistance(distance: number): void;
  12946. /**
  12947. * Calculates the distance manually
  12948. */
  12949. calculateHitDistance(): void;
  12950. /**
  12951. * Resets all the values to default
  12952. * @param from The from point on world space
  12953. * @param to The to point on world space
  12954. */
  12955. reset(from?: Vector3, to?: Vector3): void;
  12956. }
  12957. /**
  12958. * Interface for the size containing width and height
  12959. */
  12960. interface IXYZ {
  12961. /**
  12962. * X
  12963. */
  12964. x: number;
  12965. /**
  12966. * Y
  12967. */
  12968. y: number;
  12969. /**
  12970. * Z
  12971. */
  12972. z: number;
  12973. }
  12974. }
  12975. declare module BABYLON {
  12976. /**
  12977. * Interface used to describe a physics joint
  12978. */
  12979. export interface PhysicsImpostorJoint {
  12980. /** Defines the main impostor to which the joint is linked */
  12981. mainImpostor: PhysicsImpostor;
  12982. /** Defines the impostor that is connected to the main impostor using this joint */
  12983. connectedImpostor: PhysicsImpostor;
  12984. /** Defines the joint itself */
  12985. joint: PhysicsJoint;
  12986. }
  12987. /** @hidden */
  12988. export interface IPhysicsEnginePlugin {
  12989. world: any;
  12990. name: string;
  12991. setGravity(gravity: Vector3): void;
  12992. setTimeStep(timeStep: number): void;
  12993. getTimeStep(): number;
  12994. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  12995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  12996. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  12997. generatePhysicsBody(impostor: PhysicsImpostor): void;
  12998. removePhysicsBody(impostor: PhysicsImpostor): void;
  12999. generateJoint(joint: PhysicsImpostorJoint): void;
  13000. removeJoint(joint: PhysicsImpostorJoint): void;
  13001. isSupported(): boolean;
  13002. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13003. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13004. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13005. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13006. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13007. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13008. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13009. getBodyMass(impostor: PhysicsImpostor): number;
  13010. getBodyFriction(impostor: PhysicsImpostor): number;
  13011. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13012. getBodyRestitution(impostor: PhysicsImpostor): number;
  13013. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13014. getBodyPressure?(impostor: PhysicsImpostor): number;
  13015. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13016. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13017. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13018. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13019. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13020. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13021. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13022. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13023. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13024. sleepBody(impostor: PhysicsImpostor): void;
  13025. wakeUpBody(impostor: PhysicsImpostor): void;
  13026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13027. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13028. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13029. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13030. getRadius(impostor: PhysicsImpostor): number;
  13031. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13032. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13033. dispose(): void;
  13034. }
  13035. /**
  13036. * Interface used to define a physics engine
  13037. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13038. */
  13039. export interface IPhysicsEngine {
  13040. /**
  13041. * Gets the gravity vector used by the simulation
  13042. */
  13043. gravity: Vector3;
  13044. /**
  13045. * Sets the gravity vector used by the simulation
  13046. * @param gravity defines the gravity vector to use
  13047. */
  13048. setGravity(gravity: Vector3): void;
  13049. /**
  13050. * Set the time step of the physics engine.
  13051. * Default is 1/60.
  13052. * To slow it down, enter 1/600 for example.
  13053. * To speed it up, 1/30
  13054. * @param newTimeStep the new timestep to apply to this world.
  13055. */
  13056. setTimeStep(newTimeStep: number): void;
  13057. /**
  13058. * Get the time step of the physics engine.
  13059. * @returns the current time step
  13060. */
  13061. getTimeStep(): number;
  13062. /**
  13063. * Release all resources
  13064. */
  13065. dispose(): void;
  13066. /**
  13067. * Gets the name of the current physics plugin
  13068. * @returns the name of the plugin
  13069. */
  13070. getPhysicsPluginName(): string;
  13071. /**
  13072. * Adding a new impostor for the impostor tracking.
  13073. * This will be done by the impostor itself.
  13074. * @param impostor the impostor to add
  13075. */
  13076. addImpostor(impostor: PhysicsImpostor): void;
  13077. /**
  13078. * Remove an impostor from the engine.
  13079. * This impostor and its mesh will not longer be updated by the physics engine.
  13080. * @param impostor the impostor to remove
  13081. */
  13082. removeImpostor(impostor: PhysicsImpostor): void;
  13083. /**
  13084. * Add a joint to the physics engine
  13085. * @param mainImpostor defines the main impostor to which the joint is added.
  13086. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13087. * @param joint defines the joint that will connect both impostors.
  13088. */
  13089. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13090. /**
  13091. * Removes a joint from the simulation
  13092. * @param mainImpostor defines the impostor used with the joint
  13093. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13094. * @param joint defines the joint to remove
  13095. */
  13096. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13097. /**
  13098. * Gets the current plugin used to run the simulation
  13099. * @returns current plugin
  13100. */
  13101. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13102. /**
  13103. * Gets the list of physic impostors
  13104. * @returns an array of PhysicsImpostor
  13105. */
  13106. getImpostors(): Array<PhysicsImpostor>;
  13107. /**
  13108. * Gets the impostor for a physics enabled object
  13109. * @param object defines the object impersonated by the impostor
  13110. * @returns the PhysicsImpostor or null if not found
  13111. */
  13112. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13113. /**
  13114. * Gets the impostor for a physics body object
  13115. * @param body defines physics body used by the impostor
  13116. * @returns the PhysicsImpostor or null if not found
  13117. */
  13118. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13119. /**
  13120. * Does a raycast in the physics world
  13121. * @param from when should the ray start?
  13122. * @param to when should the ray end?
  13123. * @returns PhysicsRaycastResult
  13124. */
  13125. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13126. /**
  13127. * Called by the scene. No need to call it.
  13128. * @param delta defines the timespam between frames
  13129. */ private _step(delta: number): void;
  13130. }
  13131. }
  13132. declare module BABYLON {
  13133. /**
  13134. * The interface for the physics imposter parameters
  13135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13136. */
  13137. export interface PhysicsImpostorParameters {
  13138. /**
  13139. * The mass of the physics imposter
  13140. */
  13141. mass: number;
  13142. /**
  13143. * The friction of the physics imposter
  13144. */
  13145. friction?: number;
  13146. /**
  13147. * The coefficient of restitution of the physics imposter
  13148. */
  13149. restitution?: number;
  13150. /**
  13151. * The native options of the physics imposter
  13152. */
  13153. nativeOptions?: any;
  13154. /**
  13155. * Specifies if the parent should be ignored
  13156. */
  13157. ignoreParent?: boolean;
  13158. /**
  13159. * Specifies if bi-directional transformations should be disabled
  13160. */
  13161. disableBidirectionalTransformation?: boolean;
  13162. /**
  13163. * The pressure inside the physics imposter, soft object only
  13164. */
  13165. pressure?: number;
  13166. /**
  13167. * The stiffness the physics imposter, soft object only
  13168. */
  13169. stiffness?: number;
  13170. /**
  13171. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13172. */
  13173. velocityIterations?: number;
  13174. /**
  13175. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13176. */
  13177. positionIterations?: number;
  13178. /**
  13179. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13180. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13181. * Add to fix multiple points
  13182. */
  13183. fixedPoints?: number;
  13184. /**
  13185. * The collision margin around a soft object
  13186. */
  13187. margin?: number;
  13188. /**
  13189. * The collision margin around a soft object
  13190. */
  13191. damping?: number;
  13192. /**
  13193. * The path for a rope based on an extrusion
  13194. */
  13195. path?: any;
  13196. /**
  13197. * The shape of an extrusion used for a rope based on an extrusion
  13198. */
  13199. shape?: any;
  13200. }
  13201. /**
  13202. * Interface for a physics-enabled object
  13203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13204. */
  13205. export interface IPhysicsEnabledObject {
  13206. /**
  13207. * The position of the physics-enabled object
  13208. */
  13209. position: Vector3;
  13210. /**
  13211. * The rotation of the physics-enabled object
  13212. */
  13213. rotationQuaternion: Nullable<Quaternion>;
  13214. /**
  13215. * The scale of the physics-enabled object
  13216. */
  13217. scaling: Vector3;
  13218. /**
  13219. * The rotation of the physics-enabled object
  13220. */
  13221. rotation?: Vector3;
  13222. /**
  13223. * The parent of the physics-enabled object
  13224. */
  13225. parent?: any;
  13226. /**
  13227. * The bounding info of the physics-enabled object
  13228. * @returns The bounding info of the physics-enabled object
  13229. */
  13230. getBoundingInfo(): BoundingInfo;
  13231. /**
  13232. * Computes the world matrix
  13233. * @param force Specifies if the world matrix should be computed by force
  13234. * @returns A world matrix
  13235. */
  13236. computeWorldMatrix(force: boolean): Matrix;
  13237. /**
  13238. * Gets the world matrix
  13239. * @returns A world matrix
  13240. */
  13241. getWorldMatrix?(): Matrix;
  13242. /**
  13243. * Gets the child meshes
  13244. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13245. * @returns An array of abstract meshes
  13246. */
  13247. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13248. /**
  13249. * Gets the vertex data
  13250. * @param kind The type of vertex data
  13251. * @returns A nullable array of numbers, or a float32 array
  13252. */
  13253. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13254. /**
  13255. * Gets the indices from the mesh
  13256. * @returns A nullable array of index arrays
  13257. */
  13258. getIndices?(): Nullable<IndicesArray>;
  13259. /**
  13260. * Gets the scene from the mesh
  13261. * @returns the indices array or null
  13262. */
  13263. getScene?(): Scene;
  13264. /**
  13265. * Gets the absolute position from the mesh
  13266. * @returns the absolute position
  13267. */
  13268. getAbsolutePosition(): Vector3;
  13269. /**
  13270. * Gets the absolute pivot point from the mesh
  13271. * @returns the absolute pivot point
  13272. */
  13273. getAbsolutePivotPoint(): Vector3;
  13274. /**
  13275. * Rotates the mesh
  13276. * @param axis The axis of rotation
  13277. * @param amount The amount of rotation
  13278. * @param space The space of the rotation
  13279. * @returns The rotation transform node
  13280. */
  13281. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13282. /**
  13283. * Translates the mesh
  13284. * @param axis The axis of translation
  13285. * @param distance The distance of translation
  13286. * @param space The space of the translation
  13287. * @returns The transform node
  13288. */
  13289. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13290. /**
  13291. * Sets the absolute position of the mesh
  13292. * @param absolutePosition The absolute position of the mesh
  13293. * @returns The transform node
  13294. */
  13295. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13296. /**
  13297. * Gets the class name of the mesh
  13298. * @returns The class name
  13299. */
  13300. getClassName(): string;
  13301. }
  13302. /**
  13303. * Represents a physics imposter
  13304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13305. */
  13306. export class PhysicsImpostor {
  13307. /**
  13308. * The physics-enabled object used as the physics imposter
  13309. */
  13310. object: IPhysicsEnabledObject;
  13311. /**
  13312. * The type of the physics imposter
  13313. */
  13314. type: number;
  13315. private _options;
  13316. private _scene?;
  13317. /**
  13318. * The default object size of the imposter
  13319. */
  13320. static DEFAULT_OBJECT_SIZE: Vector3;
  13321. /**
  13322. * The identity quaternion of the imposter
  13323. */
  13324. static IDENTITY_QUATERNION: Quaternion;
  13325. /** @hidden */ private _pluginData: any;
  13326. private _physicsEngine;
  13327. private _physicsBody;
  13328. private _bodyUpdateRequired;
  13329. private _onBeforePhysicsStepCallbacks;
  13330. private _onAfterPhysicsStepCallbacks;
  13331. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  13332. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13333. otherImpostors: Array<PhysicsImpostor>;
  13334. }>;
  13335. private _deltaPosition;
  13336. private _deltaRotation;
  13337. private _deltaRotationConjugated;
  13338. /** @hidden */ private _isFromLine: boolean;
  13339. private _parent;
  13340. private _isDisposed;
  13341. private static _tmpVecs;
  13342. private static _tmpQuat;
  13343. /**
  13344. * Specifies if the physics imposter is disposed
  13345. */
  13346. readonly isDisposed: boolean;
  13347. /**
  13348. * Gets the mass of the physics imposter
  13349. */
  13350. mass: number;
  13351. /**
  13352. * Gets the coefficient of friction
  13353. */
  13354. /**
  13355. * Sets the coefficient of friction
  13356. */
  13357. friction: number;
  13358. /**
  13359. * Gets the coefficient of restitution
  13360. */
  13361. /**
  13362. * Sets the coefficient of restitution
  13363. */
  13364. restitution: number;
  13365. /**
  13366. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13367. */
  13368. /**
  13369. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13370. */
  13371. pressure: number;
  13372. /**
  13373. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13374. */
  13375. /**
  13376. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13377. */
  13378. stiffness: number;
  13379. /**
  13380. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13381. */
  13382. /**
  13383. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13384. */
  13385. velocityIterations: number;
  13386. /**
  13387. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13388. */
  13389. /**
  13390. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13391. */
  13392. positionIterations: number;
  13393. /**
  13394. * The unique id of the physics imposter
  13395. * set by the physics engine when adding this impostor to the array
  13396. */
  13397. uniqueId: number;
  13398. /**
  13399. * @hidden
  13400. */
  13401. soft: boolean;
  13402. /**
  13403. * @hidden
  13404. */
  13405. segments: number;
  13406. private _joints;
  13407. /**
  13408. * Initializes the physics imposter
  13409. * @param object The physics-enabled object used as the physics imposter
  13410. * @param type The type of the physics imposter
  13411. * @param _options The options for the physics imposter
  13412. * @param _scene The Babylon scene
  13413. */
  13414. constructor(
  13415. /**
  13416. * The physics-enabled object used as the physics imposter
  13417. */
  13418. object: IPhysicsEnabledObject,
  13419. /**
  13420. * The type of the physics imposter
  13421. */
  13422. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13423. /**
  13424. * This function will completly initialize this impostor.
  13425. * It will create a new body - but only if this mesh has no parent.
  13426. * If it has, this impostor will not be used other than to define the impostor
  13427. * of the child mesh.
  13428. * @hidden
  13429. */ private _init(): void;
  13430. private _getPhysicsParent;
  13431. /**
  13432. * Should a new body be generated.
  13433. * @returns boolean specifying if body initialization is required
  13434. */
  13435. isBodyInitRequired(): boolean;
  13436. /**
  13437. * Sets the updated scaling
  13438. * @param updated Specifies if the scaling is updated
  13439. */
  13440. setScalingUpdated(): void;
  13441. /**
  13442. * Force a regeneration of this or the parent's impostor's body.
  13443. * Use under cautious - This will remove all joints already implemented.
  13444. */
  13445. forceUpdate(): void;
  13446. /**
  13447. * Gets the body that holds this impostor. Either its own, or its parent.
  13448. */
  13449. /**
  13450. * Set the physics body. Used mainly by the physics engine/plugin
  13451. */
  13452. physicsBody: any;
  13453. /**
  13454. * Get the parent of the physics imposter
  13455. * @returns Physics imposter or null
  13456. */
  13457. /**
  13458. * Sets the parent of the physics imposter
  13459. */
  13460. parent: Nullable<PhysicsImpostor>;
  13461. /**
  13462. * Resets the update flags
  13463. */
  13464. resetUpdateFlags(): void;
  13465. /**
  13466. * Gets the object extend size
  13467. * @returns the object extend size
  13468. */
  13469. getObjectExtendSize(): Vector3;
  13470. /**
  13471. * Gets the object center
  13472. * @returns The object center
  13473. */
  13474. getObjectCenter(): Vector3;
  13475. /**
  13476. * Get a specific parametes from the options parameter
  13477. * @param paramName The object parameter name
  13478. * @returns The object parameter
  13479. */
  13480. getParam(paramName: string): any;
  13481. /**
  13482. * Sets a specific parameter in the options given to the physics plugin
  13483. * @param paramName The parameter name
  13484. * @param value The value of the parameter
  13485. */
  13486. setParam(paramName: string, value: number): void;
  13487. /**
  13488. * Specifically change the body's mass option. Won't recreate the physics body object
  13489. * @param mass The mass of the physics imposter
  13490. */
  13491. setMass(mass: number): void;
  13492. /**
  13493. * Gets the linear velocity
  13494. * @returns linear velocity or null
  13495. */
  13496. getLinearVelocity(): Nullable<Vector3>;
  13497. /**
  13498. * Sets the linear velocity
  13499. * @param velocity linear velocity or null
  13500. */
  13501. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13502. /**
  13503. * Gets the angular velocity
  13504. * @returns angular velocity or null
  13505. */
  13506. getAngularVelocity(): Nullable<Vector3>;
  13507. /**
  13508. * Sets the angular velocity
  13509. * @param velocity The velocity or null
  13510. */
  13511. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13512. /**
  13513. * Execute a function with the physics plugin native code
  13514. * Provide a function the will have two variables - the world object and the physics body object
  13515. * @param func The function to execute with the physics plugin native code
  13516. */
  13517. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13518. /**
  13519. * Register a function that will be executed before the physics world is stepping forward
  13520. * @param func The function to execute before the physics world is stepped forward
  13521. */
  13522. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13523. /**
  13524. * Unregister a function that will be executed before the physics world is stepping forward
  13525. * @param func The function to execute before the physics world is stepped forward
  13526. */
  13527. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13528. /**
  13529. * Register a function that will be executed after the physics step
  13530. * @param func The function to execute after physics step
  13531. */
  13532. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13533. /**
  13534. * Unregisters a function that will be executed after the physics step
  13535. * @param func The function to execute after physics step
  13536. */
  13537. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13538. /**
  13539. * register a function that will be executed when this impostor collides against a different body
  13540. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13541. * @param func Callback that is executed on collision
  13542. */
  13543. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13544. /**
  13545. * Unregisters the physics imposter on contact
  13546. * @param collideAgainst The physics object to collide against
  13547. * @param func Callback to execute on collision
  13548. */
  13549. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13550. private _tmpQuat;
  13551. private _tmpQuat2;
  13552. /**
  13553. * Get the parent rotation
  13554. * @returns The parent rotation
  13555. */
  13556. getParentsRotation(): Quaternion;
  13557. /**
  13558. * this function is executed by the physics engine.
  13559. */
  13560. beforeStep: () => void;
  13561. /**
  13562. * this function is executed by the physics engine
  13563. */
  13564. afterStep: () => void;
  13565. /**
  13566. * Legacy collision detection event support
  13567. */
  13568. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13569. /**
  13570. * event and body object due to cannon's event-based architecture.
  13571. */
  13572. onCollide: (e: {
  13573. body: any;
  13574. }) => void;
  13575. /**
  13576. * Apply a force
  13577. * @param force The force to apply
  13578. * @param contactPoint The contact point for the force
  13579. * @returns The physics imposter
  13580. */
  13581. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13582. /**
  13583. * Apply an impulse
  13584. * @param force The impulse force
  13585. * @param contactPoint The contact point for the impulse force
  13586. * @returns The physics imposter
  13587. */
  13588. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13589. /**
  13590. * A help function to create a joint
  13591. * @param otherImpostor A physics imposter used to create a joint
  13592. * @param jointType The type of joint
  13593. * @param jointData The data for the joint
  13594. * @returns The physics imposter
  13595. */
  13596. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13597. /**
  13598. * Add a joint to this impostor with a different impostor
  13599. * @param otherImpostor A physics imposter used to add a joint
  13600. * @param joint The joint to add
  13601. * @returns The physics imposter
  13602. */
  13603. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13604. /**
  13605. * Add an anchor to a cloth impostor
  13606. * @param otherImpostor rigid impostor to anchor to
  13607. * @param width ratio across width from 0 to 1
  13608. * @param height ratio up height from 0 to 1
  13609. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13610. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13611. * @returns impostor the soft imposter
  13612. */
  13613. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13614. /**
  13615. * Add a hook to a rope impostor
  13616. * @param otherImpostor rigid impostor to anchor to
  13617. * @param length ratio across rope from 0 to 1
  13618. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13619. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13620. * @returns impostor the rope imposter
  13621. */
  13622. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13623. /**
  13624. * Will keep this body still, in a sleep mode.
  13625. * @returns the physics imposter
  13626. */
  13627. sleep(): PhysicsImpostor;
  13628. /**
  13629. * Wake the body up.
  13630. * @returns The physics imposter
  13631. */
  13632. wakeUp(): PhysicsImpostor;
  13633. /**
  13634. * Clones the physics imposter
  13635. * @param newObject The physics imposter clones to this physics-enabled object
  13636. * @returns A nullable physics imposter
  13637. */
  13638. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13639. /**
  13640. * Disposes the physics imposter
  13641. */
  13642. dispose(): void;
  13643. /**
  13644. * Sets the delta position
  13645. * @param position The delta position amount
  13646. */
  13647. setDeltaPosition(position: Vector3): void;
  13648. /**
  13649. * Sets the delta rotation
  13650. * @param rotation The delta rotation amount
  13651. */
  13652. setDeltaRotation(rotation: Quaternion): void;
  13653. /**
  13654. * Gets the box size of the physics imposter and stores the result in the input parameter
  13655. * @param result Stores the box size
  13656. * @returns The physics imposter
  13657. */
  13658. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13659. /**
  13660. * Gets the radius of the physics imposter
  13661. * @returns Radius of the physics imposter
  13662. */
  13663. getRadius(): number;
  13664. /**
  13665. * Sync a bone with this impostor
  13666. * @param bone The bone to sync to the impostor.
  13667. * @param boneMesh The mesh that the bone is influencing.
  13668. * @param jointPivot The pivot of the joint / bone in local space.
  13669. * @param distToJoint Optional distance from the impostor to the joint.
  13670. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13671. */
  13672. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13673. /**
  13674. * Sync impostor to a bone
  13675. * @param bone The bone that the impostor will be synced to.
  13676. * @param boneMesh The mesh that the bone is influencing.
  13677. * @param jointPivot The pivot of the joint / bone in local space.
  13678. * @param distToJoint Optional distance from the impostor to the joint.
  13679. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13680. * @param boneAxis Optional vector3 axis the bone is aligned with
  13681. */
  13682. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13683. /**
  13684. * No-Imposter type
  13685. */
  13686. static NoImpostor: number;
  13687. /**
  13688. * Sphere-Imposter type
  13689. */
  13690. static SphereImpostor: number;
  13691. /**
  13692. * Box-Imposter type
  13693. */
  13694. static BoxImpostor: number;
  13695. /**
  13696. * Plane-Imposter type
  13697. */
  13698. static PlaneImpostor: number;
  13699. /**
  13700. * Mesh-imposter type
  13701. */
  13702. static MeshImpostor: number;
  13703. /**
  13704. * Capsule-Impostor type (Ammo.js plugin only)
  13705. */
  13706. static CapsuleImpostor: number;
  13707. /**
  13708. * Cylinder-Imposter type
  13709. */
  13710. static CylinderImpostor: number;
  13711. /**
  13712. * Particle-Imposter type
  13713. */
  13714. static ParticleImpostor: number;
  13715. /**
  13716. * Heightmap-Imposter type
  13717. */
  13718. static HeightmapImpostor: number;
  13719. /**
  13720. * ConvexHull-Impostor type (Ammo.js plugin only)
  13721. */
  13722. static ConvexHullImpostor: number;
  13723. /**
  13724. * Rope-Imposter type
  13725. */
  13726. static RopeImpostor: number;
  13727. /**
  13728. * Cloth-Imposter type
  13729. */
  13730. static ClothImpostor: number;
  13731. /**
  13732. * Softbody-Imposter type
  13733. */
  13734. static SoftbodyImpostor: number;
  13735. }
  13736. }
  13737. declare module BABYLON {
  13738. /**
  13739. * @hidden
  13740. **/
  13741. export class _CreationDataStorage {
  13742. closePath?: boolean;
  13743. closeArray?: boolean;
  13744. idx: number[];
  13745. dashSize: number;
  13746. gapSize: number;
  13747. path3D: Path3D;
  13748. pathArray: Vector3[][];
  13749. arc: number;
  13750. radius: number;
  13751. cap: number;
  13752. tessellation: number;
  13753. }
  13754. /**
  13755. * @hidden
  13756. **/ private class _InstanceDataStorage {
  13757. visibleInstances: any;
  13758. batchCache: _InstancesBatch;
  13759. instancesBufferSize: number;
  13760. instancesBuffer: Nullable<Buffer>;
  13761. instancesData: Float32Array;
  13762. overridenInstanceCount: number;
  13763. isFrozen: boolean;
  13764. previousBatch: Nullable<_InstancesBatch>;
  13765. hardwareInstancedRendering: boolean;
  13766. sideOrientation: number;
  13767. }
  13768. /**
  13769. * @hidden
  13770. **/
  13771. export class _InstancesBatch {
  13772. mustReturn: boolean;
  13773. visibleInstances: Nullable<InstancedMesh[]>[];
  13774. renderSelf: boolean[];
  13775. hardwareInstancedRendering: boolean[];
  13776. }
  13777. /**
  13778. * Class used to represent renderable models
  13779. */
  13780. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13781. /**
  13782. * Mesh side orientation : usually the external or front surface
  13783. */
  13784. static readonly FRONTSIDE: number;
  13785. /**
  13786. * Mesh side orientation : usually the internal or back surface
  13787. */
  13788. static readonly BACKSIDE: number;
  13789. /**
  13790. * Mesh side orientation : both internal and external or front and back surfaces
  13791. */
  13792. static readonly DOUBLESIDE: number;
  13793. /**
  13794. * Mesh side orientation : by default, `FRONTSIDE`
  13795. */
  13796. static readonly DEFAULTSIDE: number;
  13797. /**
  13798. * Mesh cap setting : no cap
  13799. */
  13800. static readonly NO_CAP: number;
  13801. /**
  13802. * Mesh cap setting : one cap at the beginning of the mesh
  13803. */
  13804. static readonly CAP_START: number;
  13805. /**
  13806. * Mesh cap setting : one cap at the end of the mesh
  13807. */
  13808. static readonly CAP_END: number;
  13809. /**
  13810. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13811. */
  13812. static readonly CAP_ALL: number;
  13813. /**
  13814. * Mesh pattern setting : no flip or rotate
  13815. */
  13816. static readonly NO_FLIP: number;
  13817. /**
  13818. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13819. */
  13820. static readonly FLIP_TILE: number;
  13821. /**
  13822. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13823. */
  13824. static readonly ROTATE_TILE: number;
  13825. /**
  13826. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  13827. */
  13828. static readonly FLIP_ROW: number;
  13829. /**
  13830. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  13831. */
  13832. static readonly ROTATE_ROW: number;
  13833. /**
  13834. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  13835. */
  13836. static readonly FLIP_N_ROTATE_TILE: number;
  13837. /**
  13838. * Mesh pattern setting : rotate pattern and rotate
  13839. */
  13840. static readonly FLIP_N_ROTATE_ROW: number;
  13841. /**
  13842. * Mesh tile positioning : part tiles same on left/right or top/bottom
  13843. */
  13844. static readonly CENTER: number;
  13845. /**
  13846. * Mesh tile positioning : part tiles on left
  13847. */
  13848. static readonly LEFT: number;
  13849. /**
  13850. * Mesh tile positioning : part tiles on right
  13851. */
  13852. static readonly RIGHT: number;
  13853. /**
  13854. * Mesh tile positioning : part tiles on top
  13855. */
  13856. static readonly TOP: number;
  13857. /**
  13858. * Mesh tile positioning : part tiles on bottom
  13859. */
  13860. static readonly BOTTOM: number;
  13861. /**
  13862. * Gets the default side orientation.
  13863. * @param orientation the orientation to value to attempt to get
  13864. * @returns the default orientation
  13865. * @hidden
  13866. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  13867. private _internalMeshDataInfo;
  13868. /**
  13869. * An event triggered before rendering the mesh
  13870. */
  13871. readonly onBeforeRenderObservable: Observable<Mesh>;
  13872. /**
  13873. * An event triggered before binding the mesh
  13874. */
  13875. readonly onBeforeBindObservable: Observable<Mesh>;
  13876. /**
  13877. * An event triggered after rendering the mesh
  13878. */
  13879. readonly onAfterRenderObservable: Observable<Mesh>;
  13880. /**
  13881. * An event triggered before drawing the mesh
  13882. */
  13883. readonly onBeforeDrawObservable: Observable<Mesh>;
  13884. private _onBeforeDrawObserver;
  13885. /**
  13886. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  13887. */
  13888. onBeforeDraw: () => void;
  13889. /**
  13890. * Gets the delay loading state of the mesh (when delay loading is turned on)
  13891. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  13892. */
  13893. delayLoadState: number;
  13894. /**
  13895. * Gets the list of instances created from this mesh
  13896. * it is not supposed to be modified manually.
  13897. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  13898. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  13899. */
  13900. instances: InstancedMesh[];
  13901. /**
  13902. * Gets the file containing delay loading data for this mesh
  13903. */
  13904. delayLoadingFile: string;
  13905. /** @hidden */ private _binaryInfo: any;
  13906. /**
  13907. * User defined function used to change how LOD level selection is done
  13908. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  13909. */
  13910. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  13911. /**
  13912. * Gets or sets the morph target manager
  13913. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  13914. */
  13915. morphTargetManager: Nullable<MorphTargetManager>;
  13916. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  13917. /** @hidden */ private _geometry: Nullable<Geometry>;
  13918. /** @hidden */ private _delayInfo: Array<string>;
  13919. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  13920. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  13921. private _effectiveMaterial;
  13922. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  13923. /** @hidden */ private _originalBuilderSideOrientation: number;
  13924. /**
  13925. * Use this property to change the original side orientation defined at construction time
  13926. */
  13927. overrideMaterialSideOrientation: Nullable<number>;
  13928. /**
  13929. * Gets the source mesh (the one used to clone this one from)
  13930. */
  13931. readonly source: Nullable<Mesh>;
  13932. /**
  13933. * Gets or sets a boolean indicating that this mesh does not use index buffer
  13934. */
  13935. isUnIndexed: boolean;
  13936. /**
  13937. * @constructor
  13938. * @param name The value used by scene.getMeshByName() to do a lookup.
  13939. * @param scene The scene to add this mesh to.
  13940. * @param parent The parent of this mesh, if it has one
  13941. * @param source An optional Mesh from which geometry is shared, cloned.
  13942. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  13943. * When false, achieved by calling a clone(), also passing False.
  13944. * This will make creation of children, recursive.
  13945. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  13946. */
  13947. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  13948. /**
  13949. * Gets the class name
  13950. * @returns the string "Mesh".
  13951. */
  13952. getClassName(): string;
  13953. /** @hidden */ protected readonly _isMesh: boolean;
  13954. /**
  13955. * Returns a description of this mesh
  13956. * @param fullDetails define if full details about this mesh must be used
  13957. * @returns a descriptive string representing this mesh
  13958. */
  13959. toString(fullDetails?: boolean): string;
  13960. /** @hidden */ private _unBindEffect(): void;
  13961. /**
  13962. * Gets a boolean indicating if this mesh has LOD
  13963. */
  13964. readonly hasLODLevels: boolean;
  13965. /**
  13966. * Gets the list of MeshLODLevel associated with the current mesh
  13967. * @returns an array of MeshLODLevel
  13968. */
  13969. getLODLevels(): MeshLODLevel[];
  13970. private _sortLODLevels;
  13971. /**
  13972. * Add a mesh as LOD level triggered at the given distance.
  13973. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13974. * @param distance The distance from the center of the object to show this level
  13975. * @param mesh The mesh to be added as LOD level (can be null)
  13976. * @return This mesh (for chaining)
  13977. */
  13978. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  13979. /**
  13980. * Returns the LOD level mesh at the passed distance or null if not found.
  13981. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13982. * @param distance The distance from the center of the object to show this level
  13983. * @returns a Mesh or `null`
  13984. */
  13985. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  13986. /**
  13987. * Remove a mesh from the LOD array
  13988. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13989. * @param mesh defines the mesh to be removed
  13990. * @return This mesh (for chaining)
  13991. */
  13992. removeLODLevel(mesh: Mesh): Mesh;
  13993. /**
  13994. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  13995. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  13996. * @param camera defines the camera to use to compute distance
  13997. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  13998. * @return This mesh (for chaining)
  13999. */
  14000. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14001. /**
  14002. * Gets the mesh internal Geometry object
  14003. */
  14004. readonly geometry: Nullable<Geometry>;
  14005. /**
  14006. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14007. * @returns the total number of vertices
  14008. */
  14009. getTotalVertices(): number;
  14010. /**
  14011. * Returns the content of an associated vertex buffer
  14012. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14013. * - VertexBuffer.PositionKind
  14014. * - VertexBuffer.UVKind
  14015. * - VertexBuffer.UV2Kind
  14016. * - VertexBuffer.UV3Kind
  14017. * - VertexBuffer.UV4Kind
  14018. * - VertexBuffer.UV5Kind
  14019. * - VertexBuffer.UV6Kind
  14020. * - VertexBuffer.ColorKind
  14021. * - VertexBuffer.MatricesIndicesKind
  14022. * - VertexBuffer.MatricesIndicesExtraKind
  14023. * - VertexBuffer.MatricesWeightsKind
  14024. * - VertexBuffer.MatricesWeightsExtraKind
  14025. * @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
  14026. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14027. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14028. */
  14029. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14030. /**
  14031. * Returns the mesh VertexBuffer object from the requested `kind`
  14032. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14033. * - VertexBuffer.PositionKind
  14034. * - VertexBuffer.NormalKind
  14035. * - VertexBuffer.UVKind
  14036. * - VertexBuffer.UV2Kind
  14037. * - VertexBuffer.UV3Kind
  14038. * - VertexBuffer.UV4Kind
  14039. * - VertexBuffer.UV5Kind
  14040. * - VertexBuffer.UV6Kind
  14041. * - VertexBuffer.ColorKind
  14042. * - VertexBuffer.MatricesIndicesKind
  14043. * - VertexBuffer.MatricesIndicesExtraKind
  14044. * - VertexBuffer.MatricesWeightsKind
  14045. * - VertexBuffer.MatricesWeightsExtraKind
  14046. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14047. */
  14048. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14049. /**
  14050. * Tests if a specific vertex buffer is associated with this mesh
  14051. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14052. * - VertexBuffer.PositionKind
  14053. * - VertexBuffer.NormalKind
  14054. * - VertexBuffer.UVKind
  14055. * - VertexBuffer.UV2Kind
  14056. * - VertexBuffer.UV3Kind
  14057. * - VertexBuffer.UV4Kind
  14058. * - VertexBuffer.UV5Kind
  14059. * - VertexBuffer.UV6Kind
  14060. * - VertexBuffer.ColorKind
  14061. * - VertexBuffer.MatricesIndicesKind
  14062. * - VertexBuffer.MatricesIndicesExtraKind
  14063. * - VertexBuffer.MatricesWeightsKind
  14064. * - VertexBuffer.MatricesWeightsExtraKind
  14065. * @returns a boolean
  14066. */
  14067. isVerticesDataPresent(kind: string): boolean;
  14068. /**
  14069. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14070. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14071. * - VertexBuffer.PositionKind
  14072. * - VertexBuffer.UVKind
  14073. * - VertexBuffer.UV2Kind
  14074. * - VertexBuffer.UV3Kind
  14075. * - VertexBuffer.UV4Kind
  14076. * - VertexBuffer.UV5Kind
  14077. * - VertexBuffer.UV6Kind
  14078. * - VertexBuffer.ColorKind
  14079. * - VertexBuffer.MatricesIndicesKind
  14080. * - VertexBuffer.MatricesIndicesExtraKind
  14081. * - VertexBuffer.MatricesWeightsKind
  14082. * - VertexBuffer.MatricesWeightsExtraKind
  14083. * @returns a boolean
  14084. */
  14085. isVertexBufferUpdatable(kind: string): boolean;
  14086. /**
  14087. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14089. * - VertexBuffer.PositionKind
  14090. * - VertexBuffer.NormalKind
  14091. * - VertexBuffer.UVKind
  14092. * - VertexBuffer.UV2Kind
  14093. * - VertexBuffer.UV3Kind
  14094. * - VertexBuffer.UV4Kind
  14095. * - VertexBuffer.UV5Kind
  14096. * - VertexBuffer.UV6Kind
  14097. * - VertexBuffer.ColorKind
  14098. * - VertexBuffer.MatricesIndicesKind
  14099. * - VertexBuffer.MatricesIndicesExtraKind
  14100. * - VertexBuffer.MatricesWeightsKind
  14101. * - VertexBuffer.MatricesWeightsExtraKind
  14102. * @returns an array of strings
  14103. */
  14104. getVerticesDataKinds(): string[];
  14105. /**
  14106. * Returns a positive integer : the total number of indices in this mesh geometry.
  14107. * @returns the numner of indices or zero if the mesh has no geometry.
  14108. */
  14109. getTotalIndices(): number;
  14110. /**
  14111. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14112. * @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.
  14113. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14114. * @returns the indices array or an empty array if the mesh has no geometry
  14115. */
  14116. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14117. readonly isBlocked: boolean;
  14118. /**
  14119. * Determine if the current mesh is ready to be rendered
  14120. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14121. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14122. * @returns true if all associated assets are ready (material, textures, shaders)
  14123. */
  14124. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14125. /**
  14126. * 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.
  14127. */
  14128. readonly areNormalsFrozen: boolean;
  14129. /**
  14130. * 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.
  14131. * @returns the current mesh
  14132. */
  14133. freezeNormals(): Mesh;
  14134. /**
  14135. * 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
  14136. * @returns the current mesh
  14137. */
  14138. unfreezeNormals(): Mesh;
  14139. /**
  14140. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14141. */
  14142. overridenInstanceCount: number;
  14143. /** @hidden */ private _preActivate(): Mesh;
  14144. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  14145. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14146. /**
  14147. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14148. * This means the mesh underlying bounding box and sphere are recomputed.
  14149. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14150. * @returns the current mesh
  14151. */
  14152. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14153. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14154. /**
  14155. * This function will subdivide the mesh into multiple submeshes
  14156. * @param count defines the expected number of submeshes
  14157. */
  14158. subdivide(count: number): void;
  14159. /**
  14160. * Copy a FloatArray into a specific associated vertex buffer
  14161. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14162. * - VertexBuffer.PositionKind
  14163. * - VertexBuffer.UVKind
  14164. * - VertexBuffer.UV2Kind
  14165. * - VertexBuffer.UV3Kind
  14166. * - VertexBuffer.UV4Kind
  14167. * - VertexBuffer.UV5Kind
  14168. * - VertexBuffer.UV6Kind
  14169. * - VertexBuffer.ColorKind
  14170. * - VertexBuffer.MatricesIndicesKind
  14171. * - VertexBuffer.MatricesIndicesExtraKind
  14172. * - VertexBuffer.MatricesWeightsKind
  14173. * - VertexBuffer.MatricesWeightsExtraKind
  14174. * @param data defines the data source
  14175. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14176. * @param stride defines the data stride size (can be null)
  14177. * @returns the current mesh
  14178. */
  14179. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14180. /**
  14181. * Flags an associated vertex buffer as updatable
  14182. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14183. * - VertexBuffer.PositionKind
  14184. * - VertexBuffer.UVKind
  14185. * - VertexBuffer.UV2Kind
  14186. * - VertexBuffer.UV3Kind
  14187. * - VertexBuffer.UV4Kind
  14188. * - VertexBuffer.UV5Kind
  14189. * - VertexBuffer.UV6Kind
  14190. * - VertexBuffer.ColorKind
  14191. * - VertexBuffer.MatricesIndicesKind
  14192. * - VertexBuffer.MatricesIndicesExtraKind
  14193. * - VertexBuffer.MatricesWeightsKind
  14194. * - VertexBuffer.MatricesWeightsExtraKind
  14195. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14196. */
  14197. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14198. /**
  14199. * Sets the mesh global Vertex Buffer
  14200. * @param buffer defines the buffer to use
  14201. * @returns the current mesh
  14202. */
  14203. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14204. /**
  14205. * Update a specific associated vertex buffer
  14206. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14207. * - VertexBuffer.PositionKind
  14208. * - VertexBuffer.UVKind
  14209. * - VertexBuffer.UV2Kind
  14210. * - VertexBuffer.UV3Kind
  14211. * - VertexBuffer.UV4Kind
  14212. * - VertexBuffer.UV5Kind
  14213. * - VertexBuffer.UV6Kind
  14214. * - VertexBuffer.ColorKind
  14215. * - VertexBuffer.MatricesIndicesKind
  14216. * - VertexBuffer.MatricesIndicesExtraKind
  14217. * - VertexBuffer.MatricesWeightsKind
  14218. * - VertexBuffer.MatricesWeightsExtraKind
  14219. * @param data defines the data source
  14220. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14221. * @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)
  14222. * @returns the current mesh
  14223. */
  14224. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14225. /**
  14226. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14227. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14228. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14229. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14230. * @returns the current mesh
  14231. */
  14232. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14233. /**
  14234. * Creates a un-shared specific occurence of the geometry for the mesh.
  14235. * @returns the current mesh
  14236. */
  14237. makeGeometryUnique(): Mesh;
  14238. /**
  14239. * Set the index buffer of this mesh
  14240. * @param indices defines the source data
  14241. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14242. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14243. * @returns the current mesh
  14244. */
  14245. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14246. /**
  14247. * Update the current index buffer
  14248. * @param indices defines the source data
  14249. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14250. * @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)
  14251. * @returns the current mesh
  14252. */
  14253. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14254. /**
  14255. * Invert the geometry to move from a right handed system to a left handed one.
  14256. * @returns the current mesh
  14257. */
  14258. toLeftHanded(): Mesh;
  14259. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14260. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14261. /**
  14262. * Registers for this mesh a javascript function called just before the rendering process
  14263. * @param func defines the function to call before rendering this mesh
  14264. * @returns the current mesh
  14265. */
  14266. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14267. /**
  14268. * Disposes a previously registered javascript function called before the rendering
  14269. * @param func defines the function to remove
  14270. * @returns the current mesh
  14271. */
  14272. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14273. /**
  14274. * Registers for this mesh a javascript function called just after the rendering is complete
  14275. * @param func defines the function to call after rendering this mesh
  14276. * @returns the current mesh
  14277. */
  14278. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14279. /**
  14280. * Disposes a previously registered javascript function called after the rendering.
  14281. * @param func defines the function to remove
  14282. * @returns the current mesh
  14283. */
  14284. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14285. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14286. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14287. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14288. /** @hidden */ private _rebuild(): void;
  14289. /** @hidden */ private _freeze(): void;
  14290. /** @hidden */ private _unFreeze(): void;
  14291. /**
  14292. * 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
  14293. * @param subMesh defines the subMesh to render
  14294. * @param enableAlphaMode defines if alpha mode can be changed
  14295. * @returns the current mesh
  14296. */
  14297. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14298. private _onBeforeDraw;
  14299. /**
  14300. * Renormalize the mesh and patch it up if there are no weights
  14301. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14302. * However in the case of zero weights then we set just a single influence to 1.
  14303. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14304. */
  14305. cleanMatrixWeights(): void;
  14306. private normalizeSkinFourWeights;
  14307. private normalizeSkinWeightsAndExtra;
  14308. /**
  14309. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14310. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14311. * the user know there was an issue with importing the mesh
  14312. * @returns a validation object with skinned, valid and report string
  14313. */
  14314. validateSkinning(): {
  14315. skinned: boolean;
  14316. valid: boolean;
  14317. report: string;
  14318. };
  14319. /** @hidden */ private _checkDelayState(): Mesh;
  14320. private _queueLoad;
  14321. /**
  14322. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14323. * A mesh is in the frustum if its bounding box intersects the frustum
  14324. * @param frustumPlanes defines the frustum to test
  14325. * @returns true if the mesh is in the frustum planes
  14326. */
  14327. isInFrustum(frustumPlanes: Plane[]): boolean;
  14328. /**
  14329. * Sets the mesh material by the material or multiMaterial `id` property
  14330. * @param id is a string identifying the material or the multiMaterial
  14331. * @returns the current mesh
  14332. */
  14333. setMaterialByID(id: string): Mesh;
  14334. /**
  14335. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14336. * @returns an array of IAnimatable
  14337. */
  14338. getAnimatables(): IAnimatable[];
  14339. /**
  14340. * Modifies the mesh geometry according to the passed transformation matrix.
  14341. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14342. * The mesh normals are modified using the same transformation.
  14343. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14344. * @param transform defines the transform matrix to use
  14345. * @see http://doc.babylonjs.com/resources/baking_transformations
  14346. * @returns the current mesh
  14347. */
  14348. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14349. /**
  14350. * Modifies the mesh geometry according to its own current World Matrix.
  14351. * The mesh World Matrix is then reset.
  14352. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14353. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14354. * @see http://doc.babylonjs.com/resources/baking_transformations
  14355. * @returns the current mesh
  14356. */
  14357. bakeCurrentTransformIntoVertices(): Mesh;
  14358. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  14359. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  14360. /** @hidden */ private _generatePointsArray(): boolean;
  14361. /**
  14362. * Returns a new Mesh object generated from the current mesh properties.
  14363. * This method must not get confused with createInstance()
  14364. * @param name is a string, the name given to the new mesh
  14365. * @param newParent can be any Node object (default `null`)
  14366. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14367. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14368. * @returns a new mesh
  14369. */
  14370. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14371. /**
  14372. * Releases resources associated with this mesh.
  14373. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14374. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14375. */
  14376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14377. /**
  14378. * Modifies the mesh geometry according to a displacement map.
  14379. * 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.
  14380. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14381. * @param url is a string, the URL from the image file is to be downloaded.
  14382. * @param minHeight is the lower limit of the displacement.
  14383. * @param maxHeight is the upper limit of the displacement.
  14384. * @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.
  14385. * @param uvOffset is an optional vector2 used to offset UV.
  14386. * @param uvScale is an optional vector2 used to scale UV.
  14387. * @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.
  14388. * @returns the Mesh.
  14389. */
  14390. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14391. /**
  14392. * Modifies the mesh geometry according to a displacementMap buffer.
  14393. * 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.
  14394. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14395. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14396. * @param heightMapWidth is the width of the buffer image.
  14397. * @param heightMapHeight is the height of the buffer image.
  14398. * @param minHeight is the lower limit of the displacement.
  14399. * @param maxHeight is the upper limit of the displacement.
  14400. * @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.
  14401. * @param uvOffset is an optional vector2 used to offset UV.
  14402. * @param uvScale is an optional vector2 used to scale UV.
  14403. * @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.
  14404. * @returns the Mesh.
  14405. */
  14406. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14407. /**
  14408. * Modify the mesh to get a flat shading rendering.
  14409. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14410. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14411. * @returns current mesh
  14412. */
  14413. convertToFlatShadedMesh(): Mesh;
  14414. /**
  14415. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14416. * In other words, more vertices, no more indices and a single bigger VBO.
  14417. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14418. * @returns current mesh
  14419. */
  14420. convertToUnIndexedMesh(): Mesh;
  14421. /**
  14422. * Inverses facet orientations.
  14423. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14424. * @param flipNormals will also inverts the normals
  14425. * @returns current mesh
  14426. */
  14427. flipFaces(flipNormals?: boolean): Mesh;
  14428. /**
  14429. * Increase the number of facets and hence vertices in a mesh
  14430. * Vertex normals are interpolated from existing vertex normals
  14431. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14432. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14433. */
  14434. increaseVertices(numberPerEdge: number): void;
  14435. /**
  14436. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14437. * This will undo any application of covertToFlatShadedMesh
  14438. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14439. */
  14440. forceSharedVertices(): void;
  14441. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14442. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14443. /**
  14444. * Creates a new InstancedMesh object from the mesh model.
  14445. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14446. * @param name defines the name of the new instance
  14447. * @returns a new InstancedMesh
  14448. */
  14449. createInstance(name: string): InstancedMesh;
  14450. /**
  14451. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14452. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14453. * @returns the current mesh
  14454. */
  14455. synchronizeInstances(): Mesh;
  14456. /**
  14457. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14458. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14459. * This should be used together with the simplification to avoid disappearing triangles.
  14460. * @param successCallback an optional success callback to be called after the optimization finished.
  14461. * @returns the current mesh
  14462. */
  14463. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14464. /**
  14465. * Serialize current mesh
  14466. * @param serializationObject defines the object which will receive the serialization data
  14467. */
  14468. serialize(serializationObject: any): void;
  14469. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  14470. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14471. /**
  14472. * Returns a new Mesh object parsed from the source provided.
  14473. * @param parsedMesh is the source
  14474. * @param scene defines the hosting scene
  14475. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14476. * @returns a new Mesh
  14477. */
  14478. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14479. /**
  14480. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14481. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14482. * @param name defines the name of the mesh to create
  14483. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14484. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14485. * @param closePath creates a seam between the first and the last points of each path of the path array
  14486. * @param offset is taken in account only if the `pathArray` is containing a single path
  14487. * @param scene defines the hosting scene
  14488. * @param updatable defines if the mesh must be flagged as updatable
  14489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14490. * @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)
  14491. * @returns a new Mesh
  14492. */
  14493. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14494. /**
  14495. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14496. * @param name defines the name of the mesh to create
  14497. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14498. * @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
  14499. * @param scene defines the hosting scene
  14500. * @param updatable defines if the mesh must be flagged as updatable
  14501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14502. * @returns a new Mesh
  14503. */
  14504. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14505. /**
  14506. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14507. * @param name defines the name of the mesh to create
  14508. * @param size sets the size (float) of each box side (default 1)
  14509. * @param scene defines the hosting scene
  14510. * @param updatable defines if the mesh must be flagged as updatable
  14511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14512. * @returns a new Mesh
  14513. */
  14514. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14515. /**
  14516. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14517. * @param name defines the name of the mesh to create
  14518. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14519. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14520. * @param scene defines the hosting scene
  14521. * @param updatable defines if the mesh must be flagged as updatable
  14522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14523. * @returns a new Mesh
  14524. */
  14525. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14526. /**
  14527. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14528. * @param name defines the name of the mesh to create
  14529. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14530. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14531. * @param scene defines the hosting scene
  14532. * @returns a new Mesh
  14533. */
  14534. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14535. /**
  14536. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14537. * @param name defines the name of the mesh to create
  14538. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14539. * @param diameterTop set the top cap diameter (floats, default 1)
  14540. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14541. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14542. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14543. * @param scene defines the hosting scene
  14544. * @param updatable defines if the mesh must be flagged as updatable
  14545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14546. * @returns a new Mesh
  14547. */
  14548. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14549. /**
  14550. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14551. * @param name defines the name of the mesh to create
  14552. * @param diameter sets the diameter size (float) of the torus (default 1)
  14553. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14554. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14555. * @param scene defines the hosting scene
  14556. * @param updatable defines if the mesh must be flagged as updatable
  14557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14558. * @returns a new Mesh
  14559. */
  14560. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14561. /**
  14562. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14563. * @param name defines the name of the mesh to create
  14564. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14565. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14566. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14567. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14568. * @param p the number of windings on X axis (positive integers, default 2)
  14569. * @param q the number of windings on Y axis (positive integers, default 3)
  14570. * @param scene defines the hosting scene
  14571. * @param updatable defines if the mesh must be flagged as updatable
  14572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14573. * @returns a new Mesh
  14574. */
  14575. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14576. /**
  14577. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14578. * @param name defines the name of the mesh to create
  14579. * @param points is an array successive Vector3
  14580. * @param scene defines the hosting scene
  14581. * @param updatable defines if the mesh must be flagged as updatable
  14582. * @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).
  14583. * @returns a new Mesh
  14584. */
  14585. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14586. /**
  14587. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14588. * @param name defines the name of the mesh to create
  14589. * @param points is an array successive Vector3
  14590. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14591. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14592. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14593. * @param scene defines the hosting scene
  14594. * @param updatable defines if the mesh must be flagged as updatable
  14595. * @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)
  14596. * @returns a new Mesh
  14597. */
  14598. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14599. /**
  14600. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14601. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14602. * 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.
  14603. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14604. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14605. * Remember you can only change the shape positions, not their number when updating a polygon.
  14606. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14607. * @param name defines the name of the mesh to create
  14608. * @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
  14609. * @param scene defines the hosting scene
  14610. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14611. * @param updatable defines if the mesh must be flagged as updatable
  14612. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14613. * @param earcutInjection can be used to inject your own earcut reference
  14614. * @returns a new Mesh
  14615. */
  14616. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14617. /**
  14618. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14619. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14620. * @param name defines the name of the mesh to create
  14621. * @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
  14622. * @param depth defines the height of extrusion
  14623. * @param scene defines the hosting scene
  14624. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14625. * @param updatable defines if the mesh must be flagged as updatable
  14626. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14627. * @param earcutInjection can be used to inject your own earcut reference
  14628. * @returns a new Mesh
  14629. */
  14630. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14631. /**
  14632. * Creates an extruded shape mesh.
  14633. * 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
  14634. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14635. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14636. * @param name defines the name of the mesh to create
  14637. * @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
  14638. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14639. * @param scale is the value to scale the shape
  14640. * @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
  14641. * @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
  14642. * @param scene defines the hosting scene
  14643. * @param updatable defines if the mesh must be flagged as updatable
  14644. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14645. * @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)
  14646. * @returns a new Mesh
  14647. */
  14648. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14649. /**
  14650. * Creates an custom extruded shape mesh.
  14651. * The custom extrusion is a parametric shape.
  14652. * It has no predefined shape. Its final shape will depend on the input parameters.
  14653. * Please consider using the same method from the MeshBuilder class instead
  14654. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14655. * @param name defines the name of the mesh to create
  14656. * @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
  14657. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14658. * @param scaleFunction is a custom Javascript function called on each path point
  14659. * @param rotationFunction is a custom Javascript function called on each path point
  14660. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14661. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14662. * @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
  14663. * @param scene defines the hosting scene
  14664. * @param updatable defines if the mesh must be flagged as updatable
  14665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14666. * @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)
  14667. * @returns a new Mesh
  14668. */
  14669. 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;
  14670. /**
  14671. * Creates lathe mesh.
  14672. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14673. * Please consider using the same method from the MeshBuilder class instead
  14674. * @param name defines the name of the mesh to create
  14675. * @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
  14676. * @param radius is the radius value of the lathe
  14677. * @param tessellation is the side number of the lathe.
  14678. * @param scene defines the hosting scene
  14679. * @param updatable defines if the mesh must be flagged as updatable
  14680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14681. * @returns a new Mesh
  14682. */
  14683. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14684. /**
  14685. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14686. * @param name defines the name of the mesh to create
  14687. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14688. * @param scene defines the hosting scene
  14689. * @param updatable defines if the mesh must be flagged as updatable
  14690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14691. * @returns a new Mesh
  14692. */
  14693. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14694. /**
  14695. * Creates a ground mesh.
  14696. * Please consider using the same method from the MeshBuilder class instead
  14697. * @param name defines the name of the mesh to create
  14698. * @param width set the width of the ground
  14699. * @param height set the height of the ground
  14700. * @param subdivisions sets the number of subdivisions per side
  14701. * @param scene defines the hosting scene
  14702. * @param updatable defines if the mesh must be flagged as updatable
  14703. * @returns a new Mesh
  14704. */
  14705. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14706. /**
  14707. * Creates a tiled ground mesh.
  14708. * Please consider using the same method from the MeshBuilder class instead
  14709. * @param name defines the name of the mesh to create
  14710. * @param xmin set the ground minimum X coordinate
  14711. * @param zmin set the ground minimum Y coordinate
  14712. * @param xmax set the ground maximum X coordinate
  14713. * @param zmax set the ground maximum Z coordinate
  14714. * @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
  14715. * @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
  14716. * @param scene defines the hosting scene
  14717. * @param updatable defines if the mesh must be flagged as updatable
  14718. * @returns a new Mesh
  14719. */
  14720. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14721. w: number;
  14722. h: number;
  14723. }, precision: {
  14724. w: number;
  14725. h: number;
  14726. }, scene: Scene, updatable?: boolean): Mesh;
  14727. /**
  14728. * Creates a ground mesh from a height map.
  14729. * Please consider using the same method from the MeshBuilder class instead
  14730. * @see http://doc.babylonjs.com/babylon101/height_map
  14731. * @param name defines the name of the mesh to create
  14732. * @param url sets the URL of the height map image resource
  14733. * @param width set the ground width size
  14734. * @param height set the ground height size
  14735. * @param subdivisions sets the number of subdivision per side
  14736. * @param minHeight is the minimum altitude on the ground
  14737. * @param maxHeight is the maximum altitude on the ground
  14738. * @param scene defines the hosting scene
  14739. * @param updatable defines if the mesh must be flagged as updatable
  14740. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14741. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14742. * @returns a new Mesh
  14743. */
  14744. 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;
  14745. /**
  14746. * Creates a tube mesh.
  14747. * The tube is a parametric shape.
  14748. * It has no predefined shape. Its final shape will depend on the input parameters.
  14749. * Please consider using the same method from the MeshBuilder class instead
  14750. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14751. * @param name defines the name of the mesh to create
  14752. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14753. * @param radius sets the tube radius size
  14754. * @param tessellation is the number of sides on the tubular surface
  14755. * @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
  14756. * @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
  14757. * @param scene defines the hosting scene
  14758. * @param updatable defines if the mesh must be flagged as updatable
  14759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14760. * @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)
  14761. * @returns a new Mesh
  14762. */
  14763. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14764. (i: number, distance: number): number;
  14765. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14766. /**
  14767. * Creates a polyhedron mesh.
  14768. * Please consider using the same method from the MeshBuilder class instead.
  14769. * * 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
  14770. * * The parameter `size` (positive float, default 1) sets the polygon size
  14771. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14772. * * 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`
  14773. * * 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
  14774. * * 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)`)
  14775. * * 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
  14776. * * 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
  14777. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14778. * * If you create a double-sided mesh, you can choose what parts of 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
  14779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14780. * @param name defines the name of the mesh to create
  14781. * @param options defines the options used to create the mesh
  14782. * @param scene defines the hosting scene
  14783. * @returns a new Mesh
  14784. */
  14785. static CreatePolyhedron(name: string, options: {
  14786. type?: number;
  14787. size?: number;
  14788. sizeX?: number;
  14789. sizeY?: number;
  14790. sizeZ?: number;
  14791. custom?: any;
  14792. faceUV?: Vector4[];
  14793. faceColors?: Color4[];
  14794. updatable?: boolean;
  14795. sideOrientation?: number;
  14796. }, scene: Scene): Mesh;
  14797. /**
  14798. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  14799. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  14800. * * 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`)
  14801. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  14802. * * 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
  14803. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14804. * * If you create a double-sided mesh, you can choose what parts of 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
  14805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14806. * @param name defines the name of the mesh
  14807. * @param options defines the options used to create the mesh
  14808. * @param scene defines the hosting scene
  14809. * @returns a new Mesh
  14810. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  14811. */
  14812. static CreateIcoSphere(name: string, options: {
  14813. radius?: number;
  14814. flat?: boolean;
  14815. subdivisions?: number;
  14816. sideOrientation?: number;
  14817. updatable?: boolean;
  14818. }, scene: Scene): Mesh;
  14819. /**
  14820. * Creates a decal mesh.
  14821. * Please consider using the same method from the MeshBuilder class instead.
  14822. * A decal is a mesh usually applied as a model onto the surface of another mesh
  14823. * @param name defines the name of the mesh
  14824. * @param sourceMesh defines the mesh receiving the decal
  14825. * @param position sets the position of the decal in world coordinates
  14826. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  14827. * @param size sets the decal scaling
  14828. * @param angle sets the angle to rotate the decal
  14829. * @returns a new Mesh
  14830. */
  14831. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  14832. /**
  14833. * Prepare internal position array for software CPU skinning
  14834. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  14835. */
  14836. setPositionsForCPUSkinning(): Float32Array;
  14837. /**
  14838. * Prepare internal normal array for software CPU skinning
  14839. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  14840. */
  14841. setNormalsForCPUSkinning(): Float32Array;
  14842. /**
  14843. * Updates the vertex buffer by applying transformation from the bones
  14844. * @param skeleton defines the skeleton to apply to current mesh
  14845. * @returns the current mesh
  14846. */
  14847. applySkeleton(skeleton: Skeleton): Mesh;
  14848. /**
  14849. * 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
  14850. * @param meshes defines the list of meshes to scan
  14851. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  14852. */
  14853. static MinMax(meshes: AbstractMesh[]): {
  14854. min: Vector3;
  14855. max: Vector3;
  14856. };
  14857. /**
  14858. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  14859. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  14860. * @returns a vector3
  14861. */
  14862. static Center(meshesOrMinMaxVector: {
  14863. min: Vector3;
  14864. max: Vector3;
  14865. } | AbstractMesh[]): Vector3;
  14866. /**
  14867. * Merge the array of meshes into a single mesh for performance reasons.
  14868. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  14869. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  14870. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  14871. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  14872. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  14873. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  14874. * @returns a new mesh
  14875. */
  14876. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  14877. /** @hidden */
  14878. addInstance(instance: InstancedMesh): void;
  14879. /** @hidden */
  14880. removeInstance(instance: InstancedMesh): void;
  14881. }
  14882. }
  14883. declare module BABYLON {
  14884. /**
  14885. * Interface used to define Action
  14886. */
  14887. export interface IAction {
  14888. /**
  14889. * Trigger for the action
  14890. */
  14891. trigger: number;
  14892. /** Options of the trigger */
  14893. triggerOptions: any;
  14894. /**
  14895. * Gets the trigger parameters
  14896. * @returns the trigger parameters
  14897. */
  14898. getTriggerParameter(): any;
  14899. /**
  14900. * Internal only - executes current action event
  14901. * @hidden
  14902. */ private _executeCurrent(evt?: ActionEvent): void;
  14903. /**
  14904. * Serialize placeholder for child classes
  14905. * @param parent of child
  14906. * @returns the serialized object
  14907. */
  14908. serialize(parent: any): any;
  14909. /**
  14910. * Internal only
  14911. * @hidden
  14912. */ private _prepare(): void;
  14913. /**
  14914. * Internal only - manager for action
  14915. * @hidden
  14916. */ private _actionManager: AbstractActionManager;
  14917. /**
  14918. * Adds action to chain of actions, may be a DoNothingAction
  14919. * @param action defines the next action to execute
  14920. * @returns The action passed in
  14921. * @see https://www.babylonjs-playground.com/#1T30HR#0
  14922. */
  14923. then(action: IAction): IAction;
  14924. }
  14925. /**
  14926. * The action to be carried out following a trigger
  14927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  14928. */
  14929. export class Action implements IAction {
  14930. /** the trigger, with or without parameters, for the action */
  14931. triggerOptions: any;
  14932. /**
  14933. * Trigger for the action
  14934. */
  14935. trigger: number;
  14936. /**
  14937. * Internal only - manager for action
  14938. * @hidden
  14939. */ private _actionManager: ActionManager;
  14940. private _nextActiveAction;
  14941. private _child;
  14942. private _condition?;
  14943. private _triggerParameter;
  14944. /**
  14945. * An event triggered prior to action being executed.
  14946. */
  14947. onBeforeExecuteObservable: Observable<Action>;
  14948. /**
  14949. * Creates a new Action
  14950. * @param triggerOptions the trigger, with or without parameters, for the action
  14951. * @param condition an optional determinant of action
  14952. */
  14953. constructor(
  14954. /** the trigger, with or without parameters, for the action */
  14955. triggerOptions: any, condition?: Condition);
  14956. /**
  14957. * Internal only
  14958. * @hidden
  14959. */ private _prepare(): void;
  14960. /**
  14961. * Gets the trigger parameters
  14962. * @returns the trigger parameters
  14963. */
  14964. getTriggerParameter(): any;
  14965. /**
  14966. * Internal only - executes current action event
  14967. * @hidden
  14968. */ private _executeCurrent(evt?: ActionEvent): void;
  14969. /**
  14970. * Execute placeholder for child classes
  14971. * @param evt optional action event
  14972. */
  14973. execute(evt?: ActionEvent): void;
  14974. /**
  14975. * Skips to next active action
  14976. */
  14977. skipToNextActiveAction(): void;
  14978. /**
  14979. * Adds action to chain of actions, may be a DoNothingAction
  14980. * @param action defines the next action to execute
  14981. * @returns The action passed in
  14982. * @see https://www.babylonjs-playground.com/#1T30HR#0
  14983. */
  14984. then(action: Action): Action;
  14985. /**
  14986. * Internal only
  14987. * @hidden
  14988. */ private _getProperty(propertyPath: string): string;
  14989. /**
  14990. * Internal only
  14991. * @hidden
  14992. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  14993. /**
  14994. * Serialize placeholder for child classes
  14995. * @param parent of child
  14996. * @returns the serialized object
  14997. */
  14998. serialize(parent: any): any;
  14999. /**
  15000. * Internal only called by serialize
  15001. * @hidden
  15002. */
  15003. protected _serialize(serializedAction: any, parent?: any): any;
  15004. /**
  15005. * Internal only
  15006. * @hidden
  15007. */ private static _SerializeValueAsString: (value: any) => string;
  15008. /**
  15009. * Internal only
  15010. * @hidden
  15011. */ private static _GetTargetProperty: (target: Scene | Node) => {
  15012. name: string;
  15013. targetType: string;
  15014. value: string;
  15015. };
  15016. }
  15017. }
  15018. declare module BABYLON {
  15019. /**
  15020. * A Condition applied to an Action
  15021. */
  15022. export class Condition {
  15023. /**
  15024. * Internal only - manager for action
  15025. * @hidden
  15026. */ private _actionManager: ActionManager;
  15027. /**
  15028. * Internal only
  15029. * @hidden
  15030. */ private _evaluationId: number;
  15031. /**
  15032. * Internal only
  15033. * @hidden
  15034. */ private _currentResult: boolean;
  15035. /**
  15036. * Creates a new Condition
  15037. * @param actionManager the manager of the action the condition is applied to
  15038. */
  15039. constructor(actionManager: ActionManager);
  15040. /**
  15041. * Check if the current condition is valid
  15042. * @returns a boolean
  15043. */
  15044. isValid(): boolean;
  15045. /**
  15046. * Internal only
  15047. * @hidden
  15048. */ private _getProperty(propertyPath: string): string;
  15049. /**
  15050. * Internal only
  15051. * @hidden
  15052. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  15053. /**
  15054. * Serialize placeholder for child classes
  15055. * @returns the serialized object
  15056. */
  15057. serialize(): any;
  15058. /**
  15059. * Internal only
  15060. * @hidden
  15061. */
  15062. protected _serialize(serializedCondition: any): any;
  15063. }
  15064. /**
  15065. * Defines specific conditional operators as extensions of Condition
  15066. */
  15067. export class ValueCondition extends Condition {
  15068. /** path to specify the property of the target the conditional operator uses */
  15069. propertyPath: string;
  15070. /** the value compared by the conditional operator against the current value of the property */
  15071. value: any;
  15072. /** the conditional operator, default ValueCondition.IsEqual */
  15073. operator: number;
  15074. /**
  15075. * Internal only
  15076. * @hidden
  15077. */
  15078. private static _IsEqual;
  15079. /**
  15080. * Internal only
  15081. * @hidden
  15082. */
  15083. private static _IsDifferent;
  15084. /**
  15085. * Internal only
  15086. * @hidden
  15087. */
  15088. private static _IsGreater;
  15089. /**
  15090. * Internal only
  15091. * @hidden
  15092. */
  15093. private static _IsLesser;
  15094. /**
  15095. * returns the number for IsEqual
  15096. */
  15097. static readonly IsEqual: number;
  15098. /**
  15099. * Returns the number for IsDifferent
  15100. */
  15101. static readonly IsDifferent: number;
  15102. /**
  15103. * Returns the number for IsGreater
  15104. */
  15105. static readonly IsGreater: number;
  15106. /**
  15107. * Returns the number for IsLesser
  15108. */
  15109. static readonly IsLesser: number;
  15110. /**
  15111. * Internal only The action manager for the condition
  15112. * @hidden
  15113. */ private _actionManager: ActionManager;
  15114. /**
  15115. * Internal only
  15116. * @hidden
  15117. */
  15118. private _target;
  15119. /**
  15120. * Internal only
  15121. * @hidden
  15122. */
  15123. private _effectiveTarget;
  15124. /**
  15125. * Internal only
  15126. * @hidden
  15127. */
  15128. private _property;
  15129. /**
  15130. * Creates a new ValueCondition
  15131. * @param actionManager manager for the action the condition applies to
  15132. * @param target for the action
  15133. * @param propertyPath path to specify the property of the target the conditional operator uses
  15134. * @param value the value compared by the conditional operator against the current value of the property
  15135. * @param operator the conditional operator, default ValueCondition.IsEqual
  15136. */
  15137. constructor(actionManager: ActionManager, target: any,
  15138. /** path to specify the property of the target the conditional operator uses */
  15139. propertyPath: string,
  15140. /** the value compared by the conditional operator against the current value of the property */
  15141. value: any,
  15142. /** the conditional operator, default ValueCondition.IsEqual */
  15143. operator?: number);
  15144. /**
  15145. * Compares the given value with the property value for the specified conditional operator
  15146. * @returns the result of the comparison
  15147. */
  15148. isValid(): boolean;
  15149. /**
  15150. * Serialize the ValueCondition into a JSON compatible object
  15151. * @returns serialization object
  15152. */
  15153. serialize(): any;
  15154. /**
  15155. * Gets the name of the conditional operator for the ValueCondition
  15156. * @param operator the conditional operator
  15157. * @returns the name
  15158. */
  15159. static GetOperatorName(operator: number): string;
  15160. }
  15161. /**
  15162. * Defines a predicate condition as an extension of Condition
  15163. */
  15164. export class PredicateCondition extends Condition {
  15165. /** defines the predicate function used to validate the condition */
  15166. predicate: () => boolean;
  15167. /**
  15168. * Internal only - manager for action
  15169. * @hidden
  15170. */ private _actionManager: ActionManager;
  15171. /**
  15172. * Creates a new PredicateCondition
  15173. * @param actionManager manager for the action the condition applies to
  15174. * @param predicate defines the predicate function used to validate the condition
  15175. */
  15176. constructor(actionManager: ActionManager,
  15177. /** defines the predicate function used to validate the condition */
  15178. predicate: () => boolean);
  15179. /**
  15180. * @returns the validity of the predicate condition
  15181. */
  15182. isValid(): boolean;
  15183. }
  15184. /**
  15185. * Defines a state condition as an extension of Condition
  15186. */
  15187. export class StateCondition extends Condition {
  15188. /** Value to compare with target state */
  15189. value: string;
  15190. /**
  15191. * Internal only - manager for action
  15192. * @hidden
  15193. */ private _actionManager: ActionManager;
  15194. /**
  15195. * Internal only
  15196. * @hidden
  15197. */
  15198. private _target;
  15199. /**
  15200. * Creates a new StateCondition
  15201. * @param actionManager manager for the action the condition applies to
  15202. * @param target of the condition
  15203. * @param value to compare with target state
  15204. */
  15205. constructor(actionManager: ActionManager, target: any,
  15206. /** Value to compare with target state */
  15207. value: string);
  15208. /**
  15209. * Gets a boolean indicating if the current condition is met
  15210. * @returns the validity of the state
  15211. */
  15212. isValid(): boolean;
  15213. /**
  15214. * Serialize the StateCondition into a JSON compatible object
  15215. * @returns serialization object
  15216. */
  15217. serialize(): any;
  15218. }
  15219. }
  15220. declare module BABYLON {
  15221. /**
  15222. * This defines an action responsible to toggle a boolean once triggered.
  15223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15224. */
  15225. export class SwitchBooleanAction extends Action {
  15226. /**
  15227. * The path to the boolean property in the target object
  15228. */
  15229. propertyPath: string;
  15230. private _target;
  15231. private _effectiveTarget;
  15232. private _property;
  15233. /**
  15234. * Instantiate the action
  15235. * @param triggerOptions defines the trigger options
  15236. * @param target defines the object containing the boolean
  15237. * @param propertyPath defines the path to the boolean property in the target object
  15238. * @param condition defines the trigger related conditions
  15239. */
  15240. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15241. /** @hidden */ private _prepare(): void;
  15242. /**
  15243. * Execute the action toggle the boolean value.
  15244. */
  15245. execute(): void;
  15246. /**
  15247. * Serializes the actions and its related information.
  15248. * @param parent defines the object to serialize in
  15249. * @returns the serialized object
  15250. */
  15251. serialize(parent: any): any;
  15252. }
  15253. /**
  15254. * This defines an action responsible to set a the state field of the target
  15255. * to a desired value once triggered.
  15256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15257. */
  15258. export class SetStateAction extends Action {
  15259. /**
  15260. * The value to store in the state field.
  15261. */
  15262. value: string;
  15263. private _target;
  15264. /**
  15265. * Instantiate the action
  15266. * @param triggerOptions defines the trigger options
  15267. * @param target defines the object containing the state property
  15268. * @param value defines the value to store in the state field
  15269. * @param condition defines the trigger related conditions
  15270. */
  15271. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15272. /**
  15273. * Execute the action and store the value on the target state property.
  15274. */
  15275. execute(): void;
  15276. /**
  15277. * Serializes the actions and its related information.
  15278. * @param parent defines the object to serialize in
  15279. * @returns the serialized object
  15280. */
  15281. serialize(parent: any): any;
  15282. }
  15283. /**
  15284. * This defines an action responsible to set a property of the target
  15285. * to a desired value once triggered.
  15286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15287. */
  15288. export class SetValueAction extends Action {
  15289. /**
  15290. * The path of the property to set in the target.
  15291. */
  15292. propertyPath: string;
  15293. /**
  15294. * The value to set in the property
  15295. */
  15296. value: any;
  15297. private _target;
  15298. private _effectiveTarget;
  15299. private _property;
  15300. /**
  15301. * Instantiate the action
  15302. * @param triggerOptions defines the trigger options
  15303. * @param target defines the object containing the property
  15304. * @param propertyPath defines the path of the property to set in the target
  15305. * @param value defines the value to set in the property
  15306. * @param condition defines the trigger related conditions
  15307. */
  15308. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15309. /** @hidden */ private _prepare(): void;
  15310. /**
  15311. * Execute the action and set the targetted property to the desired value.
  15312. */
  15313. execute(): void;
  15314. /**
  15315. * Serializes the actions and its related information.
  15316. * @param parent defines the object to serialize in
  15317. * @returns the serialized object
  15318. */
  15319. serialize(parent: any): any;
  15320. }
  15321. /**
  15322. * This defines an action responsible to increment the target value
  15323. * to a desired value once triggered.
  15324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15325. */
  15326. export class IncrementValueAction extends Action {
  15327. /**
  15328. * The path of the property to increment in the target.
  15329. */
  15330. propertyPath: string;
  15331. /**
  15332. * The value we should increment the property by.
  15333. */
  15334. value: any;
  15335. private _target;
  15336. private _effectiveTarget;
  15337. private _property;
  15338. /**
  15339. * Instantiate the action
  15340. * @param triggerOptions defines the trigger options
  15341. * @param target defines the object containing the property
  15342. * @param propertyPath defines the path of the property to increment in the target
  15343. * @param value defines the value value we should increment the property by
  15344. * @param condition defines the trigger related conditions
  15345. */
  15346. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15347. /** @hidden */ private _prepare(): void;
  15348. /**
  15349. * Execute the action and increment the target of the value amount.
  15350. */
  15351. execute(): void;
  15352. /**
  15353. * Serializes the actions and its related information.
  15354. * @param parent defines the object to serialize in
  15355. * @returns the serialized object
  15356. */
  15357. serialize(parent: any): any;
  15358. }
  15359. /**
  15360. * This defines an action responsible to start an animation once triggered.
  15361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15362. */
  15363. export class PlayAnimationAction extends Action {
  15364. /**
  15365. * Where the animation should start (animation frame)
  15366. */
  15367. from: number;
  15368. /**
  15369. * Where the animation should stop (animation frame)
  15370. */
  15371. to: number;
  15372. /**
  15373. * Define if the animation should loop or stop after the first play.
  15374. */
  15375. loop?: boolean;
  15376. private _target;
  15377. /**
  15378. * Instantiate the action
  15379. * @param triggerOptions defines the trigger options
  15380. * @param target defines the target animation or animation name
  15381. * @param from defines from where the animation should start (animation frame)
  15382. * @param end defines where the animation should stop (animation frame)
  15383. * @param loop defines if the animation should loop or stop after the first play
  15384. * @param condition defines the trigger related conditions
  15385. */
  15386. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15387. /** @hidden */ private _prepare(): void;
  15388. /**
  15389. * Execute the action and play the animation.
  15390. */
  15391. execute(): void;
  15392. /**
  15393. * Serializes the actions and its related information.
  15394. * @param parent defines the object to serialize in
  15395. * @returns the serialized object
  15396. */
  15397. serialize(parent: any): any;
  15398. }
  15399. /**
  15400. * This defines an action responsible to stop an animation once triggered.
  15401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15402. */
  15403. export class StopAnimationAction extends Action {
  15404. private _target;
  15405. /**
  15406. * Instantiate the action
  15407. * @param triggerOptions defines the trigger options
  15408. * @param target defines the target animation or animation name
  15409. * @param condition defines the trigger related conditions
  15410. */
  15411. constructor(triggerOptions: any, target: any, condition?: Condition);
  15412. /** @hidden */ private _prepare(): void;
  15413. /**
  15414. * Execute the action and stop the animation.
  15415. */
  15416. execute(): void;
  15417. /**
  15418. * Serializes the actions and its related information.
  15419. * @param parent defines the object to serialize in
  15420. * @returns the serialized object
  15421. */
  15422. serialize(parent: any): any;
  15423. }
  15424. /**
  15425. * This defines an action responsible that does nothing once triggered.
  15426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15427. */
  15428. export class DoNothingAction extends Action {
  15429. /**
  15430. * Instantiate the action
  15431. * @param triggerOptions defines the trigger options
  15432. * @param condition defines the trigger related conditions
  15433. */
  15434. constructor(triggerOptions?: any, condition?: Condition);
  15435. /**
  15436. * Execute the action and do nothing.
  15437. */
  15438. execute(): void;
  15439. /**
  15440. * Serializes the actions and its related information.
  15441. * @param parent defines the object to serialize in
  15442. * @returns the serialized object
  15443. */
  15444. serialize(parent: any): any;
  15445. }
  15446. /**
  15447. * This defines an action responsible to trigger several actions once triggered.
  15448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15449. */
  15450. export class CombineAction extends Action {
  15451. /**
  15452. * The list of aggregated animations to run.
  15453. */
  15454. children: Action[];
  15455. /**
  15456. * Instantiate the action
  15457. * @param triggerOptions defines the trigger options
  15458. * @param children defines the list of aggregated animations to run
  15459. * @param condition defines the trigger related conditions
  15460. */
  15461. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15462. /** @hidden */ private _prepare(): void;
  15463. /**
  15464. * Execute the action and executes all the aggregated actions.
  15465. */
  15466. execute(evt: ActionEvent): void;
  15467. /**
  15468. * Serializes the actions and its related information.
  15469. * @param parent defines the object to serialize in
  15470. * @returns the serialized object
  15471. */
  15472. serialize(parent: any): any;
  15473. }
  15474. /**
  15475. * This defines an action responsible to run code (external event) once triggered.
  15476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15477. */
  15478. export class ExecuteCodeAction extends Action {
  15479. /**
  15480. * The callback function to run.
  15481. */
  15482. func: (evt: ActionEvent) => void;
  15483. /**
  15484. * Instantiate the action
  15485. * @param triggerOptions defines the trigger options
  15486. * @param func defines the callback function to run
  15487. * @param condition defines the trigger related conditions
  15488. */
  15489. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15490. /**
  15491. * Execute the action and run the attached code.
  15492. */
  15493. execute(evt: ActionEvent): void;
  15494. }
  15495. /**
  15496. * This defines an action responsible to set the parent property of the target once triggered.
  15497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15498. */
  15499. export class SetParentAction extends Action {
  15500. private _parent;
  15501. private _target;
  15502. /**
  15503. * Instantiate the action
  15504. * @param triggerOptions defines the trigger options
  15505. * @param target defines the target containing the parent property
  15506. * @param parent defines from where the animation should start (animation frame)
  15507. * @param condition defines the trigger related conditions
  15508. */
  15509. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15510. /** @hidden */ private _prepare(): void;
  15511. /**
  15512. * Execute the action and set the parent property.
  15513. */
  15514. execute(): void;
  15515. /**
  15516. * Serializes the actions and its related information.
  15517. * @param parent defines the object to serialize in
  15518. * @returns the serialized object
  15519. */
  15520. serialize(parent: any): any;
  15521. }
  15522. }
  15523. declare module BABYLON {
  15524. /**
  15525. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15526. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15528. */
  15529. export class ActionManager extends AbstractActionManager {
  15530. /**
  15531. * Nothing
  15532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15533. */
  15534. static readonly NothingTrigger: number;
  15535. /**
  15536. * On pick
  15537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15538. */
  15539. static readonly OnPickTrigger: number;
  15540. /**
  15541. * On left pick
  15542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15543. */
  15544. static readonly OnLeftPickTrigger: number;
  15545. /**
  15546. * On right pick
  15547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15548. */
  15549. static readonly OnRightPickTrigger: number;
  15550. /**
  15551. * On center pick
  15552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15553. */
  15554. static readonly OnCenterPickTrigger: number;
  15555. /**
  15556. * On pick down
  15557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15558. */
  15559. static readonly OnPickDownTrigger: number;
  15560. /**
  15561. * On double pick
  15562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15563. */
  15564. static readonly OnDoublePickTrigger: number;
  15565. /**
  15566. * On pick up
  15567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15568. */
  15569. static readonly OnPickUpTrigger: number;
  15570. /**
  15571. * On pick out.
  15572. * This trigger will only be raised if you also declared a OnPickDown
  15573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15574. */
  15575. static readonly OnPickOutTrigger: number;
  15576. /**
  15577. * On long press
  15578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15579. */
  15580. static readonly OnLongPressTrigger: number;
  15581. /**
  15582. * On pointer over
  15583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15584. */
  15585. static readonly OnPointerOverTrigger: number;
  15586. /**
  15587. * On pointer out
  15588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15589. */
  15590. static readonly OnPointerOutTrigger: number;
  15591. /**
  15592. * On every frame
  15593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15594. */
  15595. static readonly OnEveryFrameTrigger: number;
  15596. /**
  15597. * On intersection enter
  15598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15599. */
  15600. static readonly OnIntersectionEnterTrigger: number;
  15601. /**
  15602. * On intersection exit
  15603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15604. */
  15605. static readonly OnIntersectionExitTrigger: number;
  15606. /**
  15607. * On key down
  15608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15609. */
  15610. static readonly OnKeyDownTrigger: number;
  15611. /**
  15612. * On key up
  15613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15614. */
  15615. static readonly OnKeyUpTrigger: number;
  15616. private _scene;
  15617. /**
  15618. * Creates a new action manager
  15619. * @param scene defines the hosting scene
  15620. */
  15621. constructor(scene: Scene);
  15622. /**
  15623. * Releases all associated resources
  15624. */
  15625. dispose(): void;
  15626. /**
  15627. * Gets hosting scene
  15628. * @returns the hosting scene
  15629. */
  15630. getScene(): Scene;
  15631. /**
  15632. * Does this action manager handles actions of any of the given triggers
  15633. * @param triggers defines the triggers to be tested
  15634. * @return a boolean indicating whether one (or more) of the triggers is handled
  15635. */
  15636. hasSpecificTriggers(triggers: number[]): boolean;
  15637. /**
  15638. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15639. * speed.
  15640. * @param triggerA defines the trigger to be tested
  15641. * @param triggerB defines the trigger to be tested
  15642. * @return a boolean indicating whether one (or more) of the triggers is handled
  15643. */
  15644. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15645. /**
  15646. * Does this action manager handles actions of a given trigger
  15647. * @param trigger defines the trigger to be tested
  15648. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15649. * @return whether the trigger is handled
  15650. */
  15651. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15652. /**
  15653. * Does this action manager has pointer triggers
  15654. */
  15655. readonly hasPointerTriggers: boolean;
  15656. /**
  15657. * Does this action manager has pick triggers
  15658. */
  15659. readonly hasPickTriggers: boolean;
  15660. /**
  15661. * Registers an action to this action manager
  15662. * @param action defines the action to be registered
  15663. * @return the action amended (prepared) after registration
  15664. */
  15665. registerAction(action: IAction): Nullable<IAction>;
  15666. /**
  15667. * Unregisters an action to this action manager
  15668. * @param action defines the action to be unregistered
  15669. * @return a boolean indicating whether the action has been unregistered
  15670. */
  15671. unregisterAction(action: IAction): Boolean;
  15672. /**
  15673. * Process a specific trigger
  15674. * @param trigger defines the trigger to process
  15675. * @param evt defines the event details to be processed
  15676. */
  15677. processTrigger(trigger: number, evt?: IActionEvent): void;
  15678. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  15679. /** @hidden */ private _getProperty(propertyPath: string): string;
  15680. /**
  15681. * Serialize this manager to a JSON object
  15682. * @param name defines the property name to store this manager
  15683. * @returns a JSON representation of this manager
  15684. */
  15685. serialize(name: string): any;
  15686. /**
  15687. * Creates a new ActionManager from a JSON data
  15688. * @param parsedActions defines the JSON data to read from
  15689. * @param object defines the hosting mesh
  15690. * @param scene defines the hosting scene
  15691. */
  15692. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15693. /**
  15694. * Get a trigger name by index
  15695. * @param trigger defines the trigger index
  15696. * @returns a trigger name
  15697. */
  15698. static GetTriggerName(trigger: number): string;
  15699. }
  15700. }
  15701. declare module BABYLON {
  15702. /**
  15703. * Class representing a ray with position and direction
  15704. */
  15705. export class Ray {
  15706. /** origin point */
  15707. origin: Vector3;
  15708. /** direction */
  15709. direction: Vector3;
  15710. /** length of the ray */
  15711. length: number;
  15712. private static readonly TmpVector3;
  15713. private _tmpRay;
  15714. /**
  15715. * Creates a new ray
  15716. * @param origin origin point
  15717. * @param direction direction
  15718. * @param length length of the ray
  15719. */
  15720. constructor(
  15721. /** origin point */
  15722. origin: Vector3,
  15723. /** direction */
  15724. direction: Vector3,
  15725. /** length of the ray */
  15726. length?: number);
  15727. /**
  15728. * Checks if the ray intersects a box
  15729. * @param minimum bound of the box
  15730. * @param maximum bound of the box
  15731. * @param intersectionTreshold extra extend to be added to the box in all direction
  15732. * @returns if the box was hit
  15733. */
  15734. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15735. /**
  15736. * Checks if the ray intersects a box
  15737. * @param box the bounding box to check
  15738. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15739. * @returns if the box was hit
  15740. */
  15741. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15742. /**
  15743. * If the ray hits a sphere
  15744. * @param sphere the bounding sphere to check
  15745. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15746. * @returns true if it hits the sphere
  15747. */
  15748. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15749. /**
  15750. * If the ray hits a triange
  15751. * @param vertex0 triangle vertex
  15752. * @param vertex1 triangle vertex
  15753. * @param vertex2 triangle vertex
  15754. * @returns intersection information if hit
  15755. */
  15756. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15757. /**
  15758. * Checks if ray intersects a plane
  15759. * @param plane the plane to check
  15760. * @returns the distance away it was hit
  15761. */
  15762. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15763. /**
  15764. * Checks if ray intersects a mesh
  15765. * @param mesh the mesh to check
  15766. * @param fastCheck if only the bounding box should checked
  15767. * @returns picking info of the intersecton
  15768. */
  15769. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  15770. /**
  15771. * Checks if ray intersects a mesh
  15772. * @param meshes the meshes to check
  15773. * @param fastCheck if only the bounding box should checked
  15774. * @param results array to store result in
  15775. * @returns Array of picking infos
  15776. */
  15777. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  15778. private _comparePickingInfo;
  15779. private static smallnum;
  15780. private static rayl;
  15781. /**
  15782. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  15783. * @param sega the first point of the segment to test the intersection against
  15784. * @param segb the second point of the segment to test the intersection against
  15785. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  15786. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  15787. */
  15788. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  15789. /**
  15790. * Update the ray from viewport position
  15791. * @param x position
  15792. * @param y y position
  15793. * @param viewportWidth viewport width
  15794. * @param viewportHeight viewport height
  15795. * @param world world matrix
  15796. * @param view view matrix
  15797. * @param projection projection matrix
  15798. * @returns this ray updated
  15799. */
  15800. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15801. /**
  15802. * Creates a ray with origin and direction of 0,0,0
  15803. * @returns the new ray
  15804. */
  15805. static Zero(): Ray;
  15806. /**
  15807. * Creates a new ray from screen space and viewport
  15808. * @param x position
  15809. * @param y y position
  15810. * @param viewportWidth viewport width
  15811. * @param viewportHeight viewport height
  15812. * @param world world matrix
  15813. * @param view view matrix
  15814. * @param projection projection matrix
  15815. * @returns new ray
  15816. */
  15817. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  15818. /**
  15819. * 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
  15820. * transformed to the given world matrix.
  15821. * @param origin The origin point
  15822. * @param end The end point
  15823. * @param world a matrix to transform the ray to. Default is the identity matrix.
  15824. * @returns the new ray
  15825. */
  15826. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  15827. /**
  15828. * Transforms a ray by a matrix
  15829. * @param ray ray to transform
  15830. * @param matrix matrix to apply
  15831. * @returns the resulting new ray
  15832. */
  15833. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  15834. /**
  15835. * Transforms a ray by a matrix
  15836. * @param ray ray to transform
  15837. * @param matrix matrix to apply
  15838. * @param result ray to store result in
  15839. */
  15840. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  15841. /**
  15842. * Unproject a ray from screen space to object space
  15843. * @param sourceX defines the screen space x coordinate to use
  15844. * @param sourceY defines the screen space y coordinate to use
  15845. * @param viewportWidth defines the current width of the viewport
  15846. * @param viewportHeight defines the current height of the viewport
  15847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15848. * @param view defines the view matrix to use
  15849. * @param projection defines the projection matrix to use
  15850. */
  15851. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  15852. }
  15853. /**
  15854. * Type used to define predicate used to select faces when a mesh intersection is detected
  15855. */
  15856. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  15857. interface Scene {
  15858. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  15859. /** @hidden */ private _cachedRayForTransform: Ray;
  15860. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  15861. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  15862. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  15863. }
  15864. }
  15865. declare module BABYLON {
  15866. interface Scene {
  15867. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  15868. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  15869. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  15870. /**
  15871. * All of the sprite managers added to this scene
  15872. * @see http://doc.babylonjs.com/babylon101/sprites
  15873. */
  15874. spriteManagers: Array<ISpriteManager>;
  15875. /**
  15876. * An event triggered when sprites rendering is about to start
  15877. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  15878. */
  15879. onBeforeSpritesRenderingObservable: Observable<Scene>;
  15880. /**
  15881. * An event triggered when sprites rendering is done
  15882. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  15883. */
  15884. onAfterSpritesRenderingObservable: Observable<Scene>;
  15885. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15886. /** Launch a ray to try to pick a sprite in the scene
  15887. * @param x position on screen
  15888. * @param y position on screen
  15889. * @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
  15890. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  15891. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  15892. * @returns a PickingInfo
  15893. */
  15894. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15895. /** Use the given ray to pick a sprite in the scene
  15896. * @param ray The ray (in world space) to use to pick meshes
  15897. * @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
  15898. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  15899. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  15900. * @returns a PickingInfo
  15901. */
  15902. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  15903. /**
  15904. * Force the sprite under the pointer
  15905. * @param sprite defines the sprite to use
  15906. */
  15907. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  15908. /**
  15909. * Gets the sprite under the pointer
  15910. * @returns a Sprite or null if no sprite is under the pointer
  15911. */
  15912. getPointerOverSprite(): Nullable<Sprite>;
  15913. }
  15914. /**
  15915. * Defines the sprite scene component responsible to manage sprites
  15916. * in a given scene.
  15917. */
  15918. export class SpriteSceneComponent implements ISceneComponent {
  15919. /**
  15920. * The component name helpfull to identify the component in the list of scene components.
  15921. */
  15922. readonly name: string;
  15923. /**
  15924. * The scene the component belongs to.
  15925. */
  15926. scene: Scene;
  15927. /** @hidden */
  15928. private _spritePredicate;
  15929. /**
  15930. * Creates a new instance of the component for the given scene
  15931. * @param scene Defines the scene to register the component in
  15932. */
  15933. constructor(scene: Scene);
  15934. /**
  15935. * Registers the component in a given scene
  15936. */
  15937. register(): void;
  15938. /**
  15939. * Rebuilds the elements related to this component in case of
  15940. * context lost for instance.
  15941. */
  15942. rebuild(): void;
  15943. /**
  15944. * Disposes the component and the associated ressources.
  15945. */
  15946. dispose(): void;
  15947. private _pickSpriteButKeepRay;
  15948. private _pointerMove;
  15949. private _pointerDown;
  15950. private _pointerUp;
  15951. }
  15952. }
  15953. declare module BABYLON {
  15954. /** @hidden */
  15955. export var fogFragmentDeclaration: {
  15956. name: string;
  15957. shader: string;
  15958. };
  15959. }
  15960. declare module BABYLON {
  15961. /** @hidden */
  15962. export var fogFragment: {
  15963. name: string;
  15964. shader: string;
  15965. };
  15966. }
  15967. declare module BABYLON {
  15968. /** @hidden */
  15969. export var spritesPixelShader: {
  15970. name: string;
  15971. shader: string;
  15972. };
  15973. }
  15974. declare module BABYLON {
  15975. /** @hidden */
  15976. export var fogVertexDeclaration: {
  15977. name: string;
  15978. shader: string;
  15979. };
  15980. }
  15981. declare module BABYLON {
  15982. /** @hidden */
  15983. export var spritesVertexShader: {
  15984. name: string;
  15985. shader: string;
  15986. };
  15987. }
  15988. declare module BABYLON {
  15989. /**
  15990. * Defines the minimum interface to fullfil in order to be a sprite manager.
  15991. */
  15992. export interface ISpriteManager extends IDisposable {
  15993. /**
  15994. * Restricts the camera to viewing objects with the same layerMask.
  15995. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  15996. */
  15997. layerMask: number;
  15998. /**
  15999. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16000. */
  16001. isPickable: boolean;
  16002. /**
  16003. * Specifies the rendering group id for this mesh (0 by default)
  16004. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16005. */
  16006. renderingGroupId: number;
  16007. /**
  16008. * Defines the list of sprites managed by the manager.
  16009. */
  16010. sprites: Array<Sprite>;
  16011. /**
  16012. * Tests the intersection of a sprite with a specific ray.
  16013. * @param ray The ray we are sending to test the collision
  16014. * @param camera The camera space we are sending rays in
  16015. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16016. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16017. * @returns picking info or null.
  16018. */
  16019. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16020. /**
  16021. * Renders the list of sprites on screen.
  16022. */
  16023. render(): void;
  16024. }
  16025. /**
  16026. * Class used to manage multiple sprites on the same spritesheet
  16027. * @see http://doc.babylonjs.com/babylon101/sprites
  16028. */
  16029. export class SpriteManager implements ISpriteManager {
  16030. /** defines the manager's name */
  16031. name: string;
  16032. /** Gets the list of sprites */
  16033. sprites: Sprite[];
  16034. /** Gets or sets the rendering group id (0 by default) */
  16035. renderingGroupId: number;
  16036. /** Gets or sets camera layer mask */
  16037. layerMask: number;
  16038. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16039. fogEnabled: boolean;
  16040. /** Gets or sets a boolean indicating if the sprites are pickable */
  16041. isPickable: boolean;
  16042. /** Defines the default width of a cell in the spritesheet */
  16043. cellWidth: number;
  16044. /** Defines the default height of a cell in the spritesheet */
  16045. cellHeight: number;
  16046. /**
  16047. * An event triggered when the manager is disposed.
  16048. */
  16049. onDisposeObservable: Observable<SpriteManager>;
  16050. private _onDisposeObserver;
  16051. /**
  16052. * Callback called when the manager is disposed
  16053. */
  16054. onDispose: () => void;
  16055. private _capacity;
  16056. private _spriteTexture;
  16057. private _epsilon;
  16058. private _scene;
  16059. private _vertexData;
  16060. private _buffer;
  16061. private _vertexBuffers;
  16062. private _indexBuffer;
  16063. private _effectBase;
  16064. private _effectFog;
  16065. /**
  16066. * Gets or sets the spritesheet texture
  16067. */
  16068. texture: Texture;
  16069. /**
  16070. * Creates a new sprite manager
  16071. * @param name defines the manager's name
  16072. * @param imgUrl defines the sprite sheet url
  16073. * @param capacity defines the maximum allowed number of sprites
  16074. * @param cellSize defines the size of a sprite cell
  16075. * @param scene defines the hosting scene
  16076. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16077. * @param samplingMode defines the smapling mode to use with spritesheet
  16078. */
  16079. constructor(
  16080. /** defines the manager's name */
  16081. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16082. private _appendSpriteVertex;
  16083. /**
  16084. * Intersects the sprites with a ray
  16085. * @param ray defines the ray to intersect with
  16086. * @param camera defines the current active camera
  16087. * @param predicate defines a predicate used to select candidate sprites
  16088. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16089. * @returns null if no hit or a PickingInfo
  16090. */
  16091. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16092. /**
  16093. * Render all child sprites
  16094. */
  16095. render(): void;
  16096. /**
  16097. * Release associated resources
  16098. */
  16099. dispose(): void;
  16100. }
  16101. }
  16102. declare module BABYLON {
  16103. /**
  16104. * Class used to represent a sprite
  16105. * @see http://doc.babylonjs.com/babylon101/sprites
  16106. */
  16107. export class Sprite {
  16108. /** defines the name */
  16109. name: string;
  16110. /** Gets or sets the current world position */
  16111. position: Vector3;
  16112. /** Gets or sets the main color */
  16113. color: Color4;
  16114. /** Gets or sets the width */
  16115. width: number;
  16116. /** Gets or sets the height */
  16117. height: number;
  16118. /** Gets or sets rotation angle */
  16119. angle: number;
  16120. /** Gets or sets the cell index in the sprite sheet */
  16121. cellIndex: number;
  16122. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16123. invertU: number;
  16124. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16125. invertV: number;
  16126. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16127. disposeWhenFinishedAnimating: boolean;
  16128. /** Gets the list of attached animations */
  16129. animations: Animation[];
  16130. /** Gets or sets a boolean indicating if the sprite can be picked */
  16131. isPickable: boolean;
  16132. /**
  16133. * Gets or sets the associated action manager
  16134. */
  16135. actionManager: Nullable<ActionManager>;
  16136. private _animationStarted;
  16137. private _loopAnimation;
  16138. private _fromIndex;
  16139. private _toIndex;
  16140. private _delay;
  16141. private _direction;
  16142. private _manager;
  16143. private _time;
  16144. private _onAnimationEnd;
  16145. /**
  16146. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16147. */
  16148. isVisible: boolean;
  16149. /**
  16150. * Gets or sets the sprite size
  16151. */
  16152. size: number;
  16153. /**
  16154. * Creates a new Sprite
  16155. * @param name defines the name
  16156. * @param manager defines the manager
  16157. */
  16158. constructor(
  16159. /** defines the name */
  16160. name: string, manager: ISpriteManager);
  16161. /**
  16162. * Starts an animation
  16163. * @param from defines the initial key
  16164. * @param to defines the end key
  16165. * @param loop defines if the animation must loop
  16166. * @param delay defines the start delay (in ms)
  16167. * @param onAnimationEnd defines a callback to call when animation ends
  16168. */
  16169. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16170. /** Stops current animation (if any) */
  16171. stopAnimation(): void;
  16172. /** @hidden */ private _animate(deltaTime: number): void;
  16173. /** Release associated resources */
  16174. dispose(): void;
  16175. }
  16176. }
  16177. declare module BABYLON {
  16178. /**
  16179. * Information about the result of picking within a scene
  16180. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16181. */
  16182. export class PickingInfo {
  16183. /** @hidden */ private _pickingUnavailable: boolean;
  16184. /**
  16185. * If the pick collided with an object
  16186. */
  16187. hit: boolean;
  16188. /**
  16189. * Distance away where the pick collided
  16190. */
  16191. distance: number;
  16192. /**
  16193. * The location of pick collision
  16194. */
  16195. pickedPoint: Nullable<Vector3>;
  16196. /**
  16197. * The mesh corresponding the the pick collision
  16198. */
  16199. pickedMesh: Nullable<AbstractMesh>;
  16200. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16201. bu: number;
  16202. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16203. bv: number;
  16204. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16205. faceId: number;
  16206. /** Id of the the submesh that was picked */
  16207. subMeshId: number;
  16208. /** If a sprite was picked, this will be the sprite the pick collided with */
  16209. pickedSprite: Nullable<Sprite>;
  16210. /**
  16211. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16212. */
  16213. originMesh: Nullable<AbstractMesh>;
  16214. /**
  16215. * The ray that was used to perform the picking.
  16216. */
  16217. ray: Nullable<Ray>;
  16218. /**
  16219. * Gets the normal correspodning to the face the pick collided with
  16220. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16221. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16222. * @returns The normal correspodning to the face the pick collided with
  16223. */
  16224. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16225. /**
  16226. * Gets the texture coordinates of where the pick occured
  16227. * @returns the vector containing the coordnates of the texture
  16228. */
  16229. getTextureCoordinates(): Nullable<Vector2>;
  16230. }
  16231. }
  16232. declare module BABYLON {
  16233. /**
  16234. * Gather the list of pointer event types as constants.
  16235. */
  16236. export class PointerEventTypes {
  16237. /**
  16238. * 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.
  16239. */
  16240. static readonly POINTERDOWN: number;
  16241. /**
  16242. * The pointerup event is fired when a pointer is no longer active.
  16243. */
  16244. static readonly POINTERUP: number;
  16245. /**
  16246. * The pointermove event is fired when a pointer changes coordinates.
  16247. */
  16248. static readonly POINTERMOVE: number;
  16249. /**
  16250. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16251. */
  16252. static readonly POINTERWHEEL: number;
  16253. /**
  16254. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16255. */
  16256. static readonly POINTERPICK: number;
  16257. /**
  16258. * The pointertap event is fired when a the object has been touched and released without drag.
  16259. */
  16260. static readonly POINTERTAP: number;
  16261. /**
  16262. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16263. */
  16264. static readonly POINTERDOUBLETAP: number;
  16265. }
  16266. /**
  16267. * Base class of pointer info types.
  16268. */
  16269. export class PointerInfoBase {
  16270. /**
  16271. * Defines the type of event (PointerEventTypes)
  16272. */
  16273. type: number;
  16274. /**
  16275. * Defines the related dom event
  16276. */
  16277. event: PointerEvent | MouseWheelEvent;
  16278. /**
  16279. * Instantiates the base class of pointers info.
  16280. * @param type Defines the type of event (PointerEventTypes)
  16281. * @param event Defines the related dom event
  16282. */
  16283. constructor(
  16284. /**
  16285. * Defines the type of event (PointerEventTypes)
  16286. */
  16287. type: number,
  16288. /**
  16289. * Defines the related dom event
  16290. */
  16291. event: PointerEvent | MouseWheelEvent);
  16292. }
  16293. /**
  16294. * This class is used to store pointer related info for the onPrePointerObservable event.
  16295. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16296. */
  16297. export class PointerInfoPre extends PointerInfoBase {
  16298. /**
  16299. * Ray from a pointer if availible (eg. 6dof controller)
  16300. */
  16301. ray: Nullable<Ray>;
  16302. /**
  16303. * Defines the local position of the pointer on the canvas.
  16304. */
  16305. localPosition: Vector2;
  16306. /**
  16307. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16308. */
  16309. skipOnPointerObservable: boolean;
  16310. /**
  16311. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16312. * @param type Defines the type of event (PointerEventTypes)
  16313. * @param event Defines the related dom event
  16314. * @param localX Defines the local x coordinates of the pointer when the event occured
  16315. * @param localY Defines the local y coordinates of the pointer when the event occured
  16316. */
  16317. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16318. }
  16319. /**
  16320. * This type contains all the data related to a pointer event in Babylon.js.
  16321. * 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.
  16322. */
  16323. export class PointerInfo extends PointerInfoBase {
  16324. /**
  16325. * Defines the picking info associated to the info (if any)\
  16326. */
  16327. pickInfo: Nullable<PickingInfo>;
  16328. /**
  16329. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16330. * @param type Defines the type of event (PointerEventTypes)
  16331. * @param event Defines the related dom event
  16332. * @param pickInfo Defines the picking info associated to the info (if any)\
  16333. */
  16334. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16335. /**
  16336. * Defines the picking info associated to the info (if any)\
  16337. */
  16338. pickInfo: Nullable<PickingInfo>);
  16339. }
  16340. /**
  16341. * Data relating to a touch event on the screen.
  16342. */
  16343. export interface PointerTouch {
  16344. /**
  16345. * X coordinate of touch.
  16346. */
  16347. x: number;
  16348. /**
  16349. * Y coordinate of touch.
  16350. */
  16351. y: number;
  16352. /**
  16353. * Id of touch. Unique for each finger.
  16354. */
  16355. pointerId: number;
  16356. /**
  16357. * Event type passed from DOM.
  16358. */
  16359. type: any;
  16360. }
  16361. }
  16362. declare module BABYLON {
  16363. /**
  16364. * Manage the mouse inputs to control the movement of a free camera.
  16365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16366. */
  16367. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16368. /**
  16369. * Define if touch is enabled in the mouse input
  16370. */
  16371. touchEnabled: boolean;
  16372. /**
  16373. * Defines the camera the input is attached to.
  16374. */
  16375. camera: FreeCamera;
  16376. /**
  16377. * Defines the buttons associated with the input to handle camera move.
  16378. */
  16379. buttons: number[];
  16380. /**
  16381. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16382. */
  16383. angularSensibility: number;
  16384. private _pointerInput;
  16385. private _onMouseMove;
  16386. private _observer;
  16387. private previousPosition;
  16388. /**
  16389. * Observable for when a pointer move event occurs containing the move offset
  16390. */
  16391. onPointerMovedObservable: Observable<{
  16392. offsetX: number;
  16393. offsetY: number;
  16394. }>;
  16395. /**
  16396. * @hidden
  16397. * If the camera should be rotated automatically based on pointer movement
  16398. */ private _allowCameraRotation: boolean;
  16399. /**
  16400. * Manage the mouse inputs to control the movement of a free camera.
  16401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16402. * @param touchEnabled Defines if touch is enabled or not
  16403. */
  16404. constructor(
  16405. /**
  16406. * Define if touch is enabled in the mouse input
  16407. */
  16408. touchEnabled?: boolean);
  16409. /**
  16410. * Attach the input controls to a specific dom element to get the input from.
  16411. * @param element Defines the element the controls should be listened from
  16412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16413. */
  16414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16415. /**
  16416. * Called on JS contextmenu event.
  16417. * Override this method to provide functionality.
  16418. */
  16419. protected onContextMenu(evt: PointerEvent): void;
  16420. /**
  16421. * Detach the current controls from the specified dom element.
  16422. * @param element Defines the element to stop listening the inputs from
  16423. */
  16424. detachControl(element: Nullable<HTMLElement>): void;
  16425. /**
  16426. * Gets the class name of the current intput.
  16427. * @returns the class name
  16428. */
  16429. getClassName(): string;
  16430. /**
  16431. * Get the friendly name associated with the input class.
  16432. * @returns the input friendly name
  16433. */
  16434. getSimpleName(): string;
  16435. }
  16436. }
  16437. declare module BABYLON {
  16438. /**
  16439. * Manage the touch inputs to control the movement of a free camera.
  16440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16441. */
  16442. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16443. /**
  16444. * Defines the camera the input is attached to.
  16445. */
  16446. camera: FreeCamera;
  16447. /**
  16448. * Defines the touch sensibility for rotation.
  16449. * The higher the faster.
  16450. */
  16451. touchAngularSensibility: number;
  16452. /**
  16453. * Defines the touch sensibility for move.
  16454. * The higher the faster.
  16455. */
  16456. touchMoveSensibility: number;
  16457. private _offsetX;
  16458. private _offsetY;
  16459. private _pointerPressed;
  16460. private _pointerInput;
  16461. private _observer;
  16462. private _onLostFocus;
  16463. /**
  16464. * Attach the input controls to a specific dom element to get the input from.
  16465. * @param element Defines the element the controls should be listened from
  16466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16467. */
  16468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16469. /**
  16470. * Detach the current controls from the specified dom element.
  16471. * @param element Defines the element to stop listening the inputs from
  16472. */
  16473. detachControl(element: Nullable<HTMLElement>): void;
  16474. /**
  16475. * Update the current camera state depending on the inputs that have been used this frame.
  16476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16477. */
  16478. checkInputs(): void;
  16479. /**
  16480. * Gets the class name of the current intput.
  16481. * @returns the class name
  16482. */
  16483. getClassName(): string;
  16484. /**
  16485. * Get the friendly name associated with the input class.
  16486. * @returns the input friendly name
  16487. */
  16488. getSimpleName(): string;
  16489. }
  16490. }
  16491. declare module BABYLON {
  16492. /**
  16493. * Default Inputs manager for the FreeCamera.
  16494. * It groups all the default supported inputs for ease of use.
  16495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16496. */
  16497. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16498. /**
  16499. * @hidden
  16500. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  16501. /**
  16502. * Instantiates a new FreeCameraInputsManager.
  16503. * @param camera Defines the camera the inputs belong to
  16504. */
  16505. constructor(camera: FreeCamera);
  16506. /**
  16507. * Add keyboard input support to the input manager.
  16508. * @returns the current input manager
  16509. */
  16510. addKeyboard(): FreeCameraInputsManager;
  16511. /**
  16512. * Add mouse input support to the input manager.
  16513. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16514. * @returns the current input manager
  16515. */
  16516. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16517. /**
  16518. * Removes the mouse input support from the manager
  16519. * @returns the current input manager
  16520. */
  16521. removeMouse(): FreeCameraInputsManager;
  16522. /**
  16523. * Add touch input support to the input manager.
  16524. * @returns the current input manager
  16525. */
  16526. addTouch(): FreeCameraInputsManager;
  16527. /**
  16528. * Remove all attached input methods from a camera
  16529. */
  16530. clear(): void;
  16531. }
  16532. }
  16533. declare module BABYLON {
  16534. /**
  16535. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16536. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16537. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16538. */
  16539. export class FreeCamera extends TargetCamera {
  16540. /**
  16541. * Define the collision ellipsoid of the camera.
  16542. * This is helpful to simulate a camera body like the player body around the camera
  16543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16544. */
  16545. ellipsoid: Vector3;
  16546. /**
  16547. * Define an offset for the position of the ellipsoid around the camera.
  16548. * This can be helpful to determine the center of the body near the gravity center of the body
  16549. * instead of its head.
  16550. */
  16551. ellipsoidOffset: Vector3;
  16552. /**
  16553. * Enable or disable collisions of the camera with the rest of the scene objects.
  16554. */
  16555. checkCollisions: boolean;
  16556. /**
  16557. * Enable or disable gravity on the camera.
  16558. */
  16559. applyGravity: boolean;
  16560. /**
  16561. * Define the input manager associated to the camera.
  16562. */
  16563. inputs: FreeCameraInputsManager;
  16564. /**
  16565. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16566. * Higher values reduce sensitivity.
  16567. */
  16568. /**
  16569. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16570. * Higher values reduce sensitivity.
  16571. */
  16572. angularSensibility: number;
  16573. /**
  16574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16575. */
  16576. keysUp: number[];
  16577. /**
  16578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16579. */
  16580. keysDown: number[];
  16581. /**
  16582. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16583. */
  16584. keysLeft: number[];
  16585. /**
  16586. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16587. */
  16588. keysRight: number[];
  16589. /**
  16590. * Event raised when the camera collide with a mesh in the scene.
  16591. */
  16592. onCollide: (collidedMesh: AbstractMesh) => void;
  16593. private _collider;
  16594. private _needMoveForGravity;
  16595. private _oldPosition;
  16596. private _diffPosition;
  16597. private _newPosition;
  16598. /** @hidden */ private _localDirection: Vector3;
  16599. /** @hidden */ private _transformedDirection: Vector3;
  16600. /**
  16601. * Instantiates a Free Camera.
  16602. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16603. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16605. * @param name Define the name of the camera in the scene
  16606. * @param position Define the start position of the camera in the scene
  16607. * @param scene Define the scene the camera belongs to
  16608. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16609. */
  16610. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16611. /**
  16612. * Attached controls to the current camera.
  16613. * @param element Defines the element the controls should be listened from
  16614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16615. */
  16616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16617. /**
  16618. * Detach the current controls from the camera.
  16619. * The camera will stop reacting to inputs.
  16620. * @param element Defines the element to stop listening the inputs from
  16621. */
  16622. detachControl(element: HTMLElement): void;
  16623. private _collisionMask;
  16624. /**
  16625. * Define a collision mask to limit the list of object the camera can collide with
  16626. */
  16627. collisionMask: number;
  16628. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  16629. private _onCollisionPositionChange;
  16630. /** @hidden */ private _checkInputs(): void;
  16631. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  16632. /** @hidden */ private _updatePosition(): void;
  16633. /**
  16634. * Destroy the camera and release the current resources hold by it.
  16635. */
  16636. dispose(): void;
  16637. /**
  16638. * Gets the current object class name.
  16639. * @return the class name
  16640. */
  16641. getClassName(): string;
  16642. }
  16643. }
  16644. declare module BABYLON {
  16645. /**
  16646. * Represents a gamepad control stick position
  16647. */
  16648. export class StickValues {
  16649. /**
  16650. * The x component of the control stick
  16651. */
  16652. x: number;
  16653. /**
  16654. * The y component of the control stick
  16655. */
  16656. y: number;
  16657. /**
  16658. * Initializes the gamepad x and y control stick values
  16659. * @param x The x component of the gamepad control stick value
  16660. * @param y The y component of the gamepad control stick value
  16661. */
  16662. constructor(
  16663. /**
  16664. * The x component of the control stick
  16665. */
  16666. x: number,
  16667. /**
  16668. * The y component of the control stick
  16669. */
  16670. y: number);
  16671. }
  16672. /**
  16673. * An interface which manages callbacks for gamepad button changes
  16674. */
  16675. export interface GamepadButtonChanges {
  16676. /**
  16677. * Called when a gamepad has been changed
  16678. */
  16679. changed: boolean;
  16680. /**
  16681. * Called when a gamepad press event has been triggered
  16682. */
  16683. pressChanged: boolean;
  16684. /**
  16685. * Called when a touch event has been triggered
  16686. */
  16687. touchChanged: boolean;
  16688. /**
  16689. * Called when a value has changed
  16690. */
  16691. valueChanged: boolean;
  16692. }
  16693. /**
  16694. * Represents a gamepad
  16695. */
  16696. export class Gamepad {
  16697. /**
  16698. * The id of the gamepad
  16699. */
  16700. id: string;
  16701. /**
  16702. * The index of the gamepad
  16703. */
  16704. index: number;
  16705. /**
  16706. * The browser gamepad
  16707. */
  16708. browserGamepad: any;
  16709. /**
  16710. * Specifies what type of gamepad this represents
  16711. */
  16712. type: number;
  16713. private _leftStick;
  16714. private _rightStick;
  16715. /** @hidden */ private _isConnected: boolean;
  16716. private _leftStickAxisX;
  16717. private _leftStickAxisY;
  16718. private _rightStickAxisX;
  16719. private _rightStickAxisY;
  16720. /**
  16721. * Triggered when the left control stick has been changed
  16722. */
  16723. private _onleftstickchanged;
  16724. /**
  16725. * Triggered when the right control stick has been changed
  16726. */
  16727. private _onrightstickchanged;
  16728. /**
  16729. * Represents a gamepad controller
  16730. */
  16731. static GAMEPAD: number;
  16732. /**
  16733. * Represents a generic controller
  16734. */
  16735. static GENERIC: number;
  16736. /**
  16737. * Represents an XBox controller
  16738. */
  16739. static XBOX: number;
  16740. /**
  16741. * Represents a pose-enabled controller
  16742. */
  16743. static POSE_ENABLED: number;
  16744. /**
  16745. * Specifies whether the left control stick should be Y-inverted
  16746. */
  16747. protected _invertLeftStickY: boolean;
  16748. /**
  16749. * Specifies if the gamepad has been connected
  16750. */
  16751. readonly isConnected: boolean;
  16752. /**
  16753. * Initializes the gamepad
  16754. * @param id The id of the gamepad
  16755. * @param index The index of the gamepad
  16756. * @param browserGamepad The browser gamepad
  16757. * @param leftStickX The x component of the left joystick
  16758. * @param leftStickY The y component of the left joystick
  16759. * @param rightStickX The x component of the right joystick
  16760. * @param rightStickY The y component of the right joystick
  16761. */
  16762. constructor(
  16763. /**
  16764. * The id of the gamepad
  16765. */
  16766. id: string,
  16767. /**
  16768. * The index of the gamepad
  16769. */
  16770. index: number,
  16771. /**
  16772. * The browser gamepad
  16773. */
  16774. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  16775. /**
  16776. * Callback triggered when the left joystick has changed
  16777. * @param callback
  16778. */
  16779. onleftstickchanged(callback: (values: StickValues) => void): void;
  16780. /**
  16781. * Callback triggered when the right joystick has changed
  16782. * @param callback
  16783. */
  16784. onrightstickchanged(callback: (values: StickValues) => void): void;
  16785. /**
  16786. * Gets the left joystick
  16787. */
  16788. /**
  16789. * Sets the left joystick values
  16790. */
  16791. leftStick: StickValues;
  16792. /**
  16793. * Gets the right joystick
  16794. */
  16795. /**
  16796. * Sets the right joystick value
  16797. */
  16798. rightStick: StickValues;
  16799. /**
  16800. * Updates the gamepad joystick positions
  16801. */
  16802. update(): void;
  16803. /**
  16804. * Disposes the gamepad
  16805. */
  16806. dispose(): void;
  16807. }
  16808. /**
  16809. * Represents a generic gamepad
  16810. */
  16811. export class GenericPad extends Gamepad {
  16812. private _buttons;
  16813. private _onbuttondown;
  16814. private _onbuttonup;
  16815. /**
  16816. * Observable triggered when a button has been pressed
  16817. */
  16818. onButtonDownObservable: Observable<number>;
  16819. /**
  16820. * Observable triggered when a button has been released
  16821. */
  16822. onButtonUpObservable: Observable<number>;
  16823. /**
  16824. * Callback triggered when a button has been pressed
  16825. * @param callback Called when a button has been pressed
  16826. */
  16827. onbuttondown(callback: (buttonPressed: number) => void): void;
  16828. /**
  16829. * Callback triggered when a button has been released
  16830. * @param callback Called when a button has been released
  16831. */
  16832. onbuttonup(callback: (buttonReleased: number) => void): void;
  16833. /**
  16834. * Initializes the generic gamepad
  16835. * @param id The id of the generic gamepad
  16836. * @param index The index of the generic gamepad
  16837. * @param browserGamepad The browser gamepad
  16838. */
  16839. constructor(id: string, index: number, browserGamepad: any);
  16840. private _setButtonValue;
  16841. /**
  16842. * Updates the generic gamepad
  16843. */
  16844. update(): void;
  16845. /**
  16846. * Disposes the generic gamepad
  16847. */
  16848. dispose(): void;
  16849. }
  16850. }
  16851. declare module BABYLON {
  16852. /**
  16853. * Defines the types of pose enabled controllers that are supported
  16854. */
  16855. export enum PoseEnabledControllerType {
  16856. /**
  16857. * HTC Vive
  16858. */
  16859. VIVE = 0,
  16860. /**
  16861. * Oculus Rift
  16862. */
  16863. OCULUS = 1,
  16864. /**
  16865. * Windows mixed reality
  16866. */
  16867. WINDOWS = 2,
  16868. /**
  16869. * Samsung gear VR
  16870. */
  16871. GEAR_VR = 3,
  16872. /**
  16873. * Google Daydream
  16874. */
  16875. DAYDREAM = 4,
  16876. /**
  16877. * Generic
  16878. */
  16879. GENERIC = 5
  16880. }
  16881. /**
  16882. * Defines the MutableGamepadButton interface for the state of a gamepad button
  16883. */
  16884. export interface MutableGamepadButton {
  16885. /**
  16886. * Value of the button/trigger
  16887. */
  16888. value: number;
  16889. /**
  16890. * If the button/trigger is currently touched
  16891. */
  16892. touched: boolean;
  16893. /**
  16894. * If the button/trigger is currently pressed
  16895. */
  16896. pressed: boolean;
  16897. }
  16898. /**
  16899. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  16900. * @hidden
  16901. */
  16902. export interface ExtendedGamepadButton extends GamepadButton {
  16903. /**
  16904. * If the button/trigger is currently pressed
  16905. */
  16906. readonly pressed: boolean;
  16907. /**
  16908. * If the button/trigger is currently touched
  16909. */
  16910. readonly touched: boolean;
  16911. /**
  16912. * Value of the button/trigger
  16913. */
  16914. readonly value: number;
  16915. }
  16916. /** @hidden */
  16917. export interface _GamePadFactory {
  16918. /**
  16919. * Returns wether or not the current gamepad can be created for this type of controller.
  16920. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  16921. * @returns true if it can be created, otherwise false
  16922. */
  16923. canCreate(gamepadInfo: any): boolean;
  16924. /**
  16925. * Creates a new instance of the Gamepad.
  16926. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  16927. * @returns the new gamepad instance
  16928. */
  16929. create(gamepadInfo: any): Gamepad;
  16930. }
  16931. /**
  16932. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  16933. */
  16934. export class PoseEnabledControllerHelper {
  16935. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  16936. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  16937. /**
  16938. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  16939. * @param vrGamepad the gamepad to initialized
  16940. * @returns a vr controller of the type the gamepad identified as
  16941. */
  16942. static InitiateController(vrGamepad: any): Gamepad;
  16943. }
  16944. /**
  16945. * Defines the PoseEnabledController object that contains state of a vr capable controller
  16946. */
  16947. export class PoseEnabledController extends Gamepad implements PoseControlled {
  16948. private _deviceRoomPosition;
  16949. private _deviceRoomRotationQuaternion;
  16950. /**
  16951. * The device position in babylon space
  16952. */
  16953. devicePosition: Vector3;
  16954. /**
  16955. * The device rotation in babylon space
  16956. */
  16957. deviceRotationQuaternion: Quaternion;
  16958. /**
  16959. * The scale factor of the device in babylon space
  16960. */
  16961. deviceScaleFactor: number;
  16962. /**
  16963. * (Likely devicePosition should be used instead) The device position in its room space
  16964. */
  16965. position: Vector3;
  16966. /**
  16967. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  16968. */
  16969. rotationQuaternion: Quaternion;
  16970. /**
  16971. * The type of controller (Eg. Windows mixed reality)
  16972. */
  16973. controllerType: PoseEnabledControllerType;
  16974. protected _calculatedPosition: Vector3;
  16975. private _calculatedRotation;
  16976. /**
  16977. * The raw pose from the device
  16978. */
  16979. rawPose: DevicePose;
  16980. private _trackPosition;
  16981. private _maxRotationDistFromHeadset;
  16982. private _draggedRoomRotation;
  16983. /**
  16984. * @hidden
  16985. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  16986. /**
  16987. * Internal, the mesh attached to the controller
  16988. * @hidden
  16989. */ private _mesh: Nullable<AbstractMesh>;
  16990. private _poseControlledCamera;
  16991. private _leftHandSystemQuaternion;
  16992. /**
  16993. * Internal, matrix used to convert room space to babylon space
  16994. * @hidden
  16995. */ private _deviceToWorld: Matrix;
  16996. /**
  16997. * Node to be used when casting a ray from the controller
  16998. * @hidden
  16999. */ private _pointingPoseNode: Nullable<TransformNode>;
  17000. /**
  17001. * Name of the child mesh that can be used to cast a ray from the controller
  17002. */
  17003. static readonly POINTING_POSE: string;
  17004. /**
  17005. * Creates a new PoseEnabledController from a gamepad
  17006. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17007. */
  17008. constructor(browserGamepad: any);
  17009. private _workingMatrix;
  17010. /**
  17011. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17012. */
  17013. update(): void;
  17014. /**
  17015. * Updates only the pose device and mesh without doing any button event checking
  17016. */
  17017. protected _updatePoseAndMesh(): void;
  17018. /**
  17019. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17020. * @param poseData raw pose fromthe device
  17021. */
  17022. updateFromDevice(poseData: DevicePose): void;
  17023. /**
  17024. * @hidden
  17025. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  17026. /**
  17027. * Attaches a mesh to the controller
  17028. * @param mesh the mesh to be attached
  17029. */
  17030. attachToMesh(mesh: AbstractMesh): void;
  17031. /**
  17032. * Attaches the controllers mesh to a camera
  17033. * @param camera the camera the mesh should be attached to
  17034. */
  17035. attachToPoseControlledCamera(camera: TargetCamera): void;
  17036. /**
  17037. * Disposes of the controller
  17038. */
  17039. dispose(): void;
  17040. /**
  17041. * The mesh that is attached to the controller
  17042. */
  17043. readonly mesh: Nullable<AbstractMesh>;
  17044. /**
  17045. * Gets the ray of the controller in the direction the controller is pointing
  17046. * @param length the length the resulting ray should be
  17047. * @returns a ray in the direction the controller is pointing
  17048. */
  17049. getForwardRay(length?: number): Ray;
  17050. }
  17051. }
  17052. declare module BABYLON {
  17053. /**
  17054. * Defines the WebVRController object that represents controllers tracked in 3D space
  17055. */
  17056. export abstract class WebVRController extends PoseEnabledController {
  17057. /**
  17058. * Internal, the default controller model for the controller
  17059. */
  17060. protected _defaultModel: AbstractMesh;
  17061. /**
  17062. * Fired when the trigger state has changed
  17063. */
  17064. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17065. /**
  17066. * Fired when the main button state has changed
  17067. */
  17068. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17069. /**
  17070. * Fired when the secondary button state has changed
  17071. */
  17072. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17073. /**
  17074. * Fired when the pad state has changed
  17075. */
  17076. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17077. /**
  17078. * Fired when controllers stick values have changed
  17079. */
  17080. onPadValuesChangedObservable: Observable<StickValues>;
  17081. /**
  17082. * Array of button availible on the controller
  17083. */
  17084. protected _buttons: Array<MutableGamepadButton>;
  17085. private _onButtonStateChange;
  17086. /**
  17087. * Fired when a controller button's state has changed
  17088. * @param callback the callback containing the button that was modified
  17089. */
  17090. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17091. /**
  17092. * X and Y axis corresponding to the controllers joystick
  17093. */
  17094. pad: StickValues;
  17095. /**
  17096. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17097. */
  17098. hand: string;
  17099. /**
  17100. * The default controller model for the controller
  17101. */
  17102. readonly defaultModel: AbstractMesh;
  17103. /**
  17104. * Creates a new WebVRController from a gamepad
  17105. * @param vrGamepad the gamepad that the WebVRController should be created from
  17106. */
  17107. constructor(vrGamepad: any);
  17108. /**
  17109. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17110. */
  17111. update(): void;
  17112. /**
  17113. * Function to be called when a button is modified
  17114. */
  17115. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17116. /**
  17117. * Loads a mesh and attaches it to the controller
  17118. * @param scene the scene the mesh should be added to
  17119. * @param meshLoaded callback for when the mesh has been loaded
  17120. */
  17121. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17122. private _setButtonValue;
  17123. private _changes;
  17124. private _checkChanges;
  17125. /**
  17126. * Disposes of th webVRCOntroller
  17127. */
  17128. dispose(): void;
  17129. }
  17130. }
  17131. declare module BABYLON {
  17132. /**
  17133. * The HemisphericLight simulates the ambient environment light,
  17134. * so the passed direction is the light reflection direction, not the incoming direction.
  17135. */
  17136. export class HemisphericLight extends Light {
  17137. /**
  17138. * The groundColor is the light in the opposite direction to the one specified during creation.
  17139. * 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.
  17140. */
  17141. groundColor: Color3;
  17142. /**
  17143. * The light reflection direction, not the incoming direction.
  17144. */
  17145. direction: Vector3;
  17146. /**
  17147. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17148. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17149. * The HemisphericLight can't cast shadows.
  17150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17151. * @param name The friendly name of the light
  17152. * @param direction The direction of the light reflection
  17153. * @param scene The scene the light belongs to
  17154. */
  17155. constructor(name: string, direction: Vector3, scene: Scene);
  17156. protected _buildUniformLayout(): void;
  17157. /**
  17158. * Returns the string "HemisphericLight".
  17159. * @return The class name
  17160. */
  17161. getClassName(): string;
  17162. /**
  17163. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17164. * Returns the updated direction.
  17165. * @param target The target the direction should point to
  17166. * @return The computed direction
  17167. */
  17168. setDirectionToTarget(target: Vector3): Vector3;
  17169. /**
  17170. * Returns the shadow generator associated to the light.
  17171. * @returns Always null for hemispheric lights because it does not support shadows.
  17172. */
  17173. getShadowGenerator(): Nullable<IShadowGenerator>;
  17174. /**
  17175. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17176. * @param effect The effect to update
  17177. * @param lightIndex The index of the light in the effect to update
  17178. * @returns The hemispheric light
  17179. */
  17180. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17181. /**
  17182. * Computes the world matrix of the node
  17183. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17184. * @param useWasUpdatedFlag defines a reserved property
  17185. * @returns the world matrix
  17186. */
  17187. computeWorldMatrix(): Matrix;
  17188. /**
  17189. * Returns the integer 3.
  17190. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17191. */
  17192. getTypeID(): number;
  17193. /**
  17194. * Prepares the list of defines specific to the light type.
  17195. * @param defines the list of defines
  17196. * @param lightIndex defines the index of the light for the effect
  17197. */
  17198. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17199. }
  17200. }
  17201. declare module BABYLON {
  17202. /** @hidden */
  17203. export var vrMultiviewToSingleviewPixelShader: {
  17204. name: string;
  17205. shader: string;
  17206. };
  17207. }
  17208. declare module BABYLON {
  17209. /**
  17210. * Renders to multiple views with a single draw call
  17211. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17212. */
  17213. export class MultiviewRenderTarget extends RenderTargetTexture {
  17214. /**
  17215. * Creates a multiview render target
  17216. * @param scene scene used with the render target
  17217. * @param size the size of the render target (used for each view)
  17218. */
  17219. constructor(scene: Scene, size?: number | {
  17220. width: number;
  17221. height: number;
  17222. } | {
  17223. ratio: number;
  17224. });
  17225. /**
  17226. * @hidden
  17227. * @param faceIndex the face index, if its a cube texture
  17228. */ private _bindFrameBuffer(faceIndex?: number): void;
  17229. /**
  17230. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17231. * @returns the view count
  17232. */
  17233. getViewCount(): number;
  17234. }
  17235. }
  17236. declare module BABYLON {
  17237. interface Engine {
  17238. /**
  17239. * Creates a new multiview render target
  17240. * @param width defines the width of the texture
  17241. * @param height defines the height of the texture
  17242. * @returns the created multiview texture
  17243. */
  17244. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17245. /**
  17246. * Binds a multiview framebuffer to be drawn to
  17247. * @param multiviewTexture texture to bind
  17248. */
  17249. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17250. }
  17251. interface Camera {
  17252. /**
  17253. * @hidden
  17254. * 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)
  17255. */ private _useMultiviewToSingleView: boolean;
  17256. /**
  17257. * @hidden
  17258. * 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)
  17259. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  17260. /**
  17261. * @hidden
  17262. * ensures the multiview texture of the camera exists and has the specified width/height
  17263. * @param width height to set on the multiview texture
  17264. * @param height width to set on the multiview texture
  17265. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17266. }
  17267. interface Scene {
  17268. /** @hidden */ private _transformMatrixR: Matrix;
  17269. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  17270. /** @hidden */ private _createMultiviewUbo(): void;
  17271. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17272. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  17273. }
  17274. }
  17275. declare module BABYLON {
  17276. /**
  17277. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17278. * This will not be used for webXR as it supports displaying texture arrays directly
  17279. */
  17280. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17281. /**
  17282. * Initializes a VRMultiviewToSingleview
  17283. * @param name name of the post process
  17284. * @param camera camera to be applied to
  17285. * @param scaleFactor scaling factor to the size of the output texture
  17286. */
  17287. constructor(name: string, camera: Camera, scaleFactor: number);
  17288. }
  17289. }
  17290. declare module BABYLON {
  17291. interface Engine {
  17292. /** @hidden */ private _vrDisplay: any;
  17293. /** @hidden */ private _vrSupported: boolean;
  17294. /** @hidden */ private _oldSize: Size;
  17295. /** @hidden */ private _oldHardwareScaleFactor: number;
  17296. /** @hidden */ private _vrExclusivePointerMode: boolean;
  17297. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17298. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  17299. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  17300. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  17301. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  17302. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  17303. /**
  17304. * Observable signaled when VR display mode changes
  17305. */
  17306. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17307. /**
  17308. * Observable signaled when VR request present is complete
  17309. */
  17310. onVRRequestPresentComplete: Observable<boolean>;
  17311. /**
  17312. * Observable signaled when VR request present starts
  17313. */
  17314. onVRRequestPresentStart: Observable<Engine>;
  17315. /**
  17316. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17317. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17318. */
  17319. isInVRExclusivePointerMode: boolean;
  17320. /**
  17321. * Gets a boolean indicating if a webVR device was detected
  17322. * @returns true if a webVR device was detected
  17323. */
  17324. isVRDevicePresent(): boolean;
  17325. /**
  17326. * Gets the current webVR device
  17327. * @returns the current webVR device (or null)
  17328. */
  17329. getVRDevice(): any;
  17330. /**
  17331. * Initializes a webVR display and starts listening to display change events
  17332. * The onVRDisplayChangedObservable will be notified upon these changes
  17333. * @returns A promise containing a VRDisplay and if vr is supported
  17334. */
  17335. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17336. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17337. /**
  17338. * Call this function to switch to webVR mode
  17339. * Will do nothing if webVR is not supported or if there is no webVR device
  17340. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17341. */
  17342. enableVR(): void;
  17343. /** @hidden */ private _onVRFullScreenTriggered(): void;
  17344. }
  17345. }
  17346. declare module BABYLON {
  17347. /**
  17348. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17349. * IMPORTANT!! The data is right-hand data.
  17350. * @export
  17351. * @interface DevicePose
  17352. */
  17353. export interface DevicePose {
  17354. /**
  17355. * The position of the device, values in array are [x,y,z].
  17356. */
  17357. readonly position: Nullable<Float32Array>;
  17358. /**
  17359. * The linearVelocity of the device, values in array are [x,y,z].
  17360. */
  17361. readonly linearVelocity: Nullable<Float32Array>;
  17362. /**
  17363. * The linearAcceleration of the device, values in array are [x,y,z].
  17364. */
  17365. readonly linearAcceleration: Nullable<Float32Array>;
  17366. /**
  17367. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17368. */
  17369. readonly orientation: Nullable<Float32Array>;
  17370. /**
  17371. * The angularVelocity of the device, values in array are [x,y,z].
  17372. */
  17373. readonly angularVelocity: Nullable<Float32Array>;
  17374. /**
  17375. * The angularAcceleration of the device, values in array are [x,y,z].
  17376. */
  17377. readonly angularAcceleration: Nullable<Float32Array>;
  17378. }
  17379. /**
  17380. * Interface representing a pose controlled object in Babylon.
  17381. * A pose controlled object has both regular pose values as well as pose values
  17382. * from an external device such as a VR head mounted display
  17383. */
  17384. export interface PoseControlled {
  17385. /**
  17386. * The position of the object in babylon space.
  17387. */
  17388. position: Vector3;
  17389. /**
  17390. * The rotation quaternion of the object in babylon space.
  17391. */
  17392. rotationQuaternion: Quaternion;
  17393. /**
  17394. * The position of the device in babylon space.
  17395. */
  17396. devicePosition?: Vector3;
  17397. /**
  17398. * The rotation quaternion of the device in babylon space.
  17399. */
  17400. deviceRotationQuaternion: Quaternion;
  17401. /**
  17402. * The raw pose coming from the device.
  17403. */
  17404. rawPose: Nullable<DevicePose>;
  17405. /**
  17406. * The scale of the device to be used when translating from device space to babylon space.
  17407. */
  17408. deviceScaleFactor: number;
  17409. /**
  17410. * Updates the poseControlled values based on the input device pose.
  17411. * @param poseData the pose data to update the object with
  17412. */
  17413. updateFromDevice(poseData: DevicePose): void;
  17414. }
  17415. /**
  17416. * Set of options to customize the webVRCamera
  17417. */
  17418. export interface WebVROptions {
  17419. /**
  17420. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17421. */
  17422. trackPosition?: boolean;
  17423. /**
  17424. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17425. */
  17426. positionScale?: number;
  17427. /**
  17428. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17429. */
  17430. displayName?: string;
  17431. /**
  17432. * Should the native controller meshes be initialized. (default: true)
  17433. */
  17434. controllerMeshes?: boolean;
  17435. /**
  17436. * Creating a default HemiLight only on controllers. (default: true)
  17437. */
  17438. defaultLightingOnControllers?: boolean;
  17439. /**
  17440. * If you don't want to use the default VR button of the helper. (default: false)
  17441. */
  17442. useCustomVRButton?: boolean;
  17443. /**
  17444. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17445. */
  17446. customVRButton?: HTMLButtonElement;
  17447. /**
  17448. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17449. */
  17450. rayLength?: number;
  17451. /**
  17452. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17453. */
  17454. defaultHeight?: number;
  17455. /**
  17456. * If multiview should be used if availible (default: false)
  17457. */
  17458. useMultiview?: boolean;
  17459. }
  17460. /**
  17461. * This represents a WebVR camera.
  17462. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17463. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17464. */
  17465. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17466. private webVROptions;
  17467. /**
  17468. * @hidden
  17469. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17470. */ private _vrDevice: any;
  17471. /**
  17472. * The rawPose of the vrDevice.
  17473. */
  17474. rawPose: Nullable<DevicePose>;
  17475. private _onVREnabled;
  17476. private _specsVersion;
  17477. private _attached;
  17478. private _frameData;
  17479. protected _descendants: Array<Node>;
  17480. private _deviceRoomPosition;
  17481. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  17482. private _standingMatrix;
  17483. /**
  17484. * Represents device position in babylon space.
  17485. */
  17486. devicePosition: Vector3;
  17487. /**
  17488. * Represents device rotation in babylon space.
  17489. */
  17490. deviceRotationQuaternion: Quaternion;
  17491. /**
  17492. * The scale of the device to be used when translating from device space to babylon space.
  17493. */
  17494. deviceScaleFactor: number;
  17495. private _deviceToWorld;
  17496. private _worldToDevice;
  17497. /**
  17498. * References to the webVR controllers for the vrDevice.
  17499. */
  17500. controllers: Array<WebVRController>;
  17501. /**
  17502. * Emits an event when a controller is attached.
  17503. */
  17504. onControllersAttachedObservable: Observable<WebVRController[]>;
  17505. /**
  17506. * Emits an event when a controller's mesh has been loaded;
  17507. */
  17508. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17509. /**
  17510. * Emits an event when the HMD's pose has been updated.
  17511. */
  17512. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17513. private _poseSet;
  17514. /**
  17515. * If the rig cameras be used as parent instead of this camera.
  17516. */
  17517. rigParenting: boolean;
  17518. private _lightOnControllers;
  17519. private _defaultHeight?;
  17520. /**
  17521. * Instantiates a WebVRFreeCamera.
  17522. * @param name The name of the WebVRFreeCamera
  17523. * @param position The starting anchor position for the camera
  17524. * @param scene The scene the camera belongs to
  17525. * @param webVROptions a set of customizable options for the webVRCamera
  17526. */
  17527. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17528. /**
  17529. * Gets the device distance from the ground in meters.
  17530. * @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.
  17531. */
  17532. deviceDistanceToRoomGround(): number;
  17533. /**
  17534. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17535. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17536. */
  17537. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17538. /**
  17539. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17540. * @returns A promise with a boolean set to if the standing matrix is supported.
  17541. */
  17542. useStandingMatrixAsync(): Promise<boolean>;
  17543. /**
  17544. * Disposes the camera
  17545. */
  17546. dispose(): void;
  17547. /**
  17548. * Gets a vrController by name.
  17549. * @param name The name of the controller to retreive
  17550. * @returns the controller matching the name specified or null if not found
  17551. */
  17552. getControllerByName(name: string): Nullable<WebVRController>;
  17553. private _leftController;
  17554. /**
  17555. * The controller corresponding to the users left hand.
  17556. */
  17557. readonly leftController: Nullable<WebVRController>;
  17558. private _rightController;
  17559. /**
  17560. * The controller corresponding to the users right hand.
  17561. */
  17562. readonly rightController: Nullable<WebVRController>;
  17563. /**
  17564. * Casts a ray forward from the vrCamera's gaze.
  17565. * @param length Length of the ray (default: 100)
  17566. * @returns the ray corresponding to the gaze
  17567. */
  17568. getForwardRay(length?: number): Ray;
  17569. /**
  17570. * @hidden
  17571. * Updates the camera based on device's frame data
  17572. */ private _checkInputs(): void;
  17573. /**
  17574. * Updates the poseControlled values based on the input device pose.
  17575. * @param poseData Pose coming from the device
  17576. */
  17577. updateFromDevice(poseData: DevicePose): void;
  17578. private _htmlElementAttached;
  17579. private _detachIfAttached;
  17580. /**
  17581. * WebVR's attach control will start broadcasting frames to the device.
  17582. * Note that in certain browsers (chrome for example) this function must be called
  17583. * within a user-interaction callback. Example:
  17584. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17585. *
  17586. * @param element html element to attach the vrDevice to
  17587. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17588. */
  17589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17590. /**
  17591. * Detaches the camera from the html element and disables VR
  17592. *
  17593. * @param element html element to detach from
  17594. */
  17595. detachControl(element: HTMLElement): void;
  17596. /**
  17597. * @returns the name of this class
  17598. */
  17599. getClassName(): string;
  17600. /**
  17601. * Calls resetPose on the vrDisplay
  17602. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17603. */
  17604. resetToCurrentRotation(): void;
  17605. /**
  17606. * @hidden
  17607. * Updates the rig cameras (left and right eye)
  17608. */ private _updateRigCameras(): void;
  17609. private _workingVector;
  17610. private _oneVector;
  17611. private _workingMatrix;
  17612. private updateCacheCalled;
  17613. private _correctPositionIfNotTrackPosition;
  17614. /**
  17615. * @hidden
  17616. * Updates the cached values of the camera
  17617. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17618. */ private _updateCache(ignoreParentClass?: boolean): void;
  17619. /**
  17620. * @hidden
  17621. * Get current device position in babylon world
  17622. */ private _computeDevicePosition(): void;
  17623. /**
  17624. * Updates the current device position and rotation in the babylon world
  17625. */
  17626. update(): void;
  17627. /**
  17628. * @hidden
  17629. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17630. * @returns an identity matrix
  17631. */ private _getViewMatrix(): Matrix;
  17632. private _tmpMatrix;
  17633. /**
  17634. * This function is called by the two RIG cameras.
  17635. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17636. * @hidden
  17637. */ private _getWebVRViewMatrix(): Matrix;
  17638. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  17639. private _onGamepadConnectedObserver;
  17640. private _onGamepadDisconnectedObserver;
  17641. private _updateCacheWhenTrackingDisabledObserver;
  17642. /**
  17643. * Initializes the controllers and their meshes
  17644. */
  17645. initControllers(): void;
  17646. }
  17647. }
  17648. declare module BABYLON {
  17649. /**
  17650. * Size options for a post process
  17651. */
  17652. export type PostProcessOptions = {
  17653. width: number;
  17654. height: number;
  17655. };
  17656. /**
  17657. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17658. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17659. */
  17660. export class PostProcess {
  17661. /** Name of the PostProcess. */
  17662. name: string;
  17663. /**
  17664. * Gets or sets the unique id of the post process
  17665. */
  17666. uniqueId: number;
  17667. /**
  17668. * Width of the texture to apply the post process on
  17669. */
  17670. width: number;
  17671. /**
  17672. * Height of the texture to apply the post process on
  17673. */
  17674. height: number;
  17675. /**
  17676. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17677. * @hidden
  17678. */ private _outputTexture: Nullable<InternalTexture>;
  17679. /**
  17680. * Sampling mode used by the shader
  17681. * See https://doc.babylonjs.com/classes/3.1/texture
  17682. */
  17683. renderTargetSamplingMode: number;
  17684. /**
  17685. * Clear color to use when screen clearing
  17686. */
  17687. clearColor: Color4;
  17688. /**
  17689. * If the buffer needs to be cleared before applying the post process. (default: true)
  17690. * Should be set to false if shader will overwrite all previous pixels.
  17691. */
  17692. autoClear: boolean;
  17693. /**
  17694. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17695. */
  17696. alphaMode: number;
  17697. /**
  17698. * Sets the setAlphaBlendConstants of the babylon engine
  17699. */
  17700. alphaConstants: Color4;
  17701. /**
  17702. * Animations to be used for the post processing
  17703. */
  17704. animations: Animation[];
  17705. /**
  17706. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17707. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  17708. */
  17709. enablePixelPerfectMode: boolean;
  17710. /**
  17711. * Force the postprocess to be applied without taking in account viewport
  17712. */
  17713. forceFullscreenViewport: boolean;
  17714. /**
  17715. * List of inspectable custom properties (used by the Inspector)
  17716. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17717. */
  17718. inspectableCustomProperties: IInspectable[];
  17719. /**
  17720. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  17721. *
  17722. * | Value | Type | Description |
  17723. * | ----- | ----------------------------------- | ----------- |
  17724. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  17725. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  17726. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  17727. *
  17728. */
  17729. scaleMode: number;
  17730. /**
  17731. * Force textures to be a power of two (default: false)
  17732. */
  17733. alwaysForcePOT: boolean;
  17734. private _samples;
  17735. /**
  17736. * Number of sample textures (default: 1)
  17737. */
  17738. samples: number;
  17739. /**
  17740. * Modify the scale of the post process to be the same as the viewport (default: false)
  17741. */
  17742. adaptScaleToCurrentViewport: boolean;
  17743. private _camera;
  17744. private _scene;
  17745. private _engine;
  17746. private _options;
  17747. private _reusable;
  17748. private _textureType;
  17749. /**
  17750. * Smart array of input and output textures for the post process.
  17751. * @hidden
  17752. */ private _textures: SmartArray<InternalTexture>;
  17753. /**
  17754. * The index in _textures that corresponds to the output texture.
  17755. * @hidden
  17756. */ private _currentRenderTextureInd: number;
  17757. private _effect;
  17758. private _samplers;
  17759. private _fragmentUrl;
  17760. private _vertexUrl;
  17761. private _parameters;
  17762. private _scaleRatio;
  17763. protected _indexParameters: any;
  17764. private _shareOutputWithPostProcess;
  17765. private _texelSize;
  17766. private _forcedOutputTexture;
  17767. /**
  17768. * Returns the fragment url or shader name used in the post process.
  17769. * @returns the fragment url or name in the shader store.
  17770. */
  17771. getEffectName(): string;
  17772. /**
  17773. * An event triggered when the postprocess is activated.
  17774. */
  17775. onActivateObservable: Observable<Camera>;
  17776. private _onActivateObserver;
  17777. /**
  17778. * A function that is added to the onActivateObservable
  17779. */
  17780. onActivate: Nullable<(camera: Camera) => void>;
  17781. /**
  17782. * An event triggered when the postprocess changes its size.
  17783. */
  17784. onSizeChangedObservable: Observable<PostProcess>;
  17785. private _onSizeChangedObserver;
  17786. /**
  17787. * A function that is added to the onSizeChangedObservable
  17788. */
  17789. onSizeChanged: (postProcess: PostProcess) => void;
  17790. /**
  17791. * An event triggered when the postprocess applies its effect.
  17792. */
  17793. onApplyObservable: Observable<Effect>;
  17794. private _onApplyObserver;
  17795. /**
  17796. * A function that is added to the onApplyObservable
  17797. */
  17798. onApply: (effect: Effect) => void;
  17799. /**
  17800. * An event triggered before rendering the postprocess
  17801. */
  17802. onBeforeRenderObservable: Observable<Effect>;
  17803. private _onBeforeRenderObserver;
  17804. /**
  17805. * A function that is added to the onBeforeRenderObservable
  17806. */
  17807. onBeforeRender: (effect: Effect) => void;
  17808. /**
  17809. * An event triggered after rendering the postprocess
  17810. */
  17811. onAfterRenderObservable: Observable<Effect>;
  17812. private _onAfterRenderObserver;
  17813. /**
  17814. * A function that is added to the onAfterRenderObservable
  17815. */
  17816. onAfterRender: (efect: Effect) => void;
  17817. /**
  17818. * 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
  17819. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  17820. */
  17821. inputTexture: InternalTexture;
  17822. /**
  17823. * Gets the camera which post process is applied to.
  17824. * @returns The camera the post process is applied to.
  17825. */
  17826. getCamera(): Camera;
  17827. /**
  17828. * Gets the texel size of the postprocess.
  17829. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  17830. */
  17831. readonly texelSize: Vector2;
  17832. /**
  17833. * Creates a new instance PostProcess
  17834. * @param name The name of the PostProcess.
  17835. * @param fragmentUrl The url of the fragment shader to be used.
  17836. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  17837. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  17838. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17839. * @param camera The camera to apply the render pass to.
  17840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17841. * @param engine The engine which the post process will be applied. (default: current engine)
  17842. * @param reusable If the post process can be reused on the same frame. (default: false)
  17843. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  17844. * @param textureType Type of textures used when performing the post process. (default: 0)
  17845. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  17846. * @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
  17847. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  17848. */
  17849. constructor(
  17850. /** Name of the PostProcess. */
  17851. 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);
  17852. /**
  17853. * Gets a string idenfifying the name of the class
  17854. * @returns "PostProcess" string
  17855. */
  17856. getClassName(): string;
  17857. /**
  17858. * Gets the engine which this post process belongs to.
  17859. * @returns The engine the post process was enabled with.
  17860. */
  17861. getEngine(): Engine;
  17862. /**
  17863. * The effect that is created when initializing the post process.
  17864. * @returns The created effect corresponding the the postprocess.
  17865. */
  17866. getEffect(): Effect;
  17867. /**
  17868. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  17869. * @param postProcess The post process to share the output with.
  17870. * @returns This post process.
  17871. */
  17872. shareOutputWith(postProcess: PostProcess): PostProcess;
  17873. /**
  17874. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  17875. * This should be called if the post process that shares output with this post process is disabled/disposed.
  17876. */
  17877. useOwnOutput(): void;
  17878. /**
  17879. * Updates the effect with the current post process compile time values and recompiles the shader.
  17880. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  17881. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  17882. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  17883. * @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
  17884. * @param onCompiled Called when the shader has been compiled.
  17885. * @param onError Called if there is an error when compiling a shader.
  17886. */
  17887. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17888. /**
  17889. * The post process is reusable if it can be used multiple times within one frame.
  17890. * @returns If the post process is reusable
  17891. */
  17892. isReusable(): boolean;
  17893. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  17894. markTextureDirty(): void;
  17895. /**
  17896. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  17897. * 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.
  17898. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  17899. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  17900. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  17901. * @returns The target texture that was bound to be written to.
  17902. */
  17903. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  17904. /**
  17905. * If the post process is supported.
  17906. */
  17907. readonly isSupported: boolean;
  17908. /**
  17909. * The aspect ratio of the output texture.
  17910. */
  17911. readonly aspectRatio: number;
  17912. /**
  17913. * Get a value indicating if the post-process is ready to be used
  17914. * @returns true if the post-process is ready (shader is compiled)
  17915. */
  17916. isReady(): boolean;
  17917. /**
  17918. * Binds all textures and uniforms to the shader, this will be run on every pass.
  17919. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  17920. */
  17921. apply(): Nullable<Effect>;
  17922. private _disposeTextures;
  17923. /**
  17924. * Disposes the post process.
  17925. * @param camera The camera to dispose the post process on.
  17926. */
  17927. dispose(camera?: Camera): void;
  17928. }
  17929. }
  17930. declare module BABYLON {
  17931. /** @hidden */
  17932. export var kernelBlurVaryingDeclaration: {
  17933. name: string;
  17934. shader: string;
  17935. };
  17936. }
  17937. declare module BABYLON {
  17938. /** @hidden */
  17939. export var kernelBlurFragment: {
  17940. name: string;
  17941. shader: string;
  17942. };
  17943. }
  17944. declare module BABYLON {
  17945. /** @hidden */
  17946. export var kernelBlurFragment2: {
  17947. name: string;
  17948. shader: string;
  17949. };
  17950. }
  17951. declare module BABYLON {
  17952. /** @hidden */
  17953. export var kernelBlurPixelShader: {
  17954. name: string;
  17955. shader: string;
  17956. };
  17957. }
  17958. declare module BABYLON {
  17959. /** @hidden */
  17960. export var kernelBlurVertex: {
  17961. name: string;
  17962. shader: string;
  17963. };
  17964. }
  17965. declare module BABYLON {
  17966. /** @hidden */
  17967. export var kernelBlurVertexShader: {
  17968. name: string;
  17969. shader: string;
  17970. };
  17971. }
  17972. declare module BABYLON {
  17973. /**
  17974. * The Blur Post Process which blurs an image based on a kernel and direction.
  17975. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  17976. */
  17977. export class BlurPostProcess extends PostProcess {
  17978. /** The direction in which to blur the image. */
  17979. direction: Vector2;
  17980. private blockCompilation;
  17981. protected _kernel: number;
  17982. protected _idealKernel: number;
  17983. protected _packedFloat: boolean;
  17984. private _staticDefines;
  17985. /**
  17986. * Sets the length in pixels of the blur sample region
  17987. */
  17988. /**
  17989. * Gets the length in pixels of the blur sample region
  17990. */
  17991. kernel: number;
  17992. /**
  17993. * Sets wether or not the blur needs to unpack/repack floats
  17994. */
  17995. /**
  17996. * Gets wether or not the blur is unpacking/repacking floats
  17997. */
  17998. packedFloat: boolean;
  17999. /**
  18000. * Creates a new instance BlurPostProcess
  18001. * @param name The name of the effect.
  18002. * @param direction The direction in which to blur the image.
  18003. * @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.
  18004. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18005. * @param camera The camera to apply the render pass to.
  18006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18007. * @param engine The engine which the post process will be applied. (default: current engine)
  18008. * @param reusable If the post process can be reused on the same frame. (default: false)
  18009. * @param textureType Type of textures used when performing the post process. (default: 0)
  18010. * @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)
  18011. */
  18012. constructor(name: string,
  18013. /** The direction in which to blur the image. */
  18014. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18015. /**
  18016. * Updates the effect with the current post process compile time values and recompiles the shader.
  18017. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18018. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18019. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18020. * @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
  18021. * @param onCompiled Called when the shader has been compiled.
  18022. * @param onError Called if there is an error when compiling a shader.
  18023. */
  18024. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18025. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18026. /**
  18027. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18028. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18029. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18030. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18031. * The gaps between physical kernels are compensated for in the weighting of the samples
  18032. * @param idealKernel Ideal blur kernel.
  18033. * @return Nearest best kernel.
  18034. */
  18035. protected _nearestBestKernel(idealKernel: number): number;
  18036. /**
  18037. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18038. * @param x The point on the Gaussian distribution to sample.
  18039. * @return the value of the Gaussian function at x.
  18040. */
  18041. protected _gaussianWeight(x: number): number;
  18042. /**
  18043. * Generates a string that can be used as a floating point number in GLSL.
  18044. * @param x Value to print.
  18045. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18046. * @return GLSL float string.
  18047. */
  18048. protected _glslFloat(x: number, decimalFigures?: number): string;
  18049. }
  18050. }
  18051. declare module BABYLON {
  18052. /**
  18053. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18054. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18055. * You can then easily use it as a reflectionTexture on a flat surface.
  18056. * In case the surface is not a plane, please consider relying on reflection probes.
  18057. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18058. */
  18059. export class MirrorTexture extends RenderTargetTexture {
  18060. private scene;
  18061. /**
  18062. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18063. * 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.
  18064. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18065. */
  18066. mirrorPlane: Plane;
  18067. /**
  18068. * Define the blur ratio used to blur the reflection if needed.
  18069. */
  18070. blurRatio: number;
  18071. /**
  18072. * Define the adaptive blur kernel used to blur the reflection if needed.
  18073. * This will autocompute the closest best match for the `blurKernel`
  18074. */
  18075. adaptiveBlurKernel: number;
  18076. /**
  18077. * Define the blur kernel used to blur the reflection if needed.
  18078. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18079. */
  18080. blurKernel: number;
  18081. /**
  18082. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18083. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18084. */
  18085. blurKernelX: number;
  18086. /**
  18087. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18088. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18089. */
  18090. blurKernelY: number;
  18091. private _autoComputeBlurKernel;
  18092. protected _onRatioRescale(): void;
  18093. private _updateGammaSpace;
  18094. private _imageProcessingConfigChangeObserver;
  18095. private _transformMatrix;
  18096. private _mirrorMatrix;
  18097. private _savedViewMatrix;
  18098. private _blurX;
  18099. private _blurY;
  18100. private _adaptiveBlurKernel;
  18101. private _blurKernelX;
  18102. private _blurKernelY;
  18103. private _blurRatio;
  18104. /**
  18105. * Instantiates a Mirror Texture.
  18106. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18107. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18108. * You can then easily use it as a reflectionTexture on a flat surface.
  18109. * In case the surface is not a plane, please consider relying on reflection probes.
  18110. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18111. * @param name
  18112. * @param size
  18113. * @param scene
  18114. * @param generateMipMaps
  18115. * @param type
  18116. * @param samplingMode
  18117. * @param generateDepthBuffer
  18118. */
  18119. constructor(name: string, size: number | {
  18120. width: number;
  18121. height: number;
  18122. } | {
  18123. ratio: number;
  18124. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18125. private _preparePostProcesses;
  18126. /**
  18127. * Clone the mirror texture.
  18128. * @returns the cloned texture
  18129. */
  18130. clone(): MirrorTexture;
  18131. /**
  18132. * Serialize the texture to a JSON representation you could use in Parse later on
  18133. * @returns the serialized JSON representation
  18134. */
  18135. serialize(): any;
  18136. /**
  18137. * Dispose the texture and release its associated resources.
  18138. */
  18139. dispose(): void;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18145. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18146. */
  18147. export class Texture extends BaseTexture {
  18148. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18149. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18150. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18151. /** nearest is mag = nearest and min = nearest and mip = linear */
  18152. static readonly NEAREST_SAMPLINGMODE: number;
  18153. /** nearest is mag = nearest and min = nearest and mip = linear */
  18154. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18155. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18156. static readonly BILINEAR_SAMPLINGMODE: number;
  18157. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18158. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18159. /** Trilinear is mag = linear and min = linear and mip = linear */
  18160. static readonly TRILINEAR_SAMPLINGMODE: number;
  18161. /** Trilinear is mag = linear and min = linear and mip = linear */
  18162. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18163. /** mag = nearest and min = nearest and mip = nearest */
  18164. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18165. /** mag = nearest and min = linear and mip = nearest */
  18166. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18167. /** mag = nearest and min = linear and mip = linear */
  18168. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18169. /** mag = nearest and min = linear and mip = none */
  18170. static readonly NEAREST_LINEAR: number;
  18171. /** mag = nearest and min = nearest and mip = none */
  18172. static readonly NEAREST_NEAREST: number;
  18173. /** mag = linear and min = nearest and mip = nearest */
  18174. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18175. /** mag = linear and min = nearest and mip = linear */
  18176. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18177. /** mag = linear and min = linear and mip = none */
  18178. static readonly LINEAR_LINEAR: number;
  18179. /** mag = linear and min = nearest and mip = none */
  18180. static readonly LINEAR_NEAREST: number;
  18181. /** Explicit coordinates mode */
  18182. static readonly EXPLICIT_MODE: number;
  18183. /** Spherical coordinates mode */
  18184. static readonly SPHERICAL_MODE: number;
  18185. /** Planar coordinates mode */
  18186. static readonly PLANAR_MODE: number;
  18187. /** Cubic coordinates mode */
  18188. static readonly CUBIC_MODE: number;
  18189. /** Projection coordinates mode */
  18190. static readonly PROJECTION_MODE: number;
  18191. /** Inverse Cubic coordinates mode */
  18192. static readonly SKYBOX_MODE: number;
  18193. /** Inverse Cubic coordinates mode */
  18194. static readonly INVCUBIC_MODE: number;
  18195. /** Equirectangular coordinates mode */
  18196. static readonly EQUIRECTANGULAR_MODE: number;
  18197. /** Equirectangular Fixed coordinates mode */
  18198. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18199. /** Equirectangular Fixed Mirrored coordinates mode */
  18200. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18201. /** Texture is not repeating outside of 0..1 UVs */
  18202. static readonly CLAMP_ADDRESSMODE: number;
  18203. /** Texture is repeating outside of 0..1 UVs */
  18204. static readonly WRAP_ADDRESSMODE: number;
  18205. /** Texture is repeating and mirrored */
  18206. static readonly MIRROR_ADDRESSMODE: number;
  18207. /**
  18208. * 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
  18209. */
  18210. static UseSerializedUrlIfAny: boolean;
  18211. /**
  18212. * Define the url of the texture.
  18213. */
  18214. url: Nullable<string>;
  18215. /**
  18216. * Define an offset on the texture to offset the u coordinates of the UVs
  18217. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18218. */
  18219. uOffset: number;
  18220. /**
  18221. * Define an offset on the texture to offset the v coordinates of the UVs
  18222. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18223. */
  18224. vOffset: number;
  18225. /**
  18226. * Define an offset on the texture to scale the u coordinates of the UVs
  18227. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18228. */
  18229. uScale: number;
  18230. /**
  18231. * Define an offset on the texture to scale the v coordinates of the UVs
  18232. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18233. */
  18234. vScale: number;
  18235. /**
  18236. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18237. * @see http://doc.babylonjs.com/how_to/more_materials
  18238. */
  18239. uAng: number;
  18240. /**
  18241. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18242. * @see http://doc.babylonjs.com/how_to/more_materials
  18243. */
  18244. vAng: number;
  18245. /**
  18246. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18247. * @see http://doc.babylonjs.com/how_to/more_materials
  18248. */
  18249. wAng: number;
  18250. /**
  18251. * Defines the center of rotation (U)
  18252. */
  18253. uRotationCenter: number;
  18254. /**
  18255. * Defines the center of rotation (V)
  18256. */
  18257. vRotationCenter: number;
  18258. /**
  18259. * Defines the center of rotation (W)
  18260. */
  18261. wRotationCenter: number;
  18262. /**
  18263. * Are mip maps generated for this texture or not.
  18264. */
  18265. readonly noMipmap: boolean;
  18266. /**
  18267. * List of inspectable custom properties (used by the Inspector)
  18268. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18269. */
  18270. inspectableCustomProperties: Nullable<IInspectable[]>;
  18271. private _noMipmap;
  18272. /** @hidden */ private _invertY: boolean;
  18273. private _rowGenerationMatrix;
  18274. private _cachedTextureMatrix;
  18275. private _projectionModeMatrix;
  18276. private _t0;
  18277. private _t1;
  18278. private _t2;
  18279. private _cachedUOffset;
  18280. private _cachedVOffset;
  18281. private _cachedUScale;
  18282. private _cachedVScale;
  18283. private _cachedUAng;
  18284. private _cachedVAng;
  18285. private _cachedWAng;
  18286. private _cachedProjectionMatrixId;
  18287. private _cachedCoordinatesMode;
  18288. /** @hidden */
  18289. protected _initialSamplingMode: number;
  18290. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18291. private _deleteBuffer;
  18292. protected _format: Nullable<number>;
  18293. private _delayedOnLoad;
  18294. private _delayedOnError;
  18295. /**
  18296. * Observable triggered once the texture has been loaded.
  18297. */
  18298. onLoadObservable: Observable<Texture>;
  18299. protected _isBlocking: boolean;
  18300. /**
  18301. * Is the texture preventing material to render while loading.
  18302. * If false, a default texture will be used instead of the loading one during the preparation step.
  18303. */
  18304. isBlocking: boolean;
  18305. /**
  18306. * Get the current sampling mode associated with the texture.
  18307. */
  18308. readonly samplingMode: number;
  18309. /**
  18310. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18311. */
  18312. readonly invertY: boolean;
  18313. /**
  18314. * Instantiates a new texture.
  18315. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18316. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18317. * @param url define the url of the picture to load as a texture
  18318. * @param scene define the scene or engine the texture will belong to
  18319. * @param noMipmap define if the texture will require mip maps or not
  18320. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18321. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18322. * @param onLoad define a callback triggered when the texture has been loaded
  18323. * @param onError define a callback triggered when an error occurred during the loading session
  18324. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18325. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18326. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18327. */
  18328. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18329. /**
  18330. * Update the url (and optional buffer) of this texture if url was null during construction.
  18331. * @param url the url of the texture
  18332. * @param buffer the buffer of the texture (defaults to null)
  18333. * @param onLoad callback called when the texture is loaded (defaults to null)
  18334. */
  18335. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18336. /**
  18337. * Finish the loading sequence of a texture flagged as delayed load.
  18338. * @hidden
  18339. */
  18340. delayLoad(): void;
  18341. private _prepareRowForTextureGeneration;
  18342. /**
  18343. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18344. * @returns the transform matrix of the texture.
  18345. */
  18346. getTextureMatrix(): Matrix;
  18347. /**
  18348. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18349. * @returns The reflection texture transform
  18350. */
  18351. getReflectionTextureMatrix(): Matrix;
  18352. /**
  18353. * Clones the texture.
  18354. * @returns the cloned texture
  18355. */
  18356. clone(): Texture;
  18357. /**
  18358. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18359. * @returns The JSON representation of the texture
  18360. */
  18361. serialize(): any;
  18362. /**
  18363. * Get the current class name of the texture useful for serialization or dynamic coding.
  18364. * @returns "Texture"
  18365. */
  18366. getClassName(): string;
  18367. /**
  18368. * Dispose the texture and release its associated resources.
  18369. */
  18370. dispose(): void;
  18371. /**
  18372. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18373. * @param parsedTexture Define the JSON representation of the texture
  18374. * @param scene Define the scene the parsed texture should be instantiated in
  18375. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18376. * @returns The parsed texture if successful
  18377. */
  18378. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18379. /**
  18380. * Creates a texture from its base 64 representation.
  18381. * @param data Define the base64 payload without the data: prefix
  18382. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18383. * @param scene Define the scene the texture should belong to
  18384. * @param noMipmap Forces the texture to not create mip map information if true
  18385. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18386. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18387. * @param onLoad define a callback triggered when the texture has been loaded
  18388. * @param onError define a callback triggered when an error occurred during the loading session
  18389. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18390. * @returns the created texture
  18391. */
  18392. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18393. /**
  18394. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18395. * @param data Define the base64 payload without the data: prefix
  18396. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18397. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18398. * @param scene Define the scene the texture should belong to
  18399. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18400. * @param noMipmap Forces the texture to not create mip map information if true
  18401. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18402. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18403. * @param onLoad define a callback triggered when the texture has been loaded
  18404. * @param onError define a callback triggered when an error occurred during the loading session
  18405. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18406. * @returns the created texture
  18407. */
  18408. 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;
  18409. }
  18410. }
  18411. declare module BABYLON {
  18412. /**
  18413. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18414. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18415. */
  18416. export class PostProcessManager {
  18417. private _scene;
  18418. private _indexBuffer;
  18419. private _vertexBuffers;
  18420. /**
  18421. * Creates a new instance PostProcess
  18422. * @param scene The scene that the post process is associated with.
  18423. */
  18424. constructor(scene: Scene);
  18425. private _prepareBuffers;
  18426. private _buildIndexBuffer;
  18427. /**
  18428. * Rebuilds the vertex buffers of the manager.
  18429. * @hidden
  18430. */ private _rebuild(): void;
  18431. /**
  18432. * Prepares a frame to be run through a post process.
  18433. * @param sourceTexture The input texture to the post procesess. (default: null)
  18434. * @param postProcesses An array of post processes to be run. (default: null)
  18435. * @returns True if the post processes were able to be run.
  18436. * @hidden
  18437. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18438. /**
  18439. * Manually render a set of post processes to a texture.
  18440. * @param postProcesses An array of post processes to be run.
  18441. * @param targetTexture The target texture to render to.
  18442. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18443. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18444. * @param lodLevel defines which lod of the texture to render to
  18445. */
  18446. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18447. /**
  18448. * Finalize the result of the output of the postprocesses.
  18449. * @param doNotPresent If true the result will not be displayed to the screen.
  18450. * @param targetTexture The target texture to render to.
  18451. * @param faceIndex The index of the face to bind the target texture to.
  18452. * @param postProcesses The array of post processes to render.
  18453. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18454. * @hidden
  18455. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18456. /**
  18457. * Disposes of the post process manager.
  18458. */
  18459. dispose(): void;
  18460. }
  18461. }
  18462. declare module BABYLON {
  18463. interface AbstractScene {
  18464. /**
  18465. * The list of procedural textures added to the scene
  18466. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18467. */
  18468. proceduralTextures: Array<ProceduralTexture>;
  18469. }
  18470. /**
  18471. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18472. * in a given scene.
  18473. */
  18474. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18475. /**
  18476. * The component name helpfull to identify the component in the list of scene components.
  18477. */
  18478. readonly name: string;
  18479. /**
  18480. * The scene the component belongs to.
  18481. */
  18482. scene: Scene;
  18483. /**
  18484. * Creates a new instance of the component for the given scene
  18485. * @param scene Defines the scene to register the component in
  18486. */
  18487. constructor(scene: Scene);
  18488. /**
  18489. * Registers the component in a given scene
  18490. */
  18491. register(): void;
  18492. /**
  18493. * Rebuilds the elements related to this component in case of
  18494. * context lost for instance.
  18495. */
  18496. rebuild(): void;
  18497. /**
  18498. * Disposes the component and the associated ressources.
  18499. */
  18500. dispose(): void;
  18501. private _beforeClear;
  18502. }
  18503. }
  18504. declare module BABYLON {
  18505. interface Engine {
  18506. /**
  18507. * Creates a new render target cube texture
  18508. * @param size defines the size of the texture
  18509. * @param options defines the options used to create the texture
  18510. * @returns a new render target cube texture stored in an InternalTexture
  18511. */
  18512. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18513. }
  18514. }
  18515. declare module BABYLON {
  18516. /** @hidden */
  18517. export var proceduralVertexShader: {
  18518. name: string;
  18519. shader: string;
  18520. };
  18521. }
  18522. declare module BABYLON {
  18523. /**
  18524. * 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.
  18525. * This is the base class of any Procedural texture and contains most of the shareable code.
  18526. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18527. */
  18528. export class ProceduralTexture extends Texture {
  18529. isCube: boolean;
  18530. /**
  18531. * Define if the texture is enabled or not (disabled texture will not render)
  18532. */
  18533. isEnabled: boolean;
  18534. /**
  18535. * Define if the texture must be cleared before rendering (default is true)
  18536. */
  18537. autoClear: boolean;
  18538. /**
  18539. * Callback called when the texture is generated
  18540. */
  18541. onGenerated: () => void;
  18542. /**
  18543. * Event raised when the texture is generated
  18544. */
  18545. onGeneratedObservable: Observable<ProceduralTexture>;
  18546. /** @hidden */ private _generateMipMaps: boolean;
  18547. /** @hidden **/ private _effect: Effect;
  18548. /** @hidden */ private _textures: {
  18549. [key: string]: Texture;
  18550. };
  18551. private _size;
  18552. private _currentRefreshId;
  18553. private _refreshRate;
  18554. private _vertexBuffers;
  18555. private _indexBuffer;
  18556. private _uniforms;
  18557. private _samplers;
  18558. private _fragment;
  18559. private _floats;
  18560. private _ints;
  18561. private _floatsArrays;
  18562. private _colors3;
  18563. private _colors4;
  18564. private _vectors2;
  18565. private _vectors3;
  18566. private _matrices;
  18567. private _fallbackTexture;
  18568. private _fallbackTextureUsed;
  18569. private _engine;
  18570. private _cachedDefines;
  18571. private _contentUpdateId;
  18572. private _contentData;
  18573. /**
  18574. * Instantiates a new procedural texture.
  18575. * 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.
  18576. * This is the base class of any Procedural texture and contains most of the shareable code.
  18577. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18578. * @param name Define the name of the texture
  18579. * @param size Define the size of the texture to create
  18580. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18581. * @param scene Define the scene the texture belongs to
  18582. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18583. * @param generateMipMaps Define if the texture should creates mip maps or not
  18584. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18585. */
  18586. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18587. /**
  18588. * The effect that is created when initializing the post process.
  18589. * @returns The created effect corresponding the the postprocess.
  18590. */
  18591. getEffect(): Effect;
  18592. /**
  18593. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18594. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18595. */
  18596. getContent(): Nullable<ArrayBufferView>;
  18597. private _createIndexBuffer;
  18598. /** @hidden */ private _rebuild(): void;
  18599. /**
  18600. * Resets the texture in order to recreate its associated resources.
  18601. * This can be called in case of context loss
  18602. */
  18603. reset(): void;
  18604. protected _getDefines(): string;
  18605. /**
  18606. * Is the texture ready to be used ? (rendered at least once)
  18607. * @returns true if ready, otherwise, false.
  18608. */
  18609. isReady(): boolean;
  18610. /**
  18611. * Resets the refresh counter of the texture and start bak from scratch.
  18612. * Could be useful to regenerate the texture if it is setup to render only once.
  18613. */
  18614. resetRefreshCounter(): void;
  18615. /**
  18616. * Set the fragment shader to use in order to render the texture.
  18617. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18618. */
  18619. setFragment(fragment: any): void;
  18620. /**
  18621. * Define the refresh rate of the texture or the rendering frequency.
  18622. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18623. */
  18624. refreshRate: number;
  18625. /** @hidden */ private _shouldRender(): boolean;
  18626. /**
  18627. * Get the size the texture is rendering at.
  18628. * @returns the size (texture is always squared)
  18629. */
  18630. getRenderSize(): number;
  18631. /**
  18632. * Resize the texture to new value.
  18633. * @param size Define the new size the texture should have
  18634. * @param generateMipMaps Define whether the new texture should create mip maps
  18635. */
  18636. resize(size: number, generateMipMaps: boolean): void;
  18637. private _checkUniform;
  18638. /**
  18639. * Set a texture in the shader program used to render.
  18640. * @param name Define the name of the uniform samplers as defined in the shader
  18641. * @param texture Define the texture to bind to this sampler
  18642. * @return the texture itself allowing "fluent" like uniform updates
  18643. */
  18644. setTexture(name: string, texture: Texture): ProceduralTexture;
  18645. /**
  18646. * Set a float in the shader.
  18647. * @param name Define the name of the uniform as defined in the shader
  18648. * @param value Define the value to give to the uniform
  18649. * @return the texture itself allowing "fluent" like uniform updates
  18650. */
  18651. setFloat(name: string, value: number): ProceduralTexture;
  18652. /**
  18653. * Set a int in the shader.
  18654. * @param name Define the name of the uniform as defined in the shader
  18655. * @param value Define the value to give to the uniform
  18656. * @return the texture itself allowing "fluent" like uniform updates
  18657. */
  18658. setInt(name: string, value: number): ProceduralTexture;
  18659. /**
  18660. * Set an array of floats in the shader.
  18661. * @param name Define the name of the uniform as defined in the shader
  18662. * @param value Define the value to give to the uniform
  18663. * @return the texture itself allowing "fluent" like uniform updates
  18664. */
  18665. setFloats(name: string, value: number[]): ProceduralTexture;
  18666. /**
  18667. * Set a vec3 in the shader from a Color3.
  18668. * @param name Define the name of the uniform as defined in the shader
  18669. * @param value Define the value to give to the uniform
  18670. * @return the texture itself allowing "fluent" like uniform updates
  18671. */
  18672. setColor3(name: string, value: Color3): ProceduralTexture;
  18673. /**
  18674. * Set a vec4 in the shader from a Color4.
  18675. * @param name Define the name of the uniform as defined in the shader
  18676. * @param value Define the value to give to the uniform
  18677. * @return the texture itself allowing "fluent" like uniform updates
  18678. */
  18679. setColor4(name: string, value: Color4): ProceduralTexture;
  18680. /**
  18681. * Set a vec2 in the shader from a Vector2.
  18682. * @param name Define the name of the uniform as defined in the shader
  18683. * @param value Define the value to give to the uniform
  18684. * @return the texture itself allowing "fluent" like uniform updates
  18685. */
  18686. setVector2(name: string, value: Vector2): ProceduralTexture;
  18687. /**
  18688. * Set a vec3 in the shader from a Vector3.
  18689. * @param name Define the name of the uniform as defined in the shader
  18690. * @param value Define the value to give to the uniform
  18691. * @return the texture itself allowing "fluent" like uniform updates
  18692. */
  18693. setVector3(name: string, value: Vector3): ProceduralTexture;
  18694. /**
  18695. * Set a mat4 in the shader from a MAtrix.
  18696. * @param name Define the name of the uniform as defined in the shader
  18697. * @param value Define the value to give to the uniform
  18698. * @return the texture itself allowing "fluent" like uniform updates
  18699. */
  18700. setMatrix(name: string, value: Matrix): ProceduralTexture;
  18701. /**
  18702. * Render the texture to its associated render target.
  18703. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  18704. */
  18705. render(useCameraPostProcess?: boolean): void;
  18706. /**
  18707. * Clone the texture.
  18708. * @returns the cloned texture
  18709. */
  18710. clone(): ProceduralTexture;
  18711. /**
  18712. * Dispose the texture and release its asoociated resources.
  18713. */
  18714. dispose(): void;
  18715. }
  18716. }
  18717. declare module BABYLON {
  18718. /**
  18719. * This represents the base class for particle system in Babylon.
  18720. * 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.
  18721. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18722. * @example https://doc.babylonjs.com/babylon101/particles
  18723. */
  18724. export class BaseParticleSystem {
  18725. /**
  18726. * Source color is added to the destination color without alpha affecting the result
  18727. */
  18728. static BLENDMODE_ONEONE: number;
  18729. /**
  18730. * Blend current color and particle color using particle’s alpha
  18731. */
  18732. static BLENDMODE_STANDARD: number;
  18733. /**
  18734. * Add current color and particle color multiplied by particle’s alpha
  18735. */
  18736. static BLENDMODE_ADD: number;
  18737. /**
  18738. * Multiply current color with particle color
  18739. */
  18740. static BLENDMODE_MULTIPLY: number;
  18741. /**
  18742. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  18743. */
  18744. static BLENDMODE_MULTIPLYADD: number;
  18745. /**
  18746. * List of animations used by the particle system.
  18747. */
  18748. animations: Animation[];
  18749. /**
  18750. * The id of the Particle system.
  18751. */
  18752. id: string;
  18753. /**
  18754. * The friendly name of the Particle system.
  18755. */
  18756. name: string;
  18757. /**
  18758. * The rendering group used by the Particle system to chose when to render.
  18759. */
  18760. renderingGroupId: number;
  18761. /**
  18762. * The emitter represents the Mesh or position we are attaching the particle system to.
  18763. */
  18764. emitter: Nullable<AbstractMesh | Vector3>;
  18765. /**
  18766. * The maximum number of particles to emit per frame
  18767. */
  18768. emitRate: number;
  18769. /**
  18770. * If you want to launch only a few particles at once, that can be done, as well.
  18771. */
  18772. manualEmitCount: number;
  18773. /**
  18774. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18775. */
  18776. updateSpeed: number;
  18777. /**
  18778. * The amount of time the particle system is running (depends of the overall update speed).
  18779. */
  18780. targetStopDuration: number;
  18781. /**
  18782. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18783. */
  18784. disposeOnStop: boolean;
  18785. /**
  18786. * Minimum power of emitting particles.
  18787. */
  18788. minEmitPower: number;
  18789. /**
  18790. * Maximum power of emitting particles.
  18791. */
  18792. maxEmitPower: number;
  18793. /**
  18794. * Minimum life time of emitting particles.
  18795. */
  18796. minLifeTime: number;
  18797. /**
  18798. * Maximum life time of emitting particles.
  18799. */
  18800. maxLifeTime: number;
  18801. /**
  18802. * Minimum Size of emitting particles.
  18803. */
  18804. minSize: number;
  18805. /**
  18806. * Maximum Size of emitting particles.
  18807. */
  18808. maxSize: number;
  18809. /**
  18810. * Minimum scale of emitting particles on X axis.
  18811. */
  18812. minScaleX: number;
  18813. /**
  18814. * Maximum scale of emitting particles on X axis.
  18815. */
  18816. maxScaleX: number;
  18817. /**
  18818. * Minimum scale of emitting particles on Y axis.
  18819. */
  18820. minScaleY: number;
  18821. /**
  18822. * Maximum scale of emitting particles on Y axis.
  18823. */
  18824. maxScaleY: number;
  18825. /**
  18826. * Gets or sets the minimal initial rotation in radians.
  18827. */
  18828. minInitialRotation: number;
  18829. /**
  18830. * Gets or sets the maximal initial rotation in radians.
  18831. */
  18832. maxInitialRotation: number;
  18833. /**
  18834. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18835. */
  18836. minAngularSpeed: number;
  18837. /**
  18838. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18839. */
  18840. maxAngularSpeed: number;
  18841. /**
  18842. * The texture used to render each particle. (this can be a spritesheet)
  18843. */
  18844. particleTexture: Nullable<Texture>;
  18845. /**
  18846. * The layer mask we are rendering the particles through.
  18847. */
  18848. layerMask: number;
  18849. /**
  18850. * This can help using your own shader to render the particle system.
  18851. * The according effect will be created
  18852. */
  18853. customShader: any;
  18854. /**
  18855. * By default particle system starts as soon as they are created. This prevents the
  18856. * automatic start to happen and let you decide when to start emitting particles.
  18857. */
  18858. preventAutoStart: boolean;
  18859. private _noiseTexture;
  18860. /**
  18861. * Gets or sets a texture used to add random noise to particle positions
  18862. */
  18863. noiseTexture: Nullable<ProceduralTexture>;
  18864. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18865. noiseStrength: Vector3;
  18866. /**
  18867. * Callback triggered when the particle animation is ending.
  18868. */
  18869. onAnimationEnd: Nullable<() => void>;
  18870. /**
  18871. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  18872. */
  18873. blendMode: number;
  18874. /**
  18875. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  18876. * to override the particles.
  18877. */
  18878. forceDepthWrite: boolean;
  18879. /** 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 */
  18880. preWarmCycles: number;
  18881. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  18882. preWarmStepOffset: number;
  18883. /**
  18884. * 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)
  18885. */
  18886. spriteCellChangeSpeed: number;
  18887. /**
  18888. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18889. */
  18890. startSpriteCellID: number;
  18891. /**
  18892. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18893. */
  18894. endSpriteCellID: number;
  18895. /**
  18896. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18897. */
  18898. spriteCellWidth: number;
  18899. /**
  18900. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18901. */
  18902. spriteCellHeight: number;
  18903. /**
  18904. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18905. */
  18906. spriteRandomStartCell: boolean;
  18907. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18908. translationPivot: Vector2;
  18909. /** @hidden */
  18910. protected _isAnimationSheetEnabled: boolean;
  18911. /**
  18912. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18913. */
  18914. beginAnimationOnStart: boolean;
  18915. /**
  18916. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18917. */
  18918. beginAnimationFrom: number;
  18919. /**
  18920. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18921. */
  18922. beginAnimationTo: number;
  18923. /**
  18924. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18925. */
  18926. beginAnimationLoop: boolean;
  18927. /**
  18928. * Gets or sets a world offset applied to all particles
  18929. */
  18930. worldOffset: Vector3;
  18931. /**
  18932. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  18933. */
  18934. isAnimationSheetEnabled: boolean;
  18935. /**
  18936. * Get hosting scene
  18937. * @returns the scene
  18938. */
  18939. getScene(): Scene;
  18940. /**
  18941. * You can use gravity if you want to give an orientation to your particles.
  18942. */
  18943. gravity: Vector3;
  18944. protected _colorGradients: Nullable<Array<ColorGradient>>;
  18945. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  18946. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  18947. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  18948. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  18949. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  18950. protected _dragGradients: Nullable<Array<FactorGradient>>;
  18951. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  18952. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  18953. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  18954. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  18955. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  18956. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  18957. /**
  18958. * Defines the delay in milliseconds before starting the system (0 by default)
  18959. */
  18960. startDelay: number;
  18961. /**
  18962. * Gets the current list of drag gradients.
  18963. * You must use addDragGradient and removeDragGradient to udpate this list
  18964. * @returns the list of drag gradients
  18965. */
  18966. getDragGradients(): Nullable<Array<FactorGradient>>;
  18967. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18968. limitVelocityDamping: number;
  18969. /**
  18970. * Gets the current list of limit velocity gradients.
  18971. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18972. * @returns the list of limit velocity gradients
  18973. */
  18974. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Gets the current list of color gradients.
  18977. * You must use addColorGradient and removeColorGradient to udpate this list
  18978. * @returns the list of color gradients
  18979. */
  18980. getColorGradients(): Nullable<Array<ColorGradient>>;
  18981. /**
  18982. * Gets the current list of size gradients.
  18983. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18984. * @returns the list of size gradients
  18985. */
  18986. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18987. /**
  18988. * Gets the current list of color remap gradients.
  18989. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18990. * @returns the list of color remap gradients
  18991. */
  18992. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18993. /**
  18994. * Gets the current list of alpha remap gradients.
  18995. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18996. * @returns the list of alpha remap gradients
  18997. */
  18998. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18999. /**
  19000. * Gets the current list of life time gradients.
  19001. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19002. * @returns the list of life time gradients
  19003. */
  19004. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Gets the current list of angular speed gradients.
  19007. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19008. * @returns the list of angular speed gradients
  19009. */
  19010. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19011. /**
  19012. * Gets the current list of velocity gradients.
  19013. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19014. * @returns the list of velocity gradients
  19015. */
  19016. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19017. /**
  19018. * Gets the current list of start size gradients.
  19019. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19020. * @returns the list of start size gradients
  19021. */
  19022. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19023. /**
  19024. * Gets the current list of emit rate gradients.
  19025. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19026. * @returns the list of emit rate gradients
  19027. */
  19028. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19031. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19032. */
  19033. direction1: Vector3;
  19034. /**
  19035. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19036. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19037. */
  19038. direction2: Vector3;
  19039. /**
  19040. * 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.
  19041. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19042. */
  19043. minEmitBox: Vector3;
  19044. /**
  19045. * 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.
  19046. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19047. */
  19048. maxEmitBox: Vector3;
  19049. /**
  19050. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19051. */
  19052. color1: Color4;
  19053. /**
  19054. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19055. */
  19056. color2: Color4;
  19057. /**
  19058. * Color the particle will have at the end of its lifetime
  19059. */
  19060. colorDead: Color4;
  19061. /**
  19062. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19063. */
  19064. textureMask: Color4;
  19065. /**
  19066. * The particle emitter type defines the emitter used by the particle system.
  19067. * It can be for example box, sphere, or cone...
  19068. */
  19069. particleEmitterType: IParticleEmitterType;
  19070. /** @hidden */ private _isSubEmitter: boolean;
  19071. /**
  19072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19074. */
  19075. billboardMode: number;
  19076. protected _isBillboardBased: boolean;
  19077. /**
  19078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19079. */
  19080. isBillboardBased: boolean;
  19081. /**
  19082. * The scene the particle system belongs to.
  19083. */
  19084. protected _scene: Scene;
  19085. /**
  19086. * Local cache of defines for image processing.
  19087. */
  19088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19089. /**
  19090. * Default configuration related to image processing available in the standard Material.
  19091. */
  19092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19093. /**
  19094. * Gets the image processing configuration used either in this material.
  19095. */
  19096. /**
  19097. * Sets the Default image processing configuration used either in the this material.
  19098. *
  19099. * If sets to null, the scene one is in use.
  19100. */
  19101. imageProcessingConfiguration: ImageProcessingConfiguration;
  19102. /**
  19103. * Attaches a new image processing configuration to the Standard Material.
  19104. * @param configuration
  19105. */
  19106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19107. /** @hidden */
  19108. protected _reset(): void;
  19109. /** @hidden */
  19110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19111. /**
  19112. * Instantiates a particle system.
  19113. * 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.
  19114. * @param name The name of the particle system
  19115. */
  19116. constructor(name: string);
  19117. /**
  19118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19121. * @returns the emitter
  19122. */
  19123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19124. /**
  19125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19126. * @param radius The radius of the hemisphere to emit from
  19127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19128. * @returns the emitter
  19129. */
  19130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19131. /**
  19132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19133. * @param radius The radius of the sphere to emit from
  19134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19135. * @returns the emitter
  19136. */
  19137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19138. /**
  19139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19140. * @param radius The radius of the sphere to emit from
  19141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19143. * @returns the emitter
  19144. */
  19145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19146. /**
  19147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19148. * @param radius The radius of the emission cylinder
  19149. * @param height The height of the emission cylinder
  19150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19152. * @returns the emitter
  19153. */
  19154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19155. /**
  19156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19157. * @param radius The radius of the cylinder to emit from
  19158. * @param height The height of the emission cylinder
  19159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19162. * @returns the emitter
  19163. */
  19164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19165. /**
  19166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19167. * @param radius The radius of the cone to emit from
  19168. * @param angle The base angle of the cone
  19169. * @returns the emitter
  19170. */
  19171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19172. /**
  19173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19178. * @returns the emitter
  19179. */
  19180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19181. }
  19182. }
  19183. declare module BABYLON {
  19184. /**
  19185. * Type of sub emitter
  19186. */
  19187. export enum SubEmitterType {
  19188. /**
  19189. * Attached to the particle over it's lifetime
  19190. */
  19191. ATTACHED = 0,
  19192. /**
  19193. * Created when the particle dies
  19194. */
  19195. END = 1
  19196. }
  19197. /**
  19198. * Sub emitter class used to emit particles from an existing particle
  19199. */
  19200. export class SubEmitter {
  19201. /**
  19202. * the particle system to be used by the sub emitter
  19203. */
  19204. particleSystem: ParticleSystem;
  19205. /**
  19206. * Type of the submitter (Default: END)
  19207. */
  19208. type: SubEmitterType;
  19209. /**
  19210. * 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)
  19211. * Note: This only is supported when using an emitter of type Mesh
  19212. */
  19213. inheritDirection: boolean;
  19214. /**
  19215. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19216. */
  19217. inheritedVelocityAmount: number;
  19218. /**
  19219. * Creates a sub emitter
  19220. * @param particleSystem the particle system to be used by the sub emitter
  19221. */
  19222. constructor(
  19223. /**
  19224. * the particle system to be used by the sub emitter
  19225. */
  19226. particleSystem: ParticleSystem);
  19227. /**
  19228. * Clones the sub emitter
  19229. * @returns the cloned sub emitter
  19230. */
  19231. clone(): SubEmitter;
  19232. /**
  19233. * Serialize current object to a JSON object
  19234. * @returns the serialized object
  19235. */
  19236. serialize(): any;
  19237. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19238. /**
  19239. * Creates a new SubEmitter from a serialized JSON version
  19240. * @param serializationObject defines the JSON object to read from
  19241. * @param scene defines the hosting scene
  19242. * @param rootUrl defines the rootUrl for data loading
  19243. * @returns a new SubEmitter
  19244. */
  19245. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19246. /** Release associated resources */
  19247. dispose(): void;
  19248. }
  19249. }
  19250. declare module BABYLON {
  19251. /** @hidden */
  19252. export var imageProcessingDeclaration: {
  19253. name: string;
  19254. shader: string;
  19255. };
  19256. }
  19257. declare module BABYLON {
  19258. /** @hidden */
  19259. export var imageProcessingFunctions: {
  19260. name: string;
  19261. shader: string;
  19262. };
  19263. }
  19264. declare module BABYLON {
  19265. /** @hidden */
  19266. export var particlesPixelShader: {
  19267. name: string;
  19268. shader: string;
  19269. };
  19270. }
  19271. declare module BABYLON {
  19272. /** @hidden */
  19273. export var particlesVertexShader: {
  19274. name: string;
  19275. shader: string;
  19276. };
  19277. }
  19278. declare module BABYLON {
  19279. /**
  19280. * This represents a particle system in Babylon.
  19281. * 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.
  19282. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19283. * @example https://doc.babylonjs.com/babylon101/particles
  19284. */
  19285. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19286. /**
  19287. * Billboard mode will only apply to Y axis
  19288. */
  19289. static readonly BILLBOARDMODE_Y: number;
  19290. /**
  19291. * Billboard mode will apply to all axes
  19292. */
  19293. static readonly BILLBOARDMODE_ALL: number;
  19294. /**
  19295. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19296. */
  19297. static readonly BILLBOARDMODE_STRETCHED: number;
  19298. /**
  19299. * This function can be defined to provide custom update for active particles.
  19300. * This function will be called instead of regular update (age, position, color, etc.).
  19301. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19302. */
  19303. updateFunction: (particles: Particle[]) => void;
  19304. private _emitterWorldMatrix;
  19305. /**
  19306. * This function can be defined to specify initial direction for every new particle.
  19307. * It by default use the emitterType defined function
  19308. */
  19309. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19310. /**
  19311. * This function can be defined to specify initial position for every new particle.
  19312. * It by default use the emitterType defined function
  19313. */
  19314. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19315. /**
  19316. * @hidden
  19317. */ private _inheritedVelocityOffset: Vector3;
  19318. /**
  19319. * An event triggered when the system is disposed
  19320. */
  19321. onDisposeObservable: Observable<ParticleSystem>;
  19322. private _onDisposeObserver;
  19323. /**
  19324. * Sets a callback that will be triggered when the system is disposed
  19325. */
  19326. onDispose: () => void;
  19327. private _particles;
  19328. private _epsilon;
  19329. private _capacity;
  19330. private _stockParticles;
  19331. private _newPartsExcess;
  19332. private _vertexData;
  19333. private _vertexBuffer;
  19334. private _vertexBuffers;
  19335. private _spriteBuffer;
  19336. private _indexBuffer;
  19337. private _effect;
  19338. private _customEffect;
  19339. private _cachedDefines;
  19340. private _scaledColorStep;
  19341. private _colorDiff;
  19342. private _scaledDirection;
  19343. private _scaledGravity;
  19344. private _currentRenderId;
  19345. private _alive;
  19346. private _useInstancing;
  19347. private _started;
  19348. private _stopped;
  19349. private _actualFrame;
  19350. private _scaledUpdateSpeed;
  19351. private _vertexBufferSize;
  19352. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  19353. /** @hidden */ private _currentEmitRate1: number;
  19354. /** @hidden */ private _currentEmitRate2: number;
  19355. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  19356. /** @hidden */ private _currentStartSize1: number;
  19357. /** @hidden */ private _currentStartSize2: number;
  19358. private readonly _rawTextureWidth;
  19359. private _rampGradientsTexture;
  19360. private _useRampGradients;
  19361. /** Gets or sets a boolean indicating that ramp gradients must be used
  19362. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19363. */
  19364. useRampGradients: boolean;
  19365. /**
  19366. * 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.
  19367. * 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: [])
  19368. */
  19369. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19370. private _subEmitters;
  19371. /**
  19372. * @hidden
  19373. * If the particle systems emitter should be disposed when the particle system is disposed
  19374. */ private _disposeEmitterOnDispose: boolean;
  19375. /**
  19376. * The current active Sub-systems, this property is used by the root particle system only.
  19377. */
  19378. activeSubSystems: Array<ParticleSystem>;
  19379. private _rootParticleSystem;
  19380. /**
  19381. * Gets the current list of active particles
  19382. */
  19383. readonly particles: Particle[];
  19384. /**
  19385. * Returns the string "ParticleSystem"
  19386. * @returns a string containing the class name
  19387. */
  19388. getClassName(): string;
  19389. /**
  19390. * Instantiates a particle system.
  19391. * 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.
  19392. * @param name The name of the particle system
  19393. * @param capacity The max number of particles alive at the same time
  19394. * @param scene The scene the particle system belongs to
  19395. * @param customEffect a custom effect used to change the way particles are rendered by default
  19396. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19397. * @param epsilon Offset used to render the particles
  19398. */
  19399. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19400. private _addFactorGradient;
  19401. private _removeFactorGradient;
  19402. /**
  19403. * Adds a new life time gradient
  19404. * @param gradient defines the gradient to use (between 0 and 1)
  19405. * @param factor defines the life time factor to affect to the specified gradient
  19406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19407. * @returns the current particle system
  19408. */
  19409. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19410. /**
  19411. * Remove a specific life time gradient
  19412. * @param gradient defines the gradient to remove
  19413. * @returns the current particle system
  19414. */
  19415. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19416. /**
  19417. * Adds a new size gradient
  19418. * @param gradient defines the gradient to use (between 0 and 1)
  19419. * @param factor defines the size factor to affect to the specified gradient
  19420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19421. * @returns the current particle system
  19422. */
  19423. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19424. /**
  19425. * Remove a specific size gradient
  19426. * @param gradient defines the gradient to remove
  19427. * @returns the current particle system
  19428. */
  19429. removeSizeGradient(gradient: number): IParticleSystem;
  19430. /**
  19431. * Adds a new color remap gradient
  19432. * @param gradient defines the gradient to use (between 0 and 1)
  19433. * @param min defines the color remap minimal range
  19434. * @param max defines the color remap maximal range
  19435. * @returns the current particle system
  19436. */
  19437. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19438. /**
  19439. * Remove a specific color remap gradient
  19440. * @param gradient defines the gradient to remove
  19441. * @returns the current particle system
  19442. */
  19443. removeColorRemapGradient(gradient: number): IParticleSystem;
  19444. /**
  19445. * Adds a new alpha remap gradient
  19446. * @param gradient defines the gradient to use (between 0 and 1)
  19447. * @param min defines the alpha remap minimal range
  19448. * @param max defines the alpha remap maximal range
  19449. * @returns the current particle system
  19450. */
  19451. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19452. /**
  19453. * Remove a specific alpha remap gradient
  19454. * @param gradient defines the gradient to remove
  19455. * @returns the current particle system
  19456. */
  19457. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19458. /**
  19459. * Adds a new angular speed gradient
  19460. * @param gradient defines the gradient to use (between 0 and 1)
  19461. * @param factor defines the angular speed to affect to the specified gradient
  19462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19463. * @returns the current particle system
  19464. */
  19465. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19466. /**
  19467. * Remove a specific angular speed gradient
  19468. * @param gradient defines the gradient to remove
  19469. * @returns the current particle system
  19470. */
  19471. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19472. /**
  19473. * Adds a new velocity gradient
  19474. * @param gradient defines the gradient to use (between 0 and 1)
  19475. * @param factor defines the velocity to affect to the specified gradient
  19476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19477. * @returns the current particle system
  19478. */
  19479. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19480. /**
  19481. * Remove a specific velocity gradient
  19482. * @param gradient defines the gradient to remove
  19483. * @returns the current particle system
  19484. */
  19485. removeVelocityGradient(gradient: number): IParticleSystem;
  19486. /**
  19487. * Adds a new limit velocity gradient
  19488. * @param gradient defines the gradient to use (between 0 and 1)
  19489. * @param factor defines the limit velocity value to affect to the specified gradient
  19490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19491. * @returns the current particle system
  19492. */
  19493. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19494. /**
  19495. * Remove a specific limit velocity gradient
  19496. * @param gradient defines the gradient to remove
  19497. * @returns the current particle system
  19498. */
  19499. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19500. /**
  19501. * Adds a new drag gradient
  19502. * @param gradient defines the gradient to use (between 0 and 1)
  19503. * @param factor defines the drag value to affect to the specified gradient
  19504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19505. * @returns the current particle system
  19506. */
  19507. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19508. /**
  19509. * Remove a specific drag gradient
  19510. * @param gradient defines the gradient to remove
  19511. * @returns the current particle system
  19512. */
  19513. removeDragGradient(gradient: number): IParticleSystem;
  19514. /**
  19515. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19516. * @param gradient defines the gradient to use (between 0 and 1)
  19517. * @param factor defines the emit rate value to affect to the specified gradient
  19518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19519. * @returns the current particle system
  19520. */
  19521. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19522. /**
  19523. * Remove a specific emit rate gradient
  19524. * @param gradient defines the gradient to remove
  19525. * @returns the current particle system
  19526. */
  19527. removeEmitRateGradient(gradient: number): IParticleSystem;
  19528. /**
  19529. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19530. * @param gradient defines the gradient to use (between 0 and 1)
  19531. * @param factor defines the start size value to affect to the specified gradient
  19532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19533. * @returns the current particle system
  19534. */
  19535. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19536. /**
  19537. * Remove a specific start size gradient
  19538. * @param gradient defines the gradient to remove
  19539. * @returns the current particle system
  19540. */
  19541. removeStartSizeGradient(gradient: number): IParticleSystem;
  19542. private _createRampGradientTexture;
  19543. /**
  19544. * Gets the current list of ramp gradients.
  19545. * You must use addRampGradient and removeRampGradient to udpate this list
  19546. * @returns the list of ramp gradients
  19547. */
  19548. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19549. /**
  19550. * Adds a new ramp gradient used to remap particle colors
  19551. * @param gradient defines the gradient to use (between 0 and 1)
  19552. * @param color defines the color to affect to the specified gradient
  19553. * @returns the current particle system
  19554. */
  19555. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19556. /**
  19557. * Remove a specific ramp gradient
  19558. * @param gradient defines the gradient to remove
  19559. * @returns the current particle system
  19560. */
  19561. removeRampGradient(gradient: number): ParticleSystem;
  19562. /**
  19563. * Adds a new color gradient
  19564. * @param gradient defines the gradient to use (between 0 and 1)
  19565. * @param color1 defines the color to affect to the specified gradient
  19566. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19567. * @returns this particle system
  19568. */
  19569. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19570. /**
  19571. * Remove a specific color gradient
  19572. * @param gradient defines the gradient to remove
  19573. * @returns this particle system
  19574. */
  19575. removeColorGradient(gradient: number): IParticleSystem;
  19576. private _fetchR;
  19577. protected _reset(): void;
  19578. private _resetEffect;
  19579. private _createVertexBuffers;
  19580. private _createIndexBuffer;
  19581. /**
  19582. * Gets the maximum number of particles active at the same time.
  19583. * @returns The max number of active particles.
  19584. */
  19585. getCapacity(): number;
  19586. /**
  19587. * Gets whether there are still active particles in the system.
  19588. * @returns True if it is alive, otherwise false.
  19589. */
  19590. isAlive(): boolean;
  19591. /**
  19592. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19593. * @returns True if it has been started, otherwise false.
  19594. */
  19595. isStarted(): boolean;
  19596. private _prepareSubEmitterInternalArray;
  19597. /**
  19598. * Starts the particle system and begins to emit
  19599. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19600. */
  19601. start(delay?: number): void;
  19602. /**
  19603. * Stops the particle system.
  19604. * @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.
  19605. */
  19606. stop(stopSubEmitters?: boolean): void;
  19607. /**
  19608. * Remove all active particles
  19609. */
  19610. reset(): void;
  19611. /**
  19612. * @hidden (for internal use only)
  19613. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19614. /**
  19615. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19616. * Its lifetime will start back at 0.
  19617. */
  19618. recycleParticle: (particle: Particle) => void;
  19619. private _stopSubEmitters;
  19620. private _createParticle;
  19621. private _removeFromRoot;
  19622. private _emitFromParticle;
  19623. private _update;
  19624. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19625. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19626. /** @hidden */
  19627. private _getEffect;
  19628. /**
  19629. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19630. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19631. */
  19632. animate(preWarmOnly?: boolean): void;
  19633. private _appendParticleVertices;
  19634. /**
  19635. * Rebuilds the particle system.
  19636. */
  19637. rebuild(): void;
  19638. /**
  19639. * Is this system ready to be used/rendered
  19640. * @return true if the system is ready
  19641. */
  19642. isReady(): boolean;
  19643. private _render;
  19644. /**
  19645. * Renders the particle system in its current state.
  19646. * @returns the current number of particles
  19647. */
  19648. render(): number;
  19649. /**
  19650. * Disposes the particle system and free the associated resources
  19651. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19652. */
  19653. dispose(disposeTexture?: boolean): void;
  19654. /**
  19655. * Clones the particle system.
  19656. * @param name The name of the cloned object
  19657. * @param newEmitter The new emitter to use
  19658. * @returns the cloned particle system
  19659. */
  19660. clone(name: string, newEmitter: any): ParticleSystem;
  19661. /**
  19662. * Serializes the particle system to a JSON object.
  19663. * @returns the JSON object
  19664. */
  19665. serialize(): any;
  19666. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19667. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19668. /**
  19669. * Parses a JSON object to create a particle system.
  19670. * @param parsedParticleSystem The JSON object to parse
  19671. * @param scene The scene to create the particle system in
  19672. * @param rootUrl The root url to use to load external dependencies like texture
  19673. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19674. * @returns the Parsed particle system
  19675. */
  19676. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19677. }
  19678. }
  19679. declare module BABYLON {
  19680. /**
  19681. * A particle represents one of the element emitted by a particle system.
  19682. * This is mainly define by its coordinates, direction, velocity and age.
  19683. */
  19684. export class Particle {
  19685. /**
  19686. * The particle system the particle belongs to.
  19687. */
  19688. particleSystem: ParticleSystem;
  19689. private static _Count;
  19690. /**
  19691. * Unique ID of the particle
  19692. */
  19693. id: number;
  19694. /**
  19695. * The world position of the particle in the scene.
  19696. */
  19697. position: Vector3;
  19698. /**
  19699. * The world direction of the particle in the scene.
  19700. */
  19701. direction: Vector3;
  19702. /**
  19703. * The color of the particle.
  19704. */
  19705. color: Color4;
  19706. /**
  19707. * The color change of the particle per step.
  19708. */
  19709. colorStep: Color4;
  19710. /**
  19711. * Defines how long will the life of the particle be.
  19712. */
  19713. lifeTime: number;
  19714. /**
  19715. * The current age of the particle.
  19716. */
  19717. age: number;
  19718. /**
  19719. * The current size of the particle.
  19720. */
  19721. size: number;
  19722. /**
  19723. * The current scale of the particle.
  19724. */
  19725. scale: Vector2;
  19726. /**
  19727. * The current angle of the particle.
  19728. */
  19729. angle: number;
  19730. /**
  19731. * Defines how fast is the angle changing.
  19732. */
  19733. angularSpeed: number;
  19734. /**
  19735. * Defines the cell index used by the particle to be rendered from a sprite.
  19736. */
  19737. cellIndex: number;
  19738. /**
  19739. * The information required to support color remapping
  19740. */
  19741. remapData: Vector4;
  19742. /** @hidden */ private _randomCellOffset?: number;
  19743. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  19744. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  19745. /** @hidden */ private _initialStartSpriteCellID: number;
  19746. /** @hidden */ private _initialEndSpriteCellID: number;
  19747. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  19748. /** @hidden */ private _currentColor1: Color4;
  19749. /** @hidden */ private _currentColor2: Color4;
  19750. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  19751. /** @hidden */ private _currentSize1: number;
  19752. /** @hidden */ private _currentSize2: number;
  19753. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  19754. /** @hidden */ private _currentAngularSpeed1: number;
  19755. /** @hidden */ private _currentAngularSpeed2: number;
  19756. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  19757. /** @hidden */ private _currentVelocity1: number;
  19758. /** @hidden */ private _currentVelocity2: number;
  19759. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  19760. /** @hidden */ private _currentLimitVelocity1: number;
  19761. /** @hidden */ private _currentLimitVelocity2: number;
  19762. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  19763. /** @hidden */ private _currentDrag1: number;
  19764. /** @hidden */ private _currentDrag2: number;
  19765. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  19766. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  19767. /**
  19768. * Creates a new instance Particle
  19769. * @param particleSystem the particle system the particle belongs to
  19770. */
  19771. constructor(
  19772. /**
  19773. * The particle system the particle belongs to.
  19774. */
  19775. particleSystem: ParticleSystem);
  19776. private updateCellInfoFromSystem;
  19777. /**
  19778. * Defines how the sprite cell index is updated for the particle
  19779. */
  19780. updateCellIndex(): void;
  19781. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  19782. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  19783. /** @hidden */ private _reset(): void;
  19784. /**
  19785. * Copy the properties of particle to another one.
  19786. * @param other the particle to copy the information to.
  19787. */
  19788. copyTo(other: Particle): void;
  19789. }
  19790. }
  19791. declare module BABYLON {
  19792. /**
  19793. * Particle emitter represents a volume emitting particles.
  19794. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  19795. */
  19796. export interface IParticleEmitterType {
  19797. /**
  19798. * Called by the particle System when the direction is computed for the created particle.
  19799. * @param worldMatrix is the world matrix of the particle system
  19800. * @param directionToUpdate is the direction vector to update with the result
  19801. * @param particle is the particle we are computed the direction for
  19802. */
  19803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19804. /**
  19805. * Called by the particle System when the position is computed for the created particle.
  19806. * @param worldMatrix is the world matrix of the particle system
  19807. * @param positionToUpdate is the position vector to update with the result
  19808. * @param particle is the particle we are computed the position for
  19809. */
  19810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19811. /**
  19812. * Clones the current emitter and returns a copy of it
  19813. * @returns the new emitter
  19814. */
  19815. clone(): IParticleEmitterType;
  19816. /**
  19817. * Called by the GPUParticleSystem to setup the update shader
  19818. * @param effect defines the update shader
  19819. */
  19820. applyToShader(effect: Effect): void;
  19821. /**
  19822. * Returns a string to use to update the GPU particles update shader
  19823. * @returns the effect defines string
  19824. */
  19825. getEffectDefines(): string;
  19826. /**
  19827. * Returns a string representing the class name
  19828. * @returns a string containing the class name
  19829. */
  19830. getClassName(): string;
  19831. /**
  19832. * Serializes the particle system to a JSON object.
  19833. * @returns the JSON object
  19834. */
  19835. serialize(): any;
  19836. /**
  19837. * Parse properties from a JSON object
  19838. * @param serializationObject defines the JSON object
  19839. */
  19840. parse(serializationObject: any): void;
  19841. }
  19842. }
  19843. declare module BABYLON {
  19844. /**
  19845. * Particle emitter emitting particles from the inside of a box.
  19846. * It emits the particles randomly between 2 given directions.
  19847. */
  19848. export class BoxParticleEmitter implements IParticleEmitterType {
  19849. /**
  19850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19851. */
  19852. direction1: Vector3;
  19853. /**
  19854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19855. */
  19856. direction2: Vector3;
  19857. /**
  19858. * 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.
  19859. */
  19860. minEmitBox: Vector3;
  19861. /**
  19862. * 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.
  19863. */
  19864. maxEmitBox: Vector3;
  19865. /**
  19866. * Creates a new instance BoxParticleEmitter
  19867. */
  19868. constructor();
  19869. /**
  19870. * Called by the particle System when the direction is computed for the created particle.
  19871. * @param worldMatrix is the world matrix of the particle system
  19872. * @param directionToUpdate is the direction vector to update with the result
  19873. * @param particle is the particle we are computed the direction for
  19874. */
  19875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19876. /**
  19877. * Called by the particle System when the position is computed for the created particle.
  19878. * @param worldMatrix is the world matrix of the particle system
  19879. * @param positionToUpdate is the position vector to update with the result
  19880. * @param particle is the particle we are computed the position for
  19881. */
  19882. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19883. /**
  19884. * Clones the current emitter and returns a copy of it
  19885. * @returns the new emitter
  19886. */
  19887. clone(): BoxParticleEmitter;
  19888. /**
  19889. * Called by the GPUParticleSystem to setup the update shader
  19890. * @param effect defines the update shader
  19891. */
  19892. applyToShader(effect: Effect): void;
  19893. /**
  19894. * Returns a string to use to update the GPU particles update shader
  19895. * @returns a string containng the defines string
  19896. */
  19897. getEffectDefines(): string;
  19898. /**
  19899. * Returns the string "BoxParticleEmitter"
  19900. * @returns a string containing the class name
  19901. */
  19902. getClassName(): string;
  19903. /**
  19904. * Serializes the particle system to a JSON object.
  19905. * @returns the JSON object
  19906. */
  19907. serialize(): any;
  19908. /**
  19909. * Parse properties from a JSON object
  19910. * @param serializationObject defines the JSON object
  19911. */
  19912. parse(serializationObject: any): void;
  19913. }
  19914. }
  19915. declare module BABYLON {
  19916. /**
  19917. * Particle emitter emitting particles from the inside of a cone.
  19918. * It emits the particles alongside the cone volume from the base to the particle.
  19919. * The emission direction might be randomized.
  19920. */
  19921. export class ConeParticleEmitter implements IParticleEmitterType {
  19922. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  19923. directionRandomizer: number;
  19924. private _radius;
  19925. private _angle;
  19926. private _height;
  19927. /**
  19928. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  19929. */
  19930. radiusRange: number;
  19931. /**
  19932. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  19933. */
  19934. heightRange: number;
  19935. /**
  19936. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  19937. */
  19938. emitFromSpawnPointOnly: boolean;
  19939. /**
  19940. * Gets or sets the radius of the emission cone
  19941. */
  19942. radius: number;
  19943. /**
  19944. * Gets or sets the angle of the emission cone
  19945. */
  19946. angle: number;
  19947. private _buildHeight;
  19948. /**
  19949. * Creates a new instance ConeParticleEmitter
  19950. * @param radius the radius of the emission cone (1 by default)
  19951. * @param angle the cone base angle (PI by default)
  19952. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  19953. */
  19954. constructor(radius?: number, angle?: number,
  19955. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  19956. directionRandomizer?: number);
  19957. /**
  19958. * Called by the particle System when the direction is computed for the created particle.
  19959. * @param worldMatrix is the world matrix of the particle system
  19960. * @param directionToUpdate is the direction vector to update with the result
  19961. * @param particle is the particle we are computed the direction for
  19962. */
  19963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19964. /**
  19965. * Called by the particle System when the position is computed for the created particle.
  19966. * @param worldMatrix is the world matrix of the particle system
  19967. * @param positionToUpdate is the position vector to update with the result
  19968. * @param particle is the particle we are computed the position for
  19969. */
  19970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19971. /**
  19972. * Clones the current emitter and returns a copy of it
  19973. * @returns the new emitter
  19974. */
  19975. clone(): ConeParticleEmitter;
  19976. /**
  19977. * Called by the GPUParticleSystem to setup the update shader
  19978. * @param effect defines the update shader
  19979. */
  19980. applyToShader(effect: Effect): void;
  19981. /**
  19982. * Returns a string to use to update the GPU particles update shader
  19983. * @returns a string containng the defines string
  19984. */
  19985. getEffectDefines(): string;
  19986. /**
  19987. * Returns the string "ConeParticleEmitter"
  19988. * @returns a string containing the class name
  19989. */
  19990. getClassName(): string;
  19991. /**
  19992. * Serializes the particle system to a JSON object.
  19993. * @returns the JSON object
  19994. */
  19995. serialize(): any;
  19996. /**
  19997. * Parse properties from a JSON object
  19998. * @param serializationObject defines the JSON object
  19999. */
  20000. parse(serializationObject: any): void;
  20001. }
  20002. }
  20003. declare module BABYLON {
  20004. /**
  20005. * Particle emitter emitting particles from the inside of a cylinder.
  20006. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20007. */
  20008. export class CylinderParticleEmitter implements IParticleEmitterType {
  20009. /**
  20010. * The radius of the emission cylinder.
  20011. */
  20012. radius: number;
  20013. /**
  20014. * The height of the emission cylinder.
  20015. */
  20016. height: number;
  20017. /**
  20018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20019. */
  20020. radiusRange: number;
  20021. /**
  20022. * How much to randomize the particle direction [0-1].
  20023. */
  20024. directionRandomizer: number;
  20025. /**
  20026. * Creates a new instance CylinderParticleEmitter
  20027. * @param radius the radius of the emission cylinder (1 by default)
  20028. * @param height the height of the emission cylinder (1 by default)
  20029. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20030. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20031. */
  20032. constructor(
  20033. /**
  20034. * The radius of the emission cylinder.
  20035. */
  20036. radius?: number,
  20037. /**
  20038. * The height of the emission cylinder.
  20039. */
  20040. height?: number,
  20041. /**
  20042. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20043. */
  20044. radiusRange?: number,
  20045. /**
  20046. * How much to randomize the particle direction [0-1].
  20047. */
  20048. directionRandomizer?: number);
  20049. /**
  20050. * Called by the particle System when the direction is computed for the created particle.
  20051. * @param worldMatrix is the world matrix of the particle system
  20052. * @param directionToUpdate is the direction vector to update with the result
  20053. * @param particle is the particle we are computed the direction for
  20054. */
  20055. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20056. /**
  20057. * Called by the particle System when the position is computed for the created particle.
  20058. * @param worldMatrix is the world matrix of the particle system
  20059. * @param positionToUpdate is the position vector to update with the result
  20060. * @param particle is the particle we are computed the position for
  20061. */
  20062. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20063. /**
  20064. * Clones the current emitter and returns a copy of it
  20065. * @returns the new emitter
  20066. */
  20067. clone(): CylinderParticleEmitter;
  20068. /**
  20069. * Called by the GPUParticleSystem to setup the update shader
  20070. * @param effect defines the update shader
  20071. */
  20072. applyToShader(effect: Effect): void;
  20073. /**
  20074. * Returns a string to use to update the GPU particles update shader
  20075. * @returns a string containng the defines string
  20076. */
  20077. getEffectDefines(): string;
  20078. /**
  20079. * Returns the string "CylinderParticleEmitter"
  20080. * @returns a string containing the class name
  20081. */
  20082. getClassName(): string;
  20083. /**
  20084. * Serializes the particle system to a JSON object.
  20085. * @returns the JSON object
  20086. */
  20087. serialize(): any;
  20088. /**
  20089. * Parse properties from a JSON object
  20090. * @param serializationObject defines the JSON object
  20091. */
  20092. parse(serializationObject: any): void;
  20093. }
  20094. /**
  20095. * Particle emitter emitting particles from the inside of a cylinder.
  20096. * It emits the particles randomly between two vectors.
  20097. */
  20098. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20099. /**
  20100. * The min limit of the emission direction.
  20101. */
  20102. direction1: Vector3;
  20103. /**
  20104. * The max limit of the emission direction.
  20105. */
  20106. direction2: Vector3;
  20107. /**
  20108. * Creates a new instance CylinderDirectedParticleEmitter
  20109. * @param radius the radius of the emission cylinder (1 by default)
  20110. * @param height the height of the emission cylinder (1 by default)
  20111. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20112. * @param direction1 the min limit of the emission direction (up vector by default)
  20113. * @param direction2 the max limit of the emission direction (up vector by default)
  20114. */
  20115. constructor(radius?: number, height?: number, radiusRange?: number,
  20116. /**
  20117. * The min limit of the emission direction.
  20118. */
  20119. direction1?: Vector3,
  20120. /**
  20121. * The max limit of the emission direction.
  20122. */
  20123. direction2?: Vector3);
  20124. /**
  20125. * Called by the particle System when the direction is computed for the created particle.
  20126. * @param worldMatrix is the world matrix of the particle system
  20127. * @param directionToUpdate is the direction vector to update with the result
  20128. * @param particle is the particle we are computed the direction for
  20129. */
  20130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20131. /**
  20132. * Clones the current emitter and returns a copy of it
  20133. * @returns the new emitter
  20134. */
  20135. clone(): CylinderDirectedParticleEmitter;
  20136. /**
  20137. * Called by the GPUParticleSystem to setup the update shader
  20138. * @param effect defines the update shader
  20139. */
  20140. applyToShader(effect: Effect): void;
  20141. /**
  20142. * Returns a string to use to update the GPU particles update shader
  20143. * @returns a string containng the defines string
  20144. */
  20145. getEffectDefines(): string;
  20146. /**
  20147. * Returns the string "CylinderDirectedParticleEmitter"
  20148. * @returns a string containing the class name
  20149. */
  20150. getClassName(): string;
  20151. /**
  20152. * Serializes the particle system to a JSON object.
  20153. * @returns the JSON object
  20154. */
  20155. serialize(): any;
  20156. /**
  20157. * Parse properties from a JSON object
  20158. * @param serializationObject defines the JSON object
  20159. */
  20160. parse(serializationObject: any): void;
  20161. }
  20162. }
  20163. declare module BABYLON {
  20164. /**
  20165. * Particle emitter emitting particles from the inside of a hemisphere.
  20166. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20167. */
  20168. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20169. /**
  20170. * The radius of the emission hemisphere.
  20171. */
  20172. radius: number;
  20173. /**
  20174. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20175. */
  20176. radiusRange: number;
  20177. /**
  20178. * How much to randomize the particle direction [0-1].
  20179. */
  20180. directionRandomizer: number;
  20181. /**
  20182. * Creates a new instance HemisphericParticleEmitter
  20183. * @param radius the radius of the emission hemisphere (1 by default)
  20184. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20185. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20186. */
  20187. constructor(
  20188. /**
  20189. * The radius of the emission hemisphere.
  20190. */
  20191. radius?: number,
  20192. /**
  20193. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20194. */
  20195. radiusRange?: number,
  20196. /**
  20197. * How much to randomize the particle direction [0-1].
  20198. */
  20199. directionRandomizer?: number);
  20200. /**
  20201. * Called by the particle System when the direction is computed for the created particle.
  20202. * @param worldMatrix is the world matrix of the particle system
  20203. * @param directionToUpdate is the direction vector to update with the result
  20204. * @param particle is the particle we are computed the direction for
  20205. */
  20206. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20207. /**
  20208. * Called by the particle System when the position is computed for the created particle.
  20209. * @param worldMatrix is the world matrix of the particle system
  20210. * @param positionToUpdate is the position vector to update with the result
  20211. * @param particle is the particle we are computed the position for
  20212. */
  20213. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20214. /**
  20215. * Clones the current emitter and returns a copy of it
  20216. * @returns the new emitter
  20217. */
  20218. clone(): HemisphericParticleEmitter;
  20219. /**
  20220. * Called by the GPUParticleSystem to setup the update shader
  20221. * @param effect defines the update shader
  20222. */
  20223. applyToShader(effect: Effect): void;
  20224. /**
  20225. * Returns a string to use to update the GPU particles update shader
  20226. * @returns a string containng the defines string
  20227. */
  20228. getEffectDefines(): string;
  20229. /**
  20230. * Returns the string "HemisphericParticleEmitter"
  20231. * @returns a string containing the class name
  20232. */
  20233. getClassName(): string;
  20234. /**
  20235. * Serializes the particle system to a JSON object.
  20236. * @returns the JSON object
  20237. */
  20238. serialize(): any;
  20239. /**
  20240. * Parse properties from a JSON object
  20241. * @param serializationObject defines the JSON object
  20242. */
  20243. parse(serializationObject: any): void;
  20244. }
  20245. }
  20246. declare module BABYLON {
  20247. /**
  20248. * Particle emitter emitting particles from a point.
  20249. * It emits the particles randomly between 2 given directions.
  20250. */
  20251. export class PointParticleEmitter implements IParticleEmitterType {
  20252. /**
  20253. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20254. */
  20255. direction1: Vector3;
  20256. /**
  20257. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20258. */
  20259. direction2: Vector3;
  20260. /**
  20261. * Creates a new instance PointParticleEmitter
  20262. */
  20263. constructor();
  20264. /**
  20265. * Called by the particle System when the direction is computed for the created particle.
  20266. * @param worldMatrix is the world matrix of the particle system
  20267. * @param directionToUpdate is the direction vector to update with the result
  20268. * @param particle is the particle we are computed the direction for
  20269. */
  20270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20271. /**
  20272. * Called by the particle System when the position is computed for the created particle.
  20273. * @param worldMatrix is the world matrix of the particle system
  20274. * @param positionToUpdate is the position vector to update with the result
  20275. * @param particle is the particle we are computed the position for
  20276. */
  20277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20278. /**
  20279. * Clones the current emitter and returns a copy of it
  20280. * @returns the new emitter
  20281. */
  20282. clone(): PointParticleEmitter;
  20283. /**
  20284. * Called by the GPUParticleSystem to setup the update shader
  20285. * @param effect defines the update shader
  20286. */
  20287. applyToShader(effect: Effect): void;
  20288. /**
  20289. * Returns a string to use to update the GPU particles update shader
  20290. * @returns a string containng the defines string
  20291. */
  20292. getEffectDefines(): string;
  20293. /**
  20294. * Returns the string "PointParticleEmitter"
  20295. * @returns a string containing the class name
  20296. */
  20297. getClassName(): string;
  20298. /**
  20299. * Serializes the particle system to a JSON object.
  20300. * @returns the JSON object
  20301. */
  20302. serialize(): any;
  20303. /**
  20304. * Parse properties from a JSON object
  20305. * @param serializationObject defines the JSON object
  20306. */
  20307. parse(serializationObject: any): void;
  20308. }
  20309. }
  20310. declare module BABYLON {
  20311. /**
  20312. * Particle emitter emitting particles from the inside of a sphere.
  20313. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20314. */
  20315. export class SphereParticleEmitter implements IParticleEmitterType {
  20316. /**
  20317. * The radius of the emission sphere.
  20318. */
  20319. radius: number;
  20320. /**
  20321. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20322. */
  20323. radiusRange: number;
  20324. /**
  20325. * How much to randomize the particle direction [0-1].
  20326. */
  20327. directionRandomizer: number;
  20328. /**
  20329. * Creates a new instance SphereParticleEmitter
  20330. * @param radius the radius of the emission sphere (1 by default)
  20331. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20332. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20333. */
  20334. constructor(
  20335. /**
  20336. * The radius of the emission sphere.
  20337. */
  20338. radius?: number,
  20339. /**
  20340. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20341. */
  20342. radiusRange?: number,
  20343. /**
  20344. * How much to randomize the particle direction [0-1].
  20345. */
  20346. directionRandomizer?: number);
  20347. /**
  20348. * Called by the particle System when the direction is computed for the created particle.
  20349. * @param worldMatrix is the world matrix of the particle system
  20350. * @param directionToUpdate is the direction vector to update with the result
  20351. * @param particle is the particle we are computed the direction for
  20352. */
  20353. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20354. /**
  20355. * Called by the particle System when the position is computed for the created particle.
  20356. * @param worldMatrix is the world matrix of the particle system
  20357. * @param positionToUpdate is the position vector to update with the result
  20358. * @param particle is the particle we are computed the position for
  20359. */
  20360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20361. /**
  20362. * Clones the current emitter and returns a copy of it
  20363. * @returns the new emitter
  20364. */
  20365. clone(): SphereParticleEmitter;
  20366. /**
  20367. * Called by the GPUParticleSystem to setup the update shader
  20368. * @param effect defines the update shader
  20369. */
  20370. applyToShader(effect: Effect): void;
  20371. /**
  20372. * Returns a string to use to update the GPU particles update shader
  20373. * @returns a string containng the defines string
  20374. */
  20375. getEffectDefines(): string;
  20376. /**
  20377. * Returns the string "SphereParticleEmitter"
  20378. * @returns a string containing the class name
  20379. */
  20380. getClassName(): string;
  20381. /**
  20382. * Serializes the particle system to a JSON object.
  20383. * @returns the JSON object
  20384. */
  20385. serialize(): any;
  20386. /**
  20387. * Parse properties from a JSON object
  20388. * @param serializationObject defines the JSON object
  20389. */
  20390. parse(serializationObject: any): void;
  20391. }
  20392. /**
  20393. * Particle emitter emitting particles from the inside of a sphere.
  20394. * It emits the particles randomly between two vectors.
  20395. */
  20396. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20397. /**
  20398. * The min limit of the emission direction.
  20399. */
  20400. direction1: Vector3;
  20401. /**
  20402. * The max limit of the emission direction.
  20403. */
  20404. direction2: Vector3;
  20405. /**
  20406. * Creates a new instance SphereDirectedParticleEmitter
  20407. * @param radius the radius of the emission sphere (1 by default)
  20408. * @param direction1 the min limit of the emission direction (up vector by default)
  20409. * @param direction2 the max limit of the emission direction (up vector by default)
  20410. */
  20411. constructor(radius?: number,
  20412. /**
  20413. * The min limit of the emission direction.
  20414. */
  20415. direction1?: Vector3,
  20416. /**
  20417. * The max limit of the emission direction.
  20418. */
  20419. direction2?: Vector3);
  20420. /**
  20421. * Called by the particle System when the direction is computed for the created particle.
  20422. * @param worldMatrix is the world matrix of the particle system
  20423. * @param directionToUpdate is the direction vector to update with the result
  20424. * @param particle is the particle we are computed the direction for
  20425. */
  20426. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20427. /**
  20428. * Clones the current emitter and returns a copy of it
  20429. * @returns the new emitter
  20430. */
  20431. clone(): SphereDirectedParticleEmitter;
  20432. /**
  20433. * Called by the GPUParticleSystem to setup the update shader
  20434. * @param effect defines the update shader
  20435. */
  20436. applyToShader(effect: Effect): void;
  20437. /**
  20438. * Returns a string to use to update the GPU particles update shader
  20439. * @returns a string containng the defines string
  20440. */
  20441. getEffectDefines(): string;
  20442. /**
  20443. * Returns the string "SphereDirectedParticleEmitter"
  20444. * @returns a string containing the class name
  20445. */
  20446. getClassName(): string;
  20447. /**
  20448. * Serializes the particle system to a JSON object.
  20449. * @returns the JSON object
  20450. */
  20451. serialize(): any;
  20452. /**
  20453. * Parse properties from a JSON object
  20454. * @param serializationObject defines the JSON object
  20455. */
  20456. parse(serializationObject: any): void;
  20457. }
  20458. }
  20459. declare module BABYLON {
  20460. /**
  20461. * Interface representing a particle system in Babylon.js.
  20462. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20463. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20464. */
  20465. export interface IParticleSystem {
  20466. /**
  20467. * List of animations used by the particle system.
  20468. */
  20469. animations: Animation[];
  20470. /**
  20471. * The id of the Particle system.
  20472. */
  20473. id: string;
  20474. /**
  20475. * The name of the Particle system.
  20476. */
  20477. name: string;
  20478. /**
  20479. * The emitter represents the Mesh or position we are attaching the particle system to.
  20480. */
  20481. emitter: Nullable<AbstractMesh | Vector3>;
  20482. /**
  20483. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20484. */
  20485. isBillboardBased: boolean;
  20486. /**
  20487. * The rendering group used by the Particle system to chose when to render.
  20488. */
  20489. renderingGroupId: number;
  20490. /**
  20491. * The layer mask we are rendering the particles through.
  20492. */
  20493. layerMask: number;
  20494. /**
  20495. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20496. */
  20497. updateSpeed: number;
  20498. /**
  20499. * The amount of time the particle system is running (depends of the overall update speed).
  20500. */
  20501. targetStopDuration: number;
  20502. /**
  20503. * The texture used to render each particle. (this can be a spritesheet)
  20504. */
  20505. particleTexture: Nullable<Texture>;
  20506. /**
  20507. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20508. */
  20509. blendMode: number;
  20510. /**
  20511. * Minimum life time of emitting particles.
  20512. */
  20513. minLifeTime: number;
  20514. /**
  20515. * Maximum life time of emitting particles.
  20516. */
  20517. maxLifeTime: number;
  20518. /**
  20519. * Minimum Size of emitting particles.
  20520. */
  20521. minSize: number;
  20522. /**
  20523. * Maximum Size of emitting particles.
  20524. */
  20525. maxSize: number;
  20526. /**
  20527. * Minimum scale of emitting particles on X axis.
  20528. */
  20529. minScaleX: number;
  20530. /**
  20531. * Maximum scale of emitting particles on X axis.
  20532. */
  20533. maxScaleX: number;
  20534. /**
  20535. * Minimum scale of emitting particles on Y axis.
  20536. */
  20537. minScaleY: number;
  20538. /**
  20539. * Maximum scale of emitting particles on Y axis.
  20540. */
  20541. maxScaleY: number;
  20542. /**
  20543. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20544. */
  20545. color1: Color4;
  20546. /**
  20547. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20548. */
  20549. color2: Color4;
  20550. /**
  20551. * Color the particle will have at the end of its lifetime.
  20552. */
  20553. colorDead: Color4;
  20554. /**
  20555. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20556. */
  20557. emitRate: number;
  20558. /**
  20559. * You can use gravity if you want to give an orientation to your particles.
  20560. */
  20561. gravity: Vector3;
  20562. /**
  20563. * Minimum power of emitting particles.
  20564. */
  20565. minEmitPower: number;
  20566. /**
  20567. * Maximum power of emitting particles.
  20568. */
  20569. maxEmitPower: number;
  20570. /**
  20571. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20572. */
  20573. minAngularSpeed: number;
  20574. /**
  20575. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20576. */
  20577. maxAngularSpeed: number;
  20578. /**
  20579. * Gets or sets the minimal initial rotation in radians.
  20580. */
  20581. minInitialRotation: number;
  20582. /**
  20583. * Gets or sets the maximal initial rotation in radians.
  20584. */
  20585. maxInitialRotation: number;
  20586. /**
  20587. * The particle emitter type defines the emitter used by the particle system.
  20588. * It can be for example box, sphere, or cone...
  20589. */
  20590. particleEmitterType: Nullable<IParticleEmitterType>;
  20591. /**
  20592. * Defines the delay in milliseconds before starting the system (0 by default)
  20593. */
  20594. startDelay: number;
  20595. /**
  20596. * 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
  20597. */
  20598. preWarmCycles: number;
  20599. /**
  20600. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20601. */
  20602. preWarmStepOffset: number;
  20603. /**
  20604. * 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)
  20605. */
  20606. spriteCellChangeSpeed: number;
  20607. /**
  20608. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20609. */
  20610. startSpriteCellID: number;
  20611. /**
  20612. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20613. */
  20614. endSpriteCellID: number;
  20615. /**
  20616. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20617. */
  20618. spriteCellWidth: number;
  20619. /**
  20620. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20621. */
  20622. spriteCellHeight: number;
  20623. /**
  20624. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20625. */
  20626. spriteRandomStartCell: boolean;
  20627. /**
  20628. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20629. */
  20630. isAnimationSheetEnabled: boolean;
  20631. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20632. translationPivot: Vector2;
  20633. /**
  20634. * Gets or sets a texture used to add random noise to particle positions
  20635. */
  20636. noiseTexture: Nullable<BaseTexture>;
  20637. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20638. noiseStrength: Vector3;
  20639. /**
  20640. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20641. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20642. */
  20643. billboardMode: number;
  20644. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20645. limitVelocityDamping: number;
  20646. /**
  20647. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20648. */
  20649. beginAnimationOnStart: boolean;
  20650. /**
  20651. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  20652. */
  20653. beginAnimationFrom: number;
  20654. /**
  20655. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  20656. */
  20657. beginAnimationTo: number;
  20658. /**
  20659. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  20660. */
  20661. beginAnimationLoop: boolean;
  20662. /**
  20663. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20664. */
  20665. disposeOnStop: boolean;
  20666. /**
  20667. * Gets the maximum number of particles active at the same time.
  20668. * @returns The max number of active particles.
  20669. */
  20670. getCapacity(): number;
  20671. /**
  20672. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20673. * @returns True if it has been started, otherwise false.
  20674. */
  20675. isStarted(): boolean;
  20676. /**
  20677. * Animates the particle system for this frame.
  20678. */
  20679. animate(): void;
  20680. /**
  20681. * Renders the particle system in its current state.
  20682. * @returns the current number of particles
  20683. */
  20684. render(): number;
  20685. /**
  20686. * Dispose the particle system and frees its associated resources.
  20687. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20688. */
  20689. dispose(disposeTexture?: boolean): void;
  20690. /**
  20691. * Clones the particle system.
  20692. * @param name The name of the cloned object
  20693. * @param newEmitter The new emitter to use
  20694. * @returns the cloned particle system
  20695. */
  20696. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  20697. /**
  20698. * Serializes the particle system to a JSON object.
  20699. * @returns the JSON object
  20700. */
  20701. serialize(): any;
  20702. /**
  20703. * Rebuild the particle system
  20704. */
  20705. rebuild(): void;
  20706. /**
  20707. * Starts the particle system and begins to emit
  20708. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  20709. */
  20710. start(delay?: number): void;
  20711. /**
  20712. * Stops the particle system.
  20713. */
  20714. stop(): void;
  20715. /**
  20716. * Remove all active particles
  20717. */
  20718. reset(): void;
  20719. /**
  20720. * Is this system ready to be used/rendered
  20721. * @return true if the system is ready
  20722. */
  20723. isReady(): boolean;
  20724. /**
  20725. * Adds a new color gradient
  20726. * @param gradient defines the gradient to use (between 0 and 1)
  20727. * @param color1 defines the color to affect to the specified gradient
  20728. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20729. * @returns the current particle system
  20730. */
  20731. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20732. /**
  20733. * Remove a specific color gradient
  20734. * @param gradient defines the gradient to remove
  20735. * @returns the current particle system
  20736. */
  20737. removeColorGradient(gradient: number): IParticleSystem;
  20738. /**
  20739. * Adds a new size gradient
  20740. * @param gradient defines the gradient to use (between 0 and 1)
  20741. * @param factor defines the size factor to affect to the specified gradient
  20742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20743. * @returns the current particle system
  20744. */
  20745. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20746. /**
  20747. * Remove a specific size gradient
  20748. * @param gradient defines the gradient to remove
  20749. * @returns the current particle system
  20750. */
  20751. removeSizeGradient(gradient: number): IParticleSystem;
  20752. /**
  20753. * Gets the current list of color gradients.
  20754. * You must use addColorGradient and removeColorGradient to udpate this list
  20755. * @returns the list of color gradients
  20756. */
  20757. getColorGradients(): Nullable<Array<ColorGradient>>;
  20758. /**
  20759. * Gets the current list of size gradients.
  20760. * You must use addSizeGradient and removeSizeGradient to udpate this list
  20761. * @returns the list of size gradients
  20762. */
  20763. getSizeGradients(): Nullable<Array<FactorGradient>>;
  20764. /**
  20765. * Gets the current list of angular speed gradients.
  20766. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  20767. * @returns the list of angular speed gradients
  20768. */
  20769. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  20770. /**
  20771. * Adds a new angular speed gradient
  20772. * @param gradient defines the gradient to use (between 0 and 1)
  20773. * @param factor defines the angular speed to affect to the specified gradient
  20774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20775. * @returns the current particle system
  20776. */
  20777. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20778. /**
  20779. * Remove a specific angular speed gradient
  20780. * @param gradient defines the gradient to remove
  20781. * @returns the current particle system
  20782. */
  20783. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20784. /**
  20785. * Gets the current list of velocity gradients.
  20786. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  20787. * @returns the list of velocity gradients
  20788. */
  20789. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  20790. /**
  20791. * Adds a new velocity gradient
  20792. * @param gradient defines the gradient to use (between 0 and 1)
  20793. * @param factor defines the velocity to affect to the specified gradient
  20794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20795. * @returns the current particle system
  20796. */
  20797. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20798. /**
  20799. * Remove a specific velocity gradient
  20800. * @param gradient defines the gradient to remove
  20801. * @returns the current particle system
  20802. */
  20803. removeVelocityGradient(gradient: number): IParticleSystem;
  20804. /**
  20805. * Gets the current list of limit velocity gradients.
  20806. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  20807. * @returns the list of limit velocity gradients
  20808. */
  20809. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  20810. /**
  20811. * Adds a new limit velocity gradient
  20812. * @param gradient defines the gradient to use (between 0 and 1)
  20813. * @param factor defines the limit velocity to affect to the specified gradient
  20814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20815. * @returns the current particle system
  20816. */
  20817. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20818. /**
  20819. * Remove a specific limit velocity gradient
  20820. * @param gradient defines the gradient to remove
  20821. * @returns the current particle system
  20822. */
  20823. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20824. /**
  20825. * Adds a new drag gradient
  20826. * @param gradient defines the gradient to use (between 0 and 1)
  20827. * @param factor defines the drag to affect to the specified gradient
  20828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20829. * @returns the current particle system
  20830. */
  20831. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20832. /**
  20833. * Remove a specific drag gradient
  20834. * @param gradient defines the gradient to remove
  20835. * @returns the current particle system
  20836. */
  20837. removeDragGradient(gradient: number): IParticleSystem;
  20838. /**
  20839. * Gets the current list of drag gradients.
  20840. * You must use addDragGradient and removeDragGradient to udpate this list
  20841. * @returns the list of drag gradients
  20842. */
  20843. getDragGradients(): Nullable<Array<FactorGradient>>;
  20844. /**
  20845. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20846. * @param gradient defines the gradient to use (between 0 and 1)
  20847. * @param factor defines the emit rate to affect to the specified gradient
  20848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20849. * @returns the current particle system
  20850. */
  20851. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20852. /**
  20853. * Remove a specific emit rate gradient
  20854. * @param gradient defines the gradient to remove
  20855. * @returns the current particle system
  20856. */
  20857. removeEmitRateGradient(gradient: number): IParticleSystem;
  20858. /**
  20859. * Gets the current list of emit rate gradients.
  20860. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  20861. * @returns the list of emit rate gradients
  20862. */
  20863. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  20864. /**
  20865. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20866. * @param gradient defines the gradient to use (between 0 and 1)
  20867. * @param factor defines the start size to affect to the specified gradient
  20868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20869. * @returns the current particle system
  20870. */
  20871. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20872. /**
  20873. * Remove a specific start size gradient
  20874. * @param gradient defines the gradient to remove
  20875. * @returns the current particle system
  20876. */
  20877. removeStartSizeGradient(gradient: number): IParticleSystem;
  20878. /**
  20879. * Gets the current list of start size gradients.
  20880. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  20881. * @returns the list of start size gradients
  20882. */
  20883. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  20884. /**
  20885. * Adds a new life time gradient
  20886. * @param gradient defines the gradient to use (between 0 and 1)
  20887. * @param factor defines the life time factor to affect to the specified gradient
  20888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20889. * @returns the current particle system
  20890. */
  20891. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20892. /**
  20893. * Remove a specific life time gradient
  20894. * @param gradient defines the gradient to remove
  20895. * @returns the current particle system
  20896. */
  20897. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20898. /**
  20899. * Gets the current list of life time gradients.
  20900. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  20901. * @returns the list of life time gradients
  20902. */
  20903. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  20904. /**
  20905. * Gets the current list of color gradients.
  20906. * You must use addColorGradient and removeColorGradient to udpate this list
  20907. * @returns the list of color gradients
  20908. */
  20909. getColorGradients(): Nullable<Array<ColorGradient>>;
  20910. /**
  20911. * Adds a new ramp gradient used to remap particle colors
  20912. * @param gradient defines the gradient to use (between 0 and 1)
  20913. * @param color defines the color to affect to the specified gradient
  20914. * @returns the current particle system
  20915. */
  20916. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  20917. /**
  20918. * Gets the current list of ramp gradients.
  20919. * You must use addRampGradient and removeRampGradient to udpate this list
  20920. * @returns the list of ramp gradients
  20921. */
  20922. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20923. /** Gets or sets a boolean indicating that ramp gradients must be used
  20924. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20925. */
  20926. useRampGradients: boolean;
  20927. /**
  20928. * Adds a new color remap gradient
  20929. * @param gradient defines the gradient to use (between 0 and 1)
  20930. * @param min defines the color remap minimal range
  20931. * @param max defines the color remap maximal range
  20932. * @returns the current particle system
  20933. */
  20934. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20935. /**
  20936. * Gets the current list of color remap gradients.
  20937. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  20938. * @returns the list of color remap gradients
  20939. */
  20940. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  20941. /**
  20942. * Adds a new alpha remap gradient
  20943. * @param gradient defines the gradient to use (between 0 and 1)
  20944. * @param min defines the alpha remap minimal range
  20945. * @param max defines the alpha remap maximal range
  20946. * @returns the current particle system
  20947. */
  20948. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20949. /**
  20950. * Gets the current list of alpha remap gradients.
  20951. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  20952. * @returns the list of alpha remap gradients
  20953. */
  20954. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  20955. /**
  20956. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  20957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  20958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  20959. * @returns the emitter
  20960. */
  20961. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  20962. /**
  20963. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  20964. * @param radius The radius of the hemisphere to emit from
  20965. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  20966. * @returns the emitter
  20967. */
  20968. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  20969. /**
  20970. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  20971. * @param radius The radius of the sphere to emit from
  20972. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  20973. * @returns the emitter
  20974. */
  20975. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  20976. /**
  20977. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  20978. * @param radius The radius of the sphere to emit from
  20979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  20980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  20981. * @returns the emitter
  20982. */
  20983. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  20984. /**
  20985. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  20986. * @param radius The radius of the emission cylinder
  20987. * @param height The height of the emission cylinder
  20988. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  20989. * @param directionRandomizer How much to randomize the particle direction [0-1]
  20990. * @returns the emitter
  20991. */
  20992. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  20993. /**
  20994. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  20995. * @param radius The radius of the cylinder to emit from
  20996. * @param height The height of the emission cylinder
  20997. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20998. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  20999. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21000. * @returns the emitter
  21001. */
  21002. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21003. /**
  21004. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21005. * @param radius The radius of the cone to emit from
  21006. * @param angle The base angle of the cone
  21007. * @returns the emitter
  21008. */
  21009. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21010. /**
  21011. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21014. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21015. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21016. * @returns the emitter
  21017. */
  21018. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21019. /**
  21020. * Get hosting scene
  21021. * @returns the scene
  21022. */
  21023. getScene(): Scene;
  21024. }
  21025. }
  21026. declare module BABYLON {
  21027. /** @hidden */
  21028. export var linePixelShader: {
  21029. name: string;
  21030. shader: string;
  21031. };
  21032. }
  21033. declare module BABYLON {
  21034. /** @hidden */
  21035. export var lineVertexShader: {
  21036. name: string;
  21037. shader: string;
  21038. };
  21039. }
  21040. declare module BABYLON {
  21041. interface AbstractMesh {
  21042. /**
  21043. * Gets the edgesRenderer associated with the mesh
  21044. */
  21045. edgesRenderer: Nullable<EdgesRenderer>;
  21046. }
  21047. interface LinesMesh {
  21048. /**
  21049. * Enables the edge rendering mode on the mesh.
  21050. * This mode makes the mesh edges visible
  21051. * @param epsilon defines the maximal distance between two angles to detect a face
  21052. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21053. * @returns the currentAbstractMesh
  21054. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21055. */
  21056. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21057. }
  21058. interface InstancedLinesMesh {
  21059. /**
  21060. * Enables the edge rendering mode on the mesh.
  21061. * This mode makes the mesh edges visible
  21062. * @param epsilon defines the maximal distance between two angles to detect a face
  21063. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21064. * @returns the current InstancedLinesMesh
  21065. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21066. */
  21067. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21068. }
  21069. /**
  21070. * Defines the minimum contract an Edges renderer should follow.
  21071. */
  21072. export interface IEdgesRenderer extends IDisposable {
  21073. /**
  21074. * Gets or sets a boolean indicating if the edgesRenderer is active
  21075. */
  21076. isEnabled: boolean;
  21077. /**
  21078. * Renders the edges of the attached mesh,
  21079. */
  21080. render(): void;
  21081. /**
  21082. * Checks wether or not the edges renderer is ready to render.
  21083. * @return true if ready, otherwise false.
  21084. */
  21085. isReady(): boolean;
  21086. }
  21087. /**
  21088. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21089. */
  21090. export class EdgesRenderer implements IEdgesRenderer {
  21091. /**
  21092. * Define the size of the edges with an orthographic camera
  21093. */
  21094. edgesWidthScalerForOrthographic: number;
  21095. /**
  21096. * Define the size of the edges with a perspective camera
  21097. */
  21098. edgesWidthScalerForPerspective: number;
  21099. protected _source: AbstractMesh;
  21100. protected _linesPositions: number[];
  21101. protected _linesNormals: number[];
  21102. protected _linesIndices: number[];
  21103. protected _epsilon: number;
  21104. protected _indicesCount: number;
  21105. protected _lineShader: ShaderMaterial;
  21106. protected _ib: DataBuffer;
  21107. protected _buffers: {
  21108. [key: string]: Nullable<VertexBuffer>;
  21109. };
  21110. protected _checkVerticesInsteadOfIndices: boolean;
  21111. private _meshRebuildObserver;
  21112. private _meshDisposeObserver;
  21113. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21114. isEnabled: boolean;
  21115. /**
  21116. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21117. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21118. * @param source Mesh used to create edges
  21119. * @param epsilon sum of angles in adjacency to check for edge
  21120. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21121. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21122. */
  21123. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21124. protected _prepareRessources(): void;
  21125. /** @hidden */ private _rebuild(): void;
  21126. /**
  21127. * Releases the required resources for the edges renderer
  21128. */
  21129. dispose(): void;
  21130. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21131. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21132. /**
  21133. * Checks if the pair of p0 and p1 is en edge
  21134. * @param faceIndex
  21135. * @param edge
  21136. * @param faceNormals
  21137. * @param p0
  21138. * @param p1
  21139. * @private
  21140. */
  21141. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21142. /**
  21143. * push line into the position, normal and index buffer
  21144. * @protected
  21145. */
  21146. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21147. /**
  21148. * Generates lines edges from adjacencjes
  21149. * @private
  21150. */ private _generateEdgesLines(): void;
  21151. /**
  21152. * Checks wether or not the edges renderer is ready to render.
  21153. * @return true if ready, otherwise false.
  21154. */
  21155. isReady(): boolean;
  21156. /**
  21157. * Renders the edges of the attached mesh,
  21158. */
  21159. render(): void;
  21160. }
  21161. /**
  21162. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21163. */
  21164. export class LineEdgesRenderer extends EdgesRenderer {
  21165. /**
  21166. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21167. * @param source LineMesh used to generate edges
  21168. * @param epsilon not important (specified angle for edge detection)
  21169. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21170. */
  21171. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21172. /**
  21173. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21174. */ private _generateEdgesLines(): void;
  21175. }
  21176. }
  21177. declare module BABYLON {
  21178. /**
  21179. * This represents the object necessary to create a rendering group.
  21180. * This is exclusively used and created by the rendering manager.
  21181. * To modify the behavior, you use the available helpers in your scene or meshes.
  21182. * @hidden
  21183. */
  21184. export class RenderingGroup {
  21185. index: number;
  21186. private static _zeroVector;
  21187. private _scene;
  21188. private _opaqueSubMeshes;
  21189. private _transparentSubMeshes;
  21190. private _alphaTestSubMeshes;
  21191. private _depthOnlySubMeshes;
  21192. private _particleSystems;
  21193. private _spriteManagers;
  21194. private _opaqueSortCompareFn;
  21195. private _alphaTestSortCompareFn;
  21196. private _transparentSortCompareFn;
  21197. private _renderOpaque;
  21198. private _renderAlphaTest;
  21199. private _renderTransparent;
  21200. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  21201. onBeforeTransparentRendering: () => void;
  21202. /**
  21203. * Set the opaque sort comparison function.
  21204. * If null the sub meshes will be render in the order they were created
  21205. */
  21206. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21207. /**
  21208. * Set the alpha test sort comparison function.
  21209. * If null the sub meshes will be render in the order they were created
  21210. */
  21211. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21212. /**
  21213. * Set the transparent sort comparison function.
  21214. * If null the sub meshes will be render in the order they were created
  21215. */
  21216. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21217. /**
  21218. * Creates a new rendering group.
  21219. * @param index The rendering group index
  21220. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21221. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21222. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21223. */
  21224. 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>);
  21225. /**
  21226. * Render all the sub meshes contained in the group.
  21227. * @param customRenderFunction Used to override the default render behaviour of the group.
  21228. * @returns true if rendered some submeshes.
  21229. */
  21230. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21231. /**
  21232. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21233. * @param subMeshes The submeshes to render
  21234. */
  21235. private renderOpaqueSorted;
  21236. /**
  21237. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21238. * @param subMeshes The submeshes to render
  21239. */
  21240. private renderAlphaTestSorted;
  21241. /**
  21242. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21243. * @param subMeshes The submeshes to render
  21244. */
  21245. private renderTransparentSorted;
  21246. /**
  21247. * Renders the submeshes in a specified order.
  21248. * @param subMeshes The submeshes to sort before render
  21249. * @param sortCompareFn The comparison function use to sort
  21250. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21251. * @param transparent Specifies to activate blending if true
  21252. */
  21253. private static renderSorted;
  21254. /**
  21255. * Renders the submeshes in the order they were dispatched (no sort applied).
  21256. * @param subMeshes The submeshes to render
  21257. */
  21258. private static renderUnsorted;
  21259. /**
  21260. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21261. * are rendered back to front if in the same alpha index.
  21262. *
  21263. * @param a The first submesh
  21264. * @param b The second submesh
  21265. * @returns The result of the comparison
  21266. */
  21267. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21268. /**
  21269. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21270. * are rendered back to front.
  21271. *
  21272. * @param a The first submesh
  21273. * @param b The second submesh
  21274. * @returns The result of the comparison
  21275. */
  21276. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21277. /**
  21278. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21279. * are rendered front to back (prevent overdraw).
  21280. *
  21281. * @param a The first submesh
  21282. * @param b The second submesh
  21283. * @returns The result of the comparison
  21284. */
  21285. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21286. /**
  21287. * Resets the different lists of submeshes to prepare a new frame.
  21288. */
  21289. prepare(): void;
  21290. dispose(): void;
  21291. /**
  21292. * Inserts the submesh in its correct queue depending on its material.
  21293. * @param subMesh The submesh to dispatch
  21294. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21295. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21296. */
  21297. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21298. dispatchSprites(spriteManager: ISpriteManager): void;
  21299. dispatchParticles(particleSystem: IParticleSystem): void;
  21300. private _renderParticles;
  21301. private _renderSprites;
  21302. }
  21303. }
  21304. declare module BABYLON {
  21305. /**
  21306. * Interface describing the different options available in the rendering manager
  21307. * regarding Auto Clear between groups.
  21308. */
  21309. export interface IRenderingManagerAutoClearSetup {
  21310. /**
  21311. * Defines whether or not autoclear is enable.
  21312. */
  21313. autoClear: boolean;
  21314. /**
  21315. * Defines whether or not to autoclear the depth buffer.
  21316. */
  21317. depth: boolean;
  21318. /**
  21319. * Defines whether or not to autoclear the stencil buffer.
  21320. */
  21321. stencil: boolean;
  21322. }
  21323. /**
  21324. * This class is used by the onRenderingGroupObservable
  21325. */
  21326. export class RenderingGroupInfo {
  21327. /**
  21328. * The Scene that being rendered
  21329. */
  21330. scene: Scene;
  21331. /**
  21332. * The camera currently used for the rendering pass
  21333. */
  21334. camera: Nullable<Camera>;
  21335. /**
  21336. * The ID of the renderingGroup being processed
  21337. */
  21338. renderingGroupId: number;
  21339. }
  21340. /**
  21341. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21342. * It is enable to manage the different groups as well as the different necessary sort functions.
  21343. * This should not be used directly aside of the few static configurations
  21344. */
  21345. export class RenderingManager {
  21346. /**
  21347. * The max id used for rendering groups (not included)
  21348. */
  21349. static MAX_RENDERINGGROUPS: number;
  21350. /**
  21351. * The min id used for rendering groups (included)
  21352. */
  21353. static MIN_RENDERINGGROUPS: number;
  21354. /**
  21355. * Used to globally prevent autoclearing scenes.
  21356. */
  21357. static AUTOCLEAR: boolean;
  21358. /**
  21359. * @hidden
  21360. */ private _useSceneAutoClearSetup: boolean;
  21361. private _scene;
  21362. private _renderingGroups;
  21363. private _depthStencilBufferAlreadyCleaned;
  21364. private _autoClearDepthStencil;
  21365. private _customOpaqueSortCompareFn;
  21366. private _customAlphaTestSortCompareFn;
  21367. private _customTransparentSortCompareFn;
  21368. private _renderingGroupInfo;
  21369. /**
  21370. * Instantiates a new rendering group for a particular scene
  21371. * @param scene Defines the scene the groups belongs to
  21372. */
  21373. constructor(scene: Scene);
  21374. private _clearDepthStencilBuffer;
  21375. /**
  21376. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21377. * @hidden
  21378. */
  21379. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21380. /**
  21381. * Resets the different information of the group to prepare a new frame
  21382. * @hidden
  21383. */
  21384. reset(): void;
  21385. /**
  21386. * Dispose and release the group and its associated resources.
  21387. * @hidden
  21388. */
  21389. dispose(): void;
  21390. /**
  21391. * Clear the info related to rendering groups preventing retention points during dispose.
  21392. */
  21393. freeRenderingGroups(): void;
  21394. private _prepareRenderingGroup;
  21395. /**
  21396. * Add a sprite manager to the rendering manager in order to render it this frame.
  21397. * @param spriteManager Define the sprite manager to render
  21398. */
  21399. dispatchSprites(spriteManager: ISpriteManager): void;
  21400. /**
  21401. * Add a particle system to the rendering manager in order to render it this frame.
  21402. * @param particleSystem Define the particle system to render
  21403. */
  21404. dispatchParticles(particleSystem: IParticleSystem): void;
  21405. /**
  21406. * Add a submesh to the manager in order to render it this frame
  21407. * @param subMesh The submesh to dispatch
  21408. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21409. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21410. */
  21411. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21412. /**
  21413. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21414. * This allowed control for front to back rendering or reversly depending of the special needs.
  21415. *
  21416. * @param renderingGroupId The rendering group id corresponding to its index
  21417. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21418. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21419. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21420. */
  21421. 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;
  21422. /**
  21423. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21424. *
  21425. * @param renderingGroupId The rendering group id corresponding to its index
  21426. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21427. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21428. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21429. */
  21430. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21431. /**
  21432. * Gets the current auto clear configuration for one rendering group of the rendering
  21433. * manager.
  21434. * @param index the rendering group index to get the information for
  21435. * @returns The auto clear setup for the requested rendering group
  21436. */
  21437. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21438. }
  21439. }
  21440. declare module BABYLON {
  21441. /**
  21442. * This Helps creating a texture that will be created from a camera in your scene.
  21443. * It is basically a dynamic texture that could be used to create special effects for instance.
  21444. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21445. */
  21446. export class RenderTargetTexture extends Texture {
  21447. isCube: boolean;
  21448. /**
  21449. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21450. */
  21451. static readonly REFRESHRATE_RENDER_ONCE: number;
  21452. /**
  21453. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21454. */
  21455. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21456. /**
  21457. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21458. * the central point of your effect and can save a lot of performances.
  21459. */
  21460. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21461. /**
  21462. * Use this predicate to dynamically define the list of mesh you want to render.
  21463. * If set, the renderList property will be overwritten.
  21464. */
  21465. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21466. private _renderList;
  21467. /**
  21468. * Use this list to define the list of mesh you want to render.
  21469. */
  21470. renderList: Nullable<Array<AbstractMesh>>;
  21471. private _hookArray;
  21472. /**
  21473. * Define if particles should be rendered in your texture.
  21474. */
  21475. renderParticles: boolean;
  21476. /**
  21477. * Define if sprites should be rendered in your texture.
  21478. */
  21479. renderSprites: boolean;
  21480. /**
  21481. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21482. */
  21483. coordinatesMode: number;
  21484. /**
  21485. * Define the camera used to render the texture.
  21486. */
  21487. activeCamera: Nullable<Camera>;
  21488. /**
  21489. * Override the render function of the texture with your own one.
  21490. */
  21491. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21492. /**
  21493. * Define if camera post processes should be use while rendering the texture.
  21494. */
  21495. useCameraPostProcesses: boolean;
  21496. /**
  21497. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21498. */
  21499. ignoreCameraViewport: boolean;
  21500. private _postProcessManager;
  21501. private _postProcesses;
  21502. private _resizeObserver;
  21503. /**
  21504. * An event triggered when the texture is unbind.
  21505. */
  21506. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21507. /**
  21508. * An event triggered when the texture is unbind.
  21509. */
  21510. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21511. private _onAfterUnbindObserver;
  21512. /**
  21513. * Set a after unbind callback in the texture.
  21514. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21515. */
  21516. onAfterUnbind: () => void;
  21517. /**
  21518. * An event triggered before rendering the texture
  21519. */
  21520. onBeforeRenderObservable: Observable<number>;
  21521. private _onBeforeRenderObserver;
  21522. /**
  21523. * Set a before render callback in the texture.
  21524. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21525. */
  21526. onBeforeRender: (faceIndex: number) => void;
  21527. /**
  21528. * An event triggered after rendering the texture
  21529. */
  21530. onAfterRenderObservable: Observable<number>;
  21531. private _onAfterRenderObserver;
  21532. /**
  21533. * Set a after render callback in the texture.
  21534. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21535. */
  21536. onAfterRender: (faceIndex: number) => void;
  21537. /**
  21538. * An event triggered after the texture clear
  21539. */
  21540. onClearObservable: Observable<Engine>;
  21541. private _onClearObserver;
  21542. /**
  21543. * Set a clear callback in the texture.
  21544. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21545. */
  21546. onClear: (Engine: Engine) => void;
  21547. /**
  21548. * Define the clear color of the Render Target if it should be different from the scene.
  21549. */
  21550. clearColor: Color4;
  21551. protected _size: number | {
  21552. width: number;
  21553. height: number;
  21554. };
  21555. protected _initialSizeParameter: number | {
  21556. width: number;
  21557. height: number;
  21558. } | {
  21559. ratio: number;
  21560. };
  21561. protected _sizeRatio: Nullable<number>;
  21562. /** @hidden */ private _generateMipMaps: boolean;
  21563. protected _renderingManager: RenderingManager;
  21564. /** @hidden */ private _waitingRenderList: string[];
  21565. protected _doNotChangeAspectRatio: boolean;
  21566. protected _currentRefreshId: number;
  21567. protected _refreshRate: number;
  21568. protected _textureMatrix: Matrix;
  21569. protected _samples: number;
  21570. protected _renderTargetOptions: RenderTargetCreationOptions;
  21571. /**
  21572. * Gets render target creation options that were used.
  21573. */
  21574. readonly renderTargetOptions: RenderTargetCreationOptions;
  21575. protected _engine: Engine;
  21576. protected _onRatioRescale(): void;
  21577. /**
  21578. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21579. * It must define where the camera used to render the texture is set
  21580. */
  21581. boundingBoxPosition: Vector3;
  21582. private _boundingBoxSize;
  21583. /**
  21584. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21585. * When defined, the cubemap will switch to local mode
  21586. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21587. * @example https://www.babylonjs-playground.com/#RNASML
  21588. */
  21589. boundingBoxSize: Vector3;
  21590. /**
  21591. * In case the RTT has been created with a depth texture, get the associated
  21592. * depth texture.
  21593. * Otherwise, return null.
  21594. */
  21595. depthStencilTexture: Nullable<InternalTexture>;
  21596. /**
  21597. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21598. * or used a shadow, depth texture...
  21599. * @param name The friendly name of the texture
  21600. * @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)
  21601. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21602. * @param generateMipMaps True if mip maps need to be generated after render.
  21603. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21604. * @param type The type of the buffer in the RTT (int, half float, float...)
  21605. * @param isCube True if a cube texture needs to be created
  21606. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21607. * @param generateDepthBuffer True to generate a depth buffer
  21608. * @param generateStencilBuffer True to generate a stencil buffer
  21609. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21610. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21611. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21612. */
  21613. constructor(name: string, size: number | {
  21614. width: number;
  21615. height: number;
  21616. } | {
  21617. ratio: number;
  21618. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21619. /**
  21620. * Creates a depth stencil texture.
  21621. * This is only available in WebGL 2 or with the depth texture extension available.
  21622. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21623. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21624. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21625. */
  21626. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21627. private _processSizeParameter;
  21628. /**
  21629. * Define the number of samples to use in case of MSAA.
  21630. * It defaults to one meaning no MSAA has been enabled.
  21631. */
  21632. samples: number;
  21633. /**
  21634. * Resets the refresh counter of the texture and start bak from scratch.
  21635. * Could be useful to regenerate the texture if it is setup to render only once.
  21636. */
  21637. resetRefreshCounter(): void;
  21638. /**
  21639. * Define the refresh rate of the texture or the rendering frequency.
  21640. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21641. */
  21642. refreshRate: number;
  21643. /**
  21644. * Adds a post process to the render target rendering passes.
  21645. * @param postProcess define the post process to add
  21646. */
  21647. addPostProcess(postProcess: PostProcess): void;
  21648. /**
  21649. * Clear all the post processes attached to the render target
  21650. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21651. */
  21652. clearPostProcesses(dispose?: boolean): void;
  21653. /**
  21654. * Remove one of the post process from the list of attached post processes to the texture
  21655. * @param postProcess define the post process to remove from the list
  21656. */
  21657. removePostProcess(postProcess: PostProcess): void;
  21658. /** @hidden */ private _shouldRender(): boolean;
  21659. /**
  21660. * Gets the actual render size of the texture.
  21661. * @returns the width of the render size
  21662. */
  21663. getRenderSize(): number;
  21664. /**
  21665. * Gets the actual render width of the texture.
  21666. * @returns the width of the render size
  21667. */
  21668. getRenderWidth(): number;
  21669. /**
  21670. * Gets the actual render height of the texture.
  21671. * @returns the height of the render size
  21672. */
  21673. getRenderHeight(): number;
  21674. /**
  21675. * Get if the texture can be rescaled or not.
  21676. */
  21677. readonly canRescale: boolean;
  21678. /**
  21679. * Resize the texture using a ratio.
  21680. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21681. */
  21682. scale(ratio: number): void;
  21683. /**
  21684. * Get the texture reflection matrix used to rotate/transform the reflection.
  21685. * @returns the reflection matrix
  21686. */
  21687. getReflectionTextureMatrix(): Matrix;
  21688. /**
  21689. * Resize the texture to a new desired size.
  21690. * Be carrefull as it will recreate all the data in the new texture.
  21691. * @param size Define the new size. It can be:
  21692. * - a number for squared texture,
  21693. * - an object containing { width: number, height: number }
  21694. * - or an object containing a ratio { ratio: number }
  21695. */
  21696. resize(size: number | {
  21697. width: number;
  21698. height: number;
  21699. } | {
  21700. ratio: number;
  21701. }): void;
  21702. /**
  21703. * Renders all the objects from the render list into the texture.
  21704. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21705. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21706. */
  21707. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21708. private _bestReflectionRenderTargetDimension;
  21709. /**
  21710. * @hidden
  21711. * @param faceIndex face index to bind to if this is a cubetexture
  21712. */ private _bindFrameBuffer(faceIndex?: number): void;
  21713. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21714. private renderToTarget;
  21715. /**
  21716. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21717. * This allowed control for front to back rendering or reversly depending of the special needs.
  21718. *
  21719. * @param renderingGroupId The rendering group id corresponding to its index
  21720. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21721. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21722. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21723. */
  21724. 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;
  21725. /**
  21726. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21727. *
  21728. * @param renderingGroupId The rendering group id corresponding to its index
  21729. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21730. */
  21731. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21732. /**
  21733. * Clones the texture.
  21734. * @returns the cloned texture
  21735. */
  21736. clone(): RenderTargetTexture;
  21737. /**
  21738. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21739. * @returns The JSON representation of the texture
  21740. */
  21741. serialize(): any;
  21742. /**
  21743. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21744. */
  21745. disposeFramebufferObjects(): void;
  21746. /**
  21747. * Dispose the texture and release its associated resources.
  21748. */
  21749. dispose(): void;
  21750. /** @hidden */ private _rebuild(): void;
  21751. /**
  21752. * Clear the info related to rendering groups preventing retention point in material dispose.
  21753. */
  21754. freeRenderingGroups(): void;
  21755. /**
  21756. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21757. * @returns the view count
  21758. */
  21759. getViewCount(): number;
  21760. }
  21761. }
  21762. declare module BABYLON {
  21763. /**
  21764. * Base class for the main features of a material in Babylon.js
  21765. */
  21766. export class Material implements IAnimatable {
  21767. /**
  21768. * Returns the triangle fill mode
  21769. */
  21770. static readonly TriangleFillMode: number;
  21771. /**
  21772. * Returns the wireframe mode
  21773. */
  21774. static readonly WireFrameFillMode: number;
  21775. /**
  21776. * Returns the point fill mode
  21777. */
  21778. static readonly PointFillMode: number;
  21779. /**
  21780. * Returns the point list draw mode
  21781. */
  21782. static readonly PointListDrawMode: number;
  21783. /**
  21784. * Returns the line list draw mode
  21785. */
  21786. static readonly LineListDrawMode: number;
  21787. /**
  21788. * Returns the line loop draw mode
  21789. */
  21790. static readonly LineLoopDrawMode: number;
  21791. /**
  21792. * Returns the line strip draw mode
  21793. */
  21794. static readonly LineStripDrawMode: number;
  21795. /**
  21796. * Returns the triangle strip draw mode
  21797. */
  21798. static readonly TriangleStripDrawMode: number;
  21799. /**
  21800. * Returns the triangle fan draw mode
  21801. */
  21802. static readonly TriangleFanDrawMode: number;
  21803. /**
  21804. * Stores the clock-wise side orientation
  21805. */
  21806. static readonly ClockWiseSideOrientation: number;
  21807. /**
  21808. * Stores the counter clock-wise side orientation
  21809. */
  21810. static readonly CounterClockWiseSideOrientation: number;
  21811. /**
  21812. * The dirty texture flag value
  21813. */
  21814. static readonly TextureDirtyFlag: number;
  21815. /**
  21816. * The dirty light flag value
  21817. */
  21818. static readonly LightDirtyFlag: number;
  21819. /**
  21820. * The dirty fresnel flag value
  21821. */
  21822. static readonly FresnelDirtyFlag: number;
  21823. /**
  21824. * The dirty attribute flag value
  21825. */
  21826. static readonly AttributesDirtyFlag: number;
  21827. /**
  21828. * The dirty misc flag value
  21829. */
  21830. static readonly MiscDirtyFlag: number;
  21831. /**
  21832. * The all dirty flag value
  21833. */
  21834. static readonly AllDirtyFlag: number;
  21835. /**
  21836. * The ID of the material
  21837. */
  21838. id: string;
  21839. /**
  21840. * Gets or sets the unique id of the material
  21841. */
  21842. uniqueId: number;
  21843. /**
  21844. * The name of the material
  21845. */
  21846. name: string;
  21847. /**
  21848. * Gets or sets user defined metadata
  21849. */
  21850. metadata: any;
  21851. /**
  21852. * For internal use only. Please do not use.
  21853. */
  21854. reservedDataStore: any;
  21855. /**
  21856. * Specifies if the ready state should be checked on each call
  21857. */
  21858. checkReadyOnEveryCall: boolean;
  21859. /**
  21860. * Specifies if the ready state should be checked once
  21861. */
  21862. checkReadyOnlyOnce: boolean;
  21863. /**
  21864. * The state of the material
  21865. */
  21866. state: string;
  21867. /**
  21868. * The alpha value of the material
  21869. */
  21870. protected _alpha: number;
  21871. /**
  21872. * List of inspectable custom properties (used by the Inspector)
  21873. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21874. */
  21875. inspectableCustomProperties: IInspectable[];
  21876. /**
  21877. * Sets the alpha value of the material
  21878. */
  21879. /**
  21880. * Gets the alpha value of the material
  21881. */
  21882. alpha: number;
  21883. /**
  21884. * Specifies if back face culling is enabled
  21885. */
  21886. protected _backFaceCulling: boolean;
  21887. /**
  21888. * Sets the back-face culling state
  21889. */
  21890. /**
  21891. * Gets the back-face culling state
  21892. */
  21893. backFaceCulling: boolean;
  21894. /**
  21895. * Stores the value for side orientation
  21896. */
  21897. sideOrientation: number;
  21898. /**
  21899. * Callback triggered when the material is compiled
  21900. */
  21901. onCompiled: Nullable<(effect: Effect) => void>;
  21902. /**
  21903. * Callback triggered when an error occurs
  21904. */
  21905. onError: Nullable<(effect: Effect, errors: string) => void>;
  21906. /**
  21907. * Callback triggered to get the render target textures
  21908. */
  21909. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21910. /**
  21911. * Gets a boolean indicating that current material needs to register RTT
  21912. */
  21913. readonly hasRenderTargetTextures: boolean;
  21914. /**
  21915. * Specifies if the material should be serialized
  21916. */
  21917. doNotSerialize: boolean;
  21918. /**
  21919. * @hidden
  21920. */ private _storeEffectOnSubMeshes: boolean;
  21921. /**
  21922. * Stores the animations for the material
  21923. */
  21924. animations: Nullable<Array<Animation>>;
  21925. /**
  21926. * An event triggered when the material is disposed
  21927. */
  21928. onDisposeObservable: Observable<Material>;
  21929. /**
  21930. * An observer which watches for dispose events
  21931. */
  21932. private _onDisposeObserver;
  21933. private _onUnBindObservable;
  21934. /**
  21935. * Called during a dispose event
  21936. */
  21937. onDispose: () => void;
  21938. private _onBindObservable;
  21939. /**
  21940. * An event triggered when the material is bound
  21941. */
  21942. readonly onBindObservable: Observable<AbstractMesh>;
  21943. /**
  21944. * An observer which watches for bind events
  21945. */
  21946. private _onBindObserver;
  21947. /**
  21948. * Called during a bind event
  21949. */
  21950. onBind: (Mesh: AbstractMesh) => void;
  21951. /**
  21952. * An event triggered when the material is unbound
  21953. */
  21954. readonly onUnBindObservable: Observable<Material>;
  21955. /**
  21956. * Stores the value of the alpha mode
  21957. */
  21958. private _alphaMode;
  21959. /**
  21960. * Sets the value of the alpha mode.
  21961. *
  21962. * | Value | Type | Description |
  21963. * | --- | --- | --- |
  21964. * | 0 | ALPHA_DISABLE | |
  21965. * | 1 | ALPHA_ADD | |
  21966. * | 2 | ALPHA_COMBINE | |
  21967. * | 3 | ALPHA_SUBTRACT | |
  21968. * | 4 | ALPHA_MULTIPLY | |
  21969. * | 5 | ALPHA_MAXIMIZED | |
  21970. * | 6 | ALPHA_ONEONE | |
  21971. * | 7 | ALPHA_PREMULTIPLIED | |
  21972. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21973. * | 9 | ALPHA_INTERPOLATE | |
  21974. * | 10 | ALPHA_SCREENMODE | |
  21975. *
  21976. */
  21977. /**
  21978. * Gets the value of the alpha mode
  21979. */
  21980. alphaMode: number;
  21981. /**
  21982. * Stores the state of the need depth pre-pass value
  21983. */
  21984. private _needDepthPrePass;
  21985. /**
  21986. * Sets the need depth pre-pass value
  21987. */
  21988. /**
  21989. * Gets the depth pre-pass value
  21990. */
  21991. needDepthPrePass: boolean;
  21992. /**
  21993. * Specifies if depth writing should be disabled
  21994. */
  21995. disableDepthWrite: boolean;
  21996. /**
  21997. * Specifies if depth writing should be forced
  21998. */
  21999. forceDepthWrite: boolean;
  22000. /**
  22001. * Specifies if there should be a separate pass for culling
  22002. */
  22003. separateCullingPass: boolean;
  22004. /**
  22005. * Stores the state specifing if fog should be enabled
  22006. */
  22007. private _fogEnabled;
  22008. /**
  22009. * Sets the state for enabling fog
  22010. */
  22011. /**
  22012. * Gets the value of the fog enabled state
  22013. */
  22014. fogEnabled: boolean;
  22015. /**
  22016. * Stores the size of points
  22017. */
  22018. pointSize: number;
  22019. /**
  22020. * Stores the z offset value
  22021. */
  22022. zOffset: number;
  22023. /**
  22024. * Gets a value specifying if wireframe mode is enabled
  22025. */
  22026. /**
  22027. * Sets the state of wireframe mode
  22028. */
  22029. wireframe: boolean;
  22030. /**
  22031. * Gets the value specifying if point clouds are enabled
  22032. */
  22033. /**
  22034. * Sets the state of point cloud mode
  22035. */
  22036. pointsCloud: boolean;
  22037. /**
  22038. * Gets the material fill mode
  22039. */
  22040. /**
  22041. * Sets the material fill mode
  22042. */
  22043. fillMode: number;
  22044. /**
  22045. * @hidden
  22046. * Stores the effects for the material
  22047. */ private _effect: Nullable<Effect>;
  22048. /**
  22049. * @hidden
  22050. * Specifies if the material was previously ready
  22051. */ private _wasPreviouslyReady: boolean;
  22052. /**
  22053. * Specifies if uniform buffers should be used
  22054. */
  22055. private _useUBO;
  22056. /**
  22057. * Stores a reference to the scene
  22058. */
  22059. private _scene;
  22060. /**
  22061. * Stores the fill mode state
  22062. */
  22063. private _fillMode;
  22064. /**
  22065. * Specifies if the depth write state should be cached
  22066. */
  22067. private _cachedDepthWriteState;
  22068. /**
  22069. * Stores the uniform buffer
  22070. */
  22071. protected _uniformBuffer: UniformBuffer;
  22072. /** @hidden */ private _indexInSceneMaterialArray: number;
  22073. /** @hidden */
  22074. meshMap: Nullable<{
  22075. [id: string]: AbstractMesh | undefined;
  22076. }>;
  22077. /**
  22078. * Creates a material instance
  22079. * @param name defines the name of the material
  22080. * @param scene defines the scene to reference
  22081. * @param doNotAdd specifies if the material should be added to the scene
  22082. */
  22083. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22084. /**
  22085. * Returns a string representation of the current material
  22086. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22087. * @returns a string with material information
  22088. */
  22089. toString(fullDetails?: boolean): string;
  22090. /**
  22091. * Gets the class name of the material
  22092. * @returns a string with the class name of the material
  22093. */
  22094. getClassName(): string;
  22095. /**
  22096. * Specifies if updates for the material been locked
  22097. */
  22098. readonly isFrozen: boolean;
  22099. /**
  22100. * Locks updates for the material
  22101. */
  22102. freeze(): void;
  22103. /**
  22104. * Unlocks updates for the material
  22105. */
  22106. unfreeze(): void;
  22107. /**
  22108. * Specifies if the material is ready to be used
  22109. * @param mesh defines the mesh to check
  22110. * @param useInstances specifies if instances should be used
  22111. * @returns a boolean indicating if the material is ready to be used
  22112. */
  22113. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22114. /**
  22115. * Specifies that the submesh is ready to be used
  22116. * @param mesh defines the mesh to check
  22117. * @param subMesh defines which submesh to check
  22118. * @param useInstances specifies that instances should be used
  22119. * @returns a boolean indicating that the submesh is ready or not
  22120. */
  22121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22122. /**
  22123. * Returns the material effect
  22124. * @returns the effect associated with the material
  22125. */
  22126. getEffect(): Nullable<Effect>;
  22127. /**
  22128. * Returns the current scene
  22129. * @returns a Scene
  22130. */
  22131. getScene(): Scene;
  22132. /**
  22133. * Specifies if the material will require alpha blending
  22134. * @returns a boolean specifying if alpha blending is needed
  22135. */
  22136. needAlphaBlending(): boolean;
  22137. /**
  22138. * Specifies if the mesh will require alpha blending
  22139. * @param mesh defines the mesh to check
  22140. * @returns a boolean specifying if alpha blending is needed for the mesh
  22141. */
  22142. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22143. /**
  22144. * Specifies if this material should be rendered in alpha test mode
  22145. * @returns a boolean specifying if an alpha test is needed.
  22146. */
  22147. needAlphaTesting(): boolean;
  22148. /**
  22149. * Gets the texture used for the alpha test
  22150. * @returns the texture to use for alpha testing
  22151. */
  22152. getAlphaTestTexture(): Nullable<BaseTexture>;
  22153. /**
  22154. * Marks the material to indicate that it needs to be re-calculated
  22155. */
  22156. markDirty(): void;
  22157. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22158. /**
  22159. * Binds the material to the mesh
  22160. * @param world defines the world transformation matrix
  22161. * @param mesh defines the mesh to bind the material to
  22162. */
  22163. bind(world: Matrix, mesh?: Mesh): void;
  22164. /**
  22165. * Binds the submesh to the material
  22166. * @param world defines the world transformation matrix
  22167. * @param mesh defines the mesh containing the submesh
  22168. * @param subMesh defines the submesh to bind the material to
  22169. */
  22170. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22171. /**
  22172. * Binds the world matrix to the material
  22173. * @param world defines the world transformation matrix
  22174. */
  22175. bindOnlyWorldMatrix(world: Matrix): void;
  22176. /**
  22177. * Binds the scene's uniform buffer to the effect.
  22178. * @param effect defines the effect to bind to the scene uniform buffer
  22179. * @param sceneUbo defines the uniform buffer storing scene data
  22180. */
  22181. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22182. /**
  22183. * Binds the view matrix to the effect
  22184. * @param effect defines the effect to bind the view matrix to
  22185. */
  22186. bindView(effect: Effect): void;
  22187. /**
  22188. * Binds the view projection matrix to the effect
  22189. * @param effect defines the effect to bind the view projection matrix to
  22190. */
  22191. bindViewProjection(effect: Effect): void;
  22192. /**
  22193. * Specifies if material alpha testing should be turned on for the mesh
  22194. * @param mesh defines the mesh to check
  22195. */
  22196. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22197. /**
  22198. * Processes to execute after binding the material to a mesh
  22199. * @param mesh defines the rendered mesh
  22200. */
  22201. protected _afterBind(mesh?: Mesh): void;
  22202. /**
  22203. * Unbinds the material from the mesh
  22204. */
  22205. unbind(): void;
  22206. /**
  22207. * Gets the active textures from the material
  22208. * @returns an array of textures
  22209. */
  22210. getActiveTextures(): BaseTexture[];
  22211. /**
  22212. * Specifies if the material uses a texture
  22213. * @param texture defines the texture to check against the material
  22214. * @returns a boolean specifying if the material uses the texture
  22215. */
  22216. hasTexture(texture: BaseTexture): boolean;
  22217. /**
  22218. * Makes a duplicate of the material, and gives it a new name
  22219. * @param name defines the new name for the duplicated material
  22220. * @returns the cloned material
  22221. */
  22222. clone(name: string): Nullable<Material>;
  22223. /**
  22224. * Gets the meshes bound to the material
  22225. * @returns an array of meshes bound to the material
  22226. */
  22227. getBindedMeshes(): AbstractMesh[];
  22228. /**
  22229. * Force shader compilation
  22230. * @param mesh defines the mesh associated with this material
  22231. * @param onCompiled defines a function to execute once the material is compiled
  22232. * @param options defines the options to configure the compilation
  22233. */
  22234. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22235. clipPlane: boolean;
  22236. }>): void;
  22237. /**
  22238. * Force shader compilation
  22239. * @param mesh defines the mesh that will use this material
  22240. * @param options defines additional options for compiling the shaders
  22241. * @returns a promise that resolves when the compilation completes
  22242. */
  22243. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22244. clipPlane: boolean;
  22245. }>): Promise<void>;
  22246. private static readonly _AllDirtyCallBack;
  22247. private static readonly _ImageProcessingDirtyCallBack;
  22248. private static readonly _TextureDirtyCallBack;
  22249. private static readonly _FresnelDirtyCallBack;
  22250. private static readonly _MiscDirtyCallBack;
  22251. private static readonly _LightsDirtyCallBack;
  22252. private static readonly _AttributeDirtyCallBack;
  22253. private static _FresnelAndMiscDirtyCallBack;
  22254. private static _TextureAndMiscDirtyCallBack;
  22255. private static readonly _DirtyCallbackArray;
  22256. private static readonly _RunDirtyCallBacks;
  22257. /**
  22258. * Marks a define in the material to indicate that it needs to be re-computed
  22259. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22260. */
  22261. markAsDirty(flag: number): void;
  22262. /**
  22263. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22264. * @param func defines a function which checks material defines against the submeshes
  22265. */
  22266. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22267. /**
  22268. * Indicates that we need to re-calculated for all submeshes
  22269. */
  22270. protected _markAllSubMeshesAsAllDirty(): void;
  22271. /**
  22272. * Indicates that image processing needs to be re-calculated for all submeshes
  22273. */
  22274. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22275. /**
  22276. * Indicates that textures need to be re-calculated for all submeshes
  22277. */
  22278. protected _markAllSubMeshesAsTexturesDirty(): void;
  22279. /**
  22280. * Indicates that fresnel needs to be re-calculated for all submeshes
  22281. */
  22282. protected _markAllSubMeshesAsFresnelDirty(): void;
  22283. /**
  22284. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22285. */
  22286. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22287. /**
  22288. * Indicates that lights need to be re-calculated for all submeshes
  22289. */
  22290. protected _markAllSubMeshesAsLightsDirty(): void;
  22291. /**
  22292. * Indicates that attributes need to be re-calculated for all submeshes
  22293. */
  22294. protected _markAllSubMeshesAsAttributesDirty(): void;
  22295. /**
  22296. * Indicates that misc needs to be re-calculated for all submeshes
  22297. */
  22298. protected _markAllSubMeshesAsMiscDirty(): void;
  22299. /**
  22300. * Indicates that textures and misc need to be re-calculated for all submeshes
  22301. */
  22302. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22303. /**
  22304. * Disposes the material
  22305. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22306. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22307. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22308. */
  22309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22310. /** @hidden */
  22311. private releaseVertexArrayObject;
  22312. /**
  22313. * Serializes this material
  22314. * @returns the serialized material object
  22315. */
  22316. serialize(): any;
  22317. /**
  22318. * Creates a material from parsed material data
  22319. * @param parsedMaterial defines parsed material data
  22320. * @param scene defines the hosting scene
  22321. * @param rootUrl defines the root URL to use to load textures
  22322. * @returns a new material
  22323. */
  22324. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22325. }
  22326. }
  22327. declare module BABYLON {
  22328. /**
  22329. * Base class for submeshes
  22330. */
  22331. export class BaseSubMesh {
  22332. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  22333. /** @hidden */ private _materialEffect: Nullable<Effect>;
  22334. /**
  22335. * Gets associated effect
  22336. */
  22337. readonly effect: Nullable<Effect>;
  22338. /**
  22339. * Sets associated effect (effect used to render this submesh)
  22340. * @param effect defines the effect to associate with
  22341. * @param defines defines the set of defines used to compile this effect
  22342. */
  22343. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22344. }
  22345. /**
  22346. * Defines a subdivision inside a mesh
  22347. */
  22348. export class SubMesh extends BaseSubMesh implements ICullable {
  22349. /** the material index to use */
  22350. materialIndex: number;
  22351. /** vertex index start */
  22352. verticesStart: number;
  22353. /** vertices count */
  22354. verticesCount: number;
  22355. /** index start */
  22356. indexStart: number;
  22357. /** indices count */
  22358. indexCount: number;
  22359. /** @hidden */ private _linesIndexCount: number;
  22360. private _mesh;
  22361. private _renderingMesh;
  22362. private _boundingInfo;
  22363. private _linesIndexBuffer;
  22364. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  22365. /** @hidden */ private _trianglePlanes: Plane[];
  22366. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  22367. /** @hidden */ private _renderId: number;
  22368. /** @hidden */ private _alphaIndex: number;
  22369. /** @hidden */ private _distanceToCamera: number;
  22370. /** @hidden */ private _id: number;
  22371. private _currentMaterial;
  22372. /**
  22373. * Add a new submesh to a mesh
  22374. * @param materialIndex defines the material index to use
  22375. * @param verticesStart defines vertex index start
  22376. * @param verticesCount defines vertices count
  22377. * @param indexStart defines index start
  22378. * @param indexCount defines indices count
  22379. * @param mesh defines the parent mesh
  22380. * @param renderingMesh defines an optional rendering mesh
  22381. * @param createBoundingBox defines if bounding box should be created for this submesh
  22382. * @returns the new submesh
  22383. */
  22384. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22385. /**
  22386. * Creates a new submesh
  22387. * @param materialIndex defines the material index to use
  22388. * @param verticesStart defines vertex index start
  22389. * @param verticesCount defines vertices count
  22390. * @param indexStart defines index start
  22391. * @param indexCount defines indices count
  22392. * @param mesh defines the parent mesh
  22393. * @param renderingMesh defines an optional rendering mesh
  22394. * @param createBoundingBox defines if bounding box should be created for this submesh
  22395. */
  22396. constructor(
  22397. /** the material index to use */
  22398. materialIndex: number,
  22399. /** vertex index start */
  22400. verticesStart: number,
  22401. /** vertices count */
  22402. verticesCount: number,
  22403. /** index start */
  22404. indexStart: number,
  22405. /** indices count */
  22406. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22407. /**
  22408. * Returns true if this submesh covers the entire parent mesh
  22409. * @ignorenaming
  22410. */
  22411. readonly IsGlobal: boolean;
  22412. /**
  22413. * Returns the submesh BoudingInfo object
  22414. * @returns current bounding info (or mesh's one if the submesh is global)
  22415. */
  22416. getBoundingInfo(): BoundingInfo;
  22417. /**
  22418. * Sets the submesh BoundingInfo
  22419. * @param boundingInfo defines the new bounding info to use
  22420. * @returns the SubMesh
  22421. */
  22422. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22423. /**
  22424. * Returns the mesh of the current submesh
  22425. * @return the parent mesh
  22426. */
  22427. getMesh(): AbstractMesh;
  22428. /**
  22429. * Returns the rendering mesh of the submesh
  22430. * @returns the rendering mesh (could be different from parent mesh)
  22431. */
  22432. getRenderingMesh(): Mesh;
  22433. /**
  22434. * Returns the submesh material
  22435. * @returns null or the current material
  22436. */
  22437. getMaterial(): Nullable<Material>;
  22438. /**
  22439. * Sets a new updated BoundingInfo object to the submesh
  22440. * @param data defines an optional position array to use to determine the bounding info
  22441. * @returns the SubMesh
  22442. */
  22443. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22444. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  22445. /**
  22446. * Updates the submesh BoundingInfo
  22447. * @param world defines the world matrix to use to update the bounding info
  22448. * @returns the submesh
  22449. */
  22450. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22451. /**
  22452. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22453. * @param frustumPlanes defines the frustum planes
  22454. * @returns true if the submesh is intersecting with the frustum
  22455. */
  22456. isInFrustum(frustumPlanes: Plane[]): boolean;
  22457. /**
  22458. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22459. * @param frustumPlanes defines the frustum planes
  22460. * @returns true if the submesh is inside the frustum
  22461. */
  22462. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22463. /**
  22464. * Renders the submesh
  22465. * @param enableAlphaMode defines if alpha needs to be used
  22466. * @returns the submesh
  22467. */
  22468. render(enableAlphaMode: boolean): SubMesh;
  22469. /**
  22470. * @hidden
  22471. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22472. /**
  22473. * Checks if the submesh intersects with a ray
  22474. * @param ray defines the ray to test
  22475. * @returns true is the passed ray intersects the submesh bounding box
  22476. */
  22477. canIntersects(ray: Ray): boolean;
  22478. /**
  22479. * Intersects current submesh with a ray
  22480. * @param ray defines the ray to test
  22481. * @param positions defines mesh's positions array
  22482. * @param indices defines mesh's indices array
  22483. * @param fastCheck defines if only bounding info should be used
  22484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22485. * @returns intersection info or null if no intersection
  22486. */
  22487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22488. /** @hidden */
  22489. private _intersectLines;
  22490. /** @hidden */
  22491. private _intersectUnIndexedLines;
  22492. /** @hidden */
  22493. private _intersectTriangles;
  22494. /** @hidden */
  22495. private _intersectUnIndexedTriangles;
  22496. /** @hidden */ private _rebuild(): void;
  22497. /**
  22498. * Creates a new submesh from the passed mesh
  22499. * @param newMesh defines the new hosting mesh
  22500. * @param newRenderingMesh defines an optional rendering mesh
  22501. * @returns the new submesh
  22502. */
  22503. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22504. /**
  22505. * Release associated resources
  22506. */
  22507. dispose(): void;
  22508. /**
  22509. * Gets the class name
  22510. * @returns the string "SubMesh".
  22511. */
  22512. getClassName(): string;
  22513. /**
  22514. * Creates a new submesh from indices data
  22515. * @param materialIndex the index of the main mesh material
  22516. * @param startIndex the index where to start the copy in the mesh indices array
  22517. * @param indexCount the number of indices to copy then from the startIndex
  22518. * @param mesh the main mesh to create the submesh from
  22519. * @param renderingMesh the optional rendering mesh
  22520. * @returns a new submesh
  22521. */
  22522. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22523. }
  22524. }
  22525. declare module BABYLON {
  22526. /**
  22527. * Class used to store geometry data (vertex buffers + index buffer)
  22528. */
  22529. export class Geometry implements IGetSetVerticesData {
  22530. /**
  22531. * Gets or sets the ID of the geometry
  22532. */
  22533. id: string;
  22534. /**
  22535. * Gets or sets the unique ID of the geometry
  22536. */
  22537. uniqueId: number;
  22538. /**
  22539. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22540. */
  22541. delayLoadState: number;
  22542. /**
  22543. * Gets the file containing the data to load when running in delay load state
  22544. */
  22545. delayLoadingFile: Nullable<string>;
  22546. /**
  22547. * Callback called when the geometry is updated
  22548. */
  22549. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22550. private _scene;
  22551. private _engine;
  22552. private _meshes;
  22553. private _totalVertices;
  22554. /** @hidden */ private _indices: IndicesArray;
  22555. /** @hidden */ private _vertexBuffers: {
  22556. [key: string]: VertexBuffer;
  22557. };
  22558. private _isDisposed;
  22559. private _extend;
  22560. private _boundingBias;
  22561. /** @hidden */ private _delayInfo: Array<string>;
  22562. private _indexBuffer;
  22563. private _indexBufferIsUpdatable;
  22564. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  22565. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22566. /** @hidden */ private _softwareSkinningFrameId: number;
  22567. private _vertexArrayObjects;
  22568. private _updatable;
  22569. /** @hidden */ private _positions: Nullable<Vector3[]>;
  22570. /**
  22571. * 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
  22572. */
  22573. /**
  22574. * 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
  22575. */
  22576. boundingBias: Vector2;
  22577. /**
  22578. * Static function used to attach a new empty geometry to a mesh
  22579. * @param mesh defines the mesh to attach the geometry to
  22580. * @returns the new Geometry
  22581. */
  22582. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22583. /**
  22584. * Creates a new geometry
  22585. * @param id defines the unique ID
  22586. * @param scene defines the hosting scene
  22587. * @param vertexData defines the VertexData used to get geometry data
  22588. * @param updatable defines if geometry must be updatable (false by default)
  22589. * @param mesh defines the mesh that will be associated with the geometry
  22590. */
  22591. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22592. /**
  22593. * Gets the current extend of the geometry
  22594. */
  22595. readonly extend: {
  22596. minimum: Vector3;
  22597. maximum: Vector3;
  22598. };
  22599. /**
  22600. * Gets the hosting scene
  22601. * @returns the hosting Scene
  22602. */
  22603. getScene(): Scene;
  22604. /**
  22605. * Gets the hosting engine
  22606. * @returns the hosting Engine
  22607. */
  22608. getEngine(): Engine;
  22609. /**
  22610. * Defines if the geometry is ready to use
  22611. * @returns true if the geometry is ready to be used
  22612. */
  22613. isReady(): boolean;
  22614. /**
  22615. * Gets a value indicating that the geometry should not be serialized
  22616. */
  22617. readonly doNotSerialize: boolean;
  22618. /** @hidden */ private _rebuild(): void;
  22619. /**
  22620. * Affects all geometry data in one call
  22621. * @param vertexData defines the geometry data
  22622. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22623. */
  22624. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22625. /**
  22626. * Set specific vertex data
  22627. * @param kind defines the data kind (Position, normal, etc...)
  22628. * @param data defines the vertex data to use
  22629. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22630. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22631. */
  22632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22633. /**
  22634. * Removes a specific vertex data
  22635. * @param kind defines the data kind (Position, normal, etc...)
  22636. */
  22637. removeVerticesData(kind: string): void;
  22638. /**
  22639. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22640. * @param buffer defines the vertex buffer to use
  22641. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22642. */
  22643. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22644. /**
  22645. * Update a specific vertex buffer
  22646. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22647. * It will do nothing if the buffer is not updatable
  22648. * @param kind defines the data kind (Position, normal, etc...)
  22649. * @param data defines the data to use
  22650. * @param offset defines the offset in the target buffer where to store the data
  22651. * @param useBytes set to true if the offset is in bytes
  22652. */
  22653. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22654. /**
  22655. * Update a specific vertex buffer
  22656. * This function will create a new buffer if the current one is not updatable
  22657. * @param kind defines the data kind (Position, normal, etc...)
  22658. * @param data defines the data to use
  22659. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22660. */
  22661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22662. private _updateBoundingInfo;
  22663. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22664. /**
  22665. * Gets total number of vertices
  22666. * @returns the total number of vertices
  22667. */
  22668. getTotalVertices(): number;
  22669. /**
  22670. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22671. * @param kind defines the data kind (Position, normal, etc...)
  22672. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22674. * @returns a float array containing vertex data
  22675. */
  22676. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22677. /**
  22678. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22679. * @param kind defines the data kind (Position, normal, etc...)
  22680. * @returns true if the vertex buffer with the specified kind is updatable
  22681. */
  22682. isVertexBufferUpdatable(kind: string): boolean;
  22683. /**
  22684. * Gets a specific vertex buffer
  22685. * @param kind defines the data kind (Position, normal, etc...)
  22686. * @returns a VertexBuffer
  22687. */
  22688. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22689. /**
  22690. * Returns all vertex buffers
  22691. * @return an object holding all vertex buffers indexed by kind
  22692. */
  22693. getVertexBuffers(): Nullable<{
  22694. [key: string]: VertexBuffer;
  22695. }>;
  22696. /**
  22697. * Gets a boolean indicating if specific vertex buffer is present
  22698. * @param kind defines the data kind (Position, normal, etc...)
  22699. * @returns true if data is present
  22700. */
  22701. isVerticesDataPresent(kind: string): boolean;
  22702. /**
  22703. * Gets a list of all attached data kinds (Position, normal, etc...)
  22704. * @returns a list of string containing all kinds
  22705. */
  22706. getVerticesDataKinds(): string[];
  22707. /**
  22708. * Update index buffer
  22709. * @param indices defines the indices to store in the index buffer
  22710. * @param offset defines the offset in the target buffer where to store the data
  22711. * @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)
  22712. */
  22713. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22714. /**
  22715. * Creates a new index buffer
  22716. * @param indices defines the indices to store in the index buffer
  22717. * @param totalVertices defines the total number of vertices (could be null)
  22718. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22719. */
  22720. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22721. /**
  22722. * Return the total number of indices
  22723. * @returns the total number of indices
  22724. */
  22725. getTotalIndices(): number;
  22726. /**
  22727. * Gets the index buffer array
  22728. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22729. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22730. * @returns the index buffer array
  22731. */
  22732. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22733. /**
  22734. * Gets the index buffer
  22735. * @return the index buffer
  22736. */
  22737. getIndexBuffer(): Nullable<DataBuffer>;
  22738. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22739. /**
  22740. * Release the associated resources for a specific mesh
  22741. * @param mesh defines the source mesh
  22742. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22743. */
  22744. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22745. /**
  22746. * Apply current geometry to a given mesh
  22747. * @param mesh defines the mesh to apply geometry to
  22748. */
  22749. applyToMesh(mesh: Mesh): void;
  22750. private _updateExtend;
  22751. private _applyToMesh;
  22752. private notifyUpdate;
  22753. /**
  22754. * Load the geometry if it was flagged as delay loaded
  22755. * @param scene defines the hosting scene
  22756. * @param onLoaded defines a callback called when the geometry is loaded
  22757. */
  22758. load(scene: Scene, onLoaded?: () => void): void;
  22759. private _queueLoad;
  22760. /**
  22761. * Invert the geometry to move from a right handed system to a left handed one.
  22762. */
  22763. toLeftHanded(): void;
  22764. /** @hidden */ private _resetPointsArrayCache(): void;
  22765. /** @hidden */ private _generatePointsArray(): boolean;
  22766. /**
  22767. * Gets a value indicating if the geometry is disposed
  22768. * @returns true if the geometry was disposed
  22769. */
  22770. isDisposed(): boolean;
  22771. private _disposeVertexArrayObjects;
  22772. /**
  22773. * Free all associated resources
  22774. */
  22775. dispose(): void;
  22776. /**
  22777. * Clone the current geometry into a new geometry
  22778. * @param id defines the unique ID of the new geometry
  22779. * @returns a new geometry object
  22780. */
  22781. copy(id: string): Geometry;
  22782. /**
  22783. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22784. * @return a JSON representation of the current geometry data (without the vertices data)
  22785. */
  22786. serialize(): any;
  22787. private toNumberArray;
  22788. /**
  22789. * Serialize all vertices data into a JSON oject
  22790. * @returns a JSON representation of the current geometry data
  22791. */
  22792. serializeVerticeData(): any;
  22793. /**
  22794. * Extracts a clone of a mesh geometry
  22795. * @param mesh defines the source mesh
  22796. * @param id defines the unique ID of the new geometry object
  22797. * @returns the new geometry object
  22798. */
  22799. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22800. /**
  22801. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22802. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22803. * Be aware Math.random() could cause collisions, but:
  22804. * "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"
  22805. * @returns a string containing a new GUID
  22806. */
  22807. static RandomId(): string;
  22808. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22809. private static _CleanMatricesWeights;
  22810. /**
  22811. * Create a new geometry from persisted data (Using .babylon file format)
  22812. * @param parsedVertexData defines the persisted data
  22813. * @param scene defines the hosting scene
  22814. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22815. * @returns the new geometry object
  22816. */
  22817. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22818. }
  22819. }
  22820. declare module BABYLON {
  22821. /**
  22822. * Define an interface for all classes that will get and set the data on vertices
  22823. */
  22824. export interface IGetSetVerticesData {
  22825. /**
  22826. * Gets a boolean indicating if specific vertex data is present
  22827. * @param kind defines the vertex data kind to use
  22828. * @returns true is data kind is present
  22829. */
  22830. isVerticesDataPresent(kind: string): boolean;
  22831. /**
  22832. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22833. * @param kind defines the data kind (Position, normal, etc...)
  22834. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22835. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22836. * @returns a float array containing vertex data
  22837. */
  22838. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22839. /**
  22840. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22841. * @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.
  22842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22843. * @returns the indices array or an empty array if the mesh has no geometry
  22844. */
  22845. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22846. /**
  22847. * Set specific vertex data
  22848. * @param kind defines the data kind (Position, normal, etc...)
  22849. * @param data defines the vertex data to use
  22850. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22851. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22852. */
  22853. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22854. /**
  22855. * Update a specific associated vertex buffer
  22856. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22857. * - VertexBuffer.PositionKind
  22858. * - VertexBuffer.UVKind
  22859. * - VertexBuffer.UV2Kind
  22860. * - VertexBuffer.UV3Kind
  22861. * - VertexBuffer.UV4Kind
  22862. * - VertexBuffer.UV5Kind
  22863. * - VertexBuffer.UV6Kind
  22864. * - VertexBuffer.ColorKind
  22865. * - VertexBuffer.MatricesIndicesKind
  22866. * - VertexBuffer.MatricesIndicesExtraKind
  22867. * - VertexBuffer.MatricesWeightsKind
  22868. * - VertexBuffer.MatricesWeightsExtraKind
  22869. * @param data defines the data source
  22870. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22871. * @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)
  22872. */
  22873. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22874. /**
  22875. * Creates a new index buffer
  22876. * @param indices defines the indices to store in the index buffer
  22877. * @param totalVertices defines the total number of vertices (could be null)
  22878. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22879. */
  22880. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22881. }
  22882. /**
  22883. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22884. */
  22885. export class VertexData {
  22886. /**
  22887. * Mesh side orientation : usually the external or front surface
  22888. */
  22889. static readonly FRONTSIDE: number;
  22890. /**
  22891. * Mesh side orientation : usually the internal or back surface
  22892. */
  22893. static readonly BACKSIDE: number;
  22894. /**
  22895. * Mesh side orientation : both internal and external or front and back surfaces
  22896. */
  22897. static readonly DOUBLESIDE: number;
  22898. /**
  22899. * Mesh side orientation : by default, `FRONTSIDE`
  22900. */
  22901. static readonly DEFAULTSIDE: number;
  22902. /**
  22903. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22904. */
  22905. positions: Nullable<FloatArray>;
  22906. /**
  22907. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22908. */
  22909. normals: Nullable<FloatArray>;
  22910. /**
  22911. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22912. */
  22913. tangents: Nullable<FloatArray>;
  22914. /**
  22915. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22916. */
  22917. uvs: Nullable<FloatArray>;
  22918. /**
  22919. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22920. */
  22921. uvs2: Nullable<FloatArray>;
  22922. /**
  22923. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22924. */
  22925. uvs3: Nullable<FloatArray>;
  22926. /**
  22927. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22928. */
  22929. uvs4: Nullable<FloatArray>;
  22930. /**
  22931. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22932. */
  22933. uvs5: Nullable<FloatArray>;
  22934. /**
  22935. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22936. */
  22937. uvs6: Nullable<FloatArray>;
  22938. /**
  22939. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22940. */
  22941. colors: Nullable<FloatArray>;
  22942. /**
  22943. * 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).
  22944. */
  22945. matricesIndices: Nullable<FloatArray>;
  22946. /**
  22947. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22948. */
  22949. matricesWeights: Nullable<FloatArray>;
  22950. /**
  22951. * An array extending the number of possible indices
  22952. */
  22953. matricesIndicesExtra: Nullable<FloatArray>;
  22954. /**
  22955. * An array extending the number of possible weights when the number of indices is extended
  22956. */
  22957. matricesWeightsExtra: Nullable<FloatArray>;
  22958. /**
  22959. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22960. */
  22961. indices: Nullable<IndicesArray>;
  22962. /**
  22963. * Uses the passed data array to set the set the values for the specified kind of data
  22964. * @param data a linear array of floating numbers
  22965. * @param kind the type of data that is being set, eg positions, colors etc
  22966. */
  22967. set(data: FloatArray, kind: string): void;
  22968. /**
  22969. * Associates the vertexData to the passed Mesh.
  22970. * Sets it as updatable or not (default `false`)
  22971. * @param mesh the mesh the vertexData is applied to
  22972. * @param updatable when used and having the value true allows new data to update the vertexData
  22973. * @returns the VertexData
  22974. */
  22975. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22976. /**
  22977. * Associates the vertexData to the passed Geometry.
  22978. * Sets it as updatable or not (default `false`)
  22979. * @param geometry the geometry the vertexData is applied to
  22980. * @param updatable when used and having the value true allows new data to update the vertexData
  22981. * @returns VertexData
  22982. */
  22983. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22984. /**
  22985. * Updates the associated mesh
  22986. * @param mesh the mesh to be updated
  22987. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22988. * @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
  22989. * @returns VertexData
  22990. */
  22991. updateMesh(mesh: Mesh): VertexData;
  22992. /**
  22993. * Updates the associated geometry
  22994. * @param geometry the geometry to be updated
  22995. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22996. * @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
  22997. * @returns VertexData.
  22998. */
  22999. updateGeometry(geometry: Geometry): VertexData;
  23000. private _applyTo;
  23001. private _update;
  23002. /**
  23003. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23004. * @param matrix the transforming matrix
  23005. * @returns the VertexData
  23006. */
  23007. transform(matrix: Matrix): VertexData;
  23008. /**
  23009. * Merges the passed VertexData into the current one
  23010. * @param other the VertexData to be merged into the current one
  23011. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23012. * @returns the modified VertexData
  23013. */
  23014. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23015. private _mergeElement;
  23016. private _validate;
  23017. /**
  23018. * Serializes the VertexData
  23019. * @returns a serialized object
  23020. */
  23021. serialize(): any;
  23022. /**
  23023. * Extracts the vertexData from a mesh
  23024. * @param mesh the mesh from which to extract the VertexData
  23025. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23026. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23027. * @returns the object VertexData associated to the passed mesh
  23028. */
  23029. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23030. /**
  23031. * Extracts the vertexData from the geometry
  23032. * @param geometry the geometry from which to extract the VertexData
  23033. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23034. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23035. * @returns the object VertexData associated to the passed mesh
  23036. */
  23037. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23038. private static _ExtractFrom;
  23039. /**
  23040. * Creates the VertexData for a Ribbon
  23041. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23042. * * pathArray array of paths, each of which an array of successive Vector3
  23043. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23044. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23045. * * 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
  23046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23047. * * 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)
  23048. * * 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)
  23049. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23050. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23051. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23052. * @returns the VertexData of the ribbon
  23053. */
  23054. static CreateRibbon(options: {
  23055. pathArray: Vector3[][];
  23056. closeArray?: boolean;
  23057. closePath?: boolean;
  23058. offset?: number;
  23059. sideOrientation?: number;
  23060. frontUVs?: Vector4;
  23061. backUVs?: Vector4;
  23062. invertUV?: boolean;
  23063. uvs?: Vector2[];
  23064. colors?: Color4[];
  23065. }): VertexData;
  23066. /**
  23067. * Creates the VertexData for a box
  23068. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23069. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23070. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23071. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23072. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23073. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23074. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23076. * * 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)
  23077. * * 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)
  23078. * @returns the VertexData of the box
  23079. */
  23080. static CreateBox(options: {
  23081. size?: number;
  23082. width?: number;
  23083. height?: number;
  23084. depth?: number;
  23085. faceUV?: Vector4[];
  23086. faceColors?: Color4[];
  23087. sideOrientation?: number;
  23088. frontUVs?: Vector4;
  23089. backUVs?: Vector4;
  23090. }): VertexData;
  23091. /**
  23092. * Creates the VertexData for a tiled box
  23093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23094. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23095. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23096. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23098. * @returns the VertexData of the box
  23099. */
  23100. static CreateTiledBox(options: {
  23101. pattern?: number;
  23102. width?: number;
  23103. height?: number;
  23104. depth?: number;
  23105. tileSize?: number;
  23106. tileWidth?: number;
  23107. tileHeight?: number;
  23108. alignHorizontal?: number;
  23109. alignVertical?: number;
  23110. faceUV?: Vector4[];
  23111. faceColors?: Color4[];
  23112. sideOrientation?: number;
  23113. }): VertexData;
  23114. /**
  23115. * Creates the VertexData for a tiled plane
  23116. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23117. * * pattern a limited pattern arrangement depending on the number
  23118. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23119. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23120. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23122. * * 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)
  23123. * * 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)
  23124. * @returns the VertexData of the tiled plane
  23125. */
  23126. static CreateTiledPlane(options: {
  23127. pattern?: number;
  23128. tileSize?: number;
  23129. tileWidth?: number;
  23130. tileHeight?: number;
  23131. size?: number;
  23132. width?: number;
  23133. height?: number;
  23134. alignHorizontal?: number;
  23135. alignVertical?: number;
  23136. sideOrientation?: number;
  23137. frontUVs?: Vector4;
  23138. backUVs?: Vector4;
  23139. }): VertexData;
  23140. /**
  23141. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23142. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23143. * * segments sets the number of horizontal strips optional, default 32
  23144. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23145. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23146. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23147. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23148. * * 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
  23149. * * 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
  23150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23151. * * 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)
  23152. * * 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)
  23153. * @returns the VertexData of the ellipsoid
  23154. */
  23155. static CreateSphere(options: {
  23156. segments?: number;
  23157. diameter?: number;
  23158. diameterX?: number;
  23159. diameterY?: number;
  23160. diameterZ?: number;
  23161. arc?: number;
  23162. slice?: number;
  23163. sideOrientation?: number;
  23164. frontUVs?: Vector4;
  23165. backUVs?: Vector4;
  23166. }): VertexData;
  23167. /**
  23168. * Creates the VertexData for a cylinder, cone or prism
  23169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23170. * * height sets the height (y direction) of the cylinder, optional, default 2
  23171. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23172. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23173. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23174. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23175. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23176. * * 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
  23177. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23178. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23179. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23180. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23182. * * 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)
  23183. * * 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)
  23184. * @returns the VertexData of the cylinder, cone or prism
  23185. */
  23186. static CreateCylinder(options: {
  23187. height?: number;
  23188. diameterTop?: number;
  23189. diameterBottom?: number;
  23190. diameter?: number;
  23191. tessellation?: number;
  23192. subdivisions?: number;
  23193. arc?: number;
  23194. faceColors?: Color4[];
  23195. faceUV?: Vector4[];
  23196. hasRings?: boolean;
  23197. enclose?: boolean;
  23198. sideOrientation?: number;
  23199. frontUVs?: Vector4;
  23200. backUVs?: Vector4;
  23201. }): VertexData;
  23202. /**
  23203. * Creates the VertexData for a torus
  23204. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23205. * * diameter the diameter of the torus, optional default 1
  23206. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23207. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23208. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23209. * * 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)
  23210. * * 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)
  23211. * @returns the VertexData of the torus
  23212. */
  23213. static CreateTorus(options: {
  23214. diameter?: number;
  23215. thickness?: number;
  23216. tessellation?: number;
  23217. sideOrientation?: number;
  23218. frontUVs?: Vector4;
  23219. backUVs?: Vector4;
  23220. }): VertexData;
  23221. /**
  23222. * Creates the VertexData of the LineSystem
  23223. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23224. * - lines an array of lines, each line being an array of successive Vector3
  23225. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23226. * @returns the VertexData of the LineSystem
  23227. */
  23228. static CreateLineSystem(options: {
  23229. lines: Vector3[][];
  23230. colors?: Nullable<Color4[][]>;
  23231. }): VertexData;
  23232. /**
  23233. * Create the VertexData for a DashedLines
  23234. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23235. * - points an array successive Vector3
  23236. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23237. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23238. * - dashNb the intended total number of dashes, optional, default 200
  23239. * @returns the VertexData for the DashedLines
  23240. */
  23241. static CreateDashedLines(options: {
  23242. points: Vector3[];
  23243. dashSize?: number;
  23244. gapSize?: number;
  23245. dashNb?: number;
  23246. }): VertexData;
  23247. /**
  23248. * Creates the VertexData for a Ground
  23249. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23250. * - width the width (x direction) of the ground, optional, default 1
  23251. * - height the height (z direction) of the ground, optional, default 1
  23252. * - subdivisions the number of subdivisions per side, optional, default 1
  23253. * @returns the VertexData of the Ground
  23254. */
  23255. static CreateGround(options: {
  23256. width?: number;
  23257. height?: number;
  23258. subdivisions?: number;
  23259. subdivisionsX?: number;
  23260. subdivisionsY?: number;
  23261. }): VertexData;
  23262. /**
  23263. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23264. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23265. * * xmin the ground minimum X coordinate, optional, default -1
  23266. * * zmin the ground minimum Z coordinate, optional, default -1
  23267. * * xmax the ground maximum X coordinate, optional, default 1
  23268. * * zmax the ground maximum Z coordinate, optional, default 1
  23269. * * 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}
  23270. * * 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}
  23271. * @returns the VertexData of the TiledGround
  23272. */
  23273. static CreateTiledGround(options: {
  23274. xmin: number;
  23275. zmin: number;
  23276. xmax: number;
  23277. zmax: number;
  23278. subdivisions?: {
  23279. w: number;
  23280. h: number;
  23281. };
  23282. precision?: {
  23283. w: number;
  23284. h: number;
  23285. };
  23286. }): VertexData;
  23287. /**
  23288. * Creates the VertexData of the Ground designed from a heightmap
  23289. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23290. * * width the width (x direction) of the ground
  23291. * * height the height (z direction) of the ground
  23292. * * subdivisions the number of subdivisions per side
  23293. * * minHeight the minimum altitude on the ground, optional, default 0
  23294. * * maxHeight the maximum altitude on the ground, optional default 1
  23295. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23296. * * buffer the array holding the image color data
  23297. * * bufferWidth the width of image
  23298. * * bufferHeight the height of image
  23299. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23300. * @returns the VertexData of the Ground designed from a heightmap
  23301. */
  23302. static CreateGroundFromHeightMap(options: {
  23303. width: number;
  23304. height: number;
  23305. subdivisions: number;
  23306. minHeight: number;
  23307. maxHeight: number;
  23308. colorFilter: Color3;
  23309. buffer: Uint8Array;
  23310. bufferWidth: number;
  23311. bufferHeight: number;
  23312. alphaFilter: number;
  23313. }): VertexData;
  23314. /**
  23315. * Creates the VertexData for a Plane
  23316. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23317. * * size sets the width and height of the plane to the value of size, optional default 1
  23318. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23319. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23321. * * 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)
  23322. * * 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)
  23323. * @returns the VertexData of the box
  23324. */
  23325. static CreatePlane(options: {
  23326. size?: number;
  23327. width?: number;
  23328. height?: number;
  23329. sideOrientation?: number;
  23330. frontUVs?: Vector4;
  23331. backUVs?: Vector4;
  23332. }): VertexData;
  23333. /**
  23334. * Creates the VertexData of the Disc or regular Polygon
  23335. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23336. * * radius the radius of the disc, optional default 0.5
  23337. * * tessellation the number of polygon sides, optional, default 64
  23338. * * 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
  23339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23340. * * 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)
  23341. * * 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)
  23342. * @returns the VertexData of the box
  23343. */
  23344. static CreateDisc(options: {
  23345. radius?: number;
  23346. tessellation?: number;
  23347. arc?: number;
  23348. sideOrientation?: number;
  23349. frontUVs?: Vector4;
  23350. backUVs?: Vector4;
  23351. }): VertexData;
  23352. /**
  23353. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23354. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23355. * @param polygon a mesh built from polygonTriangulation.build()
  23356. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23357. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23358. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23359. * @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)
  23360. * @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)
  23361. * @returns the VertexData of the Polygon
  23362. */
  23363. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23364. /**
  23365. * Creates the VertexData of the IcoSphere
  23366. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23367. * * radius the radius of the IcoSphere, optional default 1
  23368. * * radiusX allows stretching in the x direction, optional, default radius
  23369. * * radiusY allows stretching in the y direction, optional, default radius
  23370. * * radiusZ allows stretching in the z direction, optional, default radius
  23371. * * flat when true creates a flat shaded mesh, optional, default true
  23372. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23374. * * 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)
  23375. * * 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)
  23376. * @returns the VertexData of the IcoSphere
  23377. */
  23378. static CreateIcoSphere(options: {
  23379. radius?: number;
  23380. radiusX?: number;
  23381. radiusY?: number;
  23382. radiusZ?: number;
  23383. flat?: boolean;
  23384. subdivisions?: number;
  23385. sideOrientation?: number;
  23386. frontUVs?: Vector4;
  23387. backUVs?: Vector4;
  23388. }): VertexData;
  23389. /**
  23390. * Creates the VertexData for a Polyhedron
  23391. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23392. * * type provided types are:
  23393. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23394. * * 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)
  23395. * * size the size of the IcoSphere, optional default 1
  23396. * * sizeX allows stretching in the x direction, optional, default size
  23397. * * sizeY allows stretching in the y direction, optional, default size
  23398. * * sizeZ allows stretching in the z direction, optional, default size
  23399. * * 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
  23400. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23401. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23402. * * flat when true creates a flat shaded mesh, optional, default true
  23403. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23405. * * 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)
  23406. * * 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)
  23407. * @returns the VertexData of the Polyhedron
  23408. */
  23409. static CreatePolyhedron(options: {
  23410. type?: number;
  23411. size?: number;
  23412. sizeX?: number;
  23413. sizeY?: number;
  23414. sizeZ?: number;
  23415. custom?: any;
  23416. faceUV?: Vector4[];
  23417. faceColors?: Color4[];
  23418. flat?: boolean;
  23419. sideOrientation?: number;
  23420. frontUVs?: Vector4;
  23421. backUVs?: Vector4;
  23422. }): VertexData;
  23423. /**
  23424. * Creates the VertexData for a TorusKnot
  23425. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23426. * * radius the radius of the torus knot, optional, default 2
  23427. * * tube the thickness of the tube, optional, default 0.5
  23428. * * radialSegments the number of sides on each tube segments, optional, default 32
  23429. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23430. * * p the number of windings around the z axis, optional, default 2
  23431. * * q the number of windings around the x axis, optional, default 3
  23432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23433. * * 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)
  23434. * * 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)
  23435. * @returns the VertexData of the Torus Knot
  23436. */
  23437. static CreateTorusKnot(options: {
  23438. radius?: number;
  23439. tube?: number;
  23440. radialSegments?: number;
  23441. tubularSegments?: number;
  23442. p?: number;
  23443. q?: number;
  23444. sideOrientation?: number;
  23445. frontUVs?: Vector4;
  23446. backUVs?: Vector4;
  23447. }): VertexData;
  23448. /**
  23449. * Compute normals for given positions and indices
  23450. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23451. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23452. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23453. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23454. * * facetNormals : optional array of facet normals (vector3)
  23455. * * facetPositions : optional array of facet positions (vector3)
  23456. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23457. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23458. * * bInfo : optional bounding info, required for facetPartitioning computation
  23459. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23460. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23461. * * useRightHandedSystem: optional boolean to for right handed system computation
  23462. * * depthSort : optional boolean to enable the facet depth sort computation
  23463. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23464. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23465. */
  23466. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23467. facetNormals?: any;
  23468. facetPositions?: any;
  23469. facetPartitioning?: any;
  23470. ratio?: number;
  23471. bInfo?: any;
  23472. bbSize?: Vector3;
  23473. subDiv?: any;
  23474. useRightHandedSystem?: boolean;
  23475. depthSort?: boolean;
  23476. distanceTo?: Vector3;
  23477. depthSortedFacets?: any;
  23478. }): void;
  23479. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23480. /**
  23481. * Applies VertexData created from the imported parameters to the geometry
  23482. * @param parsedVertexData the parsed data from an imported file
  23483. * @param geometry the geometry to apply the VertexData to
  23484. */
  23485. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /**
  23490. * Class containing static functions to help procedurally build meshes
  23491. */
  23492. export class DiscBuilder {
  23493. /**
  23494. * Creates a plane polygonal mesh. By default, this is a disc
  23495. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23496. * * 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
  23497. * * 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
  23498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23501. * @param name defines the name of the mesh
  23502. * @param options defines the options used to create the mesh
  23503. * @param scene defines the hosting scene
  23504. * @returns the plane polygonal mesh
  23505. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23506. */
  23507. static CreateDisc(name: string, options: {
  23508. radius?: number;
  23509. tessellation?: number;
  23510. arc?: number;
  23511. updatable?: boolean;
  23512. sideOrientation?: number;
  23513. frontUVs?: Vector4;
  23514. backUVs?: Vector4;
  23515. }, scene?: Nullable<Scene>): Mesh;
  23516. }
  23517. }
  23518. declare module BABYLON {
  23519. /**
  23520. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23521. *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.
  23522. * The SPS is also a particle system. It provides some methods to manage the particles.
  23523. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23524. *
  23525. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23526. */
  23527. export class SolidParticleSystem implements IDisposable {
  23528. /**
  23529. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23530. * Example : var p = SPS.particles[i];
  23531. */
  23532. particles: SolidParticle[];
  23533. /**
  23534. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23535. */
  23536. nbParticles: number;
  23537. /**
  23538. * If the particles must ever face the camera (default false). Useful for planar particles.
  23539. */
  23540. billboard: boolean;
  23541. /**
  23542. * Recompute normals when adding a shape
  23543. */
  23544. recomputeNormals: boolean;
  23545. /**
  23546. * This a counter ofr your own usage. It's not set by any SPS functions.
  23547. */
  23548. counter: number;
  23549. /**
  23550. * The SPS name. This name is also given to the underlying mesh.
  23551. */
  23552. name: string;
  23553. /**
  23554. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23555. */
  23556. mesh: Mesh;
  23557. /**
  23558. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23559. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23560. */
  23561. vars: any;
  23562. /**
  23563. * This array is populated when the SPS is set as 'pickable'.
  23564. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23565. * Each element of this array is an object `{idx: int, faceId: int}`.
  23566. * `idx` is the picked particle index in the `SPS.particles` array
  23567. * `faceId` is the picked face index counted within this particle.
  23568. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23569. */
  23570. pickedParticles: {
  23571. idx: number;
  23572. faceId: number;
  23573. }[];
  23574. /**
  23575. * This array is populated when `enableDepthSort` is set to true.
  23576. * Each element of this array is an instance of the class DepthSortedParticle.
  23577. */
  23578. depthSortedParticles: DepthSortedParticle[];
  23579. /**
  23580. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23581. * @hidden
  23582. */ private _bSphereOnly: boolean;
  23583. /**
  23584. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23585. * @hidden
  23586. */ private _bSphereRadiusFactor: number;
  23587. private _scene;
  23588. private _positions;
  23589. private _indices;
  23590. private _normals;
  23591. private _colors;
  23592. private _uvs;
  23593. private _indices32;
  23594. private _positions32;
  23595. private _normals32;
  23596. private _fixedNormal32;
  23597. private _colors32;
  23598. private _uvs32;
  23599. private _index;
  23600. private _updatable;
  23601. private _pickable;
  23602. private _isVisibilityBoxLocked;
  23603. private _alwaysVisible;
  23604. private _depthSort;
  23605. private _shapeCounter;
  23606. private _copy;
  23607. private _color;
  23608. private _computeParticleColor;
  23609. private _computeParticleTexture;
  23610. private _computeParticleRotation;
  23611. private _computeParticleVertex;
  23612. private _computeBoundingBox;
  23613. private _depthSortParticles;
  23614. private _camera;
  23615. private _mustUnrotateFixedNormals;
  23616. private _particlesIntersect;
  23617. private _needs32Bits;
  23618. /**
  23619. * Creates a SPS (Solid Particle System) object.
  23620. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23621. * @param scene (Scene) is the scene in which the SPS is added.
  23622. * @param options defines the options of the sps e.g.
  23623. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23624. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23625. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23626. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23627. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23628. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23629. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23630. */
  23631. constructor(name: string, scene: Scene, options?: {
  23632. updatable?: boolean;
  23633. isPickable?: boolean;
  23634. enableDepthSort?: boolean;
  23635. particleIntersection?: boolean;
  23636. boundingSphereOnly?: boolean;
  23637. bSphereRadiusFactor?: number;
  23638. });
  23639. /**
  23640. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23641. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23642. * @returns the created mesh
  23643. */
  23644. buildMesh(): Mesh;
  23645. /**
  23646. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23647. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23648. * Thus the particles generated from `digest()` have their property `position` set yet.
  23649. * @param mesh ( Mesh ) is the mesh to be digested
  23650. * @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
  23651. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23652. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23653. * @returns the current SPS
  23654. */
  23655. digest(mesh: Mesh, options?: {
  23656. facetNb?: number;
  23657. number?: number;
  23658. delta?: number;
  23659. }): SolidParticleSystem;
  23660. private _unrotateFixedNormals;
  23661. private _resetCopy;
  23662. private _meshBuilder;
  23663. private _posToShape;
  23664. private _uvsToShapeUV;
  23665. private _addParticle;
  23666. /**
  23667. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23668. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23669. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23670. * @param nb (positive integer) the number of particles to be created from this model
  23671. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23672. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23673. * @returns the number of shapes in the system
  23674. */
  23675. addShape(mesh: Mesh, nb: number, options?: {
  23676. positionFunction?: any;
  23677. vertexFunction?: any;
  23678. }): number;
  23679. private _rebuildParticle;
  23680. /**
  23681. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23682. * @returns the SPS.
  23683. */
  23684. rebuildMesh(): SolidParticleSystem;
  23685. /**
  23686. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23687. * This method calls `updateParticle()` for each particle of the SPS.
  23688. * For an animated SPS, it is usually called within the render loop.
  23689. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23690. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23691. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23692. * @returns the SPS.
  23693. */
  23694. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23695. /**
  23696. * Disposes the SPS.
  23697. */
  23698. dispose(): void;
  23699. /**
  23700. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23701. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23702. * @returns the SPS.
  23703. */
  23704. refreshVisibleSize(): SolidParticleSystem;
  23705. /**
  23706. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23707. * @param size the size (float) of the visibility box
  23708. * note : this doesn't lock the SPS mesh bounding box.
  23709. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23710. */
  23711. setVisibilityBox(size: number): void;
  23712. /**
  23713. * Gets whether the SPS as always visible or not
  23714. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23715. */
  23716. /**
  23717. * Sets the SPS as always visible or not
  23718. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23719. */
  23720. isAlwaysVisible: boolean;
  23721. /**
  23722. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23723. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23724. */
  23725. /**
  23726. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23727. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23728. */
  23729. isVisibilityBoxLocked: boolean;
  23730. /**
  23731. * Tells to `setParticles()` to compute the particle rotations or not.
  23732. * Default value : true. The SPS is faster when it's set to false.
  23733. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23734. */
  23735. /**
  23736. * Gets if `setParticles()` computes the particle rotations or not.
  23737. * Default value : true. The SPS is faster when it's set to false.
  23738. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23739. */
  23740. computeParticleRotation: boolean;
  23741. /**
  23742. * Tells to `setParticles()` to compute the particle colors or not.
  23743. * Default value : true. The SPS is faster when it's set to false.
  23744. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23745. */
  23746. /**
  23747. * Gets if `setParticles()` computes the particle colors or not.
  23748. * Default value : true. The SPS is faster when it's set to false.
  23749. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23750. */
  23751. computeParticleColor: boolean;
  23752. /**
  23753. * Gets if `setParticles()` computes the particle textures or not.
  23754. * Default value : true. The SPS is faster when it's set to false.
  23755. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23756. */
  23757. computeParticleTexture: boolean;
  23758. /**
  23759. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23760. * Default value : false. The SPS is faster when it's set to false.
  23761. * Note : the particle custom vertex positions aren't stored values.
  23762. */
  23763. /**
  23764. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23765. * Default value : false. The SPS is faster when it's set to false.
  23766. * Note : the particle custom vertex positions aren't stored values.
  23767. */
  23768. computeParticleVertex: boolean;
  23769. /**
  23770. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23771. */
  23772. /**
  23773. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23774. */
  23775. computeBoundingBox: boolean;
  23776. /**
  23777. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23778. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23779. * Default : `true`
  23780. */
  23781. /**
  23782. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23783. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23784. * Default : `true`
  23785. */
  23786. depthSortParticles: boolean;
  23787. /**
  23788. * This function does nothing. It may be overwritten to set all the particle first values.
  23789. * The SPS doesn't call this function, you may have to call it by your own.
  23790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23791. */
  23792. initParticles(): void;
  23793. /**
  23794. * This function does nothing. It may be overwritten to recycle a particle.
  23795. * The SPS doesn't call this function, you may have to call it by your own.
  23796. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23797. * @param particle The particle to recycle
  23798. * @returns the recycled particle
  23799. */
  23800. recycleParticle(particle: SolidParticle): SolidParticle;
  23801. /**
  23802. * Updates a particle : this function should be overwritten by the user.
  23803. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23805. * @example : just set a particle position or velocity and recycle conditions
  23806. * @param particle The particle to update
  23807. * @returns the updated particle
  23808. */
  23809. updateParticle(particle: SolidParticle): SolidParticle;
  23810. /**
  23811. * Updates a vertex of a particle : it can be overwritten by the user.
  23812. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23813. * @param particle the current particle
  23814. * @param vertex the current index of the current particle
  23815. * @param pt the index of the current vertex in the particle shape
  23816. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23817. * @example : just set a vertex particle position
  23818. * @returns the updated vertex
  23819. */
  23820. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23821. /**
  23822. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23823. * This does nothing and may be overwritten by the user.
  23824. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23825. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23826. * @param update the boolean update value actually passed to setParticles()
  23827. */
  23828. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23829. /**
  23830. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23831. * This will be passed three parameters.
  23832. * This does nothing and may be overwritten by the user.
  23833. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23834. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23835. * @param update the boolean update value actually passed to setParticles()
  23836. */
  23837. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23838. }
  23839. }
  23840. declare module BABYLON {
  23841. /**
  23842. * Represents one particle of a solid particle system.
  23843. */
  23844. export class SolidParticle {
  23845. /**
  23846. * particle global index
  23847. */
  23848. idx: number;
  23849. /**
  23850. * The color of the particle
  23851. */
  23852. color: Nullable<Color4>;
  23853. /**
  23854. * The world space position of the particle.
  23855. */
  23856. position: Vector3;
  23857. /**
  23858. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23859. */
  23860. rotation: Vector3;
  23861. /**
  23862. * The world space rotation quaternion of the particle.
  23863. */
  23864. rotationQuaternion: Nullable<Quaternion>;
  23865. /**
  23866. * The scaling of the particle.
  23867. */
  23868. scaling: Vector3;
  23869. /**
  23870. * The uvs of the particle.
  23871. */
  23872. uvs: Vector4;
  23873. /**
  23874. * The current speed of the particle.
  23875. */
  23876. velocity: Vector3;
  23877. /**
  23878. * The pivot point in the particle local space.
  23879. */
  23880. pivot: Vector3;
  23881. /**
  23882. * Must the particle be translated from its pivot point in its local space ?
  23883. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23884. * Default : false
  23885. */
  23886. translateFromPivot: boolean;
  23887. /**
  23888. * Is the particle active or not ?
  23889. */
  23890. alive: boolean;
  23891. /**
  23892. * Is the particle visible or not ?
  23893. */
  23894. isVisible: boolean;
  23895. /**
  23896. * Index of this particle in the global "positions" array (Internal use)
  23897. * @hidden
  23898. */ private _pos: number;
  23899. /**
  23900. * @hidden Index of this particle in the global "indices" array (Internal use)
  23901. */ private _ind: number;
  23902. /**
  23903. * @hidden ModelShape of this particle (Internal use)
  23904. */ private _model: ModelShape;
  23905. /**
  23906. * ModelShape id of this particle
  23907. */
  23908. shapeId: number;
  23909. /**
  23910. * Index of the particle in its shape id (Internal use)
  23911. */
  23912. idxInShape: number;
  23913. /**
  23914. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23915. */ private _modelBoundingInfo: BoundingInfo;
  23916. /**
  23917. * @hidden Particle BoundingInfo object (Internal use)
  23918. */ private _boundingInfo: BoundingInfo;
  23919. /**
  23920. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23921. */ private _sps: SolidParticleSystem;
  23922. /**
  23923. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23924. */ private _stillInvisible: boolean;
  23925. /**
  23926. * @hidden Last computed particle rotation matrix
  23927. */ private _rotationMatrix: number[];
  23928. /**
  23929. * Parent particle Id, if any.
  23930. * Default null.
  23931. */
  23932. parentId: Nullable<number>;
  23933. /**
  23934. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23935. * The possible values are :
  23936. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23937. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23938. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23939. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23940. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23941. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23942. * */
  23943. cullingStrategy: number;
  23944. /**
  23945. * @hidden Internal global position in the SPS.
  23946. */ private _globalPosition: Vector3;
  23947. /**
  23948. * Creates a Solid Particle object.
  23949. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23950. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23951. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23952. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23953. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23954. * @param shapeId (integer) is the model shape identifier in the SPS.
  23955. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23956. * @param sps defines the sps it is associated to
  23957. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23958. */
  23959. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23960. /**
  23961. * Legacy support, changed scale to scaling
  23962. */
  23963. /**
  23964. * Legacy support, changed scale to scaling
  23965. */
  23966. scale: Vector3;
  23967. /**
  23968. * Legacy support, changed quaternion to rotationQuaternion
  23969. */
  23970. /**
  23971. * Legacy support, changed quaternion to rotationQuaternion
  23972. */
  23973. quaternion: Nullable<Quaternion>;
  23974. /**
  23975. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23976. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23977. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23978. * @returns true if it intersects
  23979. */
  23980. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23981. /**
  23982. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23983. * A particle is in the frustum if its bounding box intersects the frustum
  23984. * @param frustumPlanes defines the frustum to test
  23985. * @returns true if the particle is in the frustum planes
  23986. */
  23987. isInFrustum(frustumPlanes: Plane[]): boolean;
  23988. /**
  23989. * get the rotation matrix of the particle
  23990. * @hidden
  23991. */
  23992. getRotationMatrix(m: Matrix): void;
  23993. }
  23994. /**
  23995. * Represents the shape of the model used by one particle of a solid particle system.
  23996. * SPS internal tool, don't use it manually.
  23997. */
  23998. export class ModelShape {
  23999. /**
  24000. * The shape id
  24001. * @hidden
  24002. */
  24003. shapeID: number;
  24004. /**
  24005. * flat array of model positions (internal use)
  24006. * @hidden
  24007. */ private _shape: Vector3[];
  24008. /**
  24009. * flat array of model UVs (internal use)
  24010. * @hidden
  24011. */ private _shapeUV: number[];
  24012. /**
  24013. * length of the shape in the model indices array (internal use)
  24014. * @hidden
  24015. */ private _indicesLength: number;
  24016. /**
  24017. * Custom position function (internal use)
  24018. * @hidden
  24019. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24020. /**
  24021. * Custom vertex function (internal use)
  24022. * @hidden
  24023. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24024. /**
  24025. * 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.
  24026. * SPS internal tool, don't use it manually.
  24027. * @hidden
  24028. */
  24029. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  24030. }
  24031. /**
  24032. * Represents a Depth Sorted Particle in the solid particle system.
  24033. */
  24034. export class DepthSortedParticle {
  24035. /**
  24036. * Index of the particle in the "indices" array
  24037. */
  24038. ind: number;
  24039. /**
  24040. * Length of the particle shape in the "indices" array
  24041. */
  24042. indicesLength: number;
  24043. /**
  24044. * Squared distance from the particle to the camera
  24045. */
  24046. sqDistance: number;
  24047. }
  24048. }
  24049. declare module BABYLON {
  24050. /**
  24051. * @hidden
  24052. */
  24053. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24054. }
  24055. }
  24056. declare module BABYLON {
  24057. /** @hidden */ private class _FacetDataStorage {
  24058. facetPositions: Vector3[];
  24059. facetNormals: Vector3[];
  24060. facetPartitioning: number[][];
  24061. facetNb: number;
  24062. partitioningSubdivisions: number;
  24063. partitioningBBoxRatio: number;
  24064. facetDataEnabled: boolean;
  24065. facetParameters: any;
  24066. bbSize: Vector3;
  24067. subDiv: {
  24068. max: number;
  24069. X: number;
  24070. Y: number;
  24071. Z: number;
  24072. };
  24073. facetDepthSort: boolean;
  24074. facetDepthSortEnabled: boolean;
  24075. depthSortedIndices: IndicesArray;
  24076. depthSortedFacets: {
  24077. ind: number;
  24078. sqDistance: number;
  24079. }[];
  24080. facetDepthSortFunction: (f1: {
  24081. ind: number;
  24082. sqDistance: number;
  24083. }, f2: {
  24084. ind: number;
  24085. sqDistance: number;
  24086. }) => number;
  24087. facetDepthSortFrom: Vector3;
  24088. facetDepthSortOrigin: Vector3;
  24089. invertedMatrix: Matrix;
  24090. }
  24091. /**
  24092. * @hidden
  24093. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  24094. }
  24095. /**
  24096. * Class used to store all common mesh properties
  24097. */
  24098. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24099. /** No occlusion */
  24100. static OCCLUSION_TYPE_NONE: number;
  24101. /** Occlusion set to optimisitic */
  24102. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24103. /** Occlusion set to strict */
  24104. static OCCLUSION_TYPE_STRICT: number;
  24105. /** Use an accurante occlusion algorithm */
  24106. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24107. /** Use a conservative occlusion algorithm */
  24108. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24109. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24110. * Test order :
  24111. * Is the bounding sphere outside the frustum ?
  24112. * If not, are the bounding box vertices outside the frustum ?
  24113. * It not, then the cullable object is in the frustum.
  24114. */
  24115. static readonly CULLINGSTRATEGY_STANDARD: number;
  24116. /** Culling strategy : Bounding Sphere Only.
  24117. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24118. * It's also less accurate than the standard because some not visible objects can still be selected.
  24119. * Test : is the bounding sphere outside the frustum ?
  24120. * If not, then the cullable object is in the frustum.
  24121. */
  24122. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24123. /** Culling strategy : Optimistic Inclusion.
  24124. * This in an inclusion test first, then the standard exclusion test.
  24125. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24126. * 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.
  24127. * Anyway, it's as accurate as the standard strategy.
  24128. * Test :
  24129. * Is the cullable object bounding sphere center in the frustum ?
  24130. * If not, apply the default culling strategy.
  24131. */
  24132. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24133. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24134. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24135. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24136. * 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.
  24137. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24138. * Test :
  24139. * Is the cullable object bounding sphere center in the frustum ?
  24140. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24141. */
  24142. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24143. /**
  24144. * No billboard
  24145. */
  24146. static readonly BILLBOARDMODE_NONE: number;
  24147. /** Billboard on X axis */
  24148. static readonly BILLBOARDMODE_X: number;
  24149. /** Billboard on Y axis */
  24150. static readonly BILLBOARDMODE_Y: number;
  24151. /** Billboard on Z axis */
  24152. static readonly BILLBOARDMODE_Z: number;
  24153. /** Billboard on all axes */
  24154. static readonly BILLBOARDMODE_ALL: number;
  24155. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24156. /**
  24157. * The culling strategy to use to check whether the mesh must be rendered or not.
  24158. * This value can be changed at any time and will be used on the next render mesh selection.
  24159. * The possible values are :
  24160. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24161. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24162. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24163. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24164. * Please read each static variable documentation to get details about the culling process.
  24165. * */
  24166. cullingStrategy: number;
  24167. /**
  24168. * Gets the number of facets in the mesh
  24169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24170. */
  24171. readonly facetNb: number;
  24172. /**
  24173. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24175. */
  24176. partitioningSubdivisions: number;
  24177. /**
  24178. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24179. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24181. */
  24182. partitioningBBoxRatio: number;
  24183. /**
  24184. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24185. * Works only for updatable meshes.
  24186. * Doesn't work with multi-materials
  24187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24188. */
  24189. mustDepthSortFacets: boolean;
  24190. /**
  24191. * The location (Vector3) where the facet depth sort must be computed from.
  24192. * By default, the active camera position.
  24193. * Used only when facet depth sort is enabled
  24194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24195. */
  24196. facetDepthSortFrom: Vector3;
  24197. /**
  24198. * gets a boolean indicating if facetData is enabled
  24199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24200. */
  24201. readonly isFacetDataEnabled: boolean;
  24202. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  24203. /**
  24204. * An event triggered when this mesh collides with another one
  24205. */
  24206. onCollideObservable: Observable<AbstractMesh>;
  24207. /** Set a function to call when this mesh collides with another one */
  24208. onCollide: () => void;
  24209. /**
  24210. * An event triggered when the collision's position changes
  24211. */
  24212. onCollisionPositionChangeObservable: Observable<Vector3>;
  24213. /** Set a function to call when the collision's position changes */
  24214. onCollisionPositionChange: () => void;
  24215. /**
  24216. * An event triggered when material is changed
  24217. */
  24218. onMaterialChangedObservable: Observable<AbstractMesh>;
  24219. /**
  24220. * Gets or sets the orientation for POV movement & rotation
  24221. */
  24222. definedFacingForward: boolean;
  24223. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  24224. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  24225. /**
  24226. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24227. */
  24228. /**
  24229. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24230. */
  24231. visibility: number;
  24232. /** Gets or sets the alpha index used to sort transparent meshes
  24233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24234. */
  24235. alphaIndex: number;
  24236. /**
  24237. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24238. */
  24239. isVisible: boolean;
  24240. /**
  24241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24242. */
  24243. isPickable: boolean;
  24244. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24245. showSubMeshesBoundingBox: boolean;
  24246. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24247. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24248. */
  24249. isBlocker: boolean;
  24250. /**
  24251. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24252. */
  24253. enablePointerMoveEvents: boolean;
  24254. /**
  24255. * Specifies the rendering group id for this mesh (0 by default)
  24256. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24257. */
  24258. renderingGroupId: number;
  24259. private _material;
  24260. /** Gets or sets current material */
  24261. material: Nullable<Material>;
  24262. /**
  24263. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24264. * @see http://doc.babylonjs.com/babylon101/shadows
  24265. */
  24266. receiveShadows: boolean;
  24267. /** Defines color to use when rendering outline */
  24268. outlineColor: Color3;
  24269. /** Define width to use when rendering outline */
  24270. outlineWidth: number;
  24271. /** Defines color to use when rendering overlay */
  24272. overlayColor: Color3;
  24273. /** Defines alpha to use when rendering overlay */
  24274. overlayAlpha: number;
  24275. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24276. hasVertexAlpha: boolean;
  24277. /** 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) */
  24278. useVertexColors: boolean;
  24279. /**
  24280. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24281. */
  24282. computeBonesUsingShaders: boolean;
  24283. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24284. numBoneInfluencers: number;
  24285. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24286. applyFog: boolean;
  24287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24288. useOctreeForRenderingSelection: boolean;
  24289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24290. useOctreeForPicking: boolean;
  24291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24292. useOctreeForCollisions: boolean;
  24293. /**
  24294. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24295. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24296. */
  24297. layerMask: number;
  24298. /**
  24299. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24300. */
  24301. alwaysSelectAsActiveMesh: boolean;
  24302. /**
  24303. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24304. */
  24305. doNotSyncBoundingInfo: boolean;
  24306. /**
  24307. * Gets or sets the current action manager
  24308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24309. */
  24310. actionManager: Nullable<AbstractActionManager>;
  24311. private _meshCollisionData;
  24312. /**
  24313. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24315. */
  24316. ellipsoid: Vector3;
  24317. /**
  24318. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24320. */
  24321. ellipsoidOffset: Vector3;
  24322. /**
  24323. * Gets or sets a collision mask used to mask collisions (default is -1).
  24324. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24325. */
  24326. collisionMask: number;
  24327. /**
  24328. * Gets or sets the current collision group mask (-1 by default).
  24329. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24330. */
  24331. collisionGroup: number;
  24332. /**
  24333. * Defines edge width used when edgesRenderer is enabled
  24334. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24335. */
  24336. edgesWidth: number;
  24337. /**
  24338. * Defines edge color used when edgesRenderer is enabled
  24339. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24340. */
  24341. edgesColor: Color4;
  24342. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  24343. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  24344. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  24345. /** @hidden */ private _renderId: number;
  24346. /**
  24347. * Gets or sets the list of subMeshes
  24348. * @see http://doc.babylonjs.com/how_to/multi_materials
  24349. */
  24350. subMeshes: SubMesh[];
  24351. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  24352. /** @hidden */ private _unIndexed: boolean;
  24353. /** @hidden */ private _lightSources: Light[];
  24354. /** Gets the list of lights affecting that mesh */
  24355. readonly lightSources: Light[];
  24356. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24357. /** @hidden */ private _waitingData: {
  24358. lods: Nullable<any>;
  24359. actions: Nullable<any>;
  24360. freezeWorldMatrix: Nullable<boolean>;
  24361. };
  24362. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  24363. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  24364. /**
  24365. * Gets or sets a skeleton to apply skining transformations
  24366. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24367. */
  24368. skeleton: Nullable<Skeleton>;
  24369. /**
  24370. * An event triggered when the mesh is rebuilt.
  24371. */
  24372. onRebuildObservable: Observable<AbstractMesh>;
  24373. /**
  24374. * Creates a new AbstractMesh
  24375. * @param name defines the name of the mesh
  24376. * @param scene defines the hosting scene
  24377. */
  24378. constructor(name: string, scene?: Nullable<Scene>);
  24379. /**
  24380. * Returns the string "AbstractMesh"
  24381. * @returns "AbstractMesh"
  24382. */
  24383. getClassName(): string;
  24384. /**
  24385. * Gets a string representation of the current mesh
  24386. * @param fullDetails defines a boolean indicating if full details must be included
  24387. * @returns a string representation of the current mesh
  24388. */
  24389. toString(fullDetails?: boolean): string;
  24390. /**
  24391. * @hidden
  24392. */
  24393. protected _getEffectiveParent(): Nullable<Node>;
  24394. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24395. /** @hidden */ private _rebuild(): void;
  24396. /** @hidden */ private _resyncLightSources(): void;
  24397. /** @hidden */ private _resyncLighSource(light: Light): void;
  24398. /** @hidden */ private _unBindEffect(): void;
  24399. /** @hidden */ private _removeLightSource(light: Light): void;
  24400. private _markSubMeshesAsDirty;
  24401. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  24402. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  24403. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  24404. /**
  24405. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24406. */
  24407. scaling: Vector3;
  24408. /**
  24409. * Returns true if the mesh is blocked. Implemented by child classes
  24410. */
  24411. readonly isBlocked: boolean;
  24412. /**
  24413. * Returns the mesh itself by default. Implemented by child classes
  24414. * @param camera defines the camera to use to pick the right LOD level
  24415. * @returns the currentAbstractMesh
  24416. */
  24417. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24418. /**
  24419. * Returns 0 by default. Implemented by child classes
  24420. * @returns an integer
  24421. */
  24422. getTotalVertices(): number;
  24423. /**
  24424. * Returns a positive integer : the total number of indices in this mesh geometry.
  24425. * @returns the numner of indices or zero if the mesh has no geometry.
  24426. */
  24427. getTotalIndices(): number;
  24428. /**
  24429. * Returns null by default. Implemented by child classes
  24430. * @returns null
  24431. */
  24432. getIndices(): Nullable<IndicesArray>;
  24433. /**
  24434. * Returns the array of the requested vertex data kind. Implemented by child classes
  24435. * @param kind defines the vertex data kind to use
  24436. * @returns null
  24437. */
  24438. getVerticesData(kind: string): Nullable<FloatArray>;
  24439. /**
  24440. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24441. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24442. * Note that a new underlying VertexBuffer object is created each call.
  24443. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24444. * @param kind defines vertex data kind:
  24445. * * VertexBuffer.PositionKind
  24446. * * VertexBuffer.UVKind
  24447. * * VertexBuffer.UV2Kind
  24448. * * VertexBuffer.UV3Kind
  24449. * * VertexBuffer.UV4Kind
  24450. * * VertexBuffer.UV5Kind
  24451. * * VertexBuffer.UV6Kind
  24452. * * VertexBuffer.ColorKind
  24453. * * VertexBuffer.MatricesIndicesKind
  24454. * * VertexBuffer.MatricesIndicesExtraKind
  24455. * * VertexBuffer.MatricesWeightsKind
  24456. * * VertexBuffer.MatricesWeightsExtraKind
  24457. * @param data defines the data source
  24458. * @param updatable defines if the data must be flagged as updatable (or static)
  24459. * @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
  24460. * @returns the current mesh
  24461. */
  24462. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24463. /**
  24464. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24465. * If the mesh has no geometry, it is simply returned as it is.
  24466. * @param kind defines vertex data kind:
  24467. * * VertexBuffer.PositionKind
  24468. * * VertexBuffer.UVKind
  24469. * * VertexBuffer.UV2Kind
  24470. * * VertexBuffer.UV3Kind
  24471. * * VertexBuffer.UV4Kind
  24472. * * VertexBuffer.UV5Kind
  24473. * * VertexBuffer.UV6Kind
  24474. * * VertexBuffer.ColorKind
  24475. * * VertexBuffer.MatricesIndicesKind
  24476. * * VertexBuffer.MatricesIndicesExtraKind
  24477. * * VertexBuffer.MatricesWeightsKind
  24478. * * VertexBuffer.MatricesWeightsExtraKind
  24479. * @param data defines the data source
  24480. * @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
  24481. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24482. * @returns the current mesh
  24483. */
  24484. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24485. /**
  24486. * Sets the mesh indices,
  24487. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24488. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24489. * @param totalVertices Defines the total number of vertices
  24490. * @returns the current mesh
  24491. */
  24492. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24493. /**
  24494. * Gets a boolean indicating if specific vertex data is present
  24495. * @param kind defines the vertex data kind to use
  24496. * @returns true is data kind is present
  24497. */
  24498. isVerticesDataPresent(kind: string): boolean;
  24499. /**
  24500. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24501. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24502. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24503. * @returns a BoundingInfo
  24504. */
  24505. getBoundingInfo(): BoundingInfo;
  24506. /**
  24507. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24508. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24509. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24510. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24511. * @returns the current mesh
  24512. */
  24513. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24514. /**
  24515. * Overwrite the current bounding info
  24516. * @param boundingInfo defines the new bounding info
  24517. * @returns the current mesh
  24518. */
  24519. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24520. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24521. readonly useBones: boolean;
  24522. /** @hidden */ private _preActivate(): void;
  24523. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  24524. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  24525. /** @hidden */ private _postActivate(): void;
  24526. /** @hidden */ private _freeze(): void;
  24527. /** @hidden */ private _unFreeze(): void;
  24528. /**
  24529. * Gets the current world matrix
  24530. * @returns a Matrix
  24531. */
  24532. getWorldMatrix(): Matrix;
  24533. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  24534. /**
  24535. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24536. */
  24537. readonly isAnInstance: boolean;
  24538. /**
  24539. * Perform relative position change from the point of view of behind the front of the mesh.
  24540. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24541. * Supports definition of mesh facing forward or backward
  24542. * @param amountRight defines the distance on the right axis
  24543. * @param amountUp defines the distance on the up axis
  24544. * @param amountForward defines the distance on the forward axis
  24545. * @returns the current mesh
  24546. */
  24547. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24548. /**
  24549. * Calculate relative position change from the point of view of behind the front of the mesh.
  24550. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24551. * Supports definition of mesh facing forward or backward
  24552. * @param amountRight defines the distance on the right axis
  24553. * @param amountUp defines the distance on the up axis
  24554. * @param amountForward defines the distance on the forward axis
  24555. * @returns the new displacement vector
  24556. */
  24557. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24558. /**
  24559. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24560. * Supports definition of mesh facing forward or backward
  24561. * @param flipBack defines the flip
  24562. * @param twirlClockwise defines the twirl
  24563. * @param tiltRight defines the tilt
  24564. * @returns the current mesh
  24565. */
  24566. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24567. /**
  24568. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24569. * Supports definition of mesh facing forward or backward.
  24570. * @param flipBack defines the flip
  24571. * @param twirlClockwise defines the twirl
  24572. * @param tiltRight defines the tilt
  24573. * @returns the new rotation vector
  24574. */
  24575. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24576. /**
  24577. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24578. * This means the mesh underlying bounding box and sphere are recomputed.
  24579. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24580. * @returns the current mesh
  24581. */
  24582. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24583. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24584. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24585. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  24586. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24587. /** @hidden */
  24588. protected _afterComputeWorldMatrix(): void;
  24589. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24590. /**
  24591. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24592. * A mesh is in the frustum if its bounding box intersects the frustum
  24593. * @param frustumPlanes defines the frustum to test
  24594. * @returns true if the mesh is in the frustum planes
  24595. */
  24596. isInFrustum(frustumPlanes: Plane[]): boolean;
  24597. /**
  24598. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24599. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24600. * @param frustumPlanes defines the frustum to test
  24601. * @returns true if the mesh is completely in the frustum planes
  24602. */
  24603. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24604. /**
  24605. * True if the mesh intersects another mesh or a SolidParticle object
  24606. * @param mesh defines a target mesh or SolidParticle to test
  24607. * @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)
  24608. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24609. * @returns true if there is an intersection
  24610. */
  24611. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24612. /**
  24613. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24614. * @param point defines the point to test
  24615. * @returns true if there is an intersection
  24616. */
  24617. intersectsPoint(point: Vector3): boolean;
  24618. /**
  24619. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24621. */
  24622. checkCollisions: boolean;
  24623. /**
  24624. * Gets Collider object used to compute collisions (not physics)
  24625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24626. */
  24627. readonly collider: Nullable<Collider>;
  24628. /**
  24629. * Move the mesh using collision engine
  24630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24631. * @param displacement defines the requested displacement vector
  24632. * @returns the current mesh
  24633. */
  24634. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24635. private _onCollisionPositionChange;
  24636. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24637. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24638. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  24639. /** @hidden */ private _generatePointsArray(): boolean;
  24640. /**
  24641. * Checks if the passed Ray intersects with the mesh
  24642. * @param ray defines the ray to use
  24643. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24644. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24645. * @returns the picking info
  24646. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24647. */
  24648. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24649. /**
  24650. * Clones the current mesh
  24651. * @param name defines the mesh name
  24652. * @param newParent defines the new mesh parent
  24653. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24654. * @returns the new mesh
  24655. */
  24656. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24657. /**
  24658. * Disposes all the submeshes of the current meshnp
  24659. * @returns the current mesh
  24660. */
  24661. releaseSubMeshes(): AbstractMesh;
  24662. /**
  24663. * Releases resources associated with this abstract mesh.
  24664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24666. */
  24667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24668. /**
  24669. * Adds the passed mesh as a child to the current mesh
  24670. * @param mesh defines the child mesh
  24671. * @returns the current mesh
  24672. */
  24673. addChild(mesh: AbstractMesh): AbstractMesh;
  24674. /**
  24675. * Removes the passed mesh from the current mesh children list
  24676. * @param mesh defines the child mesh
  24677. * @returns the current mesh
  24678. */
  24679. removeChild(mesh: AbstractMesh): AbstractMesh;
  24680. /** @hidden */
  24681. private _initFacetData;
  24682. /**
  24683. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24684. * This method can be called within the render loop.
  24685. * 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
  24686. * @returns the current mesh
  24687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24688. */
  24689. updateFacetData(): AbstractMesh;
  24690. /**
  24691. * Returns the facetLocalNormals array.
  24692. * The normals are expressed in the mesh local spac
  24693. * @returns an array of Vector3
  24694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24695. */
  24696. getFacetLocalNormals(): Vector3[];
  24697. /**
  24698. * Returns the facetLocalPositions array.
  24699. * The facet positions are expressed in the mesh local space
  24700. * @returns an array of Vector3
  24701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24702. */
  24703. getFacetLocalPositions(): Vector3[];
  24704. /**
  24705. * Returns the facetLocalPartioning array
  24706. * @returns an array of array of numbers
  24707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24708. */
  24709. getFacetLocalPartitioning(): number[][];
  24710. /**
  24711. * Returns the i-th facet position in the world system.
  24712. * This method allocates a new Vector3 per call
  24713. * @param i defines the facet index
  24714. * @returns a new Vector3
  24715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24716. */
  24717. getFacetPosition(i: number): Vector3;
  24718. /**
  24719. * Sets the reference Vector3 with the i-th facet position in the world system
  24720. * @param i defines the facet index
  24721. * @param ref defines the target vector
  24722. * @returns the current mesh
  24723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24724. */
  24725. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24726. /**
  24727. * Returns the i-th facet normal in the world system.
  24728. * This method allocates a new Vector3 per call
  24729. * @param i defines the facet index
  24730. * @returns a new Vector3
  24731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24732. */
  24733. getFacetNormal(i: number): Vector3;
  24734. /**
  24735. * Sets the reference Vector3 with the i-th facet normal in the world system
  24736. * @param i defines the facet index
  24737. * @param ref defines the target vector
  24738. * @returns the current mesh
  24739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24740. */
  24741. getFacetNormalToRef(i: number, ref: Vector3): this;
  24742. /**
  24743. * 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)
  24744. * @param x defines x coordinate
  24745. * @param y defines y coordinate
  24746. * @param z defines z coordinate
  24747. * @returns the array of facet indexes
  24748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24749. */
  24750. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24751. /**
  24752. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24753. * @param projected sets as the (x,y,z) world projection on the facet
  24754. * @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
  24755. * @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
  24756. * @param x defines x coordinate
  24757. * @param y defines y coordinate
  24758. * @param z defines z coordinate
  24759. * @returns the face index if found (or null instead)
  24760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24761. */
  24762. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24763. /**
  24764. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24765. * @param projected sets as the (x,y,z) local projection on the facet
  24766. * @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
  24767. * @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
  24768. * @param x defines x coordinate
  24769. * @param y defines y coordinate
  24770. * @param z defines z coordinate
  24771. * @returns the face index if found (or null instead)
  24772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24773. */
  24774. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24775. /**
  24776. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24777. * @returns the parameters
  24778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24779. */
  24780. getFacetDataParameters(): any;
  24781. /**
  24782. * Disables the feature FacetData and frees the related memory
  24783. * @returns the current mesh
  24784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24785. */
  24786. disableFacetData(): AbstractMesh;
  24787. /**
  24788. * Updates the AbstractMesh indices array
  24789. * @param indices defines the data source
  24790. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24791. * @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)
  24792. * @returns the current mesh
  24793. */
  24794. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24795. /**
  24796. * Creates new normals data for the mesh
  24797. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24798. * @returns the current mesh
  24799. */
  24800. createNormals(updatable: boolean): AbstractMesh;
  24801. /**
  24802. * Align the mesh with a normal
  24803. * @param normal defines the normal to use
  24804. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24805. * @returns the current mesh
  24806. */
  24807. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24808. /** @hidden */ private _checkOcclusionQuery(): boolean;
  24809. /**
  24810. * Disables the mesh edge rendering mode
  24811. * @returns the currentAbstractMesh
  24812. */
  24813. disableEdgesRendering(): AbstractMesh;
  24814. /**
  24815. * Enables the edge rendering mode on the mesh.
  24816. * This mode makes the mesh edges visible
  24817. * @param epsilon defines the maximal distance between two angles to detect a face
  24818. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  24819. * @returns the currentAbstractMesh
  24820. * @see https://www.babylonjs-playground.com/#19O9TU#0
  24821. */
  24822. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  24823. }
  24824. }
  24825. declare module BABYLON {
  24826. /**
  24827. * Interface used to define ActionEvent
  24828. */
  24829. export interface IActionEvent {
  24830. /** The mesh or sprite that triggered the action */
  24831. source: any;
  24832. /** The X mouse cursor position at the time of the event */
  24833. pointerX: number;
  24834. /** The Y mouse cursor position at the time of the event */
  24835. pointerY: number;
  24836. /** The mesh that is currently pointed at (can be null) */
  24837. meshUnderPointer: Nullable<AbstractMesh>;
  24838. /** the original (browser) event that triggered the ActionEvent */
  24839. sourceEvent?: any;
  24840. /** additional data for the event */
  24841. additionalData?: any;
  24842. }
  24843. /**
  24844. * ActionEvent is the event being sent when an action is triggered.
  24845. */
  24846. export class ActionEvent implements IActionEvent {
  24847. /** The mesh or sprite that triggered the action */
  24848. source: any;
  24849. /** The X mouse cursor position at the time of the event */
  24850. pointerX: number;
  24851. /** The Y mouse cursor position at the time of the event */
  24852. pointerY: number;
  24853. /** The mesh that is currently pointed at (can be null) */
  24854. meshUnderPointer: Nullable<AbstractMesh>;
  24855. /** the original (browser) event that triggered the ActionEvent */
  24856. sourceEvent?: any;
  24857. /** additional data for the event */
  24858. additionalData?: any;
  24859. /**
  24860. * Creates a new ActionEvent
  24861. * @param source The mesh or sprite that triggered the action
  24862. * @param pointerX The X mouse cursor position at the time of the event
  24863. * @param pointerY The Y mouse cursor position at the time of the event
  24864. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24865. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24866. * @param additionalData additional data for the event
  24867. */
  24868. constructor(
  24869. /** The mesh or sprite that triggered the action */
  24870. source: any,
  24871. /** The X mouse cursor position at the time of the event */
  24872. pointerX: number,
  24873. /** The Y mouse cursor position at the time of the event */
  24874. pointerY: number,
  24875. /** The mesh that is currently pointed at (can be null) */
  24876. meshUnderPointer: Nullable<AbstractMesh>,
  24877. /** the original (browser) event that triggered the ActionEvent */
  24878. sourceEvent?: any,
  24879. /** additional data for the event */
  24880. additionalData?: any);
  24881. /**
  24882. * Helper function to auto-create an ActionEvent from a source mesh.
  24883. * @param source The source mesh that triggered the event
  24884. * @param evt The original (browser) event
  24885. * @param additionalData additional data for the event
  24886. * @returns the new ActionEvent
  24887. */
  24888. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24889. /**
  24890. * Helper function to auto-create an ActionEvent from a source sprite
  24891. * @param source The source sprite that triggered the event
  24892. * @param scene Scene associated with the sprite
  24893. * @param evt The original (browser) event
  24894. * @param additionalData additional data for the event
  24895. * @returns the new ActionEvent
  24896. */
  24897. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24898. /**
  24899. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24900. * @param scene the scene where the event occurred
  24901. * @param evt The original (browser) event
  24902. * @returns the new ActionEvent
  24903. */
  24904. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24905. /**
  24906. * Helper function to auto-create an ActionEvent from a primitive
  24907. * @param prim defines the target primitive
  24908. * @param pointerPos defines the pointer position
  24909. * @param evt The original (browser) event
  24910. * @param additionalData additional data for the event
  24911. * @returns the new ActionEvent
  24912. */
  24913. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24914. }
  24915. }
  24916. declare module BABYLON {
  24917. /**
  24918. * Abstract class used to decouple action Manager from scene and meshes.
  24919. * Do not instantiate.
  24920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24921. */
  24922. export abstract class AbstractActionManager implements IDisposable {
  24923. /** Gets the list of active triggers */
  24924. static Triggers: {
  24925. [key: string]: number;
  24926. };
  24927. /** Gets the cursor to use when hovering items */
  24928. hoverCursor: string;
  24929. /** Gets the list of actions */
  24930. actions: IAction[];
  24931. /**
  24932. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24933. */
  24934. isRecursive: boolean;
  24935. /**
  24936. * Releases all associated resources
  24937. */
  24938. abstract dispose(): void;
  24939. /**
  24940. * Does this action manager has pointer triggers
  24941. */
  24942. abstract readonly hasPointerTriggers: boolean;
  24943. /**
  24944. * Does this action manager has pick triggers
  24945. */
  24946. abstract readonly hasPickTriggers: boolean;
  24947. /**
  24948. * Process a specific trigger
  24949. * @param trigger defines the trigger to process
  24950. * @param evt defines the event details to be processed
  24951. */
  24952. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24953. /**
  24954. * Does this action manager handles actions of any of the given triggers
  24955. * @param triggers defines the triggers to be tested
  24956. * @return a boolean indicating whether one (or more) of the triggers is handled
  24957. */
  24958. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24959. /**
  24960. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24961. * speed.
  24962. * @param triggerA defines the trigger to be tested
  24963. * @param triggerB defines the trigger to be tested
  24964. * @return a boolean indicating whether one (or more) of the triggers is handled
  24965. */
  24966. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24967. /**
  24968. * Does this action manager handles actions of a given trigger
  24969. * @param trigger defines the trigger to be tested
  24970. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24971. * @return whether the trigger is handled
  24972. */
  24973. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24974. /**
  24975. * Serialize this manager to a JSON object
  24976. * @param name defines the property name to store this manager
  24977. * @returns a JSON representation of this manager
  24978. */
  24979. abstract serialize(name: string): any;
  24980. /**
  24981. * Registers an action to this action manager
  24982. * @param action defines the action to be registered
  24983. * @return the action amended (prepared) after registration
  24984. */
  24985. abstract registerAction(action: IAction): Nullable<IAction>;
  24986. /**
  24987. * Unregisters an action to this action manager
  24988. * @param action defines the action to be unregistered
  24989. * @return a boolean indicating whether the action has been unregistered
  24990. */
  24991. abstract unregisterAction(action: IAction): Boolean;
  24992. /**
  24993. * Does exist one action manager with at least one trigger
  24994. **/
  24995. static readonly HasTriggers: boolean;
  24996. /**
  24997. * Does exist one action manager with at least one pick trigger
  24998. **/
  24999. static readonly HasPickTriggers: boolean;
  25000. /**
  25001. * Does exist one action manager that handles actions of a given trigger
  25002. * @param trigger defines the trigger to be tested
  25003. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25004. **/
  25005. static HasSpecificTrigger(trigger: number): boolean;
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * Defines how a node can be built from a string name.
  25011. */
  25012. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25013. /**
  25014. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25015. */
  25016. export class Node implements IBehaviorAware<Node> {
  25017. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25018. private static _NodeConstructors;
  25019. /**
  25020. * Add a new node constructor
  25021. * @param type defines the type name of the node to construct
  25022. * @param constructorFunc defines the constructor function
  25023. */
  25024. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25025. /**
  25026. * Returns a node constructor based on type name
  25027. * @param type defines the type name
  25028. * @param name defines the new node name
  25029. * @param scene defines the hosting scene
  25030. * @param options defines optional options to transmit to constructors
  25031. * @returns the new constructor or null
  25032. */
  25033. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25034. /**
  25035. * Gets or sets the name of the node
  25036. */
  25037. name: string;
  25038. /**
  25039. * Gets or sets the id of the node
  25040. */
  25041. id: string;
  25042. /**
  25043. * Gets or sets the unique id of the node
  25044. */
  25045. uniqueId: number;
  25046. /**
  25047. * Gets or sets a string used to store user defined state for the node
  25048. */
  25049. state: string;
  25050. /**
  25051. * Gets or sets an object used to store user defined information for the node
  25052. */
  25053. metadata: any;
  25054. /**
  25055. * For internal use only. Please do not use.
  25056. */
  25057. reservedDataStore: any;
  25058. /**
  25059. * List of inspectable custom properties (used by the Inspector)
  25060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25061. */
  25062. inspectableCustomProperties: IInspectable[];
  25063. /**
  25064. * Gets or sets a boolean used to define if the node must be serialized
  25065. */
  25066. doNotSerialize: boolean;
  25067. /** @hidden */ private _isDisposed: boolean;
  25068. /**
  25069. * Gets a list of Animations associated with the node
  25070. */
  25071. animations: Animation[];
  25072. protected _ranges: {
  25073. [name: string]: Nullable<AnimationRange>;
  25074. };
  25075. /**
  25076. * Callback raised when the node is ready to be used
  25077. */
  25078. onReady: Nullable<(node: Node) => void>;
  25079. private _isEnabled;
  25080. private _isParentEnabled;
  25081. private _isReady;
  25082. /** @hidden */ private _currentRenderId: number;
  25083. private _parentUpdateId;
  25084. /** @hidden */ private _childUpdateId: number;
  25085. /** @hidden */ private _waitingParentId: Nullable<string>;
  25086. /** @hidden */ private _scene: Scene;
  25087. /** @hidden */ private _cache: any;
  25088. private _parentNode;
  25089. private _children;
  25090. /** @hidden */ private _worldMatrix: Matrix;
  25091. /** @hidden */ private _worldMatrixDeterminant: number;
  25092. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  25093. /** @hidden */
  25094. private _sceneRootNodesIndex;
  25095. /**
  25096. * Gets a boolean indicating if the node has been disposed
  25097. * @returns true if the node was disposed
  25098. */
  25099. isDisposed(): boolean;
  25100. /**
  25101. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25102. * @see https://doc.babylonjs.com/how_to/parenting
  25103. */
  25104. parent: Nullable<Node>;
  25105. private addToSceneRootNodes;
  25106. private removeFromSceneRootNodes;
  25107. private _animationPropertiesOverride;
  25108. /**
  25109. * Gets or sets the animation properties override
  25110. */
  25111. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25112. /**
  25113. * Gets a string idenfifying the name of the class
  25114. * @returns "Node" string
  25115. */
  25116. getClassName(): string;
  25117. /** @hidden */ protected readonly _isNode: boolean;
  25118. /**
  25119. * An event triggered when the mesh is disposed
  25120. */
  25121. onDisposeObservable: Observable<Node>;
  25122. private _onDisposeObserver;
  25123. /**
  25124. * Sets a callback that will be raised when the node will be disposed
  25125. */
  25126. onDispose: () => void;
  25127. /**
  25128. * Creates a new Node
  25129. * @param name the name and id to be given to this node
  25130. * @param scene the scene this node will be added to
  25131. * @param addToRootNodes the node will be added to scene.rootNodes
  25132. */
  25133. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25134. /**
  25135. * Gets the scene of the node
  25136. * @returns a scene
  25137. */
  25138. getScene(): Scene;
  25139. /**
  25140. * Gets the engine of the node
  25141. * @returns a Engine
  25142. */
  25143. getEngine(): Engine;
  25144. private _behaviors;
  25145. /**
  25146. * Attach a behavior to the node
  25147. * @see http://doc.babylonjs.com/features/behaviour
  25148. * @param behavior defines the behavior to attach
  25149. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25150. * @returns the current Node
  25151. */
  25152. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25153. /**
  25154. * Remove an attached behavior
  25155. * @see http://doc.babylonjs.com/features/behaviour
  25156. * @param behavior defines the behavior to attach
  25157. * @returns the current Node
  25158. */
  25159. removeBehavior(behavior: Behavior<Node>): Node;
  25160. /**
  25161. * Gets the list of attached behaviors
  25162. * @see http://doc.babylonjs.com/features/behaviour
  25163. */
  25164. readonly behaviors: Behavior<Node>[];
  25165. /**
  25166. * Gets an attached behavior by name
  25167. * @param name defines the name of the behavior to look for
  25168. * @see http://doc.babylonjs.com/features/behaviour
  25169. * @returns null if behavior was not found else the requested behavior
  25170. */
  25171. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25172. /**
  25173. * Returns the latest update of the World matrix
  25174. * @returns a Matrix
  25175. */
  25176. getWorldMatrix(): Matrix;
  25177. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25178. /**
  25179. * Returns directly the latest state of the mesh World matrix.
  25180. * A Matrix is returned.
  25181. */
  25182. readonly worldMatrixFromCache: Matrix;
  25183. /** @hidden */ private _initCache(): void;
  25184. /** @hidden */
  25185. updateCache(force?: boolean): void;
  25186. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25187. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  25188. /** @hidden */ private _isSynchronized(): boolean;
  25189. /** @hidden */ private _markSyncedWithParent(): void;
  25190. /** @hidden */
  25191. isSynchronizedWithParent(): boolean;
  25192. /** @hidden */
  25193. isSynchronized(): boolean;
  25194. /**
  25195. * Is this node ready to be used/rendered
  25196. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25197. * @return true if the node is ready
  25198. */
  25199. isReady(completeCheck?: boolean): boolean;
  25200. /**
  25201. * Is this node enabled?
  25202. * 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
  25203. * @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
  25204. * @return whether this node (and its parent) is enabled
  25205. */
  25206. isEnabled(checkAncestors?: boolean): boolean;
  25207. /** @hidden */
  25208. protected _syncParentEnabledState(): void;
  25209. /**
  25210. * Set the enabled state of this node
  25211. * @param value defines the new enabled state
  25212. */
  25213. setEnabled(value: boolean): void;
  25214. /**
  25215. * Is this node a descendant of the given node?
  25216. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25217. * @param ancestor defines the parent node to inspect
  25218. * @returns a boolean indicating if this node is a descendant of the given node
  25219. */
  25220. isDescendantOf(ancestor: Node): boolean;
  25221. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25222. /**
  25223. * Will return all nodes that have this node as ascendant
  25224. * @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
  25225. * @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
  25226. * @return all children nodes of all types
  25227. */
  25228. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25229. /**
  25230. * Get all child-meshes of this node
  25231. * @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)
  25232. * @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
  25233. * @returns an array of AbstractMesh
  25234. */
  25235. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25236. /**
  25237. * Get all direct children of this node
  25238. * @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
  25239. * @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)
  25240. * @returns an array of Node
  25241. */
  25242. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25243. /** @hidden */ private _setReady(state: boolean): void;
  25244. /**
  25245. * Get an animation by name
  25246. * @param name defines the name of the animation to look for
  25247. * @returns null if not found else the requested animation
  25248. */
  25249. getAnimationByName(name: string): Nullable<Animation>;
  25250. /**
  25251. * Creates an animation range for this node
  25252. * @param name defines the name of the range
  25253. * @param from defines the starting key
  25254. * @param to defines the end key
  25255. */
  25256. createAnimationRange(name: string, from: number, to: number): void;
  25257. /**
  25258. * Delete a specific animation range
  25259. * @param name defines the name of the range to delete
  25260. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25261. */
  25262. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25263. /**
  25264. * Get an animation range by name
  25265. * @param name defines the name of the animation range to look for
  25266. * @returns null if not found else the requested animation range
  25267. */
  25268. getAnimationRange(name: string): Nullable<AnimationRange>;
  25269. /**
  25270. * Gets the list of all animation ranges defined on this node
  25271. * @returns an array
  25272. */
  25273. getAnimationRanges(): Nullable<AnimationRange>[];
  25274. /**
  25275. * Will start the animation sequence
  25276. * @param name defines the range frames for animation sequence
  25277. * @param loop defines if the animation should loop (false by default)
  25278. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25279. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25280. * @returns the object created for this animation. If range does not exist, it will return null
  25281. */
  25282. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25283. /**
  25284. * Serialize animation ranges into a JSON compatible object
  25285. * @returns serialization object
  25286. */
  25287. serializeAnimationRanges(): any;
  25288. /**
  25289. * Computes the world matrix of the node
  25290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25291. * @returns the world matrix
  25292. */
  25293. computeWorldMatrix(force?: boolean): Matrix;
  25294. /**
  25295. * Releases resources associated with this node.
  25296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25298. */
  25299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25300. /**
  25301. * Parse animation range data from a serialization object and store them into a given node
  25302. * @param node defines where to store the animation ranges
  25303. * @param parsedNode defines the serialization object to read data from
  25304. * @param scene defines the hosting scene
  25305. */
  25306. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25307. /**
  25308. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25309. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25310. * @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
  25311. * @returns the new bounding vectors
  25312. */
  25313. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25314. min: Vector3;
  25315. max: Vector3;
  25316. };
  25317. }
  25318. }
  25319. declare module BABYLON {
  25320. /**
  25321. * @hidden
  25322. */
  25323. export class _IAnimationState {
  25324. key: number;
  25325. repeatCount: number;
  25326. workValue?: any;
  25327. loopMode?: number;
  25328. offsetValue?: any;
  25329. highLimitValue?: any;
  25330. }
  25331. /**
  25332. * Class used to store any kind of animation
  25333. */
  25334. export class Animation {
  25335. /**Name of the animation */
  25336. name: string;
  25337. /**Property to animate */
  25338. targetProperty: string;
  25339. /**The frames per second of the animation */
  25340. framePerSecond: number;
  25341. /**The data type of the animation */
  25342. dataType: number;
  25343. /**The loop mode of the animation */
  25344. loopMode?: number | undefined;
  25345. /**Specifies if blending should be enabled */
  25346. enableBlending?: boolean | undefined;
  25347. /**
  25348. * Use matrix interpolation instead of using direct key value when animating matrices
  25349. */
  25350. static AllowMatricesInterpolation: boolean;
  25351. /**
  25352. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25353. */
  25354. static AllowMatrixDecomposeForInterpolation: boolean;
  25355. /**
  25356. * Stores the key frames of the animation
  25357. */
  25358. private _keys;
  25359. /**
  25360. * Stores the easing function of the animation
  25361. */
  25362. private _easingFunction;
  25363. /**
  25364. * @hidden Internal use only
  25365. */ private _runtimeAnimations: RuntimeAnimation[];
  25366. /**
  25367. * The set of event that will be linked to this animation
  25368. */
  25369. private _events;
  25370. /**
  25371. * Stores an array of target property paths
  25372. */
  25373. targetPropertyPath: string[];
  25374. /**
  25375. * Stores the blending speed of the animation
  25376. */
  25377. blendingSpeed: number;
  25378. /**
  25379. * Stores the animation ranges for the animation
  25380. */
  25381. private _ranges;
  25382. /**
  25383. * @hidden Internal use
  25384. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25385. /**
  25386. * Sets up an animation
  25387. * @param property The property to animate
  25388. * @param animationType The animation type to apply
  25389. * @param framePerSecond The frames per second of the animation
  25390. * @param easingFunction The easing function used in the animation
  25391. * @returns The created animation
  25392. */
  25393. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25394. /**
  25395. * Create and start an animation on a node
  25396. * @param name defines the name of the global animation that will be run on all nodes
  25397. * @param node defines the root node where the animation will take place
  25398. * @param targetProperty defines property to animate
  25399. * @param framePerSecond defines the number of frame per second yo use
  25400. * @param totalFrame defines the number of frames in total
  25401. * @param from defines the initial value
  25402. * @param to defines the final value
  25403. * @param loopMode defines which loop mode you want to use (off by default)
  25404. * @param easingFunction defines the easing function to use (linear by default)
  25405. * @param onAnimationEnd defines the callback to call when animation end
  25406. * @returns the animatable created for this animation
  25407. */
  25408. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25409. /**
  25410. * Create and start an animation on a node and its descendants
  25411. * @param name defines the name of the global animation that will be run on all nodes
  25412. * @param node defines the root node where the animation will take place
  25413. * @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
  25414. * @param targetProperty defines property to animate
  25415. * @param framePerSecond defines the number of frame per second to use
  25416. * @param totalFrame defines the number of frames in total
  25417. * @param from defines the initial value
  25418. * @param to defines the final value
  25419. * @param loopMode defines which loop mode you want to use (off by default)
  25420. * @param easingFunction defines the easing function to use (linear by default)
  25421. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25422. * @returns the list of animatables created for all nodes
  25423. * @example https://www.babylonjs-playground.com/#MH0VLI
  25424. */
  25425. 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[]>;
  25426. /**
  25427. * Creates a new animation, merges it with the existing animations and starts it
  25428. * @param name Name of the animation
  25429. * @param node Node which contains the scene that begins the animations
  25430. * @param targetProperty Specifies which property to animate
  25431. * @param framePerSecond The frames per second of the animation
  25432. * @param totalFrame The total number of frames
  25433. * @param from The frame at the beginning of the animation
  25434. * @param to The frame at the end of the animation
  25435. * @param loopMode Specifies the loop mode of the animation
  25436. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25437. * @param onAnimationEnd Callback to run once the animation is complete
  25438. * @returns Nullable animation
  25439. */
  25440. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25441. /**
  25442. * Transition property of an host to the target Value
  25443. * @param property The property to transition
  25444. * @param targetValue The target Value of the property
  25445. * @param host The object where the property to animate belongs
  25446. * @param scene Scene used to run the animation
  25447. * @param frameRate Framerate (in frame/s) to use
  25448. * @param transition The transition type we want to use
  25449. * @param duration The duration of the animation, in milliseconds
  25450. * @param onAnimationEnd Callback trigger at the end of the animation
  25451. * @returns Nullable animation
  25452. */
  25453. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25454. /**
  25455. * Return the array of runtime animations currently using this animation
  25456. */
  25457. readonly runtimeAnimations: RuntimeAnimation[];
  25458. /**
  25459. * Specifies if any of the runtime animations are currently running
  25460. */
  25461. readonly hasRunningRuntimeAnimations: boolean;
  25462. /**
  25463. * Initializes the animation
  25464. * @param name Name of the animation
  25465. * @param targetProperty Property to animate
  25466. * @param framePerSecond The frames per second of the animation
  25467. * @param dataType The data type of the animation
  25468. * @param loopMode The loop mode of the animation
  25469. * @param enableBlending Specifies if blending should be enabled
  25470. */
  25471. constructor(
  25472. /**Name of the animation */
  25473. name: string,
  25474. /**Property to animate */
  25475. targetProperty: string,
  25476. /**The frames per second of the animation */
  25477. framePerSecond: number,
  25478. /**The data type of the animation */
  25479. dataType: number,
  25480. /**The loop mode of the animation */
  25481. loopMode?: number | undefined,
  25482. /**Specifies if blending should be enabled */
  25483. enableBlending?: boolean | undefined);
  25484. /**
  25485. * Converts the animation to a string
  25486. * @param fullDetails support for multiple levels of logging within scene loading
  25487. * @returns String form of the animation
  25488. */
  25489. toString(fullDetails?: boolean): string;
  25490. /**
  25491. * Add an event to this animation
  25492. * @param event Event to add
  25493. */
  25494. addEvent(event: AnimationEvent): void;
  25495. /**
  25496. * Remove all events found at the given frame
  25497. * @param frame The frame to remove events from
  25498. */
  25499. removeEvents(frame: number): void;
  25500. /**
  25501. * Retrieves all the events from the animation
  25502. * @returns Events from the animation
  25503. */
  25504. getEvents(): AnimationEvent[];
  25505. /**
  25506. * Creates an animation range
  25507. * @param name Name of the animation range
  25508. * @param from Starting frame of the animation range
  25509. * @param to Ending frame of the animation
  25510. */
  25511. createRange(name: string, from: number, to: number): void;
  25512. /**
  25513. * Deletes an animation range by name
  25514. * @param name Name of the animation range to delete
  25515. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25516. */
  25517. deleteRange(name: string, deleteFrames?: boolean): void;
  25518. /**
  25519. * Gets the animation range by name, or null if not defined
  25520. * @param name Name of the animation range
  25521. * @returns Nullable animation range
  25522. */
  25523. getRange(name: string): Nullable<AnimationRange>;
  25524. /**
  25525. * Gets the key frames from the animation
  25526. * @returns The key frames of the animation
  25527. */
  25528. getKeys(): Array<IAnimationKey>;
  25529. /**
  25530. * Gets the highest frame rate of the animation
  25531. * @returns Highest frame rate of the animation
  25532. */
  25533. getHighestFrame(): number;
  25534. /**
  25535. * Gets the easing function of the animation
  25536. * @returns Easing function of the animation
  25537. */
  25538. getEasingFunction(): IEasingFunction;
  25539. /**
  25540. * Sets the easing function of the animation
  25541. * @param easingFunction A custom mathematical formula for animation
  25542. */
  25543. setEasingFunction(easingFunction: EasingFunction): void;
  25544. /**
  25545. * Interpolates a scalar linearly
  25546. * @param startValue Start value of the animation curve
  25547. * @param endValue End value of the animation curve
  25548. * @param gradient Scalar amount to interpolate
  25549. * @returns Interpolated scalar value
  25550. */
  25551. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25552. /**
  25553. * Interpolates a scalar cubically
  25554. * @param startValue Start value of the animation curve
  25555. * @param outTangent End tangent of the animation
  25556. * @param endValue End value of the animation curve
  25557. * @param inTangent Start tangent of the animation curve
  25558. * @param gradient Scalar amount to interpolate
  25559. * @returns Interpolated scalar value
  25560. */
  25561. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25562. /**
  25563. * Interpolates a quaternion using a spherical linear interpolation
  25564. * @param startValue Start value of the animation curve
  25565. * @param endValue End value of the animation curve
  25566. * @param gradient Scalar amount to interpolate
  25567. * @returns Interpolated quaternion value
  25568. */
  25569. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25570. /**
  25571. * Interpolates a quaternion cubically
  25572. * @param startValue Start value of the animation curve
  25573. * @param outTangent End tangent of the animation curve
  25574. * @param endValue End value of the animation curve
  25575. * @param inTangent Start tangent of the animation curve
  25576. * @param gradient Scalar amount to interpolate
  25577. * @returns Interpolated quaternion value
  25578. */
  25579. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25580. /**
  25581. * Interpolates a Vector3 linearl
  25582. * @param startValue Start value of the animation curve
  25583. * @param endValue End value of the animation curve
  25584. * @param gradient Scalar amount to interpolate
  25585. * @returns Interpolated scalar value
  25586. */
  25587. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25588. /**
  25589. * Interpolates a Vector3 cubically
  25590. * @param startValue Start value of the animation curve
  25591. * @param outTangent End tangent of the animation
  25592. * @param endValue End value of the animation curve
  25593. * @param inTangent Start tangent of the animation curve
  25594. * @param gradient Scalar amount to interpolate
  25595. * @returns InterpolatedVector3 value
  25596. */
  25597. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25598. /**
  25599. * Interpolates a Vector2 linearly
  25600. * @param startValue Start value of the animation curve
  25601. * @param endValue End value of the animation curve
  25602. * @param gradient Scalar amount to interpolate
  25603. * @returns Interpolated Vector2 value
  25604. */
  25605. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25606. /**
  25607. * Interpolates a Vector2 cubically
  25608. * @param startValue Start value of the animation curve
  25609. * @param outTangent End tangent of the animation
  25610. * @param endValue End value of the animation curve
  25611. * @param inTangent Start tangent of the animation curve
  25612. * @param gradient Scalar amount to interpolate
  25613. * @returns Interpolated Vector2 value
  25614. */
  25615. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25616. /**
  25617. * Interpolates a size linearly
  25618. * @param startValue Start value of the animation curve
  25619. * @param endValue End value of the animation curve
  25620. * @param gradient Scalar amount to interpolate
  25621. * @returns Interpolated Size value
  25622. */
  25623. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25624. /**
  25625. * Interpolates a Color3 linearly
  25626. * @param startValue Start value of the animation curve
  25627. * @param endValue End value of the animation curve
  25628. * @param gradient Scalar amount to interpolate
  25629. * @returns Interpolated Color3 value
  25630. */
  25631. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25632. /**
  25633. * @hidden Internal use only
  25634. */ private _getKeyValue(value: any): any;
  25635. /**
  25636. * @hidden Internal use only
  25637. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  25638. /**
  25639. * Defines the function to use to interpolate matrices
  25640. * @param startValue defines the start matrix
  25641. * @param endValue defines the end matrix
  25642. * @param gradient defines the gradient between both matrices
  25643. * @param result defines an optional target matrix where to store the interpolation
  25644. * @returns the interpolated matrix
  25645. */
  25646. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25647. /**
  25648. * Makes a copy of the animation
  25649. * @returns Cloned animation
  25650. */
  25651. clone(): Animation;
  25652. /**
  25653. * Sets the key frames of the animation
  25654. * @param values The animation key frames to set
  25655. */
  25656. setKeys(values: Array<IAnimationKey>): void;
  25657. /**
  25658. * Serializes the animation to an object
  25659. * @returns Serialized object
  25660. */
  25661. serialize(): any;
  25662. /**
  25663. * Float animation type
  25664. */
  25665. private static _ANIMATIONTYPE_FLOAT;
  25666. /**
  25667. * Vector3 animation type
  25668. */
  25669. private static _ANIMATIONTYPE_VECTOR3;
  25670. /**
  25671. * Quaternion animation type
  25672. */
  25673. private static _ANIMATIONTYPE_QUATERNION;
  25674. /**
  25675. * Matrix animation type
  25676. */
  25677. private static _ANIMATIONTYPE_MATRIX;
  25678. /**
  25679. * Color3 animation type
  25680. */
  25681. private static _ANIMATIONTYPE_COLOR3;
  25682. /**
  25683. * Vector2 animation type
  25684. */
  25685. private static _ANIMATIONTYPE_VECTOR2;
  25686. /**
  25687. * Size animation type
  25688. */
  25689. private static _ANIMATIONTYPE_SIZE;
  25690. /**
  25691. * Relative Loop Mode
  25692. */
  25693. private static _ANIMATIONLOOPMODE_RELATIVE;
  25694. /**
  25695. * Cycle Loop Mode
  25696. */
  25697. private static _ANIMATIONLOOPMODE_CYCLE;
  25698. /**
  25699. * Constant Loop Mode
  25700. */
  25701. private static _ANIMATIONLOOPMODE_CONSTANT;
  25702. /**
  25703. * Get the float animation type
  25704. */
  25705. static readonly ANIMATIONTYPE_FLOAT: number;
  25706. /**
  25707. * Get the Vector3 animation type
  25708. */
  25709. static readonly ANIMATIONTYPE_VECTOR3: number;
  25710. /**
  25711. * Get the Vector2 animation type
  25712. */
  25713. static readonly ANIMATIONTYPE_VECTOR2: number;
  25714. /**
  25715. * Get the Size animation type
  25716. */
  25717. static readonly ANIMATIONTYPE_SIZE: number;
  25718. /**
  25719. * Get the Quaternion animation type
  25720. */
  25721. static readonly ANIMATIONTYPE_QUATERNION: number;
  25722. /**
  25723. * Get the Matrix animation type
  25724. */
  25725. static readonly ANIMATIONTYPE_MATRIX: number;
  25726. /**
  25727. * Get the Color3 animation type
  25728. */
  25729. static readonly ANIMATIONTYPE_COLOR3: number;
  25730. /**
  25731. * Get the Relative Loop Mode
  25732. */
  25733. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25734. /**
  25735. * Get the Cycle Loop Mode
  25736. */
  25737. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25738. /**
  25739. * Get the Constant Loop Mode
  25740. */
  25741. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25742. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25743. /**
  25744. * Parses an animation object and creates an animation
  25745. * @param parsedAnimation Parsed animation object
  25746. * @returns Animation object
  25747. */
  25748. static Parse(parsedAnimation: any): Animation;
  25749. /**
  25750. * Appends the serialized animations from the source animations
  25751. * @param source Source containing the animations
  25752. * @param destination Target to store the animations
  25753. */
  25754. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25755. }
  25756. }
  25757. declare module BABYLON {
  25758. /**
  25759. * Base class of all the textures in babylon.
  25760. * It groups all the common properties the materials, post process, lights... might need
  25761. * in order to make a correct use of the texture.
  25762. */
  25763. export class BaseTexture implements IAnimatable {
  25764. /**
  25765. * Default anisotropic filtering level for the application.
  25766. * It is set to 4 as a good tradeoff between perf and quality.
  25767. */
  25768. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25769. /**
  25770. * Gets or sets the unique id of the texture
  25771. */
  25772. uniqueId: number;
  25773. /**
  25774. * Define the name of the texture.
  25775. */
  25776. name: string;
  25777. /**
  25778. * Gets or sets an object used to store user defined information.
  25779. */
  25780. metadata: any;
  25781. /**
  25782. * For internal use only. Please do not use.
  25783. */
  25784. reservedDataStore: any;
  25785. private _hasAlpha;
  25786. /**
  25787. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25788. */
  25789. hasAlpha: boolean;
  25790. /**
  25791. * Defines if the alpha value should be determined via the rgb values.
  25792. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25793. */
  25794. getAlphaFromRGB: boolean;
  25795. /**
  25796. * Intensity or strength of the texture.
  25797. * It is commonly used by materials to fine tune the intensity of the texture
  25798. */
  25799. level: number;
  25800. /**
  25801. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25802. * This is part of the texture as textures usually maps to one uv set.
  25803. */
  25804. coordinatesIndex: number;
  25805. private _coordinatesMode;
  25806. /**
  25807. * How a texture is mapped.
  25808. *
  25809. * | Value | Type | Description |
  25810. * | ----- | ----------------------------------- | ----------- |
  25811. * | 0 | EXPLICIT_MODE | |
  25812. * | 1 | SPHERICAL_MODE | |
  25813. * | 2 | PLANAR_MODE | |
  25814. * | 3 | CUBIC_MODE | |
  25815. * | 4 | PROJECTION_MODE | |
  25816. * | 5 | SKYBOX_MODE | |
  25817. * | 6 | INVCUBIC_MODE | |
  25818. * | 7 | EQUIRECTANGULAR_MODE | |
  25819. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25820. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25821. */
  25822. coordinatesMode: number;
  25823. /**
  25824. * | Value | Type | Description |
  25825. * | ----- | ------------------ | ----------- |
  25826. * | 0 | CLAMP_ADDRESSMODE | |
  25827. * | 1 | WRAP_ADDRESSMODE | |
  25828. * | 2 | MIRROR_ADDRESSMODE | |
  25829. */
  25830. wrapU: number;
  25831. /**
  25832. * | Value | Type | Description |
  25833. * | ----- | ------------------ | ----------- |
  25834. * | 0 | CLAMP_ADDRESSMODE | |
  25835. * | 1 | WRAP_ADDRESSMODE | |
  25836. * | 2 | MIRROR_ADDRESSMODE | |
  25837. */
  25838. wrapV: number;
  25839. /**
  25840. * | Value | Type | Description |
  25841. * | ----- | ------------------ | ----------- |
  25842. * | 0 | CLAMP_ADDRESSMODE | |
  25843. * | 1 | WRAP_ADDRESSMODE | |
  25844. * | 2 | MIRROR_ADDRESSMODE | |
  25845. */
  25846. wrapR: number;
  25847. /**
  25848. * With compliant hardware and browser (supporting anisotropic filtering)
  25849. * this defines the level of anisotropic filtering in the texture.
  25850. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25851. */
  25852. anisotropicFilteringLevel: number;
  25853. /**
  25854. * Define if the texture is a cube texture or if false a 2d texture.
  25855. */
  25856. isCube: boolean;
  25857. /**
  25858. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25859. */
  25860. is3D: boolean;
  25861. /**
  25862. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25863. * HDR texture are usually stored in linear space.
  25864. * This only impacts the PBR and Background materials
  25865. */
  25866. gammaSpace: boolean;
  25867. /**
  25868. * Gets whether or not the texture contains RGBD data.
  25869. */
  25870. readonly isRGBD: boolean;
  25871. /**
  25872. * Is Z inverted in the texture (useful in a cube texture).
  25873. */
  25874. invertZ: boolean;
  25875. /**
  25876. * Are mip maps generated for this texture or not.
  25877. */
  25878. readonly noMipmap: boolean;
  25879. /**
  25880. * @hidden
  25881. */
  25882. lodLevelInAlpha: boolean;
  25883. /**
  25884. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25885. */
  25886. lodGenerationOffset: number;
  25887. /**
  25888. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25889. */
  25890. lodGenerationScale: number;
  25891. /**
  25892. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  25893. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  25894. * average roughness values.
  25895. */
  25896. linearSpecularLOD: boolean;
  25897. /**
  25898. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  25899. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  25900. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  25901. */
  25902. irradianceTexture: Nullable<BaseTexture>;
  25903. /**
  25904. * Define if the texture is a render target.
  25905. */
  25906. isRenderTarget: boolean;
  25907. /**
  25908. * Define the unique id of the texture in the scene.
  25909. */
  25910. readonly uid: string;
  25911. /**
  25912. * Return a string representation of the texture.
  25913. * @returns the texture as a string
  25914. */
  25915. toString(): string;
  25916. /**
  25917. * Get the class name of the texture.
  25918. * @returns "BaseTexture"
  25919. */
  25920. getClassName(): string;
  25921. /**
  25922. * Define the list of animation attached to the texture.
  25923. */
  25924. animations: Animation[];
  25925. /**
  25926. * An event triggered when the texture is disposed.
  25927. */
  25928. onDisposeObservable: Observable<BaseTexture>;
  25929. private _onDisposeObserver;
  25930. /**
  25931. * Callback triggered when the texture has been disposed.
  25932. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25933. */
  25934. onDispose: () => void;
  25935. /**
  25936. * Define the current state of the loading sequence when in delayed load mode.
  25937. */
  25938. delayLoadState: number;
  25939. private _scene;
  25940. /** @hidden */ private _texture: Nullable<InternalTexture>;
  25941. private _uid;
  25942. /**
  25943. * Define if the texture is preventinga material to render or not.
  25944. * If not and the texture is not ready, the engine will use a default black texture instead.
  25945. */
  25946. readonly isBlocking: boolean;
  25947. /**
  25948. * Instantiates a new BaseTexture.
  25949. * Base class of all the textures in babylon.
  25950. * It groups all the common properties the materials, post process, lights... might need
  25951. * in order to make a correct use of the texture.
  25952. * @param scene Define the scene the texture blongs to
  25953. */
  25954. constructor(scene: Nullable<Scene>);
  25955. /**
  25956. * Get the scene the texture belongs to.
  25957. * @returns the scene or null if undefined
  25958. */
  25959. getScene(): Nullable<Scene>;
  25960. /**
  25961. * Get the texture transform matrix used to offset tile the texture for istance.
  25962. * @returns the transformation matrix
  25963. */
  25964. getTextureMatrix(): Matrix;
  25965. /**
  25966. * Get the texture reflection matrix used to rotate/transform the reflection.
  25967. * @returns the reflection matrix
  25968. */
  25969. getReflectionTextureMatrix(): Matrix;
  25970. /**
  25971. * Get the underlying lower level texture from Babylon.
  25972. * @returns the insternal texture
  25973. */
  25974. getInternalTexture(): Nullable<InternalTexture>;
  25975. /**
  25976. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25977. * @returns true if ready or not blocking
  25978. */
  25979. isReadyOrNotBlocking(): boolean;
  25980. /**
  25981. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25982. * @returns true if fully ready
  25983. */
  25984. isReady(): boolean;
  25985. private _cachedSize;
  25986. /**
  25987. * Get the size of the texture.
  25988. * @returns the texture size.
  25989. */
  25990. getSize(): ISize;
  25991. /**
  25992. * Get the base size of the texture.
  25993. * It can be different from the size if the texture has been resized for POT for instance
  25994. * @returns the base size
  25995. */
  25996. getBaseSize(): ISize;
  25997. /**
  25998. * Update the sampling mode of the texture.
  25999. * Default is Trilinear mode.
  26000. *
  26001. * | Value | Type | Description |
  26002. * | ----- | ------------------ | ----------- |
  26003. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26004. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26005. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26006. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26007. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26008. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26009. * | 7 | NEAREST_LINEAR | |
  26010. * | 8 | NEAREST_NEAREST | |
  26011. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26012. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26013. * | 11 | LINEAR_LINEAR | |
  26014. * | 12 | LINEAR_NEAREST | |
  26015. *
  26016. * > _mag_: magnification filter (close to the viewer)
  26017. * > _min_: minification filter (far from the viewer)
  26018. * > _mip_: filter used between mip map levels
  26019. *@param samplingMode Define the new sampling mode of the texture
  26020. */
  26021. updateSamplingMode(samplingMode: number): void;
  26022. /**
  26023. * Scales the texture if is `canRescale()`
  26024. * @param ratio the resize factor we want to use to rescale
  26025. */
  26026. scale(ratio: number): void;
  26027. /**
  26028. * Get if the texture can rescale.
  26029. */
  26030. readonly canRescale: boolean;
  26031. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26032. /** @hidden */ private _rebuild(): void;
  26033. /**
  26034. * Triggers the load sequence in delayed load mode.
  26035. */
  26036. delayLoad(): void;
  26037. /**
  26038. * Clones the texture.
  26039. * @returns the cloned texture
  26040. */
  26041. clone(): Nullable<BaseTexture>;
  26042. /**
  26043. * Get the texture underlying type (INT, FLOAT...)
  26044. */
  26045. readonly textureType: number;
  26046. /**
  26047. * Get the texture underlying format (RGB, RGBA...)
  26048. */
  26049. readonly textureFormat: number;
  26050. /**
  26051. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26052. * This will returns an RGBA array buffer containing either in values (0-255) or
  26053. * float values (0-1) depending of the underlying buffer type.
  26054. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26055. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26056. * @param buffer defines a user defined buffer to fill with data (can be null)
  26057. * @returns The Array buffer containing the pixels data.
  26058. */
  26059. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26060. /**
  26061. * Release and destroy the underlying lower level texture aka internalTexture.
  26062. */
  26063. releaseInternalTexture(): void;
  26064. /**
  26065. * Get the polynomial representation of the texture data.
  26066. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26067. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26068. */
  26069. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26070. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  26071. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  26072. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  26073. /**
  26074. * Dispose the texture and release its associated resources.
  26075. */
  26076. dispose(): void;
  26077. /**
  26078. * Serialize the texture into a JSON representation that can be parsed later on.
  26079. * @returns the JSON representation of the texture
  26080. */
  26081. serialize(): any;
  26082. /**
  26083. * Helper function to be called back once a list of texture contains only ready textures.
  26084. * @param textures Define the list of textures to wait for
  26085. * @param callback Define the callback triggered once the entire list will be ready
  26086. */
  26087. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26088. }
  26089. }
  26090. declare module BABYLON {
  26091. /**
  26092. * Uniform buffer objects.
  26093. *
  26094. * Handles blocks of uniform on the GPU.
  26095. *
  26096. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26097. *
  26098. * For more information, please refer to :
  26099. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26100. */
  26101. export class UniformBuffer {
  26102. private _engine;
  26103. private _buffer;
  26104. private _data;
  26105. private _bufferData;
  26106. private _dynamic?;
  26107. private _uniformLocations;
  26108. private _uniformSizes;
  26109. private _uniformLocationPointer;
  26110. private _needSync;
  26111. private _noUBO;
  26112. private _currentEffect;
  26113. private static _MAX_UNIFORM_SIZE;
  26114. private static _tempBuffer;
  26115. /**
  26116. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26117. * This is dynamic to allow compat with webgl 1 and 2.
  26118. * You will need to pass the name of the uniform as well as the value.
  26119. */
  26120. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26121. /**
  26122. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26123. * This is dynamic to allow compat with webgl 1 and 2.
  26124. * You will need to pass the name of the uniform as well as the value.
  26125. */
  26126. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26127. /**
  26128. * Lambda to Update a single float in a uniform buffer.
  26129. * This is dynamic to allow compat with webgl 1 and 2.
  26130. * You will need to pass the name of the uniform as well as the value.
  26131. */
  26132. updateFloat: (name: string, x: number) => void;
  26133. /**
  26134. * Lambda to Update a vec2 of float in a uniform buffer.
  26135. * This is dynamic to allow compat with webgl 1 and 2.
  26136. * You will need to pass the name of the uniform as well as the value.
  26137. */
  26138. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26139. /**
  26140. * Lambda to Update a vec3 of float in a uniform buffer.
  26141. * This is dynamic to allow compat with webgl 1 and 2.
  26142. * You will need to pass the name of the uniform as well as the value.
  26143. */
  26144. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26145. /**
  26146. * Lambda to Update a vec4 of float in a uniform buffer.
  26147. * This is dynamic to allow compat with webgl 1 and 2.
  26148. * You will need to pass the name of the uniform as well as the value.
  26149. */
  26150. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26151. /**
  26152. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26153. * This is dynamic to allow compat with webgl 1 and 2.
  26154. * You will need to pass the name of the uniform as well as the value.
  26155. */
  26156. updateMatrix: (name: string, mat: Matrix) => void;
  26157. /**
  26158. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26159. * This is dynamic to allow compat with webgl 1 and 2.
  26160. * You will need to pass the name of the uniform as well as the value.
  26161. */
  26162. updateVector3: (name: string, vector: Vector3) => void;
  26163. /**
  26164. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26165. * This is dynamic to allow compat with webgl 1 and 2.
  26166. * You will need to pass the name of the uniform as well as the value.
  26167. */
  26168. updateVector4: (name: string, vector: Vector4) => void;
  26169. /**
  26170. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26171. * This is dynamic to allow compat with webgl 1 and 2.
  26172. * You will need to pass the name of the uniform as well as the value.
  26173. */
  26174. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26175. /**
  26176. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26177. * This is dynamic to allow compat with webgl 1 and 2.
  26178. * You will need to pass the name of the uniform as well as the value.
  26179. */
  26180. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26181. /**
  26182. * Instantiates a new Uniform buffer objects.
  26183. *
  26184. * Handles blocks of uniform on the GPU.
  26185. *
  26186. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26187. *
  26188. * For more information, please refer to :
  26189. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26190. * @param engine Define the engine the buffer is associated with
  26191. * @param data Define the data contained in the buffer
  26192. * @param dynamic Define if the buffer is updatable
  26193. */
  26194. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26195. /**
  26196. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26197. * or just falling back on setUniformXXX calls.
  26198. */
  26199. readonly useUbo: boolean;
  26200. /**
  26201. * Indicates if the WebGL underlying uniform buffer is in sync
  26202. * with the javascript cache data.
  26203. */
  26204. readonly isSync: boolean;
  26205. /**
  26206. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26207. * Also, a dynamic UniformBuffer will disable cache verification and always
  26208. * update the underlying WebGL uniform buffer to the GPU.
  26209. * @returns if Dynamic, otherwise false
  26210. */
  26211. isDynamic(): boolean;
  26212. /**
  26213. * The data cache on JS side.
  26214. * @returns the underlying data as a float array
  26215. */
  26216. getData(): Float32Array;
  26217. /**
  26218. * The underlying WebGL Uniform buffer.
  26219. * @returns the webgl buffer
  26220. */
  26221. getBuffer(): Nullable<DataBuffer>;
  26222. /**
  26223. * std140 layout specifies how to align data within an UBO structure.
  26224. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26225. * for specs.
  26226. */
  26227. private _fillAlignment;
  26228. /**
  26229. * Adds an uniform in the buffer.
  26230. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26231. * for the layout to be correct !
  26232. * @param name Name of the uniform, as used in the uniform block in the shader.
  26233. * @param size Data size, or data directly.
  26234. */
  26235. addUniform(name: string, size: number | number[]): void;
  26236. /**
  26237. * Adds a Matrix 4x4 to the uniform buffer.
  26238. * @param name Name of the uniform, as used in the uniform block in the shader.
  26239. * @param mat A 4x4 matrix.
  26240. */
  26241. addMatrix(name: string, mat: Matrix): void;
  26242. /**
  26243. * Adds a vec2 to the uniform buffer.
  26244. * @param name Name of the uniform, as used in the uniform block in the shader.
  26245. * @param x Define the x component value of the vec2
  26246. * @param y Define the y component value of the vec2
  26247. */
  26248. addFloat2(name: string, x: number, y: number): void;
  26249. /**
  26250. * Adds a vec3 to the uniform buffer.
  26251. * @param name Name of the uniform, as used in the uniform block in the shader.
  26252. * @param x Define the x component value of the vec3
  26253. * @param y Define the y component value of the vec3
  26254. * @param z Define the z component value of the vec3
  26255. */
  26256. addFloat3(name: string, x: number, y: number, z: number): void;
  26257. /**
  26258. * Adds a vec3 to the uniform buffer.
  26259. * @param name Name of the uniform, as used in the uniform block in the shader.
  26260. * @param color Define the vec3 from a Color
  26261. */
  26262. addColor3(name: string, color: Color3): void;
  26263. /**
  26264. * Adds a vec4 to the uniform buffer.
  26265. * @param name Name of the uniform, as used in the uniform block in the shader.
  26266. * @param color Define the rgb components from a Color
  26267. * @param alpha Define the a component of the vec4
  26268. */
  26269. addColor4(name: string, color: Color3, alpha: number): void;
  26270. /**
  26271. * Adds a vec3 to the uniform buffer.
  26272. * @param name Name of the uniform, as used in the uniform block in the shader.
  26273. * @param vector Define the vec3 components from a Vector
  26274. */
  26275. addVector3(name: string, vector: Vector3): void;
  26276. /**
  26277. * Adds a Matrix 3x3 to the uniform buffer.
  26278. * @param name Name of the uniform, as used in the uniform block in the shader.
  26279. */
  26280. addMatrix3x3(name: string): void;
  26281. /**
  26282. * Adds a Matrix 2x2 to the uniform buffer.
  26283. * @param name Name of the uniform, as used in the uniform block in the shader.
  26284. */
  26285. addMatrix2x2(name: string): void;
  26286. /**
  26287. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26288. */
  26289. create(): void;
  26290. /** @hidden */ private _rebuild(): void;
  26291. /**
  26292. * Updates the WebGL Uniform Buffer on the GPU.
  26293. * If the `dynamic` flag is set to true, no cache comparison is done.
  26294. * Otherwise, the buffer will be updated only if the cache differs.
  26295. */
  26296. update(): void;
  26297. /**
  26298. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26299. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26300. * @param data Define the flattened data
  26301. * @param size Define the size of the data.
  26302. */
  26303. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26304. private _updateMatrix3x3ForUniform;
  26305. private _updateMatrix3x3ForEffect;
  26306. private _updateMatrix2x2ForEffect;
  26307. private _updateMatrix2x2ForUniform;
  26308. private _updateFloatForEffect;
  26309. private _updateFloatForUniform;
  26310. private _updateFloat2ForEffect;
  26311. private _updateFloat2ForUniform;
  26312. private _updateFloat3ForEffect;
  26313. private _updateFloat3ForUniform;
  26314. private _updateFloat4ForEffect;
  26315. private _updateFloat4ForUniform;
  26316. private _updateMatrixForEffect;
  26317. private _updateMatrixForUniform;
  26318. private _updateVector3ForEffect;
  26319. private _updateVector3ForUniform;
  26320. private _updateVector4ForEffect;
  26321. private _updateVector4ForUniform;
  26322. private _updateColor3ForEffect;
  26323. private _updateColor3ForUniform;
  26324. private _updateColor4ForEffect;
  26325. private _updateColor4ForUniform;
  26326. /**
  26327. * Sets a sampler uniform on the effect.
  26328. * @param name Define the name of the sampler.
  26329. * @param texture Define the texture to set in the sampler
  26330. */
  26331. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26332. /**
  26333. * Directly updates the value of the uniform in the cache AND on the GPU.
  26334. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26335. * @param data Define the flattened data
  26336. */
  26337. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26338. /**
  26339. * Binds this uniform buffer to an effect.
  26340. * @param effect Define the effect to bind the buffer to
  26341. * @param name Name of the uniform block in the shader.
  26342. */
  26343. bindToEffect(effect: Effect, name: string): void;
  26344. /**
  26345. * Disposes the uniform buffer.
  26346. */
  26347. dispose(): void;
  26348. }
  26349. }
  26350. declare module BABYLON {
  26351. /**
  26352. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26354. */
  26355. export class Analyser {
  26356. /**
  26357. * Gets or sets the smoothing
  26358. * @ignorenaming
  26359. */
  26360. SMOOTHING: number;
  26361. /**
  26362. * Gets or sets the FFT table size
  26363. * @ignorenaming
  26364. */
  26365. FFT_SIZE: number;
  26366. /**
  26367. * Gets or sets the bar graph amplitude
  26368. * @ignorenaming
  26369. */
  26370. BARGRAPHAMPLITUDE: number;
  26371. /**
  26372. * Gets or sets the position of the debug canvas
  26373. * @ignorenaming
  26374. */
  26375. DEBUGCANVASPOS: {
  26376. x: number;
  26377. y: number;
  26378. };
  26379. /**
  26380. * Gets or sets the debug canvas size
  26381. * @ignorenaming
  26382. */
  26383. DEBUGCANVASSIZE: {
  26384. width: number;
  26385. height: number;
  26386. };
  26387. private _byteFreqs;
  26388. private _byteTime;
  26389. private _floatFreqs;
  26390. private _webAudioAnalyser;
  26391. private _debugCanvas;
  26392. private _debugCanvasContext;
  26393. private _scene;
  26394. private _registerFunc;
  26395. private _audioEngine;
  26396. /**
  26397. * Creates a new analyser
  26398. * @param scene defines hosting scene
  26399. */
  26400. constructor(scene: Scene);
  26401. /**
  26402. * Get the number of data values you will have to play with for the visualization
  26403. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26404. * @returns a number
  26405. */
  26406. getFrequencyBinCount(): number;
  26407. /**
  26408. * Gets the current frequency data as a byte array
  26409. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26410. * @returns a Uint8Array
  26411. */
  26412. getByteFrequencyData(): Uint8Array;
  26413. /**
  26414. * Gets the current waveform as a byte array
  26415. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26416. * @returns a Uint8Array
  26417. */
  26418. getByteTimeDomainData(): Uint8Array;
  26419. /**
  26420. * Gets the current frequency data as a float array
  26421. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26422. * @returns a Float32Array
  26423. */
  26424. getFloatFrequencyData(): Float32Array;
  26425. /**
  26426. * Renders the debug canvas
  26427. */
  26428. drawDebugCanvas(): void;
  26429. /**
  26430. * Stops rendering the debug canvas and removes it
  26431. */
  26432. stopDebugCanvas(): void;
  26433. /**
  26434. * Connects two audio nodes
  26435. * @param inputAudioNode defines first node to connect
  26436. * @param outputAudioNode defines second node to connect
  26437. */
  26438. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26439. /**
  26440. * Releases all associated resources
  26441. */
  26442. dispose(): void;
  26443. }
  26444. }
  26445. declare module BABYLON {
  26446. /**
  26447. * This represents an audio engine and it is responsible
  26448. * to play, synchronize and analyse sounds throughout the application.
  26449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26450. */
  26451. export interface IAudioEngine extends IDisposable {
  26452. /**
  26453. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26454. */
  26455. readonly canUseWebAudio: boolean;
  26456. /**
  26457. * Gets the current AudioContext if available.
  26458. */
  26459. readonly audioContext: Nullable<AudioContext>;
  26460. /**
  26461. * The master gain node defines the global audio volume of your audio engine.
  26462. */
  26463. readonly masterGain: GainNode;
  26464. /**
  26465. * Gets whether or not mp3 are supported by your browser.
  26466. */
  26467. readonly isMP3supported: boolean;
  26468. /**
  26469. * Gets whether or not ogg are supported by your browser.
  26470. */
  26471. readonly isOGGsupported: boolean;
  26472. /**
  26473. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26474. * @ignoreNaming
  26475. */
  26476. WarnedWebAudioUnsupported: boolean;
  26477. /**
  26478. * Defines if the audio engine relies on a custom unlocked button.
  26479. * In this case, the embedded button will not be displayed.
  26480. */
  26481. useCustomUnlockedButton: boolean;
  26482. /**
  26483. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26484. */
  26485. readonly unlocked: boolean;
  26486. /**
  26487. * Event raised when audio has been unlocked on the browser.
  26488. */
  26489. onAudioUnlockedObservable: Observable<AudioEngine>;
  26490. /**
  26491. * Event raised when audio has been locked on the browser.
  26492. */
  26493. onAudioLockedObservable: Observable<AudioEngine>;
  26494. /**
  26495. * Flags the audio engine in Locked state.
  26496. * This happens due to new browser policies preventing audio to autoplay.
  26497. */
  26498. lock(): void;
  26499. /**
  26500. * Unlocks the audio engine once a user action has been done on the dom.
  26501. * This is helpful to resume play once browser policies have been satisfied.
  26502. */
  26503. unlock(): void;
  26504. }
  26505. /**
  26506. * This represents the default audio engine used in babylon.
  26507. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26509. */
  26510. export class AudioEngine implements IAudioEngine {
  26511. private _audioContext;
  26512. private _audioContextInitialized;
  26513. private _muteButton;
  26514. private _hostElement;
  26515. /**
  26516. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26517. */
  26518. canUseWebAudio: boolean;
  26519. /**
  26520. * The master gain node defines the global audio volume of your audio engine.
  26521. */
  26522. masterGain: GainNode;
  26523. /**
  26524. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26525. * @ignoreNaming
  26526. */
  26527. WarnedWebAudioUnsupported: boolean;
  26528. /**
  26529. * Gets whether or not mp3 are supported by your browser.
  26530. */
  26531. isMP3supported: boolean;
  26532. /**
  26533. * Gets whether or not ogg are supported by your browser.
  26534. */
  26535. isOGGsupported: boolean;
  26536. /**
  26537. * Gets whether audio has been unlocked on the device.
  26538. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26539. * a user interaction has happened.
  26540. */
  26541. unlocked: boolean;
  26542. /**
  26543. * Defines if the audio engine relies on a custom unlocked button.
  26544. * In this case, the embedded button will not be displayed.
  26545. */
  26546. useCustomUnlockedButton: boolean;
  26547. /**
  26548. * Event raised when audio has been unlocked on the browser.
  26549. */
  26550. onAudioUnlockedObservable: Observable<AudioEngine>;
  26551. /**
  26552. * Event raised when audio has been locked on the browser.
  26553. */
  26554. onAudioLockedObservable: Observable<AudioEngine>;
  26555. /**
  26556. * Gets the current AudioContext if available.
  26557. */
  26558. readonly audioContext: Nullable<AudioContext>;
  26559. private _connectedAnalyser;
  26560. /**
  26561. * Instantiates a new audio engine.
  26562. *
  26563. * There should be only one per page as some browsers restrict the number
  26564. * of audio contexts you can create.
  26565. * @param hostElement defines the host element where to display the mute icon if necessary
  26566. */
  26567. constructor(hostElement?: Nullable<HTMLElement>);
  26568. /**
  26569. * Flags the audio engine in Locked state.
  26570. * This happens due to new browser policies preventing audio to autoplay.
  26571. */
  26572. lock(): void;
  26573. /**
  26574. * Unlocks the audio engine once a user action has been done on the dom.
  26575. * This is helpful to resume play once browser policies have been satisfied.
  26576. */
  26577. unlock(): void;
  26578. private _resumeAudioContext;
  26579. private _initializeAudioContext;
  26580. private _tryToRun;
  26581. private _triggerRunningState;
  26582. private _triggerSuspendedState;
  26583. private _displayMuteButton;
  26584. private _moveButtonToTopLeft;
  26585. private _onResize;
  26586. private _hideMuteButton;
  26587. /**
  26588. * Destroy and release the resources associated with the audio ccontext.
  26589. */
  26590. dispose(): void;
  26591. /**
  26592. * Gets the global volume sets on the master gain.
  26593. * @returns the global volume if set or -1 otherwise
  26594. */
  26595. getGlobalVolume(): number;
  26596. /**
  26597. * Sets the global volume of your experience (sets on the master gain).
  26598. * @param newVolume Defines the new global volume of the application
  26599. */
  26600. setGlobalVolume(newVolume: number): void;
  26601. /**
  26602. * Connect the audio engine to an audio analyser allowing some amazing
  26603. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26605. * @param analyser The analyser to connect to the engine
  26606. */
  26607. connectToAnalyser(analyser: Analyser): void;
  26608. }
  26609. }
  26610. declare module BABYLON {
  26611. /**
  26612. * Interface used to present a loading screen while loading a scene
  26613. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26614. */
  26615. export interface ILoadingScreen {
  26616. /**
  26617. * Function called to display the loading screen
  26618. */
  26619. displayLoadingUI: () => void;
  26620. /**
  26621. * Function called to hide the loading screen
  26622. */
  26623. hideLoadingUI: () => void;
  26624. /**
  26625. * Gets or sets the color to use for the background
  26626. */
  26627. loadingUIBackgroundColor: string;
  26628. /**
  26629. * Gets or sets the text to display while loading
  26630. */
  26631. loadingUIText: string;
  26632. }
  26633. /**
  26634. * Class used for the default loading screen
  26635. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26636. */
  26637. export class DefaultLoadingScreen implements ILoadingScreen {
  26638. private _renderingCanvas;
  26639. private _loadingText;
  26640. private _loadingDivBackgroundColor;
  26641. private _loadingDiv;
  26642. private _loadingTextDiv;
  26643. /** Gets or sets the logo url to use for the default loading screen */
  26644. static DefaultLogoUrl: string;
  26645. /** Gets or sets the spinner url to use for the default loading screen */
  26646. static DefaultSpinnerUrl: string;
  26647. /**
  26648. * Creates a new default loading screen
  26649. * @param _renderingCanvas defines the canvas used to render the scene
  26650. * @param _loadingText defines the default text to display
  26651. * @param _loadingDivBackgroundColor defines the default background color
  26652. */
  26653. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26654. /**
  26655. * Function called to display the loading screen
  26656. */
  26657. displayLoadingUI(): void;
  26658. /**
  26659. * Function called to hide the loading screen
  26660. */
  26661. hideLoadingUI(): void;
  26662. /**
  26663. * Gets or sets the text to display while loading
  26664. */
  26665. loadingUIText: string;
  26666. /**
  26667. * Gets or sets the color to use for the background
  26668. */
  26669. loadingUIBackgroundColor: string;
  26670. private _resizeLoadingUI;
  26671. }
  26672. }
  26673. declare module BABYLON {
  26674. /** @hidden */
  26675. export class WebGLPipelineContext implements IPipelineContext {
  26676. engine: Engine;
  26677. program: Nullable<WebGLProgram>;
  26678. context?: WebGLRenderingContext;
  26679. vertexShader?: WebGLShader;
  26680. fragmentShader?: WebGLShader;
  26681. isParallelCompiled: boolean;
  26682. onCompiled?: () => void;
  26683. transformFeedback?: WebGLTransformFeedback | null;
  26684. readonly isAsync: boolean;
  26685. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26686. }
  26687. }
  26688. declare module BABYLON {
  26689. /** @hidden */
  26690. export class WebGLDataBuffer extends DataBuffer {
  26691. private _buffer;
  26692. constructor(resource: WebGLBuffer);
  26693. readonly underlyingResource: any;
  26694. }
  26695. }
  26696. declare module BABYLON {
  26697. /** @hidden */
  26698. export class WebGL2ShaderProcessor implements IShaderProcessor {
  26699. attributeProcessor(attribute: string): string;
  26700. varyingProcessor(varying: string, isFragment: boolean): string;
  26701. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  26702. }
  26703. }
  26704. declare module BABYLON {
  26705. /**
  26706. * Settings for finer control over video usage
  26707. */
  26708. export interface VideoTextureSettings {
  26709. /**
  26710. * Applies `autoplay` to video, if specified
  26711. */
  26712. autoPlay?: boolean;
  26713. /**
  26714. * Applies `loop` to video, if specified
  26715. */
  26716. loop?: boolean;
  26717. /**
  26718. * Automatically updates internal texture from video at every frame in the render loop
  26719. */
  26720. autoUpdateTexture: boolean;
  26721. /**
  26722. * Image src displayed during the video loading or until the user interacts with the video.
  26723. */
  26724. poster?: string;
  26725. }
  26726. /**
  26727. * If you want to display a video in your scene, this is the special texture for that.
  26728. * This special texture works similar to other textures, with the exception of a few parameters.
  26729. * @see https://doc.babylonjs.com/how_to/video_texture
  26730. */
  26731. export class VideoTexture extends Texture {
  26732. /**
  26733. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26734. */
  26735. readonly autoUpdateTexture: boolean;
  26736. /**
  26737. * The video instance used by the texture internally
  26738. */
  26739. readonly video: HTMLVideoElement;
  26740. private _onUserActionRequestedObservable;
  26741. /**
  26742. * Event triggerd when a dom action is required by the user to play the video.
  26743. * This happens due to recent changes in browser policies preventing video to auto start.
  26744. */
  26745. readonly onUserActionRequestedObservable: Observable<Texture>;
  26746. private _generateMipMaps;
  26747. private _engine;
  26748. private _stillImageCaptured;
  26749. private _displayingPosterTexture;
  26750. private _settings;
  26751. private _createInternalTextureOnEvent;
  26752. /**
  26753. * Creates a video texture.
  26754. * If you want to display a video in your scene, this is the special texture for that.
  26755. * This special texture works similar to other textures, with the exception of a few parameters.
  26756. * @see https://doc.babylonjs.com/how_to/video_texture
  26757. * @param name optional name, will detect from video source, if not defined
  26758. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26759. * @param scene is obviously the current scene.
  26760. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26761. * @param invertY is false by default but can be used to invert video on Y axis
  26762. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26763. * @param settings allows finer control over video usage
  26764. */
  26765. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26766. private _getName;
  26767. private _getVideo;
  26768. private _createInternalTexture;
  26769. private reset;
  26770. /**
  26771. * @hidden Internal method to initiate `update`.
  26772. */ private _rebuild(): void;
  26773. /**
  26774. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26775. */
  26776. update(): void;
  26777. /**
  26778. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26779. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26780. */
  26781. updateTexture(isVisible: boolean): void;
  26782. protected _updateInternalTexture: () => void;
  26783. /**
  26784. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26785. * @param url New url.
  26786. */
  26787. updateURL(url: string): void;
  26788. /**
  26789. * Dispose the texture and release its associated resources.
  26790. */
  26791. dispose(): void;
  26792. /**
  26793. * Creates a video texture straight from a stream.
  26794. * @param scene Define the scene the texture should be created in
  26795. * @param stream Define the stream the texture should be created from
  26796. * @returns The created video texture as a promise
  26797. */
  26798. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26799. /**
  26800. * Creates a video texture straight from your WebCam video feed.
  26801. * @param scene Define the scene the texture should be created in
  26802. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26803. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26804. * @returns The created video texture as a promise
  26805. */
  26806. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26807. minWidth: number;
  26808. maxWidth: number;
  26809. minHeight: number;
  26810. maxHeight: number;
  26811. deviceId: string;
  26812. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26813. /**
  26814. * Creates a video texture straight from your WebCam video feed.
  26815. * @param scene Define the scene the texture should be created in
  26816. * @param onReady Define a callback to triggered once the texture will be ready
  26817. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26818. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26819. */
  26820. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26821. minWidth: number;
  26822. maxWidth: number;
  26823. minHeight: number;
  26824. maxHeight: number;
  26825. deviceId: string;
  26826. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26827. }
  26828. }
  26829. declare module BABYLON {
  26830. /**
  26831. * Interface for attribute information associated with buffer instanciation
  26832. */
  26833. export class InstancingAttributeInfo {
  26834. /**
  26835. * Index/offset of the attribute in the vertex shader
  26836. */
  26837. index: number;
  26838. /**
  26839. * size of the attribute, 1, 2, 3 or 4
  26840. */
  26841. attributeSize: number;
  26842. /**
  26843. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26844. * default is FLOAT
  26845. */
  26846. attribyteType: number;
  26847. /**
  26848. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26849. */
  26850. normalized: boolean;
  26851. /**
  26852. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26853. */
  26854. offset: number;
  26855. /**
  26856. * Name of the GLSL attribute, for debugging purpose only
  26857. */
  26858. attributeName: string;
  26859. }
  26860. /**
  26861. * Define options used to create a depth texture
  26862. */
  26863. export class DepthTextureCreationOptions {
  26864. /** Specifies whether or not a stencil should be allocated in the texture */
  26865. generateStencil?: boolean;
  26866. /** Specifies whether or not bilinear filtering is enable on the texture */
  26867. bilinearFiltering?: boolean;
  26868. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26869. comparisonFunction?: number;
  26870. /** Specifies if the created texture is a cube texture */
  26871. isCube?: boolean;
  26872. }
  26873. /**
  26874. * Class used to describe the capabilities of the engine relatively to the current browser
  26875. */
  26876. export class EngineCapabilities {
  26877. /** Maximum textures units per fragment shader */
  26878. maxTexturesImageUnits: number;
  26879. /** Maximum texture units per vertex shader */
  26880. maxVertexTextureImageUnits: number;
  26881. /** Maximum textures units in the entire pipeline */
  26882. maxCombinedTexturesImageUnits: number;
  26883. /** Maximum texture size */
  26884. maxTextureSize: number;
  26885. /** Maximum cube texture size */
  26886. maxCubemapTextureSize: number;
  26887. /** Maximum render texture size */
  26888. maxRenderTextureSize: number;
  26889. /** Maximum number of vertex attributes */
  26890. maxVertexAttribs: number;
  26891. /** Maximum number of varyings */
  26892. maxVaryingVectors: number;
  26893. /** Maximum number of uniforms per vertex shader */
  26894. maxVertexUniformVectors: number;
  26895. /** Maximum number of uniforms per fragment shader */
  26896. maxFragmentUniformVectors: number;
  26897. /** Defines if standard derivates (dx/dy) are supported */
  26898. standardDerivatives: boolean;
  26899. /** Defines if s3tc texture compression is supported */
  26900. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26901. /** Defines if pvrtc texture compression is supported */
  26902. pvrtc: any;
  26903. /** Defines if etc1 texture compression is supported */
  26904. etc1: any;
  26905. /** Defines if etc2 texture compression is supported */
  26906. etc2: any;
  26907. /** Defines if astc texture compression is supported */
  26908. astc: any;
  26909. /** Defines if float textures are supported */
  26910. textureFloat: boolean;
  26911. /** Defines if vertex array objects are supported */
  26912. vertexArrayObject: boolean;
  26913. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26914. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26915. /** Gets the maximum level of anisotropy supported */
  26916. maxAnisotropy: number;
  26917. /** Defines if instancing is supported */
  26918. instancedArrays: boolean;
  26919. /** Defines if 32 bits indices are supported */
  26920. uintIndices: boolean;
  26921. /** Defines if high precision shaders are supported */
  26922. highPrecisionShaderSupported: boolean;
  26923. /** Defines if depth reading in the fragment shader is supported */
  26924. fragmentDepthSupported: boolean;
  26925. /** Defines if float texture linear filtering is supported*/
  26926. textureFloatLinearFiltering: boolean;
  26927. /** Defines if rendering to float textures is supported */
  26928. textureFloatRender: boolean;
  26929. /** Defines if half float textures are supported*/
  26930. textureHalfFloat: boolean;
  26931. /** Defines if half float texture linear filtering is supported*/
  26932. textureHalfFloatLinearFiltering: boolean;
  26933. /** Defines if rendering to half float textures is supported */
  26934. textureHalfFloatRender: boolean;
  26935. /** Defines if textureLOD shader command is supported */
  26936. textureLOD: boolean;
  26937. /** Defines if draw buffers extension is supported */
  26938. drawBuffersExtension: boolean;
  26939. /** Defines if depth textures are supported */
  26940. depthTextureExtension: boolean;
  26941. /** Defines if float color buffer are supported */
  26942. colorBufferFloat: boolean;
  26943. /** Gets disjoint timer query extension (null if not supported) */
  26944. timerQuery: EXT_disjoint_timer_query;
  26945. /** Defines if timestamp can be used with timer query */
  26946. canUseTimestampForTimerQuery: boolean;
  26947. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26948. multiview: any;
  26949. /** Function used to let the system compiles shaders in background */
  26950. parallelShaderCompile: {
  26951. COMPLETION_STATUS_KHR: number;
  26952. };
  26953. }
  26954. /** Interface defining initialization parameters for Engine class */
  26955. export interface EngineOptions extends WebGLContextAttributes {
  26956. /**
  26957. * Defines if the engine should no exceed a specified device ratio
  26958. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26959. */
  26960. limitDeviceRatio?: number;
  26961. /**
  26962. * Defines if webvr should be enabled automatically
  26963. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26964. */
  26965. autoEnableWebVR?: boolean;
  26966. /**
  26967. * Defines if webgl2 should be turned off even if supported
  26968. * @see http://doc.babylonjs.com/features/webgl2
  26969. */
  26970. disableWebGL2Support?: boolean;
  26971. /**
  26972. * Defines if webaudio should be initialized as well
  26973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26974. */
  26975. audioEngine?: boolean;
  26976. /**
  26977. * Defines if animations should run using a deterministic lock step
  26978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26979. */
  26980. deterministicLockstep?: boolean;
  26981. /** Defines the maximum steps to use with deterministic lock step mode */
  26982. lockstepMaxSteps?: number;
  26983. /**
  26984. * Defines that engine should ignore context lost events
  26985. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26986. */
  26987. doNotHandleContextLost?: boolean;
  26988. /**
  26989. * Defines that engine should ignore modifying touch action attribute and style
  26990. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26991. */
  26992. doNotHandleTouchAction?: boolean;
  26993. /**
  26994. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26995. */
  26996. useHighPrecisionFloats?: boolean;
  26997. }
  26998. /**
  26999. * Defines the interface used by display changed events
  27000. */
  27001. export interface IDisplayChangedEventArgs {
  27002. /** Gets the vrDisplay object (if any) */
  27003. vrDisplay: Nullable<any>;
  27004. /** Gets a boolean indicating if webVR is supported */
  27005. vrSupported: boolean;
  27006. }
  27007. /**
  27008. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27009. */
  27010. export class Engine {
  27011. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27012. static ExceptionList: ({
  27013. key: string;
  27014. capture: string;
  27015. captureConstraint: number;
  27016. targets: string[];
  27017. } | {
  27018. key: string;
  27019. capture: null;
  27020. captureConstraint: null;
  27021. targets: string[];
  27022. })[];
  27023. /** Gets the list of created engines */
  27024. static readonly Instances: Engine[];
  27025. /**
  27026. * Gets the latest created engine
  27027. */
  27028. static readonly LastCreatedEngine: Nullable<Engine>;
  27029. /**
  27030. * Gets the latest created scene
  27031. */
  27032. static readonly LastCreatedScene: Nullable<Scene>;
  27033. /**
  27034. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27035. * @param flag defines which part of the materials must be marked as dirty
  27036. * @param predicate defines a predicate used to filter which materials should be affected
  27037. */
  27038. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27039. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  27040. /** Defines that alpha blending is disabled */
  27041. static readonly ALPHA_DISABLE: number;
  27042. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27043. static readonly ALPHA_ADD: number;
  27044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27045. static readonly ALPHA_COMBINE: number;
  27046. /** Defines that alpha blending to DEST - SRC * DEST */
  27047. static readonly ALPHA_SUBTRACT: number;
  27048. /** Defines that alpha blending to SRC * DEST */
  27049. static readonly ALPHA_MULTIPLY: number;
  27050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27051. static readonly ALPHA_MAXIMIZED: number;
  27052. /** Defines that alpha blending to SRC + DEST */
  27053. static readonly ALPHA_ONEONE: number;
  27054. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27055. static readonly ALPHA_PREMULTIPLIED: number;
  27056. /**
  27057. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27058. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27059. */
  27060. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27061. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27062. static readonly ALPHA_INTERPOLATE: number;
  27063. /**
  27064. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27065. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27066. */
  27067. static readonly ALPHA_SCREENMODE: number;
  27068. /** Defines that the ressource is not delayed*/
  27069. static readonly DELAYLOADSTATE_NONE: number;
  27070. /** Defines that the ressource was successfully delay loaded */
  27071. static readonly DELAYLOADSTATE_LOADED: number;
  27072. /** Defines that the ressource is currently delay loading */
  27073. static readonly DELAYLOADSTATE_LOADING: number;
  27074. /** Defines that the ressource is delayed and has not started loading */
  27075. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27077. static readonly NEVER: number;
  27078. /** 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 */
  27079. static readonly ALWAYS: number;
  27080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27081. static readonly LESS: number;
  27082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27083. static readonly EQUAL: number;
  27084. /** 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 */
  27085. static readonly LEQUAL: number;
  27086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27087. static readonly GREATER: number;
  27088. /** 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 */
  27089. static readonly GEQUAL: number;
  27090. /** 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 */
  27091. static readonly NOTEQUAL: number;
  27092. /** Passed to stencilOperation to specify that stencil value must be kept */
  27093. static readonly KEEP: number;
  27094. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27095. static readonly REPLACE: number;
  27096. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27097. static readonly INCR: number;
  27098. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27099. static readonly DECR: number;
  27100. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27101. static readonly INVERT: number;
  27102. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27103. static readonly INCR_WRAP: number;
  27104. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27105. static readonly DECR_WRAP: number;
  27106. /** Texture is not repeating outside of 0..1 UVs */
  27107. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27108. /** Texture is repeating outside of 0..1 UVs */
  27109. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27110. /** Texture is repeating and mirrored */
  27111. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27112. /** ALPHA */
  27113. static readonly TEXTUREFORMAT_ALPHA: number;
  27114. /** LUMINANCE */
  27115. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27116. /** LUMINANCE_ALPHA */
  27117. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27118. /** RGB */
  27119. static readonly TEXTUREFORMAT_RGB: number;
  27120. /** RGBA */
  27121. static readonly TEXTUREFORMAT_RGBA: number;
  27122. /** RED */
  27123. static readonly TEXTUREFORMAT_RED: number;
  27124. /** RED (2nd reference) */
  27125. static readonly TEXTUREFORMAT_R: number;
  27126. /** RG */
  27127. static readonly TEXTUREFORMAT_RG: number;
  27128. /** RED_INTEGER */
  27129. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27130. /** RED_INTEGER (2nd reference) */
  27131. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27132. /** RG_INTEGER */
  27133. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27134. /** RGB_INTEGER */
  27135. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27136. /** RGBA_INTEGER */
  27137. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27138. /** UNSIGNED_BYTE */
  27139. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27140. /** UNSIGNED_BYTE (2nd reference) */
  27141. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27142. /** FLOAT */
  27143. static readonly TEXTURETYPE_FLOAT: number;
  27144. /** HALF_FLOAT */
  27145. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27146. /** BYTE */
  27147. static readonly TEXTURETYPE_BYTE: number;
  27148. /** SHORT */
  27149. static readonly TEXTURETYPE_SHORT: number;
  27150. /** UNSIGNED_SHORT */
  27151. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27152. /** INT */
  27153. static readonly TEXTURETYPE_INT: number;
  27154. /** UNSIGNED_INT */
  27155. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27156. /** UNSIGNED_SHORT_4_4_4_4 */
  27157. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27158. /** UNSIGNED_SHORT_5_5_5_1 */
  27159. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27160. /** UNSIGNED_SHORT_5_6_5 */
  27161. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27162. /** UNSIGNED_INT_2_10_10_10_REV */
  27163. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27164. /** UNSIGNED_INT_24_8 */
  27165. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27166. /** UNSIGNED_INT_10F_11F_11F_REV */
  27167. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27168. /** UNSIGNED_INT_5_9_9_9_REV */
  27169. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27170. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27171. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27172. /** nearest is mag = nearest and min = nearest and mip = linear */
  27173. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27175. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27176. /** Trilinear is mag = linear and min = linear and mip = linear */
  27177. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27178. /** nearest is mag = nearest and min = nearest and mip = linear */
  27179. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27181. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27182. /** Trilinear is mag = linear and min = linear and mip = linear */
  27183. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27184. /** mag = nearest and min = nearest and mip = nearest */
  27185. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27186. /** mag = nearest and min = linear and mip = nearest */
  27187. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27188. /** mag = nearest and min = linear and mip = linear */
  27189. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27190. /** mag = nearest and min = linear and mip = none */
  27191. static readonly TEXTURE_NEAREST_LINEAR: number;
  27192. /** mag = nearest and min = nearest and mip = none */
  27193. static readonly TEXTURE_NEAREST_NEAREST: number;
  27194. /** mag = linear and min = nearest and mip = nearest */
  27195. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27196. /** mag = linear and min = nearest and mip = linear */
  27197. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27198. /** mag = linear and min = linear and mip = none */
  27199. static readonly TEXTURE_LINEAR_LINEAR: number;
  27200. /** mag = linear and min = nearest and mip = none */
  27201. static readonly TEXTURE_LINEAR_NEAREST: number;
  27202. /** Explicit coordinates mode */
  27203. static readonly TEXTURE_EXPLICIT_MODE: number;
  27204. /** Spherical coordinates mode */
  27205. static readonly TEXTURE_SPHERICAL_MODE: number;
  27206. /** Planar coordinates mode */
  27207. static readonly TEXTURE_PLANAR_MODE: number;
  27208. /** Cubic coordinates mode */
  27209. static readonly TEXTURE_CUBIC_MODE: number;
  27210. /** Projection coordinates mode */
  27211. static readonly TEXTURE_PROJECTION_MODE: number;
  27212. /** Skybox coordinates mode */
  27213. static readonly TEXTURE_SKYBOX_MODE: number;
  27214. /** Inverse Cubic coordinates mode */
  27215. static readonly TEXTURE_INVCUBIC_MODE: number;
  27216. /** Equirectangular coordinates mode */
  27217. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27218. /** Equirectangular Fixed coordinates mode */
  27219. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27220. /** Equirectangular Fixed Mirrored coordinates mode */
  27221. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27222. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27223. static readonly SCALEMODE_FLOOR: number;
  27224. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27225. static readonly SCALEMODE_NEAREST: number;
  27226. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27227. static readonly SCALEMODE_CEILING: number;
  27228. /**
  27229. * Returns the current npm package of the sdk
  27230. */
  27231. static readonly NpmPackage: string;
  27232. /**
  27233. * Returns the current version of the framework
  27234. */
  27235. static readonly Version: string;
  27236. /**
  27237. * Returns a string describing the current engine
  27238. */
  27239. readonly description: string;
  27240. /**
  27241. * Gets or sets the epsilon value used by collision engine
  27242. */
  27243. static CollisionsEpsilon: number;
  27244. /**
  27245. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27246. */
  27247. static ShadersRepository: string;
  27248. /**
  27249. * Method called to create the default loading screen.
  27250. * This can be overriden in your own app.
  27251. * @param canvas The rendering canvas element
  27252. * @returns The loading screen
  27253. */
  27254. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27255. /**
  27256. * Method called to create the default rescale post process on each engine.
  27257. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27258. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  27259. /**
  27260. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27261. */
  27262. forcePOTTextures: boolean;
  27263. /**
  27264. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27265. */
  27266. isFullscreen: boolean;
  27267. /**
  27268. * Gets a boolean indicating if the pointer is currently locked
  27269. */
  27270. isPointerLock: boolean;
  27271. /**
  27272. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27273. */
  27274. cullBackFaces: boolean;
  27275. /**
  27276. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27277. */
  27278. renderEvenInBackground: boolean;
  27279. /**
  27280. * Gets or sets a boolean indicating that cache can be kept between frames
  27281. */
  27282. preventCacheWipeBetweenFrames: boolean;
  27283. /**
  27284. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27285. **/
  27286. enableOfflineSupport: boolean;
  27287. /**
  27288. * 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)
  27289. **/
  27290. disableManifestCheck: boolean;
  27291. /**
  27292. * Gets the list of created scenes
  27293. */
  27294. scenes: Scene[];
  27295. /**
  27296. * Event raised when a new scene is created
  27297. */
  27298. onNewSceneAddedObservable: Observable<Scene>;
  27299. /**
  27300. * Gets the list of created postprocesses
  27301. */
  27302. postProcesses: PostProcess[];
  27303. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27304. validateShaderPrograms: boolean;
  27305. /**
  27306. * Observable event triggered each time the rendering canvas is resized
  27307. */
  27308. onResizeObservable: Observable<Engine>;
  27309. /**
  27310. * Observable event triggered each time the canvas loses focus
  27311. */
  27312. onCanvasBlurObservable: Observable<Engine>;
  27313. /**
  27314. * Observable event triggered each time the canvas gains focus
  27315. */
  27316. onCanvasFocusObservable: Observable<Engine>;
  27317. /**
  27318. * Observable event triggered each time the canvas receives pointerout event
  27319. */
  27320. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27321. /**
  27322. * Observable event triggered before each texture is initialized
  27323. */
  27324. onBeforeTextureInitObservable: Observable<Texture>;
  27325. /**
  27326. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27327. */
  27328. disableUniformBuffers: boolean;
  27329. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  27330. /**
  27331. * Gets a boolean indicating that the engine supports uniform buffers
  27332. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27333. */
  27334. readonly supportsUniformBuffers: boolean;
  27335. /**
  27336. * Observable raised when the engine begins a new frame
  27337. */
  27338. onBeginFrameObservable: Observable<Engine>;
  27339. /**
  27340. * If set, will be used to request the next animation frame for the render loop
  27341. */
  27342. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27343. /**
  27344. * Observable raised when the engine ends the current frame
  27345. */
  27346. onEndFrameObservable: Observable<Engine>;
  27347. /**
  27348. * Observable raised when the engine is about to compile a shader
  27349. */
  27350. onBeforeShaderCompilationObservable: Observable<Engine>;
  27351. /**
  27352. * Observable raised when the engine has jsut compiled a shader
  27353. */
  27354. onAfterShaderCompilationObservable: Observable<Engine>;
  27355. /** @hidden */ private _gl: WebGLRenderingContext;
  27356. private _renderingCanvas;
  27357. private _windowIsBackground;
  27358. private _webGLVersion;
  27359. protected _highPrecisionShadersAllowed: boolean;
  27360. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27361. /**
  27362. * Gets a boolean indicating that only power of 2 textures are supported
  27363. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27364. */
  27365. readonly needPOTTextures: boolean;
  27366. /** @hidden */ private _badOS: boolean;
  27367. /** @hidden */ private _badDesktopOS: boolean;
  27368. /**
  27369. * Gets the audio engine
  27370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27371. * @ignorenaming
  27372. */
  27373. static audioEngine: IAudioEngine;
  27374. /**
  27375. * Default AudioEngine factory responsible of creating the Audio Engine.
  27376. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27377. */
  27378. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27379. /**
  27380. * Default offline support factory responsible of creating a tool used to store data locally.
  27381. * By default, this will create a Database object if the workload has been embedded.
  27382. */
  27383. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27384. private _onFocus;
  27385. private _onBlur;
  27386. private _onCanvasPointerOut;
  27387. private _onCanvasBlur;
  27388. private _onCanvasFocus;
  27389. private _onFullscreenChange;
  27390. private _onPointerLockChange;
  27391. private _hardwareScalingLevel;
  27392. /** @hidden */ private _caps: EngineCapabilities;
  27393. private _pointerLockRequested;
  27394. private _isStencilEnable;
  27395. private _colorWrite;
  27396. private _loadingScreen;
  27397. /** @hidden */ private _drawCalls: PerfCounter;
  27398. private _glVersion;
  27399. private _glRenderer;
  27400. private _glVendor;
  27401. private _videoTextureSupported;
  27402. private _renderingQueueLaunched;
  27403. private _activeRenderLoops;
  27404. private _deterministicLockstep;
  27405. private _lockstepMaxSteps;
  27406. /**
  27407. * Observable signaled when a context lost event is raised
  27408. */
  27409. onContextLostObservable: Observable<Engine>;
  27410. /**
  27411. * Observable signaled when a context restored event is raised
  27412. */
  27413. onContextRestoredObservable: Observable<Engine>;
  27414. private _onContextLost;
  27415. private _onContextRestored;
  27416. private _contextWasLost;
  27417. /** @hidden */ private _doNotHandleContextLost: boolean;
  27418. /**
  27419. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27421. */
  27422. doNotHandleContextLost: boolean;
  27423. private _performanceMonitor;
  27424. private _fps;
  27425. private _deltaTime;
  27426. /**
  27427. * Turn this value on if you want to pause FPS computation when in background
  27428. */
  27429. disablePerformanceMonitorInBackground: boolean;
  27430. /**
  27431. * Gets the performance monitor attached to this engine
  27432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27433. */
  27434. readonly performanceMonitor: PerformanceMonitor;
  27435. /**
  27436. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27437. */
  27438. disableVertexArrayObjects: boolean;
  27439. /** @hidden */
  27440. protected _depthCullingState: _DepthCullingState;
  27441. /** @hidden */
  27442. protected _stencilState: _StencilState;
  27443. /** @hidden */
  27444. protected _alphaState: _AlphaState;
  27445. /** @hidden */
  27446. protected _alphaMode: number;
  27447. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  27448. /** @hidden */
  27449. protected _activeChannel: number;
  27450. private _currentTextureChannel;
  27451. /** @hidden */
  27452. protected _boundTexturesCache: {
  27453. [key: string]: Nullable<InternalTexture>;
  27454. };
  27455. /** @hidden */
  27456. protected _currentEffect: Nullable<Effect>;
  27457. /** @hidden */
  27458. protected _currentProgram: Nullable<WebGLProgram>;
  27459. private _compiledEffects;
  27460. private _vertexAttribArraysEnabled;
  27461. /** @hidden */
  27462. protected _cachedViewport: Nullable<Viewport>;
  27463. private _cachedVertexArrayObject;
  27464. /** @hidden */
  27465. protected _cachedVertexBuffers: any;
  27466. /** @hidden */
  27467. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27468. /** @hidden */
  27469. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27470. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  27471. private _uintIndicesCurrentlySet;
  27472. private _currentBoundBuffer;
  27473. /** @hidden */
  27474. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27475. private _currentBufferPointers;
  27476. private _currentInstanceLocations;
  27477. private _currentInstanceBuffers;
  27478. private _textureUnits;
  27479. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27480. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27481. private _rescalePostProcess;
  27482. private _dummyFramebuffer;
  27483. private _externalData;
  27484. /** @hidden */ private _bindedRenderFunction: any;
  27485. private _vaoRecordInProgress;
  27486. private _mustWipeVertexAttributes;
  27487. private _emptyTexture;
  27488. private _emptyCubeTexture;
  27489. private _emptyTexture3D;
  27490. /** @hidden */ private _frameHandler: number;
  27491. private _nextFreeTextureSlots;
  27492. private _maxSimultaneousTextures;
  27493. private _activeRequests;
  27494. private _texturesSupported;
  27495. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  27496. /**
  27497. * Gets the list of texture formats supported
  27498. */
  27499. readonly texturesSupported: Array<string>;
  27500. /**
  27501. * Gets the list of texture formats in use
  27502. */
  27503. readonly textureFormatInUse: Nullable<string>;
  27504. /**
  27505. * Gets the current viewport
  27506. */
  27507. readonly currentViewport: Nullable<Viewport>;
  27508. /**
  27509. * Gets the default empty texture
  27510. */
  27511. readonly emptyTexture: InternalTexture;
  27512. /**
  27513. * Gets the default empty 3D texture
  27514. */
  27515. readonly emptyTexture3D: InternalTexture;
  27516. /**
  27517. * Gets the default empty cube texture
  27518. */
  27519. readonly emptyCubeTexture: InternalTexture;
  27520. /**
  27521. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27522. */
  27523. readonly premultipliedAlpha: boolean;
  27524. /**
  27525. * Creates a new engine
  27526. * @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
  27527. * @param antialias defines enable antialiasing (default: false)
  27528. * @param options defines further options to be sent to the getContext() function
  27529. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27530. */
  27531. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27532. /**
  27533. * Initializes a webVR display and starts listening to display change events
  27534. * The onVRDisplayChangedObservable will be notified upon these changes
  27535. * @returns The onVRDisplayChangedObservable
  27536. */
  27537. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27538. /** @hidden */ private _prepareVRComponent(): void;
  27539. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27540. /** @hidden */ private _submitVRFrame(): void;
  27541. /**
  27542. * Call this function to leave webVR mode
  27543. * Will do nothing if webVR is not supported or if there is no webVR device
  27544. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27545. */
  27546. disableVR(): void;
  27547. /**
  27548. * Gets a boolean indicating that the system is in VR mode and is presenting
  27549. * @returns true if VR mode is engaged
  27550. */
  27551. isVRPresenting(): boolean;
  27552. /** @hidden */ private _requestVRFrame(): void;
  27553. private _disableTouchAction;
  27554. private _rebuildInternalTextures;
  27555. private _rebuildEffects;
  27556. /**
  27557. * Gets a boolean indicating if all created effects are ready
  27558. * @returns true if all effects are ready
  27559. */
  27560. areAllEffectsReady(): boolean;
  27561. private _rebuildBuffers;
  27562. private _initGLContext;
  27563. /**
  27564. * Gets version of the current webGL context
  27565. */
  27566. readonly webGLVersion: number;
  27567. /**
  27568. * Gets a string idenfifying the name of the class
  27569. * @returns "Engine" string
  27570. */
  27571. getClassName(): string;
  27572. /**
  27573. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27574. */
  27575. readonly isStencilEnable: boolean;
  27576. /** @hidden */ private _prepareWorkingCanvas(): void;
  27577. /**
  27578. * Reset the texture cache to empty state
  27579. */
  27580. resetTextureCache(): void;
  27581. /**
  27582. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27583. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27584. * @returns true if engine is in deterministic lock step mode
  27585. */
  27586. isDeterministicLockStep(): boolean;
  27587. /**
  27588. * Gets the max steps when engine is running in deterministic lock step
  27589. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27590. * @returns the max steps
  27591. */
  27592. getLockstepMaxSteps(): number;
  27593. /**
  27594. * Gets an object containing information about the current webGL context
  27595. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27596. */
  27597. getGlInfo(): {
  27598. vendor: string;
  27599. renderer: string;
  27600. version: string;
  27601. };
  27602. /**
  27603. * Gets current aspect ratio
  27604. * @param camera defines the camera to use to get the aspect ratio
  27605. * @param useScreen defines if screen size must be used (or the current render target if any)
  27606. * @returns a number defining the aspect ratio
  27607. */
  27608. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27609. /**
  27610. * Gets current screen aspect ratio
  27611. * @returns a number defining the aspect ratio
  27612. */
  27613. getScreenAspectRatio(): number;
  27614. /**
  27615. * Gets the current render width
  27616. * @param useScreen defines if screen size must be used (or the current render target if any)
  27617. * @returns a number defining the current render width
  27618. */
  27619. getRenderWidth(useScreen?: boolean): number;
  27620. /**
  27621. * Gets the current render height
  27622. * @param useScreen defines if screen size must be used (or the current render target if any)
  27623. * @returns a number defining the current render height
  27624. */
  27625. getRenderHeight(useScreen?: boolean): number;
  27626. /**
  27627. * Gets the HTML canvas attached with the current webGL context
  27628. * @returns a HTML canvas
  27629. */
  27630. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27631. /**
  27632. * Gets the client rect of the HTML canvas attached with the current webGL context
  27633. * @returns a client rectanglee
  27634. */
  27635. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27636. /**
  27637. * Defines the hardware scaling level.
  27638. * By default the hardware scaling level is computed from the window device ratio.
  27639. * 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.
  27640. * @param level defines the level to use
  27641. */
  27642. setHardwareScalingLevel(level: number): void;
  27643. /**
  27644. * Gets the current hardware scaling level.
  27645. * By default the hardware scaling level is computed from the window device ratio.
  27646. * 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.
  27647. * @returns a number indicating the current hardware scaling level
  27648. */
  27649. getHardwareScalingLevel(): number;
  27650. /**
  27651. * Gets the list of loaded textures
  27652. * @returns an array containing all loaded textures
  27653. */
  27654. getLoadedTexturesCache(): InternalTexture[];
  27655. /**
  27656. * Gets the object containing all engine capabilities
  27657. * @returns the EngineCapabilities object
  27658. */
  27659. getCaps(): EngineCapabilities;
  27660. /**
  27661. * Gets the current depth function
  27662. * @returns a number defining the depth function
  27663. */
  27664. getDepthFunction(): Nullable<number>;
  27665. /**
  27666. * Sets the current depth function
  27667. * @param depthFunc defines the function to use
  27668. */
  27669. setDepthFunction(depthFunc: number): void;
  27670. /**
  27671. * Sets the current depth function to GREATER
  27672. */
  27673. setDepthFunctionToGreater(): void;
  27674. /**
  27675. * Sets the current depth function to GEQUAL
  27676. */
  27677. setDepthFunctionToGreaterOrEqual(): void;
  27678. /**
  27679. * Sets the current depth function to LESS
  27680. */
  27681. setDepthFunctionToLess(): void;
  27682. private _cachedStencilBuffer;
  27683. private _cachedStencilFunction;
  27684. private _cachedStencilMask;
  27685. private _cachedStencilOperationPass;
  27686. private _cachedStencilOperationFail;
  27687. private _cachedStencilOperationDepthFail;
  27688. private _cachedStencilReference;
  27689. /**
  27690. * Caches the the state of the stencil buffer
  27691. */
  27692. cacheStencilState(): void;
  27693. /**
  27694. * Restores the state of the stencil buffer
  27695. */
  27696. restoreStencilState(): void;
  27697. /**
  27698. * Sets the current depth function to LEQUAL
  27699. */
  27700. setDepthFunctionToLessOrEqual(): void;
  27701. /**
  27702. * Gets a boolean indicating if stencil buffer is enabled
  27703. * @returns the current stencil buffer state
  27704. */
  27705. getStencilBuffer(): boolean;
  27706. /**
  27707. * Enable or disable the stencil buffer
  27708. * @param enable defines if the stencil buffer must be enabled or disabled
  27709. */
  27710. setStencilBuffer(enable: boolean): void;
  27711. /**
  27712. * Gets the current stencil mask
  27713. * @returns a number defining the new stencil mask to use
  27714. */
  27715. getStencilMask(): number;
  27716. /**
  27717. * Sets the current stencil mask
  27718. * @param mask defines the new stencil mask to use
  27719. */
  27720. setStencilMask(mask: number): void;
  27721. /**
  27722. * Gets the current stencil function
  27723. * @returns a number defining the stencil function to use
  27724. */
  27725. getStencilFunction(): number;
  27726. /**
  27727. * Gets the current stencil reference value
  27728. * @returns a number defining the stencil reference value to use
  27729. */
  27730. getStencilFunctionReference(): number;
  27731. /**
  27732. * Gets the current stencil mask
  27733. * @returns a number defining the stencil mask to use
  27734. */
  27735. getStencilFunctionMask(): number;
  27736. /**
  27737. * Sets the current stencil function
  27738. * @param stencilFunc defines the new stencil function to use
  27739. */
  27740. setStencilFunction(stencilFunc: number): void;
  27741. /**
  27742. * Sets the current stencil reference
  27743. * @param reference defines the new stencil reference to use
  27744. */
  27745. setStencilFunctionReference(reference: number): void;
  27746. /**
  27747. * Sets the current stencil mask
  27748. * @param mask defines the new stencil mask to use
  27749. */
  27750. setStencilFunctionMask(mask: number): void;
  27751. /**
  27752. * Gets the current stencil operation when stencil fails
  27753. * @returns a number defining stencil operation to use when stencil fails
  27754. */
  27755. getStencilOperationFail(): number;
  27756. /**
  27757. * Gets the current stencil operation when depth fails
  27758. * @returns a number defining stencil operation to use when depth fails
  27759. */
  27760. getStencilOperationDepthFail(): number;
  27761. /**
  27762. * Gets the current stencil operation when stencil passes
  27763. * @returns a number defining stencil operation to use when stencil passes
  27764. */
  27765. getStencilOperationPass(): number;
  27766. /**
  27767. * Sets the stencil operation to use when stencil fails
  27768. * @param operation defines the stencil operation to use when stencil fails
  27769. */
  27770. setStencilOperationFail(operation: number): void;
  27771. /**
  27772. * Sets the stencil operation to use when depth fails
  27773. * @param operation defines the stencil operation to use when depth fails
  27774. */
  27775. setStencilOperationDepthFail(operation: number): void;
  27776. /**
  27777. * Sets the stencil operation to use when stencil passes
  27778. * @param operation defines the stencil operation to use when stencil passes
  27779. */
  27780. setStencilOperationPass(operation: number): void;
  27781. /**
  27782. * Sets a boolean indicating if the dithering state is enabled or disabled
  27783. * @param value defines the dithering state
  27784. */
  27785. setDitheringState(value: boolean): void;
  27786. /**
  27787. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27788. * @param value defines the rasterizer state
  27789. */
  27790. setRasterizerState(value: boolean): void;
  27791. /**
  27792. * stop executing a render loop function and remove it from the execution array
  27793. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27794. */
  27795. stopRenderLoop(renderFunction?: () => void): void;
  27796. /** @hidden */ private _renderLoop(): void;
  27797. /**
  27798. * Register and execute a render loop. The engine can have more than one render function
  27799. * @param renderFunction defines the function to continuously execute
  27800. */
  27801. runRenderLoop(renderFunction: () => void): void;
  27802. /**
  27803. * Toggle full screen mode
  27804. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27805. */
  27806. switchFullscreen(requestPointerLock: boolean): void;
  27807. /**
  27808. * Enters full screen mode
  27809. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27810. */
  27811. enterFullscreen(requestPointerLock: boolean): void;
  27812. /**
  27813. * Exits full screen mode
  27814. */
  27815. exitFullscreen(): void;
  27816. /**
  27817. * Enters Pointerlock mode
  27818. */
  27819. enterPointerlock(): void;
  27820. /**
  27821. * Exits Pointerlock mode
  27822. */
  27823. exitPointerlock(): void;
  27824. /**
  27825. * Clear the current render buffer or the current render target (if any is set up)
  27826. * @param color defines the color to use
  27827. * @param backBuffer defines if the back buffer must be cleared
  27828. * @param depth defines if the depth buffer must be cleared
  27829. * @param stencil defines if the stencil buffer must be cleared
  27830. */
  27831. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27832. /**
  27833. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27834. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27835. * @param y defines the y-coordinate of the corner of the clear rectangle
  27836. * @param width defines the width of the clear rectangle
  27837. * @param height defines the height of the clear rectangle
  27838. * @param clearColor defines the clear color
  27839. */
  27840. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27841. /**
  27842. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27843. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27844. * @param y defines the y-coordinate of the corner of the clear rectangle
  27845. * @param width defines the width of the clear rectangle
  27846. * @param height defines the height of the clear rectangle
  27847. */
  27848. enableScissor(x: number, y: number, width: number, height: number): void;
  27849. /**
  27850. * Disable previously set scissor test rectangle
  27851. */
  27852. disableScissor(): void;
  27853. private _viewportCached;
  27854. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  27855. /**
  27856. * Set the WebGL's viewport
  27857. * @param viewport defines the viewport element to be used
  27858. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27859. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27860. */
  27861. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27862. /**
  27863. * Directly set the WebGL Viewport
  27864. * @param x defines the x coordinate of the viewport (in screen space)
  27865. * @param y defines the y coordinate of the viewport (in screen space)
  27866. * @param width defines the width of the viewport (in screen space)
  27867. * @param height defines the height of the viewport (in screen space)
  27868. * @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
  27869. */
  27870. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27871. /**
  27872. * Begin a new frame
  27873. */
  27874. beginFrame(): void;
  27875. /**
  27876. * Enf the current frame
  27877. */
  27878. endFrame(): void;
  27879. /**
  27880. * Resize the view according to the canvas' size
  27881. */
  27882. resize(): void;
  27883. /**
  27884. * Force a specific size of the canvas
  27885. * @param width defines the new canvas' width
  27886. * @param height defines the new canvas' height
  27887. */
  27888. setSize(width: number, height: number): void;
  27889. /**
  27890. * Binds the frame buffer to the specified texture.
  27891. * @param texture The texture to render to or null for the default canvas
  27892. * @param faceIndex The face of the texture to render to in case of cube texture
  27893. * @param requiredWidth The width of the target to render to
  27894. * @param requiredHeight The height of the target to render to
  27895. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27896. * @param depthStencilTexture The depth stencil texture to use to render
  27897. * @param lodLevel defines le lod level to bind to the frame buffer
  27898. */
  27899. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27900. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27901. /**
  27902. * Unbind the current render target texture from the webGL context
  27903. * @param texture defines the render target texture to unbind
  27904. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27905. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27906. */
  27907. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27908. /**
  27909. * Force the mipmap generation for the given render target texture
  27910. * @param texture defines the render target texture to use
  27911. */
  27912. generateMipMapsForCubemap(texture: InternalTexture): void;
  27913. /**
  27914. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27915. */
  27916. flushFramebuffer(): void;
  27917. /**
  27918. * Unbind the current render target and bind the default framebuffer
  27919. */
  27920. restoreDefaultFramebuffer(): void;
  27921. /**
  27922. * Create an uniform buffer
  27923. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27924. * @param elements defines the content of the uniform buffer
  27925. * @returns the webGL uniform buffer
  27926. */
  27927. createUniformBuffer(elements: FloatArray): DataBuffer;
  27928. /**
  27929. * Create a dynamic uniform buffer
  27930. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27931. * @param elements defines the content of the uniform buffer
  27932. * @returns the webGL uniform buffer
  27933. */
  27934. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27935. /**
  27936. * Update an existing uniform buffer
  27937. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27938. * @param uniformBuffer defines the target uniform buffer
  27939. * @param elements defines the content to update
  27940. * @param offset defines the offset in the uniform buffer where update should start
  27941. * @param count defines the size of the data to update
  27942. */
  27943. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27944. private _resetVertexBufferBinding;
  27945. /**
  27946. * Creates a vertex buffer
  27947. * @param data the data for the vertex buffer
  27948. * @returns the new WebGL static buffer
  27949. */
  27950. createVertexBuffer(data: DataArray): DataBuffer;
  27951. /**
  27952. * Creates a dynamic vertex buffer
  27953. * @param data the data for the dynamic vertex buffer
  27954. * @returns the new WebGL dynamic buffer
  27955. */
  27956. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27957. /**
  27958. * Update a dynamic index buffer
  27959. * @param indexBuffer defines the target index buffer
  27960. * @param indices defines the data to update
  27961. * @param offset defines the offset in the target index buffer where update should start
  27962. */
  27963. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27964. /**
  27965. * Updates a dynamic vertex buffer.
  27966. * @param vertexBuffer the vertex buffer to update
  27967. * @param data the data used to update the vertex buffer
  27968. * @param byteOffset the byte offset of the data
  27969. * @param byteLength the byte length of the data
  27970. */
  27971. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27972. private _resetIndexBufferBinding;
  27973. /**
  27974. * Creates a new index buffer
  27975. * @param indices defines the content of the index buffer
  27976. * @param updatable defines if the index buffer must be updatable
  27977. * @returns a new webGL buffer
  27978. */
  27979. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27980. /**
  27981. * Bind a webGL buffer to the webGL context
  27982. * @param buffer defines the buffer to bind
  27983. */
  27984. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27985. /**
  27986. * Bind an uniform buffer to the current webGL context
  27987. * @param buffer defines the buffer to bind
  27988. */
  27989. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27990. /**
  27991. * Bind a buffer to the current webGL context at a given location
  27992. * @param buffer defines the buffer to bind
  27993. * @param location defines the index where to bind the buffer
  27994. */
  27995. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27996. /**
  27997. * Bind a specific block at a given index in a specific shader program
  27998. * @param pipelineContext defines the pipeline context to use
  27999. * @param blockName defines the block name
  28000. * @param index defines the index where to bind the block
  28001. */
  28002. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28003. private bindIndexBuffer;
  28004. private bindBuffer;
  28005. /**
  28006. * update the bound buffer with the given data
  28007. * @param data defines the data to update
  28008. */
  28009. updateArrayBuffer(data: Float32Array): void;
  28010. private _vertexAttribPointer;
  28011. private _bindIndexBufferWithCache;
  28012. private _bindVertexBuffersAttributes;
  28013. /**
  28014. * Records a vertex array object
  28015. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28016. * @param vertexBuffers defines the list of vertex buffers to store
  28017. * @param indexBuffer defines the index buffer to store
  28018. * @param effect defines the effect to store
  28019. * @returns the new vertex array object
  28020. */
  28021. recordVertexArrayObject(vertexBuffers: {
  28022. [key: string]: VertexBuffer;
  28023. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28024. /**
  28025. * Bind a specific vertex array object
  28026. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28027. * @param vertexArrayObject defines the vertex array object to bind
  28028. * @param indexBuffer defines the index buffer to bind
  28029. */
  28030. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28031. /**
  28032. * Bind webGl buffers directly to the webGL context
  28033. * @param vertexBuffer defines the vertex buffer to bind
  28034. * @param indexBuffer defines the index buffer to bind
  28035. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28036. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28037. * @param effect defines the effect associated with the vertex buffer
  28038. */
  28039. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28040. private _unbindVertexArrayObject;
  28041. /**
  28042. * Bind a list of vertex buffers to the webGL context
  28043. * @param vertexBuffers defines the list of vertex buffers to bind
  28044. * @param indexBuffer defines the index buffer to bind
  28045. * @param effect defines the effect associated with the vertex buffers
  28046. */
  28047. bindBuffers(vertexBuffers: {
  28048. [key: string]: Nullable<VertexBuffer>;
  28049. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28050. /**
  28051. * Unbind all instance attributes
  28052. */
  28053. unbindInstanceAttributes(): void;
  28054. /**
  28055. * Release and free the memory of a vertex array object
  28056. * @param vao defines the vertex array object to delete
  28057. */
  28058. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28059. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  28060. /**
  28061. * Creates a webGL buffer to use with instanciation
  28062. * @param capacity defines the size of the buffer
  28063. * @returns the webGL buffer
  28064. */
  28065. createInstancesBuffer(capacity: number): DataBuffer;
  28066. /**
  28067. * Delete a webGL buffer used with instanciation
  28068. * @param buffer defines the webGL buffer to delete
  28069. */
  28070. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28071. /**
  28072. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28073. * @param instancesBuffer defines the webGL buffer to update and bind
  28074. * @param data defines the data to store in the buffer
  28075. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28076. */
  28077. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28078. /**
  28079. * Apply all cached states (depth, culling, stencil and alpha)
  28080. */
  28081. applyStates(): void;
  28082. /**
  28083. * Send a draw order
  28084. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28085. * @param indexStart defines the starting index
  28086. * @param indexCount defines the number of index to draw
  28087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28088. */
  28089. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28090. /**
  28091. * Draw a list of points
  28092. * @param verticesStart defines the index of first vertex to draw
  28093. * @param verticesCount defines the count of vertices to draw
  28094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28095. */
  28096. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28097. /**
  28098. * Draw a list of unindexed primitives
  28099. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28100. * @param verticesStart defines the index of first vertex to draw
  28101. * @param verticesCount defines the count of vertices to draw
  28102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28103. */
  28104. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28105. /**
  28106. * Draw a list of indexed primitives
  28107. * @param fillMode defines the primitive to use
  28108. * @param indexStart defines the starting index
  28109. * @param indexCount defines the number of index to draw
  28110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28111. */
  28112. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28113. /**
  28114. * Draw a list of unindexed primitives
  28115. * @param fillMode defines the primitive to use
  28116. * @param verticesStart defines the index of first vertex to draw
  28117. * @param verticesCount defines the count of vertices to draw
  28118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28119. */
  28120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28121. private _drawMode;
  28122. /** @hidden */ private _releaseEffect(effect: Effect): void;
  28123. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28124. /**
  28125. * Create a new effect (used to store vertex/fragment shaders)
  28126. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28127. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28128. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28129. * @param samplers defines an array of string used to represent textures
  28130. * @param defines defines the string containing the defines to use to compile the shaders
  28131. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28132. * @param onCompiled defines a function to call when the effect creation is successful
  28133. * @param onError defines a function to call when the effect creation has failed
  28134. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28135. * @returns the new Effect
  28136. */
  28137. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28138. private _compileShader;
  28139. private _compileRawShader;
  28140. /**
  28141. * Directly creates a webGL program
  28142. * @param pipelineContext defines the pipeline context to attach to
  28143. * @param vertexCode defines the vertex shader code to use
  28144. * @param fragmentCode defines the fragment shader code to use
  28145. * @param context defines the webGL context to use (if not set, the current one will be used)
  28146. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28147. * @returns the new webGL program
  28148. */
  28149. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28150. /**
  28151. * Creates a webGL program
  28152. * @param pipelineContext defines the pipeline context to attach to
  28153. * @param vertexCode defines the vertex shader code to use
  28154. * @param fragmentCode defines the fragment shader code to use
  28155. * @param defines defines the string containing the defines to use to compile the shaders
  28156. * @param context defines the webGL context to use (if not set, the current one will be used)
  28157. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28158. * @returns the new webGL program
  28159. */
  28160. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28161. /**
  28162. * Creates a new pipeline context
  28163. * @returns the new pipeline
  28164. */
  28165. createPipelineContext(): WebGLPipelineContext;
  28166. private _createShaderProgram;
  28167. private _finalizePipelineContext;
  28168. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28169. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28170. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28171. /**
  28172. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28173. * @param pipelineContext defines the pipeline context to use
  28174. * @param uniformsNames defines the list of uniform names
  28175. * @returns an array of webGL uniform locations
  28176. */
  28177. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28178. /**
  28179. * Gets the lsit of active attributes for a given webGL program
  28180. * @param pipelineContext defines the pipeline context to use
  28181. * @param attributesNames defines the list of attribute names to get
  28182. * @returns an array of indices indicating the offset of each attribute
  28183. */
  28184. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28185. /**
  28186. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28187. * @param effect defines the effect to activate
  28188. */
  28189. enableEffect(effect: Nullable<Effect>): void;
  28190. /**
  28191. * Set the value of an uniform to an array of int32
  28192. * @param uniform defines the webGL uniform location where to store the value
  28193. * @param array defines the array of int32 to store
  28194. */
  28195. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28196. /**
  28197. * Set the value of an uniform to an array of int32 (stored as vec2)
  28198. * @param uniform defines the webGL uniform location where to store the value
  28199. * @param array defines the array of int32 to store
  28200. */
  28201. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28202. /**
  28203. * Set the value of an uniform to an array of int32 (stored as vec3)
  28204. * @param uniform defines the webGL uniform location where to store the value
  28205. * @param array defines the array of int32 to store
  28206. */
  28207. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28208. /**
  28209. * Set the value of an uniform to an array of int32 (stored as vec4)
  28210. * @param uniform defines the webGL uniform location where to store the value
  28211. * @param array defines the array of int32 to store
  28212. */
  28213. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28214. /**
  28215. * Set the value of an uniform to an array of float32
  28216. * @param uniform defines the webGL uniform location where to store the value
  28217. * @param array defines the array of float32 to store
  28218. */
  28219. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28220. /**
  28221. * Set the value of an uniform to an array of float32 (stored as vec2)
  28222. * @param uniform defines the webGL uniform location where to store the value
  28223. * @param array defines the array of float32 to store
  28224. */
  28225. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28226. /**
  28227. * Set the value of an uniform to an array of float32 (stored as vec3)
  28228. * @param uniform defines the webGL uniform location where to store the value
  28229. * @param array defines the array of float32 to store
  28230. */
  28231. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28232. /**
  28233. * Set the value of an uniform to an array of float32 (stored as vec4)
  28234. * @param uniform defines the webGL uniform location where to store the value
  28235. * @param array defines the array of float32 to store
  28236. */
  28237. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28238. /**
  28239. * Set the value of an uniform to an array of number
  28240. * @param uniform defines the webGL uniform location where to store the value
  28241. * @param array defines the array of number to store
  28242. */
  28243. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28244. /**
  28245. * Set the value of an uniform to an array of number (stored as vec2)
  28246. * @param uniform defines the webGL uniform location where to store the value
  28247. * @param array defines the array of number to store
  28248. */
  28249. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28250. /**
  28251. * Set the value of an uniform to an array of number (stored as vec3)
  28252. * @param uniform defines the webGL uniform location where to store the value
  28253. * @param array defines the array of number to store
  28254. */
  28255. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28256. /**
  28257. * Set the value of an uniform to an array of number (stored as vec4)
  28258. * @param uniform defines the webGL uniform location where to store the value
  28259. * @param array defines the array of number to store
  28260. */
  28261. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28262. /**
  28263. * Set the value of an uniform to an array of float32 (stored as matrices)
  28264. * @param uniform defines the webGL uniform location where to store the value
  28265. * @param matrices defines the array of float32 to store
  28266. */
  28267. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28268. /**
  28269. * Set the value of an uniform to a matrix
  28270. * @param uniform defines the webGL uniform location where to store the value
  28271. * @param matrix defines the matrix to store
  28272. */
  28273. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28274. /**
  28275. * Set the value of an uniform to a matrix (3x3)
  28276. * @param uniform defines the webGL uniform location where to store the value
  28277. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28278. */
  28279. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28280. /**
  28281. * Set the value of an uniform to a matrix (2x2)
  28282. * @param uniform defines the webGL uniform location where to store the value
  28283. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28284. */
  28285. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28286. /**
  28287. * Set the value of an uniform to a number (int)
  28288. * @param uniform defines the webGL uniform location where to store the value
  28289. * @param value defines the int number to store
  28290. */
  28291. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28292. /**
  28293. * Set the value of an uniform to a number (float)
  28294. * @param uniform defines the webGL uniform location where to store the value
  28295. * @param value defines the float number to store
  28296. */
  28297. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28298. /**
  28299. * Set the value of an uniform to a vec2
  28300. * @param uniform defines the webGL uniform location where to store the value
  28301. * @param x defines the 1st component of the value
  28302. * @param y defines the 2nd component of the value
  28303. */
  28304. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28305. /**
  28306. * Set the value of an uniform to a vec3
  28307. * @param uniform defines the webGL uniform location where to store the value
  28308. * @param x defines the 1st component of the value
  28309. * @param y defines the 2nd component of the value
  28310. * @param z defines the 3rd component of the value
  28311. */
  28312. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28313. /**
  28314. * Set the value of an uniform to a boolean
  28315. * @param uniform defines the webGL uniform location where to store the value
  28316. * @param bool defines the boolean to store
  28317. */
  28318. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28319. /**
  28320. * Set the value of an uniform to a vec4
  28321. * @param uniform defines the webGL uniform location where to store the value
  28322. * @param x defines the 1st component of the value
  28323. * @param y defines the 2nd component of the value
  28324. * @param z defines the 3rd component of the value
  28325. * @param w defines the 4th component of the value
  28326. */
  28327. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28328. /**
  28329. * Set the value of an uniform to a Color3
  28330. * @param uniform defines the webGL uniform location where to store the value
  28331. * @param color3 defines the color to store
  28332. */
  28333. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28334. /**
  28335. * Set the value of an uniform to a Color3 and an alpha value
  28336. * @param uniform defines the webGL uniform location where to store the value
  28337. * @param color3 defines the color to store
  28338. * @param alpha defines the alpha component to store
  28339. */
  28340. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28341. /**
  28342. * Sets a Color4 on a uniform variable
  28343. * @param uniform defines the uniform location
  28344. * @param color4 defines the value to be set
  28345. */
  28346. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28347. /**
  28348. * Set various states to the webGL context
  28349. * @param culling defines backface culling state
  28350. * @param zOffset defines the value to apply to zOffset (0 by default)
  28351. * @param force defines if states must be applied even if cache is up to date
  28352. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28353. */
  28354. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28355. /**
  28356. * Set the z offset to apply to current rendering
  28357. * @param value defines the offset to apply
  28358. */
  28359. setZOffset(value: number): void;
  28360. /**
  28361. * Gets the current value of the zOffset
  28362. * @returns the current zOffset state
  28363. */
  28364. getZOffset(): number;
  28365. /**
  28366. * Enable or disable depth buffering
  28367. * @param enable defines the state to set
  28368. */
  28369. setDepthBuffer(enable: boolean): void;
  28370. /**
  28371. * Gets a boolean indicating if depth writing is enabled
  28372. * @returns the current depth writing state
  28373. */
  28374. getDepthWrite(): boolean;
  28375. /**
  28376. * Enable or disable depth writing
  28377. * @param enable defines the state to set
  28378. */
  28379. setDepthWrite(enable: boolean): void;
  28380. /**
  28381. * Enable or disable color writing
  28382. * @param enable defines the state to set
  28383. */
  28384. setColorWrite(enable: boolean): void;
  28385. /**
  28386. * Gets a boolean indicating if color writing is enabled
  28387. * @returns the current color writing state
  28388. */
  28389. getColorWrite(): boolean;
  28390. /**
  28391. * Sets alpha constants used by some alpha blending modes
  28392. * @param r defines the red component
  28393. * @param g defines the green component
  28394. * @param b defines the blue component
  28395. * @param a defines the alpha component
  28396. */
  28397. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28398. /**
  28399. * Sets the current alpha mode
  28400. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28401. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28403. */
  28404. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28405. /**
  28406. * Gets the current alpha mode
  28407. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28408. * @returns the current alpha mode
  28409. */
  28410. getAlphaMode(): number;
  28411. /**
  28412. * Clears the list of texture accessible through engine.
  28413. * This can help preventing texture load conflict due to name collision.
  28414. */
  28415. clearInternalTexturesCache(): void;
  28416. /**
  28417. * Force the entire cache to be cleared
  28418. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28419. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28420. */
  28421. wipeCaches(bruteForce?: boolean): void;
  28422. /**
  28423. * Set the compressed texture format to use, based on the formats you have, and the formats
  28424. * supported by the hardware / browser.
  28425. *
  28426. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28427. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28428. * to API arguments needed to compressed textures. This puts the burden on the container
  28429. * generator to house the arcane code for determining these for current & future formats.
  28430. *
  28431. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28432. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28433. *
  28434. * Note: The result of this call is not taken into account when a texture is base64.
  28435. *
  28436. * @param formatsAvailable defines the list of those format families you have created
  28437. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28438. *
  28439. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28440. * @returns The extension selected.
  28441. */
  28442. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28443. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28444. min: number;
  28445. mag: number;
  28446. };
  28447. /** @hidden */ private _createTexture(): WebGLTexture;
  28448. /**
  28449. * Usually called from Texture.ts.
  28450. * Passed information to create a WebGLTexture
  28451. * @param urlArg defines a value which contains one of the following:
  28452. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28453. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28454. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28455. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28456. * @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)
  28457. * @param scene needed for loading to the correct scene
  28458. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28459. * @param onLoad optional callback to be called upon successful completion
  28460. * @param onError optional callback to be called upon failure
  28461. * @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
  28462. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28463. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28464. * @param forcedExtension defines the extension to use to pick the right loader
  28465. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28466. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28467. */
  28468. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28469. /**
  28470. * @hidden
  28471. * Rescales a texture
  28472. * @param source input texutre
  28473. * @param destination destination texture
  28474. * @param scene scene to use to render the resize
  28475. * @param internalFormat format to use when resizing
  28476. * @param onComplete callback to be called when resize has completed
  28477. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28478. private _unpackFlipYCached;
  28479. /**
  28480. * In case you are sharing the context with other applications, it might
  28481. * be interested to not cache the unpack flip y state to ensure a consistent
  28482. * value would be set.
  28483. */
  28484. enableUnpackFlipYCached: boolean;
  28485. /** @hidden */ private _unpackFlipY(value: boolean): void;
  28486. /** @hidden */ private _getUnpackAlignement(): number;
  28487. /**
  28488. * Creates a dynamic texture
  28489. * @param width defines the width of the texture
  28490. * @param height defines the height of the texture
  28491. * @param generateMipMaps defines if the engine should generate the mip levels
  28492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28493. * @returns the dynamic texture inside an InternalTexture
  28494. */
  28495. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28496. /**
  28497. * Update the sampling mode of a given texture
  28498. * @param samplingMode defines the required sampling mode
  28499. * @param texture defines the texture to update
  28500. */
  28501. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28502. /**
  28503. * Update the content of a dynamic texture
  28504. * @param texture defines the texture to update
  28505. * @param canvas defines the canvas containing the source
  28506. * @param invertY defines if data must be stored with Y axis inverted
  28507. * @param premulAlpha defines if alpha is stored as premultiplied
  28508. * @param format defines the format of the data
  28509. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28510. */
  28511. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28512. /**
  28513. * Update a video texture
  28514. * @param texture defines the texture to update
  28515. * @param video defines the video element to use
  28516. * @param invertY defines if data must be stored with Y axis inverted
  28517. */
  28518. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28519. /**
  28520. * Updates a depth texture Comparison Mode and Function.
  28521. * If the comparison Function is equal to 0, the mode will be set to none.
  28522. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28523. * @param texture The texture to set the comparison function for
  28524. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28525. */
  28526. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28527. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28528. width: number;
  28529. height: number;
  28530. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28531. /**
  28532. * Creates a depth stencil texture.
  28533. * This is only available in WebGL 2 or with the depth texture extension available.
  28534. * @param size The size of face edge in the texture.
  28535. * @param options The options defining the texture.
  28536. * @returns The texture
  28537. */
  28538. createDepthStencilTexture(size: number | {
  28539. width: number;
  28540. height: number;
  28541. }, options: DepthTextureCreationOptions): InternalTexture;
  28542. /**
  28543. * Creates a depth stencil texture.
  28544. * This is only available in WebGL 2 or with the depth texture extension available.
  28545. * @param size The size of face edge in the texture.
  28546. * @param options The options defining the texture.
  28547. * @returns The texture
  28548. */
  28549. private _createDepthStencilTexture;
  28550. /**
  28551. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28552. * @param renderTarget The render target to set the frame buffer for
  28553. */
  28554. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28555. /**
  28556. * Creates a new render target texture
  28557. * @param size defines the size of the texture
  28558. * @param options defines the options used to create the texture
  28559. * @returns a new render target texture stored in an InternalTexture
  28560. */
  28561. createRenderTargetTexture(size: number | {
  28562. width: number;
  28563. height: number;
  28564. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28565. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28566. /**
  28567. * Updates the sample count of a render target texture
  28568. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28569. * @param texture defines the texture to update
  28570. * @param samples defines the sample count to set
  28571. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28572. */
  28573. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28574. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28575. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  28576. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28577. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28578. /**
  28579. * @hidden
  28580. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  28581. private _prepareWebGLTextureContinuation;
  28582. private _prepareWebGLTexture;
  28583. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28584. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  28585. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  28586. private setProgram;
  28587. private _boundUniforms;
  28588. /**
  28589. * Binds an effect to the webGL context
  28590. * @param effect defines the effect to bind
  28591. */
  28592. bindSamplers(effect: Effect): void;
  28593. private _activateCurrentTexture;
  28594. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28595. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28596. /**
  28597. * Sets a texture to the webGL context from a postprocess
  28598. * @param channel defines the channel to use
  28599. * @param postProcess defines the source postprocess
  28600. */
  28601. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28602. /**
  28603. * Binds the output of the passed in post process to the texture channel specified
  28604. * @param channel The channel the texture should be bound to
  28605. * @param postProcess The post process which's output should be bound
  28606. */
  28607. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28608. /**
  28609. * Unbind all textures from the webGL context
  28610. */
  28611. unbindAllTextures(): void;
  28612. /**
  28613. * Sets a texture to the according uniform.
  28614. * @param channel The texture channel
  28615. * @param uniform The uniform to set
  28616. * @param texture The texture to apply
  28617. */
  28618. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28619. /**
  28620. * Sets a depth stencil texture from a render target to the according uniform.
  28621. * @param channel The texture channel
  28622. * @param uniform The uniform to set
  28623. * @param texture The render target texture containing the depth stencil texture to apply
  28624. */
  28625. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28626. private _bindSamplerUniformToChannel;
  28627. private _getTextureWrapMode;
  28628. private _setTexture;
  28629. /**
  28630. * Sets an array of texture to the webGL context
  28631. * @param channel defines the channel where the texture array must be set
  28632. * @param uniform defines the associated uniform location
  28633. * @param textures defines the array of textures to bind
  28634. */
  28635. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28636. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28637. private _setTextureParameterFloat;
  28638. private _setTextureParameterInteger;
  28639. /**
  28640. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28641. * @param x defines the x coordinate of the rectangle where pixels must be read
  28642. * @param y defines the y coordinate of the rectangle where pixels must be read
  28643. * @param width defines the width of the rectangle where pixels must be read
  28644. * @param height defines the height of the rectangle where pixels must be read
  28645. * @returns a Uint8Array containing RGBA colors
  28646. */
  28647. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28648. /**
  28649. * Add an externaly attached data from its key.
  28650. * This method call will fail and return false, if such key already exists.
  28651. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28652. * @param key the unique key that identifies the data
  28653. * @param data the data object to associate to the key for this Engine instance
  28654. * @return true if no such key were already present and the data was added successfully, false otherwise
  28655. */
  28656. addExternalData<T>(key: string, data: T): boolean;
  28657. /**
  28658. * Get an externaly attached data from its key
  28659. * @param key the unique key that identifies the data
  28660. * @return the associated data, if present (can be null), or undefined if not present
  28661. */
  28662. getExternalData<T>(key: string): T;
  28663. /**
  28664. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28665. * @param key the unique key that identifies the data
  28666. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28667. * @return the associated data, can be null if the factory returned null.
  28668. */
  28669. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28670. /**
  28671. * Remove an externaly attached data from the Engine instance
  28672. * @param key the unique key that identifies the data
  28673. * @return true if the data was successfully removed, false if it doesn't exist
  28674. */
  28675. removeExternalData(key: string): boolean;
  28676. /**
  28677. * Unbind all vertex attributes from the webGL context
  28678. */
  28679. unbindAllAttributes(): void;
  28680. /**
  28681. * 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
  28682. */
  28683. releaseEffects(): void;
  28684. /**
  28685. * Dispose and release all associated resources
  28686. */
  28687. dispose(): void;
  28688. /**
  28689. * Display the loading screen
  28690. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28691. */
  28692. displayLoadingUI(): void;
  28693. /**
  28694. * Hide the loading screen
  28695. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28696. */
  28697. hideLoadingUI(): void;
  28698. /**
  28699. * Gets the current loading screen object
  28700. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28701. */
  28702. /**
  28703. * Sets the current loading screen object
  28704. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28705. */
  28706. loadingScreen: ILoadingScreen;
  28707. /**
  28708. * Sets the current loading screen text
  28709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28710. */
  28711. loadingUIText: string;
  28712. /**
  28713. * Sets the current loading screen background color
  28714. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28715. */
  28716. loadingUIBackgroundColor: string;
  28717. /**
  28718. * Attach a new callback raised when context lost event is fired
  28719. * @param callback defines the callback to call
  28720. */
  28721. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28722. /**
  28723. * Attach a new callback raised when context restored event is fired
  28724. * @param callback defines the callback to call
  28725. */
  28726. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28727. /**
  28728. * Gets the source code of the vertex shader associated with a specific webGL program
  28729. * @param program defines the program to use
  28730. * @returns a string containing the source code of the vertex shader associated with the program
  28731. */
  28732. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28733. /**
  28734. * Gets the source code of the fragment shader associated with a specific webGL program
  28735. * @param program defines the program to use
  28736. * @returns a string containing the source code of the fragment shader associated with the program
  28737. */
  28738. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28739. /**
  28740. * Get the current error code of the webGL context
  28741. * @returns the error code
  28742. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28743. */
  28744. getError(): number;
  28745. /**
  28746. * Gets the current framerate
  28747. * @returns a number representing the framerate
  28748. */
  28749. getFps(): number;
  28750. /**
  28751. * Gets the time spent between current and previous frame
  28752. * @returns a number representing the delta time in ms
  28753. */
  28754. getDeltaTime(): number;
  28755. private _measureFps;
  28756. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28757. private _canRenderToFloatFramebuffer;
  28758. private _canRenderToHalfFloatFramebuffer;
  28759. private _canRenderToFramebuffer;
  28760. /** @hidden */ private _getWebGLTextureType(type: number): number;
  28761. /** @hidden */ private _getInternalFormat(format: number): number;
  28762. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28763. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  28764. /** @hidden */ private _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;
  28765. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28766. /**
  28767. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28768. * @returns true if the engine can be created
  28769. * @ignorenaming
  28770. */
  28771. static isSupported(): boolean;
  28772. }
  28773. }
  28774. declare module BABYLON {
  28775. /**
  28776. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28777. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28778. */
  28779. export class EffectFallbacks {
  28780. private _defines;
  28781. private _currentRank;
  28782. private _maxRank;
  28783. private _mesh;
  28784. /**
  28785. * Removes the fallback from the bound mesh.
  28786. */
  28787. unBindMesh(): void;
  28788. /**
  28789. * Adds a fallback on the specified property.
  28790. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28791. * @param define The name of the define in the shader
  28792. */
  28793. addFallback(rank: number, define: string): void;
  28794. /**
  28795. * Sets the mesh to use CPU skinning when needing to fallback.
  28796. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28797. * @param mesh The mesh to use the fallbacks.
  28798. */
  28799. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28800. /**
  28801. * Checks to see if more fallbacks are still availible.
  28802. */
  28803. readonly isMoreFallbacks: boolean;
  28804. /**
  28805. * Removes the defines that should be removed when falling back.
  28806. * @param currentDefines defines the current define statements for the shader.
  28807. * @param effect defines the current effect we try to compile
  28808. * @returns The resulting defines with defines of the current rank removed.
  28809. */
  28810. reduce(currentDefines: string, effect: Effect): string;
  28811. }
  28812. /**
  28813. * Options to be used when creating an effect.
  28814. */
  28815. export class EffectCreationOptions {
  28816. /**
  28817. * Atrributes that will be used in the shader.
  28818. */
  28819. attributes: string[];
  28820. /**
  28821. * Uniform varible names that will be set in the shader.
  28822. */
  28823. uniformsNames: string[];
  28824. /**
  28825. * Uniform buffer varible names that will be set in the shader.
  28826. */
  28827. uniformBuffersNames: string[];
  28828. /**
  28829. * Sampler texture variable names that will be set in the shader.
  28830. */
  28831. samplers: string[];
  28832. /**
  28833. * Define statements that will be set in the shader.
  28834. */
  28835. defines: any;
  28836. /**
  28837. * Possible fallbacks for this effect to improve performance when needed.
  28838. */
  28839. fallbacks: Nullable<EffectFallbacks>;
  28840. /**
  28841. * Callback that will be called when the shader is compiled.
  28842. */
  28843. onCompiled: Nullable<(effect: Effect) => void>;
  28844. /**
  28845. * Callback that will be called if an error occurs during shader compilation.
  28846. */
  28847. onError: Nullable<(effect: Effect, errors: string) => void>;
  28848. /**
  28849. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28850. */
  28851. indexParameters: any;
  28852. /**
  28853. * Max number of lights that can be used in the shader.
  28854. */
  28855. maxSimultaneousLights: number;
  28856. /**
  28857. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28858. */
  28859. transformFeedbackVaryings: Nullable<string[]>;
  28860. }
  28861. /**
  28862. * Effect containing vertex and fragment shader that can be executed on an object.
  28863. */
  28864. export class Effect implements IDisposable {
  28865. /**
  28866. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28867. */
  28868. static ShadersRepository: string;
  28869. /**
  28870. * Name of the effect.
  28871. */
  28872. name: any;
  28873. /**
  28874. * String container all the define statements that should be set on the shader.
  28875. */
  28876. defines: string;
  28877. /**
  28878. * Callback that will be called when the shader is compiled.
  28879. */
  28880. onCompiled: Nullable<(effect: Effect) => void>;
  28881. /**
  28882. * Callback that will be called if an error occurs during shader compilation.
  28883. */
  28884. onError: Nullable<(effect: Effect, errors: string) => void>;
  28885. /**
  28886. * Callback that will be called when effect is bound.
  28887. */
  28888. onBind: Nullable<(effect: Effect) => void>;
  28889. /**
  28890. * Unique ID of the effect.
  28891. */
  28892. uniqueId: number;
  28893. /**
  28894. * Observable that will be called when the shader is compiled.
  28895. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28896. */
  28897. onCompileObservable: Observable<Effect>;
  28898. /**
  28899. * Observable that will be called if an error occurs during shader compilation.
  28900. */
  28901. onErrorObservable: Observable<Effect>;
  28902. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  28903. /**
  28904. * Observable that will be called when effect is bound.
  28905. */
  28906. readonly onBindObservable: Observable<Effect>;
  28907. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  28908. private static _uniqueIdSeed;
  28909. private _engine;
  28910. private _uniformBuffersNames;
  28911. private _uniformsNames;
  28912. private _samplerList;
  28913. private _samplers;
  28914. private _isReady;
  28915. private _compilationError;
  28916. private _attributesNames;
  28917. private _attributes;
  28918. private _uniforms;
  28919. /**
  28920. * Key for the effect.
  28921. * @hidden
  28922. */ private _key: string;
  28923. private _indexParameters;
  28924. private _fallbacks;
  28925. private _vertexSourceCode;
  28926. private _fragmentSourceCode;
  28927. private _vertexSourceCodeOverride;
  28928. private _fragmentSourceCodeOverride;
  28929. private _transformFeedbackVaryings;
  28930. /**
  28931. * Compiled shader to webGL program.
  28932. * @hidden
  28933. */ private _pipelineContext: Nullable<IPipelineContext>;
  28934. private _valueCache;
  28935. private static _baseCache;
  28936. /**
  28937. * Instantiates an effect.
  28938. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28939. * @param baseName Name of the effect.
  28940. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28941. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28942. * @param samplers List of sampler variables that will be passed to the shader.
  28943. * @param engine Engine to be used to render the effect
  28944. * @param defines Define statements to be added to the shader.
  28945. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28946. * @param onCompiled Callback that will be called when the shader is compiled.
  28947. * @param onError Callback that will be called if an error occurs during shader compilation.
  28948. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28949. */
  28950. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28951. private _useFinalCode;
  28952. /**
  28953. * Unique key for this effect
  28954. */
  28955. readonly key: string;
  28956. /**
  28957. * If the effect has been compiled and prepared.
  28958. * @returns if the effect is compiled and prepared.
  28959. */
  28960. isReady(): boolean;
  28961. /**
  28962. * The engine the effect was initialized with.
  28963. * @returns the engine.
  28964. */
  28965. getEngine(): Engine;
  28966. /**
  28967. * The pipeline context for this effect
  28968. * @returns the associated pipeline context
  28969. */
  28970. getPipelineContext(): Nullable<IPipelineContext>;
  28971. /**
  28972. * The set of names of attribute variables for the shader.
  28973. * @returns An array of attribute names.
  28974. */
  28975. getAttributesNames(): string[];
  28976. /**
  28977. * Returns the attribute at the given index.
  28978. * @param index The index of the attribute.
  28979. * @returns The location of the attribute.
  28980. */
  28981. getAttributeLocation(index: number): number;
  28982. /**
  28983. * Returns the attribute based on the name of the variable.
  28984. * @param name of the attribute to look up.
  28985. * @returns the attribute location.
  28986. */
  28987. getAttributeLocationByName(name: string): number;
  28988. /**
  28989. * The number of attributes.
  28990. * @returns the numnber of attributes.
  28991. */
  28992. getAttributesCount(): number;
  28993. /**
  28994. * Gets the index of a uniform variable.
  28995. * @param uniformName of the uniform to look up.
  28996. * @returns the index.
  28997. */
  28998. getUniformIndex(uniformName: string): number;
  28999. /**
  29000. * Returns the attribute based on the name of the variable.
  29001. * @param uniformName of the uniform to look up.
  29002. * @returns the location of the uniform.
  29003. */
  29004. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29005. /**
  29006. * Returns an array of sampler variable names
  29007. * @returns The array of sampler variable neames.
  29008. */
  29009. getSamplers(): string[];
  29010. /**
  29011. * The error from the last compilation.
  29012. * @returns the error string.
  29013. */
  29014. getCompilationError(): string;
  29015. /**
  29016. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29017. * @param func The callback to be used.
  29018. */
  29019. executeWhenCompiled(func: (effect: Effect) => void): void;
  29020. private _checkIsReady;
  29021. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29022. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29023. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29024. /**
  29025. * Recompiles the webGL program
  29026. * @param vertexSourceCode The source code for the vertex shader.
  29027. * @param fragmentSourceCode The source code for the fragment shader.
  29028. * @param onCompiled Callback called when completed.
  29029. * @param onError Callback called on error.
  29030. * @hidden
  29031. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29032. /**
  29033. * Prepares the effect
  29034. * @hidden
  29035. */ private _prepareEffect(): void;
  29036. /**
  29037. * Checks if the effect is supported. (Must be called after compilation)
  29038. */
  29039. readonly isSupported: boolean;
  29040. /**
  29041. * Binds a texture to the engine to be used as output of the shader.
  29042. * @param channel Name of the output variable.
  29043. * @param texture Texture to bind.
  29044. * @hidden
  29045. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  29046. /**
  29047. * Sets a texture on the engine to be used in the shader.
  29048. * @param channel Name of the sampler variable.
  29049. * @param texture Texture to set.
  29050. */
  29051. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29052. /**
  29053. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29054. * @param channel Name of the sampler variable.
  29055. * @param texture Texture to set.
  29056. */
  29057. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29058. /**
  29059. * Sets an array of textures on the engine to be used in the shader.
  29060. * @param channel Name of the variable.
  29061. * @param textures Textures to set.
  29062. */
  29063. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29064. /**
  29065. * 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)
  29066. * @param channel Name of the sampler variable.
  29067. * @param postProcess Post process to get the input texture from.
  29068. */
  29069. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29070. /**
  29071. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29072. * 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)
  29073. * @param channel Name of the sampler variable.
  29074. * @param postProcess Post process to get the output texture from.
  29075. */
  29076. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29077. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29078. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29079. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29080. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29081. /**
  29082. * Binds a buffer to a uniform.
  29083. * @param buffer Buffer to bind.
  29084. * @param name Name of the uniform variable to bind to.
  29085. */
  29086. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29087. /**
  29088. * Binds block to a uniform.
  29089. * @param blockName Name of the block to bind.
  29090. * @param index Index to bind.
  29091. */
  29092. bindUniformBlock(blockName: string, index: number): void;
  29093. /**
  29094. * Sets an interger value on a uniform variable.
  29095. * @param uniformName Name of the variable.
  29096. * @param value Value to be set.
  29097. * @returns this effect.
  29098. */
  29099. setInt(uniformName: string, value: number): Effect;
  29100. /**
  29101. * Sets an int array on a uniform variable.
  29102. * @param uniformName Name of the variable.
  29103. * @param array array to be set.
  29104. * @returns this effect.
  29105. */
  29106. setIntArray(uniformName: string, array: Int32Array): Effect;
  29107. /**
  29108. * 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)
  29109. * @param uniformName Name of the variable.
  29110. * @param array array to be set.
  29111. * @returns this effect.
  29112. */
  29113. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29114. /**
  29115. * 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)
  29116. * @param uniformName Name of the variable.
  29117. * @param array array to be set.
  29118. * @returns this effect.
  29119. */
  29120. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29121. /**
  29122. * 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)
  29123. * @param uniformName Name of the variable.
  29124. * @param array array to be set.
  29125. * @returns this effect.
  29126. */
  29127. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29128. /**
  29129. * Sets an float array on a uniform variable.
  29130. * @param uniformName Name of the variable.
  29131. * @param array array to be set.
  29132. * @returns this effect.
  29133. */
  29134. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29135. /**
  29136. * 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)
  29137. * @param uniformName Name of the variable.
  29138. * @param array array to be set.
  29139. * @returns this effect.
  29140. */
  29141. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29142. /**
  29143. * 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)
  29144. * @param uniformName Name of the variable.
  29145. * @param array array to be set.
  29146. * @returns this effect.
  29147. */
  29148. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29149. /**
  29150. * 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)
  29151. * @param uniformName Name of the variable.
  29152. * @param array array to be set.
  29153. * @returns this effect.
  29154. */
  29155. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29156. /**
  29157. * Sets an array on a uniform variable.
  29158. * @param uniformName Name of the variable.
  29159. * @param array array to be set.
  29160. * @returns this effect.
  29161. */
  29162. setArray(uniformName: string, array: number[]): Effect;
  29163. /**
  29164. * 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)
  29165. * @param uniformName Name of the variable.
  29166. * @param array array to be set.
  29167. * @returns this effect.
  29168. */
  29169. setArray2(uniformName: string, array: number[]): Effect;
  29170. /**
  29171. * 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)
  29172. * @param uniformName Name of the variable.
  29173. * @param array array to be set.
  29174. * @returns this effect.
  29175. */
  29176. setArray3(uniformName: string, array: number[]): Effect;
  29177. /**
  29178. * 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)
  29179. * @param uniformName Name of the variable.
  29180. * @param array array to be set.
  29181. * @returns this effect.
  29182. */
  29183. setArray4(uniformName: string, array: number[]): Effect;
  29184. /**
  29185. * Sets matrices on a uniform variable.
  29186. * @param uniformName Name of the variable.
  29187. * @param matrices matrices to be set.
  29188. * @returns this effect.
  29189. */
  29190. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29191. /**
  29192. * Sets matrix on a uniform variable.
  29193. * @param uniformName Name of the variable.
  29194. * @param matrix matrix to be set.
  29195. * @returns this effect.
  29196. */
  29197. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29198. /**
  29199. * 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)
  29200. * @param uniformName Name of the variable.
  29201. * @param matrix matrix to be set.
  29202. * @returns this effect.
  29203. */
  29204. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29205. /**
  29206. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29207. * @param uniformName Name of the variable.
  29208. * @param matrix matrix to be set.
  29209. * @returns this effect.
  29210. */
  29211. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29212. /**
  29213. * Sets a float on a uniform variable.
  29214. * @param uniformName Name of the variable.
  29215. * @param value value to be set.
  29216. * @returns this effect.
  29217. */
  29218. setFloat(uniformName: string, value: number): Effect;
  29219. /**
  29220. * Sets a boolean on a uniform variable.
  29221. * @param uniformName Name of the variable.
  29222. * @param bool value to be set.
  29223. * @returns this effect.
  29224. */
  29225. setBool(uniformName: string, bool: boolean): Effect;
  29226. /**
  29227. * Sets a Vector2 on a uniform variable.
  29228. * @param uniformName Name of the variable.
  29229. * @param vector2 vector2 to be set.
  29230. * @returns this effect.
  29231. */
  29232. setVector2(uniformName: string, vector2: Vector2): Effect;
  29233. /**
  29234. * Sets a float2 on a uniform variable.
  29235. * @param uniformName Name of the variable.
  29236. * @param x First float in float2.
  29237. * @param y Second float in float2.
  29238. * @returns this effect.
  29239. */
  29240. setFloat2(uniformName: string, x: number, y: number): Effect;
  29241. /**
  29242. * Sets a Vector3 on a uniform variable.
  29243. * @param uniformName Name of the variable.
  29244. * @param vector3 Value to be set.
  29245. * @returns this effect.
  29246. */
  29247. setVector3(uniformName: string, vector3: Vector3): Effect;
  29248. /**
  29249. * Sets a float3 on a uniform variable.
  29250. * @param uniformName Name of the variable.
  29251. * @param x First float in float3.
  29252. * @param y Second float in float3.
  29253. * @param z Third float in float3.
  29254. * @returns this effect.
  29255. */
  29256. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29257. /**
  29258. * Sets a Vector4 on a uniform variable.
  29259. * @param uniformName Name of the variable.
  29260. * @param vector4 Value to be set.
  29261. * @returns this effect.
  29262. */
  29263. setVector4(uniformName: string, vector4: Vector4): Effect;
  29264. /**
  29265. * Sets a float4 on a uniform variable.
  29266. * @param uniformName Name of the variable.
  29267. * @param x First float in float4.
  29268. * @param y Second float in float4.
  29269. * @param z Third float in float4.
  29270. * @param w Fourth float in float4.
  29271. * @returns this effect.
  29272. */
  29273. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29274. /**
  29275. * Sets a Color3 on a uniform variable.
  29276. * @param uniformName Name of the variable.
  29277. * @param color3 Value to be set.
  29278. * @returns this effect.
  29279. */
  29280. setColor3(uniformName: string, color3: Color3): Effect;
  29281. /**
  29282. * Sets a Color4 on a uniform variable.
  29283. * @param uniformName Name of the variable.
  29284. * @param color3 Value to be set.
  29285. * @param alpha Alpha value to be set.
  29286. * @returns this effect.
  29287. */
  29288. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29289. /**
  29290. * Sets a Color4 on a uniform variable
  29291. * @param uniformName defines the name of the variable
  29292. * @param color4 defines the value to be set
  29293. * @returns this effect.
  29294. */
  29295. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29296. /** Release all associated resources */
  29297. dispose(): void;
  29298. /**
  29299. * This function will add a new shader to the shader store
  29300. * @param name the name of the shader
  29301. * @param pixelShader optional pixel shader content
  29302. * @param vertexShader optional vertex shader content
  29303. */
  29304. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29305. /**
  29306. * Store of each shader (The can be looked up using effect.key)
  29307. */
  29308. static ShadersStore: {
  29309. [key: string]: string;
  29310. };
  29311. /**
  29312. * Store of each included file for a shader (The can be looked up using effect.key)
  29313. */
  29314. static IncludesShadersStore: {
  29315. [key: string]: string;
  29316. };
  29317. /**
  29318. * Resets the cache of effects.
  29319. */
  29320. static ResetCache(): void;
  29321. }
  29322. }
  29323. declare module BABYLON {
  29324. /**
  29325. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29326. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29327. * 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;
  29328. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29329. */
  29330. export class ColorCurves {
  29331. private _dirty;
  29332. private _tempColor;
  29333. private _globalCurve;
  29334. private _highlightsCurve;
  29335. private _midtonesCurve;
  29336. private _shadowsCurve;
  29337. private _positiveCurve;
  29338. private _negativeCurve;
  29339. private _globalHue;
  29340. private _globalDensity;
  29341. private _globalSaturation;
  29342. private _globalExposure;
  29343. /**
  29344. * Gets the global Hue value.
  29345. * 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).
  29346. */
  29347. /**
  29348. * Sets the global Hue value.
  29349. * 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).
  29350. */
  29351. globalHue: number;
  29352. /**
  29353. * Gets the global Density value.
  29354. * 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.
  29355. * Values less than zero provide a filter of opposite hue.
  29356. */
  29357. /**
  29358. * Sets the global Density value.
  29359. * 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.
  29360. * Values less than zero provide a filter of opposite hue.
  29361. */
  29362. globalDensity: number;
  29363. /**
  29364. * Gets the global Saturation value.
  29365. * 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.
  29366. */
  29367. /**
  29368. * Sets the global Saturation value.
  29369. * 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.
  29370. */
  29371. globalSaturation: number;
  29372. /**
  29373. * Gets the global Exposure value.
  29374. * 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.
  29375. */
  29376. /**
  29377. * Sets the global Exposure value.
  29378. * 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.
  29379. */
  29380. globalExposure: number;
  29381. private _highlightsHue;
  29382. private _highlightsDensity;
  29383. private _highlightsSaturation;
  29384. private _highlightsExposure;
  29385. /**
  29386. * Gets the highlights Hue value.
  29387. * 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).
  29388. */
  29389. /**
  29390. * Sets the highlights Hue value.
  29391. * 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).
  29392. */
  29393. highlightsHue: number;
  29394. /**
  29395. * Gets the highlights Density value.
  29396. * 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.
  29397. * Values less than zero provide a filter of opposite hue.
  29398. */
  29399. /**
  29400. * Sets the highlights Density value.
  29401. * 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.
  29402. * Values less than zero provide a filter of opposite hue.
  29403. */
  29404. highlightsDensity: number;
  29405. /**
  29406. * Gets the highlights Saturation value.
  29407. * 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.
  29408. */
  29409. /**
  29410. * Sets the highlights Saturation value.
  29411. * 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.
  29412. */
  29413. highlightsSaturation: number;
  29414. /**
  29415. * Gets the highlights Exposure value.
  29416. * 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.
  29417. */
  29418. /**
  29419. * Sets the highlights Exposure value.
  29420. * 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.
  29421. */
  29422. highlightsExposure: number;
  29423. private _midtonesHue;
  29424. private _midtonesDensity;
  29425. private _midtonesSaturation;
  29426. private _midtonesExposure;
  29427. /**
  29428. * Gets the midtones Hue value.
  29429. * 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).
  29430. */
  29431. /**
  29432. * Sets the midtones Hue value.
  29433. * 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).
  29434. */
  29435. midtonesHue: number;
  29436. /**
  29437. * Gets the midtones Density value.
  29438. * 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.
  29439. * Values less than zero provide a filter of opposite hue.
  29440. */
  29441. /**
  29442. * Sets the midtones Density value.
  29443. * 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.
  29444. * Values less than zero provide a filter of opposite hue.
  29445. */
  29446. midtonesDensity: number;
  29447. /**
  29448. * Gets the midtones Saturation value.
  29449. * 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.
  29450. */
  29451. /**
  29452. * Sets the midtones Saturation value.
  29453. * 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.
  29454. */
  29455. midtonesSaturation: number;
  29456. /**
  29457. * Gets the midtones Exposure value.
  29458. * 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.
  29459. */
  29460. /**
  29461. * Sets the midtones Exposure value.
  29462. * 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.
  29463. */
  29464. midtonesExposure: number;
  29465. private _shadowsHue;
  29466. private _shadowsDensity;
  29467. private _shadowsSaturation;
  29468. private _shadowsExposure;
  29469. /**
  29470. * Gets the shadows Hue value.
  29471. * 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).
  29472. */
  29473. /**
  29474. * Sets the shadows Hue value.
  29475. * 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).
  29476. */
  29477. shadowsHue: number;
  29478. /**
  29479. * Gets the shadows Density value.
  29480. * 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.
  29481. * Values less than zero provide a filter of opposite hue.
  29482. */
  29483. /**
  29484. * Sets the shadows Density value.
  29485. * 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.
  29486. * Values less than zero provide a filter of opposite hue.
  29487. */
  29488. shadowsDensity: number;
  29489. /**
  29490. * Gets the shadows Saturation value.
  29491. * 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.
  29492. */
  29493. /**
  29494. * Sets the shadows Saturation value.
  29495. * 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.
  29496. */
  29497. shadowsSaturation: number;
  29498. /**
  29499. * Gets the shadows Exposure value.
  29500. * 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.
  29501. */
  29502. /**
  29503. * Sets the shadows Exposure value.
  29504. * 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.
  29505. */
  29506. shadowsExposure: number;
  29507. /**
  29508. * Returns the class name
  29509. * @returns The class name
  29510. */
  29511. getClassName(): string;
  29512. /**
  29513. * Binds the color curves to the shader.
  29514. * @param colorCurves The color curve to bind
  29515. * @param effect The effect to bind to
  29516. * @param positiveUniform The positive uniform shader parameter
  29517. * @param neutralUniform The neutral uniform shader parameter
  29518. * @param negativeUniform The negative uniform shader parameter
  29519. */
  29520. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29521. /**
  29522. * Prepare the list of uniforms associated with the ColorCurves effects.
  29523. * @param uniformsList The list of uniforms used in the effect
  29524. */
  29525. static PrepareUniforms(uniformsList: string[]): void;
  29526. /**
  29527. * Returns color grading data based on a hue, density, saturation and exposure value.
  29528. * @param filterHue The hue of the color filter.
  29529. * @param filterDensity The density of the color filter.
  29530. * @param saturation The saturation.
  29531. * @param exposure The exposure.
  29532. * @param result The result data container.
  29533. */
  29534. private getColorGradingDataToRef;
  29535. /**
  29536. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29537. * @param value The input slider value in range [-100,100].
  29538. * @returns Adjusted value.
  29539. */
  29540. private static applyColorGradingSliderNonlinear;
  29541. /**
  29542. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29543. * @param hue The hue (H) input.
  29544. * @param saturation The saturation (S) input.
  29545. * @param brightness The brightness (B) input.
  29546. * @result An RGBA color represented as Vector4.
  29547. */
  29548. private static fromHSBToRef;
  29549. /**
  29550. * Returns a value clamped between min and max
  29551. * @param value The value to clamp
  29552. * @param min The minimum of value
  29553. * @param max The maximum of value
  29554. * @returns The clamped value.
  29555. */
  29556. private static clamp;
  29557. /**
  29558. * Clones the current color curve instance.
  29559. * @return The cloned curves
  29560. */
  29561. clone(): ColorCurves;
  29562. /**
  29563. * Serializes the current color curve instance to a json representation.
  29564. * @return a JSON representation
  29565. */
  29566. serialize(): any;
  29567. /**
  29568. * Parses the color curve from a json representation.
  29569. * @param source the JSON source to parse
  29570. * @return The parsed curves
  29571. */
  29572. static Parse(source: any): ColorCurves;
  29573. }
  29574. }
  29575. declare module BABYLON {
  29576. /**
  29577. * Interface to follow in your material defines to integrate easily the
  29578. * Image proccessing functions.
  29579. * @hidden
  29580. */
  29581. export interface IImageProcessingConfigurationDefines {
  29582. IMAGEPROCESSING: boolean;
  29583. VIGNETTE: boolean;
  29584. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29585. VIGNETTEBLENDMODEOPAQUE: boolean;
  29586. TONEMAPPING: boolean;
  29587. TONEMAPPING_ACES: boolean;
  29588. CONTRAST: boolean;
  29589. EXPOSURE: boolean;
  29590. COLORCURVES: boolean;
  29591. COLORGRADING: boolean;
  29592. COLORGRADING3D: boolean;
  29593. SAMPLER3DGREENDEPTH: boolean;
  29594. SAMPLER3DBGRMAP: boolean;
  29595. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29596. }
  29597. /**
  29598. * @hidden
  29599. */
  29600. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29601. IMAGEPROCESSING: boolean;
  29602. VIGNETTE: boolean;
  29603. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29604. VIGNETTEBLENDMODEOPAQUE: boolean;
  29605. TONEMAPPING: boolean;
  29606. TONEMAPPING_ACES: boolean;
  29607. CONTRAST: boolean;
  29608. COLORCURVES: boolean;
  29609. COLORGRADING: boolean;
  29610. COLORGRADING3D: boolean;
  29611. SAMPLER3DGREENDEPTH: boolean;
  29612. SAMPLER3DBGRMAP: boolean;
  29613. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29614. EXPOSURE: boolean;
  29615. constructor();
  29616. }
  29617. /**
  29618. * This groups together the common properties used for image processing either in direct forward pass
  29619. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29620. * or not.
  29621. */
  29622. export class ImageProcessingConfiguration {
  29623. /**
  29624. * Default tone mapping applied in BabylonJS.
  29625. */
  29626. static readonly TONEMAPPING_STANDARD: number;
  29627. /**
  29628. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29629. * to other engines rendering to increase portability.
  29630. */
  29631. static readonly TONEMAPPING_ACES: number;
  29632. /**
  29633. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29634. */
  29635. colorCurves: Nullable<ColorCurves>;
  29636. private _colorCurvesEnabled;
  29637. /**
  29638. * Gets wether the color curves effect is enabled.
  29639. */
  29640. /**
  29641. * Sets wether the color curves effect is enabled.
  29642. */
  29643. colorCurvesEnabled: boolean;
  29644. private _colorGradingTexture;
  29645. /**
  29646. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29647. */
  29648. /**
  29649. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29650. */
  29651. colorGradingTexture: Nullable<BaseTexture>;
  29652. private _colorGradingEnabled;
  29653. /**
  29654. * Gets wether the color grading effect is enabled.
  29655. */
  29656. /**
  29657. * Sets wether the color grading effect is enabled.
  29658. */
  29659. colorGradingEnabled: boolean;
  29660. private _colorGradingWithGreenDepth;
  29661. /**
  29662. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29663. */
  29664. /**
  29665. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29666. */
  29667. colorGradingWithGreenDepth: boolean;
  29668. private _colorGradingBGR;
  29669. /**
  29670. * Gets wether the color grading texture contains BGR values.
  29671. */
  29672. /**
  29673. * Sets wether the color grading texture contains BGR values.
  29674. */
  29675. colorGradingBGR: boolean;
  29676. /** @hidden */ private _exposure: number;
  29677. /**
  29678. * Gets the Exposure used in the effect.
  29679. */
  29680. /**
  29681. * Sets the Exposure used in the effect.
  29682. */
  29683. exposure: number;
  29684. private _toneMappingEnabled;
  29685. /**
  29686. * Gets wether the tone mapping effect is enabled.
  29687. */
  29688. /**
  29689. * Sets wether the tone mapping effect is enabled.
  29690. */
  29691. toneMappingEnabled: boolean;
  29692. private _toneMappingType;
  29693. /**
  29694. * Gets the type of tone mapping effect.
  29695. */
  29696. /**
  29697. * Sets the type of tone mapping effect used in BabylonJS.
  29698. */
  29699. toneMappingType: number;
  29700. protected _contrast: number;
  29701. /**
  29702. * Gets the contrast used in the effect.
  29703. */
  29704. /**
  29705. * Sets the contrast used in the effect.
  29706. */
  29707. contrast: number;
  29708. /**
  29709. * Vignette stretch size.
  29710. */
  29711. vignetteStretch: number;
  29712. /**
  29713. * Vignette centre X Offset.
  29714. */
  29715. vignetteCentreX: number;
  29716. /**
  29717. * Vignette centre Y Offset.
  29718. */
  29719. vignetteCentreY: number;
  29720. /**
  29721. * Vignette weight or intensity of the vignette effect.
  29722. */
  29723. vignetteWeight: number;
  29724. /**
  29725. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29726. * if vignetteEnabled is set to true.
  29727. */
  29728. vignetteColor: Color4;
  29729. /**
  29730. * Camera field of view used by the Vignette effect.
  29731. */
  29732. vignetteCameraFov: number;
  29733. private _vignetteBlendMode;
  29734. /**
  29735. * Gets the vignette blend mode allowing different kind of effect.
  29736. */
  29737. /**
  29738. * Sets the vignette blend mode allowing different kind of effect.
  29739. */
  29740. vignetteBlendMode: number;
  29741. private _vignetteEnabled;
  29742. /**
  29743. * Gets wether the vignette effect is enabled.
  29744. */
  29745. /**
  29746. * Sets wether the vignette effect is enabled.
  29747. */
  29748. vignetteEnabled: boolean;
  29749. private _applyByPostProcess;
  29750. /**
  29751. * Gets wether the image processing is applied through a post process or not.
  29752. */
  29753. /**
  29754. * Sets wether the image processing is applied through a post process or not.
  29755. */
  29756. applyByPostProcess: boolean;
  29757. private _isEnabled;
  29758. /**
  29759. * Gets wether the image processing is enabled or not.
  29760. */
  29761. /**
  29762. * Sets wether the image processing is enabled or not.
  29763. */
  29764. isEnabled: boolean;
  29765. /**
  29766. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29767. */
  29768. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29769. /**
  29770. * Method called each time the image processing information changes requires to recompile the effect.
  29771. */
  29772. protected _updateParameters(): void;
  29773. /**
  29774. * Gets the current class name.
  29775. * @return "ImageProcessingConfiguration"
  29776. */
  29777. getClassName(): string;
  29778. /**
  29779. * Prepare the list of uniforms associated with the Image Processing effects.
  29780. * @param uniforms The list of uniforms used in the effect
  29781. * @param defines the list of defines currently in use
  29782. */
  29783. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29784. /**
  29785. * Prepare the list of samplers associated with the Image Processing effects.
  29786. * @param samplersList The list of uniforms used in the effect
  29787. * @param defines the list of defines currently in use
  29788. */
  29789. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29790. /**
  29791. * Prepare the list of defines associated to the shader.
  29792. * @param defines the list of defines to complete
  29793. * @param forPostProcess Define if we are currently in post process mode or not
  29794. */
  29795. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29796. /**
  29797. * Returns true if all the image processing information are ready.
  29798. * @returns True if ready, otherwise, false
  29799. */
  29800. isReady(): boolean;
  29801. /**
  29802. * Binds the image processing to the shader.
  29803. * @param effect The effect to bind to
  29804. * @param aspectRatio Define the current aspect ratio of the effect
  29805. */
  29806. bind(effect: Effect, aspectRatio?: number): void;
  29807. /**
  29808. * Clones the current image processing instance.
  29809. * @return The cloned image processing
  29810. */
  29811. clone(): ImageProcessingConfiguration;
  29812. /**
  29813. * Serializes the current image processing instance to a json representation.
  29814. * @return a JSON representation
  29815. */
  29816. serialize(): any;
  29817. /**
  29818. * Parses the image processing from a json representation.
  29819. * @param source the JSON source to parse
  29820. * @return The parsed image processing
  29821. */
  29822. static Parse(source: any): ImageProcessingConfiguration;
  29823. private static _VIGNETTEMODE_MULTIPLY;
  29824. private static _VIGNETTEMODE_OPAQUE;
  29825. /**
  29826. * Used to apply the vignette as a mix with the pixel color.
  29827. */
  29828. static readonly VIGNETTEMODE_MULTIPLY: number;
  29829. /**
  29830. * Used to apply the vignette as a replacement of the pixel color.
  29831. */
  29832. static readonly VIGNETTEMODE_OPAQUE: number;
  29833. }
  29834. }
  29835. declare module BABYLON {
  29836. /**
  29837. * This represents all the required information to add a fresnel effect on a material:
  29838. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29839. */
  29840. export class FresnelParameters {
  29841. private _isEnabled;
  29842. /**
  29843. * Define if the fresnel effect is enable or not.
  29844. */
  29845. isEnabled: boolean;
  29846. /**
  29847. * Define the color used on edges (grazing angle)
  29848. */
  29849. leftColor: Color3;
  29850. /**
  29851. * Define the color used on center
  29852. */
  29853. rightColor: Color3;
  29854. /**
  29855. * Define bias applied to computed fresnel term
  29856. */
  29857. bias: number;
  29858. /**
  29859. * Defined the power exponent applied to fresnel term
  29860. */
  29861. power: number;
  29862. /**
  29863. * Clones the current fresnel and its valuues
  29864. * @returns a clone fresnel configuration
  29865. */
  29866. clone(): FresnelParameters;
  29867. /**
  29868. * Serializes the current fresnel parameters to a JSON representation.
  29869. * @return the JSON serialization
  29870. */
  29871. serialize(): any;
  29872. /**
  29873. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29874. * @param parsedFresnelParameters Define the JSON representation
  29875. * @returns the parsed parameters
  29876. */
  29877. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29878. }
  29879. }
  29880. declare module BABYLON {
  29881. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29882. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29883. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29884. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29885. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29886. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29887. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29888. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29889. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29890. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29891. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29892. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29893. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29894. /**
  29895. * Decorator used to define property that can be serialized as reference to a camera
  29896. * @param sourceName defines the name of the property to decorate
  29897. */
  29898. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29899. /**
  29900. * Class used to help serialization objects
  29901. */
  29902. export class SerializationHelper {
  29903. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29904. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29905. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29906. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29907. /**
  29908. * Appends the serialized animations from the source animations
  29909. * @param source Source containing the animations
  29910. * @param destination Target to store the animations
  29911. */
  29912. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29913. /**
  29914. * Static function used to serialized a specific entity
  29915. * @param entity defines the entity to serialize
  29916. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29917. * @returns a JSON compatible object representing the serialization of the entity
  29918. */
  29919. static Serialize<T>(entity: T, serializationObject?: any): any;
  29920. /**
  29921. * Creates a new entity from a serialization data object
  29922. * @param creationFunction defines a function used to instanciated the new entity
  29923. * @param source defines the source serialization data
  29924. * @param scene defines the hosting scene
  29925. * @param rootUrl defines the root url for resources
  29926. * @returns a new entity
  29927. */
  29928. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29929. /**
  29930. * Clones an object
  29931. * @param creationFunction defines the function used to instanciate the new object
  29932. * @param source defines the source object
  29933. * @returns the cloned object
  29934. */
  29935. static Clone<T>(creationFunction: () => T, source: T): T;
  29936. /**
  29937. * Instanciates a new object based on a source one (some data will be shared between both object)
  29938. * @param creationFunction defines the function used to instanciate the new object
  29939. * @param source defines the source object
  29940. * @returns the new object
  29941. */
  29942. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29943. }
  29944. }
  29945. declare module BABYLON {
  29946. /**
  29947. * This is the base class of all the camera used in the application.
  29948. * @see http://doc.babylonjs.com/features/cameras
  29949. */
  29950. export class Camera extends Node {
  29951. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29952. /**
  29953. * This is the default projection mode used by the cameras.
  29954. * It helps recreating a feeling of perspective and better appreciate depth.
  29955. * This is the best way to simulate real life cameras.
  29956. */
  29957. static readonly PERSPECTIVE_CAMERA: number;
  29958. /**
  29959. * This helps creating camera with an orthographic mode.
  29960. * 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.
  29961. */
  29962. static readonly ORTHOGRAPHIC_CAMERA: number;
  29963. /**
  29964. * This is the default FOV mode for perspective cameras.
  29965. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29966. */
  29967. static readonly FOVMODE_VERTICAL_FIXED: number;
  29968. /**
  29969. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29970. */
  29971. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29972. /**
  29973. * This specifies ther is no need for a camera rig.
  29974. * Basically only one eye is rendered corresponding to the camera.
  29975. */
  29976. static readonly RIG_MODE_NONE: number;
  29977. /**
  29978. * Simulates a camera Rig with one blue eye and one red eye.
  29979. * This can be use with 3d blue and red glasses.
  29980. */
  29981. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29982. /**
  29983. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29984. */
  29985. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29986. /**
  29987. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29988. */
  29989. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29990. /**
  29991. * Defines that both eyes of the camera will be rendered over under each other.
  29992. */
  29993. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29994. /**
  29995. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29996. */
  29997. static readonly RIG_MODE_VR: number;
  29998. /**
  29999. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30000. */
  30001. static readonly RIG_MODE_WEBVR: number;
  30002. /**
  30003. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30004. */
  30005. static readonly RIG_MODE_CUSTOM: number;
  30006. /**
  30007. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30008. */
  30009. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30010. /**
  30011. * Define the input manager associated with the camera.
  30012. */
  30013. inputs: CameraInputsManager<Camera>;
  30014. /** @hidden */ private _position: Vector3;
  30015. /**
  30016. * Define the current local position of the camera in the scene
  30017. */
  30018. position: Vector3;
  30019. /**
  30020. * The vector the camera should consider as up.
  30021. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30022. */
  30023. upVector: Vector3;
  30024. /**
  30025. * Define the current limit on the left side for an orthographic camera
  30026. * In scene unit
  30027. */
  30028. orthoLeft: Nullable<number>;
  30029. /**
  30030. * Define the current limit on the right side for an orthographic camera
  30031. * In scene unit
  30032. */
  30033. orthoRight: Nullable<number>;
  30034. /**
  30035. * Define the current limit on the bottom side for an orthographic camera
  30036. * In scene unit
  30037. */
  30038. orthoBottom: Nullable<number>;
  30039. /**
  30040. * Define the current limit on the top side for an orthographic camera
  30041. * In scene unit
  30042. */
  30043. orthoTop: Nullable<number>;
  30044. /**
  30045. * Field Of View is set in Radians. (default is 0.8)
  30046. */
  30047. fov: number;
  30048. /**
  30049. * Define the minimum distance the camera can see from.
  30050. * This is important to note that the depth buffer are not infinite and the closer it starts
  30051. * the more your scene might encounter depth fighting issue.
  30052. */
  30053. minZ: number;
  30054. /**
  30055. * Define the maximum distance the camera can see to.
  30056. * This is important to note that the depth buffer are not infinite and the further it end
  30057. * the more your scene might encounter depth fighting issue.
  30058. */
  30059. maxZ: number;
  30060. /**
  30061. * Define the default inertia of the camera.
  30062. * This helps giving a smooth feeling to the camera movement.
  30063. */
  30064. inertia: number;
  30065. /**
  30066. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30067. */
  30068. mode: number;
  30069. /**
  30070. * Define wether the camera is intermediate.
  30071. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30072. */
  30073. isIntermediate: boolean;
  30074. /**
  30075. * Define the viewport of the camera.
  30076. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30077. */
  30078. viewport: Viewport;
  30079. /**
  30080. * Restricts the camera to viewing objects with the same layerMask.
  30081. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30082. */
  30083. layerMask: number;
  30084. /**
  30085. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30086. */
  30087. fovMode: number;
  30088. /**
  30089. * Rig mode of the camera.
  30090. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30091. * This is normally controlled byt the camera themselves as internal use.
  30092. */
  30093. cameraRigMode: number;
  30094. /**
  30095. * Defines the distance between both "eyes" in case of a RIG
  30096. */
  30097. interaxialDistance: number;
  30098. /**
  30099. * Defines if stereoscopic rendering is done side by side or over under.
  30100. */
  30101. isStereoscopicSideBySide: boolean;
  30102. /**
  30103. * 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
  30104. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30105. * else in the scene.
  30106. */
  30107. customRenderTargets: RenderTargetTexture[];
  30108. /**
  30109. * When set, the camera will render to this render target instead of the default canvas
  30110. */
  30111. outputRenderTarget: Nullable<RenderTargetTexture>;
  30112. /**
  30113. * Observable triggered when the camera view matrix has changed.
  30114. */
  30115. onViewMatrixChangedObservable: Observable<Camera>;
  30116. /**
  30117. * Observable triggered when the camera Projection matrix has changed.
  30118. */
  30119. onProjectionMatrixChangedObservable: Observable<Camera>;
  30120. /**
  30121. * Observable triggered when the inputs have been processed.
  30122. */
  30123. onAfterCheckInputsObservable: Observable<Camera>;
  30124. /**
  30125. * Observable triggered when reset has been called and applied to the camera.
  30126. */
  30127. onRestoreStateObservable: Observable<Camera>;
  30128. /** @hidden */ private _cameraRigParams: any;
  30129. /** @hidden */ private _rigCameras: Camera[];
  30130. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  30131. protected _webvrViewMatrix: Matrix;
  30132. /** @hidden */ private _skipRendering: boolean;
  30133. /** @hidden */ private _projectionMatrix: Matrix;
  30134. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  30135. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  30136. protected _globalPosition: Vector3;
  30137. /** @hidden */ private _computedViewMatrix: Matrix;
  30138. private _doNotComputeProjectionMatrix;
  30139. private _transformMatrix;
  30140. private _frustumPlanes;
  30141. private _refreshFrustumPlanes;
  30142. private _storedFov;
  30143. private _stateStored;
  30144. /**
  30145. * Instantiates a new camera object.
  30146. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30147. * @see http://doc.babylonjs.com/features/cameras
  30148. * @param name Defines the name of the camera in the scene
  30149. * @param position Defines the position of the camera
  30150. * @param scene Defines the scene the camera belongs too
  30151. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30152. */
  30153. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30154. /**
  30155. * Store current camera state (fov, position, etc..)
  30156. * @returns the camera
  30157. */
  30158. storeState(): Camera;
  30159. /**
  30160. * Restores the camera state values if it has been stored. You must call storeState() first
  30161. */
  30162. protected _restoreStateValues(): boolean;
  30163. /**
  30164. * Restored camera state. You must call storeState() first.
  30165. * @returns true if restored and false otherwise
  30166. */
  30167. restoreState(): boolean;
  30168. /**
  30169. * Gets the class name of the camera.
  30170. * @returns the class name
  30171. */
  30172. getClassName(): string;
  30173. /** @hidden */ protected readonly _isCamera: boolean;
  30174. /**
  30175. * Gets a string representation of the camera useful for debug purpose.
  30176. * @param fullDetails Defines that a more verboe level of logging is required
  30177. * @returns the string representation
  30178. */
  30179. toString(fullDetails?: boolean): string;
  30180. /**
  30181. * Gets the current world space position of the camera.
  30182. */
  30183. readonly globalPosition: Vector3;
  30184. /**
  30185. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30186. * @returns the active meshe list
  30187. */
  30188. getActiveMeshes(): SmartArray<AbstractMesh>;
  30189. /**
  30190. * Check wether a mesh is part of the current active mesh list of the camera
  30191. * @param mesh Defines the mesh to check
  30192. * @returns true if active, false otherwise
  30193. */
  30194. isActiveMesh(mesh: Mesh): boolean;
  30195. /**
  30196. * Is this camera ready to be used/rendered
  30197. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30198. * @return true if the camera is ready
  30199. */
  30200. isReady(completeCheck?: boolean): boolean;
  30201. /** @hidden */ private _initCache(): void;
  30202. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  30203. /** @hidden */ private _isSynchronized(): boolean;
  30204. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  30205. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  30206. /**
  30207. * Attach the input controls to a specific dom element to get the input from.
  30208. * @param element Defines the element the controls should be listened from
  30209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30210. */
  30211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30212. /**
  30213. * Detach the current controls from the specified dom element.
  30214. * @param element Defines the element to stop listening the inputs from
  30215. */
  30216. detachControl(element: HTMLElement): void;
  30217. /**
  30218. * Update the camera state according to the different inputs gathered during the frame.
  30219. */
  30220. update(): void;
  30221. /** @hidden */ private _checkInputs(): void;
  30222. /** @hidden */
  30223. readonly rigCameras: Camera[];
  30224. /**
  30225. * Gets the post process used by the rig cameras
  30226. */
  30227. readonly rigPostProcess: Nullable<PostProcess>;
  30228. /**
  30229. * Internal, gets the first post proces.
  30230. * @returns the first post process to be run on this camera.
  30231. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  30232. private _cascadePostProcessesToRigCams;
  30233. /**
  30234. * Attach a post process to the camera.
  30235. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30236. * @param postProcess The post process to attach to the camera
  30237. * @param insertAt The position of the post process in case several of them are in use in the scene
  30238. * @returns the position the post process has been inserted at
  30239. */
  30240. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30241. /**
  30242. * Detach a post process to the camera.
  30243. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30244. * @param postProcess The post process to detach from the camera
  30245. */
  30246. detachPostProcess(postProcess: PostProcess): void;
  30247. /**
  30248. * Gets the current world matrix of the camera
  30249. */
  30250. getWorldMatrix(): Matrix;
  30251. /** @hidden */ private _getViewMatrix(): Matrix;
  30252. /**
  30253. * Gets the current view matrix of the camera.
  30254. * @param force forces the camera to recompute the matrix without looking at the cached state
  30255. * @returns the view matrix
  30256. */
  30257. getViewMatrix(force?: boolean): Matrix;
  30258. /**
  30259. * Freeze the projection matrix.
  30260. * It will prevent the cache check of the camera projection compute and can speed up perf
  30261. * if no parameter of the camera are meant to change
  30262. * @param projection Defines manually a projection if necessary
  30263. */
  30264. freezeProjectionMatrix(projection?: Matrix): void;
  30265. /**
  30266. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30267. */
  30268. unfreezeProjectionMatrix(): void;
  30269. /**
  30270. * Gets the current projection matrix of the camera.
  30271. * @param force forces the camera to recompute the matrix without looking at the cached state
  30272. * @returns the projection matrix
  30273. */
  30274. getProjectionMatrix(force?: boolean): Matrix;
  30275. /**
  30276. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30277. * @returns a Matrix
  30278. */
  30279. getTransformationMatrix(): Matrix;
  30280. private _updateFrustumPlanes;
  30281. /**
  30282. * Checks if a cullable object (mesh...) is in the camera frustum
  30283. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30284. * @param target The object to check
  30285. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30286. * @returns true if the object is in frustum otherwise false
  30287. */
  30288. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30289. /**
  30290. * Checks if a cullable object (mesh...) is in the camera frustum
  30291. * Unlike isInFrustum this cheks the full bounding box
  30292. * @param target The object to check
  30293. * @returns true if the object is in frustum otherwise false
  30294. */
  30295. isCompletelyInFrustum(target: ICullable): boolean;
  30296. /**
  30297. * Gets a ray in the forward direction from the camera.
  30298. * @param length Defines the length of the ray to create
  30299. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30300. * @param origin Defines the start point of the ray which defaults to the camera position
  30301. * @returns the forward ray
  30302. */
  30303. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30304. /**
  30305. * Releases resources associated with this node.
  30306. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30307. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30308. */
  30309. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30310. /** @hidden */ private _isLeftCamera: boolean;
  30311. /**
  30312. * Gets the left camera of a rig setup in case of Rigged Camera
  30313. */
  30314. readonly isLeftCamera: boolean;
  30315. /** @hidden */ private _isRightCamera: boolean;
  30316. /**
  30317. * Gets the right camera of a rig setup in case of Rigged Camera
  30318. */
  30319. readonly isRightCamera: boolean;
  30320. /**
  30321. * Gets the left camera of a rig setup in case of Rigged Camera
  30322. */
  30323. readonly leftCamera: Nullable<FreeCamera>;
  30324. /**
  30325. * Gets the right camera of a rig setup in case of Rigged Camera
  30326. */
  30327. readonly rightCamera: Nullable<FreeCamera>;
  30328. /**
  30329. * Gets the left camera target of a rig setup in case of Rigged Camera
  30330. * @returns the target position
  30331. */
  30332. getLeftTarget(): Nullable<Vector3>;
  30333. /**
  30334. * Gets the right camera target of a rig setup in case of Rigged Camera
  30335. * @returns the target position
  30336. */
  30337. getRightTarget(): Nullable<Vector3>;
  30338. /**
  30339. * @hidden
  30340. */
  30341. setCameraRigMode(mode: number, rigParams: any): void;
  30342. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30343. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30344. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30345. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30346. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  30347. protected _updateCameraRotationMatrix(): void;
  30348. protected _updateWebVRCameraRotationMatrix(): void;
  30349. /**
  30350. * This function MUST be overwritten by the different WebVR cameras available.
  30351. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30352. * @hidden
  30353. */ private _getWebVRProjectionMatrix(): Matrix;
  30354. /**
  30355. * This function MUST be overwritten by the different WebVR cameras available.
  30356. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30357. * @hidden
  30358. */ private _getWebVRViewMatrix(): Matrix;
  30359. /** @hidden */
  30360. setCameraRigParameter(name: string, value: any): void;
  30361. /**
  30362. * needs to be overridden by children so sub has required properties to be copied
  30363. * @hidden
  30364. */
  30365. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30366. /**
  30367. * May need to be overridden by children
  30368. * @hidden
  30369. */ private _updateRigCameras(): void;
  30370. /** @hidden */ private _setupInputs(): void;
  30371. /**
  30372. * Serialiaze the camera setup to a json represention
  30373. * @returns the JSON representation
  30374. */
  30375. serialize(): any;
  30376. /**
  30377. * Clones the current camera.
  30378. * @param name The cloned camera name
  30379. * @returns the cloned camera
  30380. */
  30381. clone(name: string): Camera;
  30382. /**
  30383. * Gets the direction of the camera relative to a given local axis.
  30384. * @param localAxis Defines the reference axis to provide a relative direction.
  30385. * @return the direction
  30386. */
  30387. getDirection(localAxis: Vector3): Vector3;
  30388. /**
  30389. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30390. * @param localAxis Defines the reference axis to provide a relative direction.
  30391. * @param result Defines the vector to store the result in
  30392. */
  30393. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30394. /**
  30395. * Gets a camera constructor for a given camera type
  30396. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30397. * @param name The name of the camera the result will be able to instantiate
  30398. * @param scene The scene the result will construct the camera in
  30399. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30400. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30401. * @returns a factory method to construc the camera
  30402. */
  30403. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30404. /**
  30405. * Compute the world matrix of the camera.
  30406. * @returns the camera workd matrix
  30407. */
  30408. computeWorldMatrix(): Matrix;
  30409. /**
  30410. * Parse a JSON and creates the camera from the parsed information
  30411. * @param parsedCamera The JSON to parse
  30412. * @param scene The scene to instantiate the camera in
  30413. * @returns the newly constructed camera
  30414. */
  30415. static Parse(parsedCamera: any, scene: Scene): Camera;
  30416. }
  30417. }
  30418. declare module BABYLON {
  30419. /**
  30420. * Interface for any object that can request an animation frame
  30421. */
  30422. export interface ICustomAnimationFrameRequester {
  30423. /**
  30424. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30425. */
  30426. renderFunction?: Function;
  30427. /**
  30428. * Called to request the next frame to render to
  30429. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30430. */
  30431. requestAnimationFrame: Function;
  30432. /**
  30433. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30434. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30435. */
  30436. requestID?: number;
  30437. }
  30438. /**
  30439. * Interface containing an array of animations
  30440. */
  30441. export interface IAnimatable {
  30442. /**
  30443. * Array of animations
  30444. */
  30445. animations: Nullable<Array<Animation>>;
  30446. }
  30447. /** Interface used by value gradients (color, factor, ...) */
  30448. export interface IValueGradient {
  30449. /**
  30450. * Gets or sets the gradient value (between 0 and 1)
  30451. */
  30452. gradient: number;
  30453. }
  30454. /** Class used to store color4 gradient */
  30455. export class ColorGradient implements IValueGradient {
  30456. /**
  30457. * Gets or sets the gradient value (between 0 and 1)
  30458. */
  30459. gradient: number;
  30460. /**
  30461. * Gets or sets first associated color
  30462. */
  30463. color1: Color4;
  30464. /**
  30465. * Gets or sets second associated color
  30466. */
  30467. color2?: Color4;
  30468. /**
  30469. * Will get a color picked randomly between color1 and color2.
  30470. * If color2 is undefined then color1 will be used
  30471. * @param result defines the target Color4 to store the result in
  30472. */
  30473. getColorToRef(result: Color4): void;
  30474. }
  30475. /** Class used to store color 3 gradient */
  30476. export class Color3Gradient implements IValueGradient {
  30477. /**
  30478. * Gets or sets the gradient value (between 0 and 1)
  30479. */
  30480. gradient: number;
  30481. /**
  30482. * Gets or sets the associated color
  30483. */
  30484. color: Color3;
  30485. }
  30486. /** Class used to store factor gradient */
  30487. export class FactorGradient implements IValueGradient {
  30488. /**
  30489. * Gets or sets the gradient value (between 0 and 1)
  30490. */
  30491. gradient: number;
  30492. /**
  30493. * Gets or sets first associated factor
  30494. */
  30495. factor1: number;
  30496. /**
  30497. * Gets or sets second associated factor
  30498. */
  30499. factor2?: number;
  30500. /**
  30501. * Will get a number picked randomly between factor1 and factor2.
  30502. * If factor2 is undefined then factor1 will be used
  30503. * @returns the picked number
  30504. */
  30505. getFactor(): number;
  30506. }
  30507. /**
  30508. * @ignore
  30509. * Application error to support additional information when loading a file
  30510. */
  30511. export class LoadFileError extends Error {
  30512. /** defines the optional web request */
  30513. request?: WebRequest | undefined;
  30514. private static _setPrototypeOf;
  30515. /**
  30516. * Creates a new LoadFileError
  30517. * @param message defines the message of the error
  30518. * @param request defines the optional web request
  30519. */
  30520. constructor(message: string,
  30521. /** defines the optional web request */
  30522. request?: WebRequest | undefined);
  30523. }
  30524. /**
  30525. * Class used to define a retry strategy when error happens while loading assets
  30526. */
  30527. export class RetryStrategy {
  30528. /**
  30529. * Function used to defines an exponential back off strategy
  30530. * @param maxRetries defines the maximum number of retries (3 by default)
  30531. * @param baseInterval defines the interval between retries
  30532. * @returns the strategy function to use
  30533. */
  30534. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30535. }
  30536. /**
  30537. * File request interface
  30538. */
  30539. export interface IFileRequest {
  30540. /**
  30541. * Raised when the request is complete (success or error).
  30542. */
  30543. onCompleteObservable: Observable<IFileRequest>;
  30544. /**
  30545. * Aborts the request for a file.
  30546. */
  30547. abort: () => void;
  30548. }
  30549. /**
  30550. * Class containing a set of static utilities functions
  30551. */
  30552. export class Tools {
  30553. /**
  30554. * Gets or sets the base URL to use to load assets
  30555. */
  30556. static BaseUrl: string;
  30557. /**
  30558. * Enable/Disable Custom HTTP Request Headers globally.
  30559. * default = false
  30560. * @see CustomRequestHeaders
  30561. */
  30562. static UseCustomRequestHeaders: boolean;
  30563. /**
  30564. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30565. * i.e. when loading files, where the server/service expects an Authorization header
  30566. */
  30567. static CustomRequestHeaders: {
  30568. [key: string]: string;
  30569. };
  30570. /**
  30571. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30572. */
  30573. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30574. /**
  30575. * Default behaviour for cors in the application.
  30576. * It can be a string if the expected behavior is identical in the entire app.
  30577. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30578. */
  30579. static CorsBehavior: string | ((url: string | string[]) => string);
  30580. /**
  30581. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30582. * @ignorenaming
  30583. */
  30584. static UseFallbackTexture: boolean;
  30585. /**
  30586. * Use this object to register external classes like custom textures or material
  30587. * to allow the laoders to instantiate them
  30588. */
  30589. static RegisteredExternalClasses: {
  30590. [key: string]: Object;
  30591. };
  30592. /**
  30593. * Texture content used if a texture cannot loaded
  30594. * @ignorenaming
  30595. */
  30596. static fallbackTexture: string;
  30597. /**
  30598. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30599. * @param u defines the coordinate on X axis
  30600. * @param v defines the coordinate on Y axis
  30601. * @param width defines the width of the source data
  30602. * @param height defines the height of the source data
  30603. * @param pixels defines the source byte array
  30604. * @param color defines the output color
  30605. */
  30606. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30607. /**
  30608. * Interpolates between a and b via alpha
  30609. * @param a The lower value (returned when alpha = 0)
  30610. * @param b The upper value (returned when alpha = 1)
  30611. * @param alpha The interpolation-factor
  30612. * @return The mixed value
  30613. */
  30614. static Mix(a: number, b: number, alpha: number): number;
  30615. /**
  30616. * Tries to instantiate a new object from a given class name
  30617. * @param className defines the class name to instantiate
  30618. * @returns the new object or null if the system was not able to do the instantiation
  30619. */
  30620. static Instantiate(className: string): any;
  30621. /**
  30622. * Provides a slice function that will work even on IE
  30623. * @param data defines the array to slice
  30624. * @param start defines the start of the data (optional)
  30625. * @param end defines the end of the data (optional)
  30626. * @returns the new sliced array
  30627. */
  30628. static Slice<T>(data: T, start?: number, end?: number): T;
  30629. /**
  30630. * Polyfill for setImmediate
  30631. * @param action defines the action to execute after the current execution block
  30632. */
  30633. static SetImmediate(action: () => void): void;
  30634. /**
  30635. * Function indicating if a number is an exponent of 2
  30636. * @param value defines the value to test
  30637. * @returns true if the value is an exponent of 2
  30638. */
  30639. static IsExponentOfTwo(value: number): boolean;
  30640. private static _tmpFloatArray;
  30641. /**
  30642. * Returns the nearest 32-bit single precision float representation of a Number
  30643. * @param value A Number. If the parameter is of a different type, it will get converted
  30644. * to a number or to NaN if it cannot be converted
  30645. * @returns number
  30646. */
  30647. static FloatRound(value: number): number;
  30648. /**
  30649. * Find the next highest power of two.
  30650. * @param x Number to start search from.
  30651. * @return Next highest power of two.
  30652. */
  30653. static CeilingPOT(x: number): number;
  30654. /**
  30655. * Find the next lowest power of two.
  30656. * @param x Number to start search from.
  30657. * @return Next lowest power of two.
  30658. */
  30659. static FloorPOT(x: number): number;
  30660. /**
  30661. * Find the nearest power of two.
  30662. * @param x Number to start search from.
  30663. * @return Next nearest power of two.
  30664. */
  30665. static NearestPOT(x: number): number;
  30666. /**
  30667. * Get the closest exponent of two
  30668. * @param value defines the value to approximate
  30669. * @param max defines the maximum value to return
  30670. * @param mode defines how to define the closest value
  30671. * @returns closest exponent of two of the given value
  30672. */
  30673. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30674. /**
  30675. * Extracts the filename from a path
  30676. * @param path defines the path to use
  30677. * @returns the filename
  30678. */
  30679. static GetFilename(path: string): string;
  30680. /**
  30681. * Extracts the "folder" part of a path (everything before the filename).
  30682. * @param uri The URI to extract the info from
  30683. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30684. * @returns The "folder" part of the path
  30685. */
  30686. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30687. /**
  30688. * Extracts text content from a DOM element hierarchy
  30689. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30690. */
  30691. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30692. /**
  30693. * Convert an angle in radians to degrees
  30694. * @param angle defines the angle to convert
  30695. * @returns the angle in degrees
  30696. */
  30697. static ToDegrees(angle: number): number;
  30698. /**
  30699. * Convert an angle in degrees to radians
  30700. * @param angle defines the angle to convert
  30701. * @returns the angle in radians
  30702. */
  30703. static ToRadians(angle: number): number;
  30704. /**
  30705. * Encode a buffer to a base64 string
  30706. * @param buffer defines the buffer to encode
  30707. * @returns the encoded string
  30708. */
  30709. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30710. /**
  30711. * Extracts minimum and maximum values from a list of indexed positions
  30712. * @param positions defines the positions to use
  30713. * @param indices defines the indices to the positions
  30714. * @param indexStart defines the start index
  30715. * @param indexCount defines the end index
  30716. * @param bias defines bias value to add to the result
  30717. * @return minimum and maximum values
  30718. */
  30719. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30720. minimum: Vector3;
  30721. maximum: Vector3;
  30722. };
  30723. /**
  30724. * Extracts minimum and maximum values from a list of positions
  30725. * @param positions defines the positions to use
  30726. * @param start defines the start index in the positions array
  30727. * @param count defines the number of positions to handle
  30728. * @param bias defines bias value to add to the result
  30729. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30730. * @return minimum and maximum values
  30731. */
  30732. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30733. minimum: Vector3;
  30734. maximum: Vector3;
  30735. };
  30736. /**
  30737. * Returns an array if obj is not an array
  30738. * @param obj defines the object to evaluate as an array
  30739. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30740. * @returns either obj directly if obj is an array or a new array containing obj
  30741. */
  30742. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30743. /**
  30744. * Gets the pointer prefix to use
  30745. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30746. */
  30747. static GetPointerPrefix(): string;
  30748. /**
  30749. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30750. * @param func - the function to be called
  30751. * @param requester - the object that will request the next frame. Falls back to window.
  30752. * @returns frame number
  30753. */
  30754. static QueueNewFrame(func: () => void, requester?: any): number;
  30755. /**
  30756. * Ask the browser to promote the current element to fullscreen rendering mode
  30757. * @param element defines the DOM element to promote
  30758. */
  30759. static RequestFullscreen(element: HTMLElement): void;
  30760. /**
  30761. * Asks the browser to exit fullscreen mode
  30762. */
  30763. static ExitFullscreen(): void;
  30764. /**
  30765. * Ask the browser to promote the current element to pointerlock mode
  30766. * @param element defines the DOM element to promote
  30767. */
  30768. static RequestPointerlock(element: HTMLElement): void;
  30769. /**
  30770. * Asks the browser to exit pointerlock mode
  30771. */
  30772. static ExitPointerlock(): void;
  30773. /**
  30774. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30775. * @param url define the url we are trying
  30776. * @param element define the dom element where to configure the cors policy
  30777. */
  30778. static SetCorsBehavior(url: string | string[], element: {
  30779. crossOrigin: string | null;
  30780. }): void;
  30781. /**
  30782. * Removes unwanted characters from an url
  30783. * @param url defines the url to clean
  30784. * @returns the cleaned url
  30785. */
  30786. static CleanUrl(url: string): string;
  30787. /**
  30788. * Gets or sets a function used to pre-process url before using them to load assets
  30789. */
  30790. static PreprocessUrl: (url: string) => string;
  30791. /**
  30792. * Loads an image as an HTMLImageElement.
  30793. * @param input url string, ArrayBuffer, or Blob to load
  30794. * @param onLoad callback called when the image successfully loads
  30795. * @param onError callback called when the image fails to load
  30796. * @param offlineProvider offline provider for caching
  30797. * @returns the HTMLImageElement of the loaded image
  30798. */
  30799. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30800. /**
  30801. * Loads a file
  30802. * @param url url string, ArrayBuffer, or Blob to load
  30803. * @param onSuccess callback called when the file successfully loads
  30804. * @param onProgress callback called while file is loading (if the server supports this mode)
  30805. * @param offlineProvider defines the offline provider for caching
  30806. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30807. * @param onError callback called when the file fails to load
  30808. * @returns a file request object
  30809. */
  30810. 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;
  30811. /**
  30812. * Loads a file from a url
  30813. * @param url the file url to load
  30814. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  30815. */
  30816. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  30817. /**
  30818. * Load a script (identified by an url). When the url returns, the
  30819. * content of this file is added into a new script element, attached to the DOM (body element)
  30820. * @param scriptUrl defines the url of the script to laod
  30821. * @param onSuccess defines the callback called when the script is loaded
  30822. * @param onError defines the callback to call if an error occurs
  30823. * @param scriptId defines the id of the script element
  30824. */
  30825. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30826. /**
  30827. * Load an asynchronous script (identified by an url). When the url returns, the
  30828. * content of this file is added into a new script element, attached to the DOM (body element)
  30829. * @param scriptUrl defines the url of the script to laod
  30830. * @param scriptId defines the id of the script element
  30831. * @returns a promise request object
  30832. */
  30833. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  30834. /**
  30835. * Loads a file from a blob
  30836. * @param fileToLoad defines the blob to use
  30837. * @param callback defines the callback to call when data is loaded
  30838. * @param progressCallback defines the callback to call during loading process
  30839. * @returns a file request object
  30840. */
  30841. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30842. /**
  30843. * Loads a file
  30844. * @param fileToLoad defines the file to load
  30845. * @param callback defines the callback to call when data is loaded
  30846. * @param progressCallBack defines the callback to call during loading process
  30847. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30848. * @returns a file request object
  30849. */
  30850. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30851. /**
  30852. * Creates a data url from a given string content
  30853. * @param content defines the content to convert
  30854. * @returns the new data url link
  30855. */
  30856. static FileAsURL(content: string): string;
  30857. /**
  30858. * Format the given number to a specific decimal format
  30859. * @param value defines the number to format
  30860. * @param decimals defines the number of decimals to use
  30861. * @returns the formatted string
  30862. */
  30863. static Format(value: number, decimals?: number): string;
  30864. /**
  30865. * Checks if a given vector is inside a specific range
  30866. * @param v defines the vector to test
  30867. * @param min defines the minimum range
  30868. * @param max defines the maximum range
  30869. */
  30870. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30871. /**
  30872. * Tries to copy an object by duplicating every property
  30873. * @param source defines the source object
  30874. * @param destination defines the target object
  30875. * @param doNotCopyList defines a list of properties to avoid
  30876. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30877. */
  30878. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30879. /**
  30880. * Gets a boolean indicating if the given object has no own property
  30881. * @param obj defines the object to test
  30882. * @returns true if object has no own property
  30883. */
  30884. static IsEmpty(obj: any): boolean;
  30885. /**
  30886. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30887. * @param str Source string
  30888. * @param suffix Suffix to search for in the source string
  30889. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30890. */
  30891. static EndsWith(str: string, suffix: string): boolean;
  30892. /**
  30893. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  30894. * @param str Source string
  30895. * @param suffix Suffix to search for in the source string
  30896. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30897. */
  30898. static StartsWith(str: string, suffix: string): boolean;
  30899. /**
  30900. * Function used to register events at window level
  30901. * @param events defines the events to register
  30902. */
  30903. static RegisterTopRootEvents(events: {
  30904. name: string;
  30905. handler: Nullable<(e: FocusEvent) => any>;
  30906. }[]): void;
  30907. /**
  30908. * Function used to unregister events from window level
  30909. * @param events defines the events to unregister
  30910. */
  30911. static UnregisterTopRootEvents(events: {
  30912. name: string;
  30913. handler: Nullable<(e: FocusEvent) => any>;
  30914. }[]): void;
  30915. /**
  30916. * @ignore
  30917. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30918. /**
  30919. * Dumps the current bound framebuffer
  30920. * @param width defines the rendering width
  30921. * @param height defines the rendering height
  30922. * @param engine defines the hosting engine
  30923. * @param successCallback defines the callback triggered once the data are available
  30924. * @param mimeType defines the mime type of the result
  30925. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30926. */
  30927. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30928. /**
  30929. * Converts the canvas data to blob.
  30930. * This acts as a polyfill for browsers not supporting the to blob function.
  30931. * @param canvas Defines the canvas to extract the data from
  30932. * @param successCallback Defines the callback triggered once the data are available
  30933. * @param mimeType Defines the mime type of the result
  30934. */
  30935. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30936. /**
  30937. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30938. * @param successCallback defines the callback triggered once the data are available
  30939. * @param mimeType defines the mime type of the result
  30940. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30941. */
  30942. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30943. /**
  30944. * Downloads a blob in the browser
  30945. * @param blob defines the blob to download
  30946. * @param fileName defines the name of the downloaded file
  30947. */
  30948. static Download(blob: Blob, fileName: string): void;
  30949. /**
  30950. * Captures a screenshot of the current rendering
  30951. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30952. * @param engine defines the rendering engine
  30953. * @param camera defines the source camera
  30954. * @param size This parameter can be set to a single number or to an object with the
  30955. * following (optional) properties: precision, width, height. If a single number is passed,
  30956. * it will be used for both width and height. If an object is passed, the screenshot size
  30957. * will be derived from the parameters. The precision property is a multiplier allowing
  30958. * rendering at a higher or lower resolution
  30959. * @param successCallback defines the callback receives a single parameter which contains the
  30960. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30961. * src parameter of an <img> to display it
  30962. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30963. * Check your browser for supported MIME types
  30964. */
  30965. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30966. /**
  30967. * Generates an image screenshot from the specified camera.
  30968. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30969. * @param engine The engine to use for rendering
  30970. * @param camera The camera to use for rendering
  30971. * @param size This parameter can be set to a single number or to an object with the
  30972. * following (optional) properties: precision, width, height. If a single number is passed,
  30973. * it will be used for both width and height. If an object is passed, the screenshot size
  30974. * will be derived from the parameters. The precision property is a multiplier allowing
  30975. * rendering at a higher or lower resolution
  30976. * @param successCallback The callback receives a single parameter which contains the
  30977. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30978. * src parameter of an <img> to display it
  30979. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30980. * Check your browser for supported MIME types
  30981. * @param samples Texture samples (default: 1)
  30982. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30983. * @param fileName A name for for the downloaded file.
  30984. */
  30985. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30986. /**
  30987. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30988. * Be aware Math.random() could cause collisions, but:
  30989. * "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"
  30990. * @returns a pseudo random id
  30991. */
  30992. static RandomId(): string;
  30993. /**
  30994. * Test if the given uri is a base64 string
  30995. * @param uri The uri to test
  30996. * @return True if the uri is a base64 string or false otherwise
  30997. */
  30998. static IsBase64(uri: string): boolean;
  30999. /**
  31000. * Decode the given base64 uri.
  31001. * @param uri The uri to decode
  31002. * @return The decoded base64 data.
  31003. */
  31004. static DecodeBase64(uri: string): ArrayBuffer;
  31005. /**
  31006. * Gets the absolute url.
  31007. * @param url the input url
  31008. * @return the absolute url
  31009. */
  31010. static GetAbsoluteUrl(url: string): string;
  31011. /**
  31012. * No log
  31013. */
  31014. static readonly NoneLogLevel: number;
  31015. /**
  31016. * Only message logs
  31017. */
  31018. static readonly MessageLogLevel: number;
  31019. /**
  31020. * Only warning logs
  31021. */
  31022. static readonly WarningLogLevel: number;
  31023. /**
  31024. * Only error logs
  31025. */
  31026. static readonly ErrorLogLevel: number;
  31027. /**
  31028. * All logs
  31029. */
  31030. static readonly AllLogLevel: number;
  31031. /**
  31032. * Gets a value indicating the number of loading errors
  31033. * @ignorenaming
  31034. */
  31035. static readonly errorsCount: number;
  31036. /**
  31037. * Callback called when a new log is added
  31038. */
  31039. static OnNewCacheEntry: (entry: string) => void;
  31040. /**
  31041. * Log a message to the console
  31042. * @param message defines the message to log
  31043. */
  31044. static Log(message: string): void;
  31045. /**
  31046. * Write a warning message to the console
  31047. * @param message defines the message to log
  31048. */
  31049. static Warn(message: string): void;
  31050. /**
  31051. * Write an error message to the console
  31052. * @param message defines the message to log
  31053. */
  31054. static Error(message: string): void;
  31055. /**
  31056. * Gets current log cache (list of logs)
  31057. */
  31058. static readonly LogCache: string;
  31059. /**
  31060. * Clears the log cache
  31061. */
  31062. static ClearLogCache(): void;
  31063. /**
  31064. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31065. */
  31066. static LogLevels: number;
  31067. /**
  31068. * Checks if the loaded document was accessed via `file:`-Protocol.
  31069. * @returns boolean
  31070. */
  31071. static IsFileURL(): boolean;
  31072. /**
  31073. * Checks if the window object exists
  31074. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31075. */
  31076. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31077. /**
  31078. * No performance log
  31079. */
  31080. static readonly PerformanceNoneLogLevel: number;
  31081. /**
  31082. * Use user marks to log performance
  31083. */
  31084. static readonly PerformanceUserMarkLogLevel: number;
  31085. /**
  31086. * Log performance to the console
  31087. */
  31088. static readonly PerformanceConsoleLogLevel: number;
  31089. private static _performance;
  31090. /**
  31091. * Sets the current performance log level
  31092. */
  31093. static PerformanceLogLevel: number;
  31094. private static _StartPerformanceCounterDisabled;
  31095. private static _EndPerformanceCounterDisabled;
  31096. private static _StartUserMark;
  31097. private static _EndUserMark;
  31098. private static _StartPerformanceConsole;
  31099. private static _EndPerformanceConsole;
  31100. /**
  31101. * Starts a performance counter
  31102. */
  31103. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31104. /**
  31105. * Ends a specific performance coutner
  31106. */
  31107. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31108. /**
  31109. * Gets either window.performance.now() if supported or Date.now() else
  31110. */
  31111. static readonly Now: number;
  31112. /**
  31113. * This method will return the name of the class used to create the instance of the given object.
  31114. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31115. * @param object the object to get the class name from
  31116. * @param isType defines if the object is actually a type
  31117. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31118. */
  31119. static GetClassName(object: any, isType?: boolean): string;
  31120. /**
  31121. * Gets the first element of an array satisfying a given predicate
  31122. * @param array defines the array to browse
  31123. * @param predicate defines the predicate to use
  31124. * @returns null if not found or the element
  31125. */
  31126. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31127. /**
  31128. * This method will return the name of the full name of the class, including its owning module (if any).
  31129. * 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).
  31130. * @param object the object to get the class name from
  31131. * @param isType defines if the object is actually a type
  31132. * @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.
  31133. * @ignorenaming
  31134. */
  31135. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31136. /**
  31137. * Returns a promise that resolves after the given amount of time.
  31138. * @param delay Number of milliseconds to delay
  31139. * @returns Promise that resolves after the given amount of time
  31140. */
  31141. static DelayAsync(delay: number): Promise<void>;
  31142. /**
  31143. * Gets the current gradient from an array of IValueGradient
  31144. * @param ratio defines the current ratio to get
  31145. * @param gradients defines the array of IValueGradient
  31146. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31147. */
  31148. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31149. }
  31150. /**
  31151. * This class is used to track a performance counter which is number based.
  31152. * The user has access to many properties which give statistics of different nature.
  31153. *
  31154. * The implementer can track two kinds of Performance Counter: time and count.
  31155. * 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.
  31156. * 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.
  31157. */
  31158. export class PerfCounter {
  31159. /**
  31160. * Gets or sets a global boolean to turn on and off all the counters
  31161. */
  31162. static Enabled: boolean;
  31163. /**
  31164. * Returns the smallest value ever
  31165. */
  31166. readonly min: number;
  31167. /**
  31168. * Returns the biggest value ever
  31169. */
  31170. readonly max: number;
  31171. /**
  31172. * Returns the average value since the performance counter is running
  31173. */
  31174. readonly average: number;
  31175. /**
  31176. * Returns the average value of the last second the counter was monitored
  31177. */
  31178. readonly lastSecAverage: number;
  31179. /**
  31180. * Returns the current value
  31181. */
  31182. readonly current: number;
  31183. /**
  31184. * Gets the accumulated total
  31185. */
  31186. readonly total: number;
  31187. /**
  31188. * Gets the total value count
  31189. */
  31190. readonly count: number;
  31191. /**
  31192. * Creates a new counter
  31193. */
  31194. constructor();
  31195. /**
  31196. * Call this method to start monitoring a new frame.
  31197. * 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.
  31198. */
  31199. fetchNewFrame(): void;
  31200. /**
  31201. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31202. * @param newCount the count value to add to the monitored count
  31203. * @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.
  31204. */
  31205. addCount(newCount: number, fetchResult: boolean): void;
  31206. /**
  31207. * Start monitoring this performance counter
  31208. */
  31209. beginMonitoring(): void;
  31210. /**
  31211. * Compute the time lapsed since the previous beginMonitoring() call.
  31212. * @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
  31213. */
  31214. endMonitoring(newFrame?: boolean): void;
  31215. private _fetchResult;
  31216. private _startMonitoringTime;
  31217. private _min;
  31218. private _max;
  31219. private _average;
  31220. private _current;
  31221. private _totalValueCount;
  31222. private _totalAccumulated;
  31223. private _lastSecAverage;
  31224. private _lastSecAccumulated;
  31225. private _lastSecTime;
  31226. private _lastSecValueCount;
  31227. }
  31228. /**
  31229. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31230. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31231. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31232. * @param name The name of the class, case should be preserved
  31233. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31234. */
  31235. export function className(name: string, module?: string): (target: Object) => void;
  31236. /**
  31237. * An implementation of a loop for asynchronous functions.
  31238. */
  31239. export class AsyncLoop {
  31240. /**
  31241. * Defines the number of iterations for the loop
  31242. */
  31243. iterations: number;
  31244. /**
  31245. * Defines the current index of the loop.
  31246. */
  31247. index: number;
  31248. private _done;
  31249. private _fn;
  31250. private _successCallback;
  31251. /**
  31252. * Constructor.
  31253. * @param iterations the number of iterations.
  31254. * @param func the function to run each iteration
  31255. * @param successCallback the callback that will be called upon succesful execution
  31256. * @param offset starting offset.
  31257. */
  31258. constructor(
  31259. /**
  31260. * Defines the number of iterations for the loop
  31261. */
  31262. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31263. /**
  31264. * Execute the next iteration. Must be called after the last iteration was finished.
  31265. */
  31266. executeNext(): void;
  31267. /**
  31268. * Break the loop and run the success callback.
  31269. */
  31270. breakLoop(): void;
  31271. /**
  31272. * Create and run an async loop.
  31273. * @param iterations the number of iterations.
  31274. * @param fn the function to run each iteration
  31275. * @param successCallback the callback that will be called upon succesful execution
  31276. * @param offset starting offset.
  31277. * @returns the created async loop object
  31278. */
  31279. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31280. /**
  31281. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31282. * @param iterations total number of iterations
  31283. * @param syncedIterations number of synchronous iterations in each async iteration.
  31284. * @param fn the function to call each iteration.
  31285. * @param callback a success call back that will be called when iterating stops.
  31286. * @param breakFunction a break condition (optional)
  31287. * @param timeout timeout settings for the setTimeout function. default - 0.
  31288. * @returns the created async loop object
  31289. */
  31290. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31291. }
  31292. }
  31293. declare module BABYLON {
  31294. /** @hidden */
  31295. export interface ICollisionCoordinator {
  31296. createCollider(): Collider;
  31297. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31298. init(scene: Scene): void;
  31299. }
  31300. /** @hidden */
  31301. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31302. private _scene;
  31303. private _scaledPosition;
  31304. private _scaledVelocity;
  31305. private _finalPosition;
  31306. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31307. createCollider(): Collider;
  31308. init(scene: Scene): void;
  31309. private _collideWithWorld;
  31310. }
  31311. }
  31312. declare module BABYLON {
  31313. /**
  31314. * Class used to manage all inputs for the scene.
  31315. */
  31316. export class InputManager {
  31317. /** The distance in pixel that you have to move to prevent some events */
  31318. static DragMovementThreshold: number;
  31319. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31320. static LongPressDelay: number;
  31321. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31322. static DoubleClickDelay: number;
  31323. /** If you need to check double click without raising a single click at first click, enable this flag */
  31324. static ExclusiveDoubleClickMode: boolean;
  31325. private _wheelEventName;
  31326. private _onPointerMove;
  31327. private _onPointerDown;
  31328. private _onPointerUp;
  31329. private _initClickEvent;
  31330. private _initActionManager;
  31331. private _delayedSimpleClick;
  31332. private _delayedSimpleClickTimeout;
  31333. private _previousDelayedSimpleClickTimeout;
  31334. private _meshPickProceed;
  31335. private _previousButtonPressed;
  31336. private _currentPickResult;
  31337. private _previousPickResult;
  31338. private _totalPointersPressed;
  31339. private _doubleClickOccured;
  31340. private _pointerOverMesh;
  31341. private _pickedDownMesh;
  31342. private _pickedUpMesh;
  31343. private _pointerX;
  31344. private _pointerY;
  31345. private _unTranslatedPointerX;
  31346. private _unTranslatedPointerY;
  31347. private _startingPointerPosition;
  31348. private _previousStartingPointerPosition;
  31349. private _startingPointerTime;
  31350. private _previousStartingPointerTime;
  31351. private _pointerCaptures;
  31352. private _onKeyDown;
  31353. private _onKeyUp;
  31354. private _onCanvasFocusObserver;
  31355. private _onCanvasBlurObserver;
  31356. private _scene;
  31357. /**
  31358. * Creates a new InputManager
  31359. * @param scene defines the hosting scene
  31360. */
  31361. constructor(scene: Scene);
  31362. /**
  31363. * Gets the mesh that is currently under the pointer
  31364. */
  31365. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31366. /**
  31367. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31368. */
  31369. readonly unTranslatedPointer: Vector2;
  31370. /**
  31371. * Gets or sets the current on-screen X position of the pointer
  31372. */
  31373. pointerX: number;
  31374. /**
  31375. * Gets or sets the current on-screen Y position of the pointer
  31376. */
  31377. pointerY: number;
  31378. private _updatePointerPosition;
  31379. private _processPointerMove;
  31380. private _setRayOnPointerInfo;
  31381. private _checkPrePointerObservable;
  31382. /**
  31383. * Use this method to simulate a pointer move on a mesh
  31384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31387. */
  31388. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31389. /**
  31390. * Use this method to simulate a pointer down on a mesh
  31391. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31392. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31393. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31394. */
  31395. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31396. private _processPointerDown;
  31397. /** @hidden */ private _isPointerSwiping(): boolean;
  31398. /**
  31399. * Use this method to simulate a pointer up on a mesh
  31400. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31401. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31402. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31403. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31404. */
  31405. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31406. private _processPointerUp;
  31407. /**
  31408. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31409. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31410. * @returns true if the pointer was captured
  31411. */
  31412. isPointerCaptured(pointerId?: number): boolean;
  31413. /**
  31414. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31415. * @param attachUp defines if you want to attach events to pointerup
  31416. * @param attachDown defines if you want to attach events to pointerdown
  31417. * @param attachMove defines if you want to attach events to pointermove
  31418. */
  31419. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31420. /**
  31421. * Detaches all event handlers
  31422. */
  31423. detachControl(): void;
  31424. /**
  31425. * Force the value of meshUnderPointer
  31426. * @param mesh defines the mesh to use
  31427. */
  31428. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31429. /**
  31430. * Gets the mesh under the pointer
  31431. * @returns a Mesh or null if no mesh is under the pointer
  31432. */
  31433. getPointerOverMesh(): Nullable<AbstractMesh>;
  31434. }
  31435. }
  31436. declare module BABYLON {
  31437. /**
  31438. * This class defines the direct association between an animation and a target
  31439. */
  31440. export class TargetedAnimation {
  31441. /**
  31442. * Animation to perform
  31443. */
  31444. animation: Animation;
  31445. /**
  31446. * Target to animate
  31447. */
  31448. target: any;
  31449. /**
  31450. * Serialize the object
  31451. * @returns the JSON object representing the current entity
  31452. */
  31453. serialize(): any;
  31454. }
  31455. /**
  31456. * Use this class to create coordinated animations on multiple targets
  31457. */
  31458. export class AnimationGroup implements IDisposable {
  31459. /** The name of the animation group */
  31460. name: string;
  31461. private _scene;
  31462. private _targetedAnimations;
  31463. private _animatables;
  31464. private _from;
  31465. private _to;
  31466. private _isStarted;
  31467. private _isPaused;
  31468. private _speedRatio;
  31469. private _loopAnimation;
  31470. /**
  31471. * Gets or sets the unique id of the node
  31472. */
  31473. uniqueId: number;
  31474. /**
  31475. * This observable will notify when one animation have ended
  31476. */
  31477. onAnimationEndObservable: Observable<TargetedAnimation>;
  31478. /**
  31479. * Observer raised when one animation loops
  31480. */
  31481. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31482. /**
  31483. * This observable will notify when all animations have ended.
  31484. */
  31485. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31486. /**
  31487. * This observable will notify when all animations have paused.
  31488. */
  31489. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31490. /**
  31491. * This observable will notify when all animations are playing.
  31492. */
  31493. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31494. /**
  31495. * Gets the first frame
  31496. */
  31497. readonly from: number;
  31498. /**
  31499. * Gets the last frame
  31500. */
  31501. readonly to: number;
  31502. /**
  31503. * Define if the animations are started
  31504. */
  31505. readonly isStarted: boolean;
  31506. /**
  31507. * Gets a value indicating that the current group is playing
  31508. */
  31509. readonly isPlaying: boolean;
  31510. /**
  31511. * Gets or sets the speed ratio to use for all animations
  31512. */
  31513. /**
  31514. * Gets or sets the speed ratio to use for all animations
  31515. */
  31516. speedRatio: number;
  31517. /**
  31518. * Gets or sets if all animations should loop or not
  31519. */
  31520. loopAnimation: boolean;
  31521. /**
  31522. * Gets the targeted animations for this animation group
  31523. */
  31524. readonly targetedAnimations: Array<TargetedAnimation>;
  31525. /**
  31526. * returning the list of animatables controlled by this animation group.
  31527. */
  31528. readonly animatables: Array<Animatable>;
  31529. /**
  31530. * Instantiates a new Animation Group.
  31531. * This helps managing several animations at once.
  31532. * @see http://doc.babylonjs.com/how_to/group
  31533. * @param name Defines the name of the group
  31534. * @param scene Defines the scene the group belongs to
  31535. */
  31536. constructor(
  31537. /** The name of the animation group */
  31538. name: string, scene?: Nullable<Scene>);
  31539. /**
  31540. * Add an animation (with its target) in the group
  31541. * @param animation defines the animation we want to add
  31542. * @param target defines the target of the animation
  31543. * @returns the TargetedAnimation object
  31544. */
  31545. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31546. /**
  31547. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31548. * It can add constant keys at begin or end
  31549. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31550. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31551. * @returns the animation group
  31552. */
  31553. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31554. /**
  31555. * Start all animations on given targets
  31556. * @param loop defines if animations must loop
  31557. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31558. * @param from defines the from key (optional)
  31559. * @param to defines the to key (optional)
  31560. * @returns the current animation group
  31561. */
  31562. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31563. /**
  31564. * Pause all animations
  31565. * @returns the animation group
  31566. */
  31567. pause(): AnimationGroup;
  31568. /**
  31569. * Play all animations to initial state
  31570. * This function will start() the animations if they were not started or will restart() them if they were paused
  31571. * @param loop defines if animations must loop
  31572. * @returns the animation group
  31573. */
  31574. play(loop?: boolean): AnimationGroup;
  31575. /**
  31576. * Reset all animations to initial state
  31577. * @returns the animation group
  31578. */
  31579. reset(): AnimationGroup;
  31580. /**
  31581. * Restart animations from key 0
  31582. * @returns the animation group
  31583. */
  31584. restart(): AnimationGroup;
  31585. /**
  31586. * Stop all animations
  31587. * @returns the animation group
  31588. */
  31589. stop(): AnimationGroup;
  31590. /**
  31591. * Set animation weight for all animatables
  31592. * @param weight defines the weight to use
  31593. * @return the animationGroup
  31594. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31595. */
  31596. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31597. /**
  31598. * Synchronize and normalize all animatables with a source animatable
  31599. * @param root defines the root animatable to synchronize with
  31600. * @return the animationGroup
  31601. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31602. */
  31603. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31604. /**
  31605. * Goes to a specific frame in this animation group
  31606. * @param frame the frame number to go to
  31607. * @return the animationGroup
  31608. */
  31609. goToFrame(frame: number): AnimationGroup;
  31610. /**
  31611. * Dispose all associated resources
  31612. */
  31613. dispose(): void;
  31614. private _checkAnimationGroupEnded;
  31615. /**
  31616. * Clone the current animation group and returns a copy
  31617. * @param newName defines the name of the new group
  31618. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31619. * @returns the new aniamtion group
  31620. */
  31621. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31622. /**
  31623. * Serializes the animationGroup to an object
  31624. * @returns Serialized object
  31625. */
  31626. serialize(): any;
  31627. /**
  31628. * Returns a new AnimationGroup object parsed from the source provided.
  31629. * @param parsedAnimationGroup defines the source
  31630. * @param scene defines the scene that will receive the animationGroup
  31631. * @returns a new AnimationGroup
  31632. */
  31633. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31634. /**
  31635. * Returns the string "AnimationGroup"
  31636. * @returns "AnimationGroup"
  31637. */
  31638. getClassName(): string;
  31639. /**
  31640. * Creates a detailled string about the object
  31641. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31642. * @returns a string representing the object
  31643. */
  31644. toString(fullDetails?: boolean): string;
  31645. }
  31646. }
  31647. declare module BABYLON {
  31648. /**
  31649. * Define an interface for all classes that will hold resources
  31650. */
  31651. export interface IDisposable {
  31652. /**
  31653. * Releases all held resources
  31654. */
  31655. dispose(): void;
  31656. }
  31657. /** Interface defining initialization parameters for Scene class */
  31658. export interface SceneOptions {
  31659. /**
  31660. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31661. * It will improve performance when the number of geometries becomes important.
  31662. */
  31663. useGeometryUniqueIdsMap?: boolean;
  31664. /**
  31665. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31666. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31667. */
  31668. useMaterialMeshMap?: boolean;
  31669. /**
  31670. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31671. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31672. */
  31673. useClonedMeshhMap?: boolean;
  31674. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31675. virtual?: boolean;
  31676. }
  31677. /**
  31678. * Represents a scene to be rendered by the engine.
  31679. * @see http://doc.babylonjs.com/features/scene
  31680. */
  31681. export class Scene extends AbstractScene implements IAnimatable {
  31682. private static _uniqueIdCounter;
  31683. /** The fog is deactivated */
  31684. static readonly FOGMODE_NONE: number;
  31685. /** The fog density is following an exponential function */
  31686. static readonly FOGMODE_EXP: number;
  31687. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31688. static readonly FOGMODE_EXP2: number;
  31689. /** The fog density is following a linear function. */
  31690. static readonly FOGMODE_LINEAR: number;
  31691. /**
  31692. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31693. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31694. */
  31695. static MinDeltaTime: number;
  31696. /**
  31697. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31698. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31699. */
  31700. static MaxDeltaTime: number;
  31701. /**
  31702. * Factory used to create the default material.
  31703. * @param name The name of the material to create
  31704. * @param scene The scene to create the material for
  31705. * @returns The default material
  31706. */
  31707. static DefaultMaterialFactory(scene: Scene): Material;
  31708. /**
  31709. * Factory used to create the a collision coordinator.
  31710. * @returns The collision coordinator
  31711. */
  31712. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31713. /** @hidden */ private _inputManager: InputManager;
  31714. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31715. cameraToUseForPointers: Nullable<Camera>;
  31716. /** @hidden */ protected readonly _isScene: boolean;
  31717. /**
  31718. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31719. */
  31720. autoClear: boolean;
  31721. /**
  31722. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31723. */
  31724. autoClearDepthAndStencil: boolean;
  31725. /**
  31726. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31727. */
  31728. clearColor: Color4;
  31729. /**
  31730. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31731. */
  31732. ambientColor: Color3;
  31733. /**
  31734. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31735. * It should only be one of the following (if not the default embedded one):
  31736. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31737. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31738. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31739. * The material properties need to be setup according to the type of texture in use.
  31740. */
  31741. environmentBRDFTexture: BaseTexture;
  31742. /** @hidden */
  31743. protected _environmentTexture: Nullable<BaseTexture>;
  31744. /**
  31745. * Texture used in all pbr material as the reflection texture.
  31746. * As in the majority of the scene they are the same (exception for multi room and so on),
  31747. * this is easier to reference from here than from all the materials.
  31748. */
  31749. /**
  31750. * Texture used in all pbr material as the reflection texture.
  31751. * As in the majority of the scene they are the same (exception for multi room and so on),
  31752. * this is easier to set here than in all the materials.
  31753. */
  31754. environmentTexture: Nullable<BaseTexture>;
  31755. /** @hidden */
  31756. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31757. /**
  31758. * Default image processing configuration used either in the rendering
  31759. * Forward main pass or through the imageProcessingPostProcess if present.
  31760. * As in the majority of the scene they are the same (exception for multi camera),
  31761. * this is easier to reference from here than from all the materials and post process.
  31762. *
  31763. * No setter as we it is a shared configuration, you can set the values instead.
  31764. */
  31765. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31766. private _forceWireframe;
  31767. /**
  31768. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31769. */
  31770. forceWireframe: boolean;
  31771. private _forcePointsCloud;
  31772. /**
  31773. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31774. */
  31775. forcePointsCloud: boolean;
  31776. /**
  31777. * Gets or sets the active clipplane 1
  31778. */
  31779. clipPlane: Nullable<Plane>;
  31780. /**
  31781. * Gets or sets the active clipplane 2
  31782. */
  31783. clipPlane2: Nullable<Plane>;
  31784. /**
  31785. * Gets or sets the active clipplane 3
  31786. */
  31787. clipPlane3: Nullable<Plane>;
  31788. /**
  31789. * Gets or sets the active clipplane 4
  31790. */
  31791. clipPlane4: Nullable<Plane>;
  31792. /**
  31793. * Gets or sets a boolean indicating if animations are enabled
  31794. */
  31795. animationsEnabled: boolean;
  31796. private _animationPropertiesOverride;
  31797. /**
  31798. * Gets or sets the animation properties override
  31799. */
  31800. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31801. /**
  31802. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31803. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31804. */
  31805. useConstantAnimationDeltaTime: boolean;
  31806. /**
  31807. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31808. * Please note that it requires to run a ray cast through the scene on every frame
  31809. */
  31810. constantlyUpdateMeshUnderPointer: boolean;
  31811. /**
  31812. * Defines the HTML cursor to use when hovering over interactive elements
  31813. */
  31814. hoverCursor: string;
  31815. /**
  31816. * Defines the HTML default cursor to use (empty by default)
  31817. */
  31818. defaultCursor: string;
  31819. /**
  31820. * This is used to call preventDefault() on pointer down
  31821. * in order to block unwanted artifacts like system double clicks
  31822. */
  31823. preventDefaultOnPointerDown: boolean;
  31824. /**
  31825. * This is used to call preventDefault() on pointer up
  31826. * in order to block unwanted artifacts like system double clicks
  31827. */
  31828. preventDefaultOnPointerUp: boolean;
  31829. /**
  31830. * Gets or sets user defined metadata
  31831. */
  31832. metadata: any;
  31833. /**
  31834. * For internal use only. Please do not use.
  31835. */
  31836. reservedDataStore: any;
  31837. /**
  31838. * Gets the name of the plugin used to load this scene (null by default)
  31839. */
  31840. loadingPluginName: string;
  31841. /**
  31842. * Use this array to add regular expressions used to disable offline support for specific urls
  31843. */
  31844. disableOfflineSupportExceptionRules: RegExp[];
  31845. /**
  31846. * An event triggered when the scene is disposed.
  31847. */
  31848. onDisposeObservable: Observable<Scene>;
  31849. private _onDisposeObserver;
  31850. /** Sets a function to be executed when this scene is disposed. */
  31851. onDispose: () => void;
  31852. /**
  31853. * An event triggered before rendering the scene (right after animations and physics)
  31854. */
  31855. onBeforeRenderObservable: Observable<Scene>;
  31856. private _onBeforeRenderObserver;
  31857. /** Sets a function to be executed before rendering this scene */
  31858. beforeRender: Nullable<() => void>;
  31859. /**
  31860. * An event triggered after rendering the scene
  31861. */
  31862. onAfterRenderObservable: Observable<Scene>;
  31863. /**
  31864. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  31865. */
  31866. onAfterRenderCameraObservable: Observable<Camera>;
  31867. private _onAfterRenderObserver;
  31868. /** Sets a function to be executed after rendering this scene */
  31869. afterRender: Nullable<() => void>;
  31870. /**
  31871. * An event triggered before animating the scene
  31872. */
  31873. onBeforeAnimationsObservable: Observable<Scene>;
  31874. /**
  31875. * An event triggered after animations processing
  31876. */
  31877. onAfterAnimationsObservable: Observable<Scene>;
  31878. /**
  31879. * An event triggered before draw calls are ready to be sent
  31880. */
  31881. onBeforeDrawPhaseObservable: Observable<Scene>;
  31882. /**
  31883. * An event triggered after draw calls have been sent
  31884. */
  31885. onAfterDrawPhaseObservable: Observable<Scene>;
  31886. /**
  31887. * An event triggered when the scene is ready
  31888. */
  31889. onReadyObservable: Observable<Scene>;
  31890. /**
  31891. * An event triggered before rendering a camera
  31892. */
  31893. onBeforeCameraRenderObservable: Observable<Camera>;
  31894. private _onBeforeCameraRenderObserver;
  31895. /** Sets a function to be executed before rendering a camera*/
  31896. beforeCameraRender: () => void;
  31897. /**
  31898. * An event triggered after rendering a camera
  31899. */
  31900. onAfterCameraRenderObservable: Observable<Camera>;
  31901. private _onAfterCameraRenderObserver;
  31902. /** Sets a function to be executed after rendering a camera*/
  31903. afterCameraRender: () => void;
  31904. /**
  31905. * An event triggered when active meshes evaluation is about to start
  31906. */
  31907. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31908. /**
  31909. * An event triggered when active meshes evaluation is done
  31910. */
  31911. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31912. /**
  31913. * An event triggered when particles rendering is about to start
  31914. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31915. */
  31916. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31917. /**
  31918. * An event triggered when particles rendering is done
  31919. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31920. */
  31921. onAfterParticlesRenderingObservable: Observable<Scene>;
  31922. /**
  31923. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31924. */
  31925. onDataLoadedObservable: Observable<Scene>;
  31926. /**
  31927. * An event triggered when a camera is created
  31928. */
  31929. onNewCameraAddedObservable: Observable<Camera>;
  31930. /**
  31931. * An event triggered when a camera is removed
  31932. */
  31933. onCameraRemovedObservable: Observable<Camera>;
  31934. /**
  31935. * An event triggered when a light is created
  31936. */
  31937. onNewLightAddedObservable: Observable<Light>;
  31938. /**
  31939. * An event triggered when a light is removed
  31940. */
  31941. onLightRemovedObservable: Observable<Light>;
  31942. /**
  31943. * An event triggered when a geometry is created
  31944. */
  31945. onNewGeometryAddedObservable: Observable<Geometry>;
  31946. /**
  31947. * An event triggered when a geometry is removed
  31948. */
  31949. onGeometryRemovedObservable: Observable<Geometry>;
  31950. /**
  31951. * An event triggered when a transform node is created
  31952. */
  31953. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31954. /**
  31955. * An event triggered when a transform node is removed
  31956. */
  31957. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31958. /**
  31959. * An event triggered when a mesh is created
  31960. */
  31961. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31962. /**
  31963. * An event triggered when a mesh is removed
  31964. */
  31965. onMeshRemovedObservable: Observable<AbstractMesh>;
  31966. /**
  31967. * An event triggered when a skeleton is created
  31968. */
  31969. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31970. /**
  31971. * An event triggered when a skeleton is removed
  31972. */
  31973. onSkeletonRemovedObservable: Observable<Skeleton>;
  31974. /**
  31975. * An event triggered when a material is created
  31976. */
  31977. onNewMaterialAddedObservable: Observable<Material>;
  31978. /**
  31979. * An event triggered when a material is removed
  31980. */
  31981. onMaterialRemovedObservable: Observable<Material>;
  31982. /**
  31983. * An event triggered when a texture is created
  31984. */
  31985. onNewTextureAddedObservable: Observable<BaseTexture>;
  31986. /**
  31987. * An event triggered when a texture is removed
  31988. */
  31989. onTextureRemovedObservable: Observable<BaseTexture>;
  31990. /**
  31991. * An event triggered when render targets are about to be rendered
  31992. * Can happen multiple times per frame.
  31993. */
  31994. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31995. /**
  31996. * An event triggered when render targets were rendered.
  31997. * Can happen multiple times per frame.
  31998. */
  31999. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32000. /**
  32001. * An event triggered before calculating deterministic simulation step
  32002. */
  32003. onBeforeStepObservable: Observable<Scene>;
  32004. /**
  32005. * An event triggered after calculating deterministic simulation step
  32006. */
  32007. onAfterStepObservable: Observable<Scene>;
  32008. /**
  32009. * An event triggered when the activeCamera property is updated
  32010. */
  32011. onActiveCameraChanged: Observable<Scene>;
  32012. /**
  32013. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32014. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32015. * 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)
  32016. */
  32017. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32018. /**
  32019. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32020. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32021. * 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)
  32022. */
  32023. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32024. /**
  32025. * This Observable will when a mesh has been imported into the scene.
  32026. */
  32027. onMeshImportedObservable: Observable<AbstractMesh>;
  32028. /**
  32029. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32030. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32031. */
  32032. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32033. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32034. /**
  32035. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32036. */
  32037. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32038. /**
  32039. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32040. */
  32041. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32042. /**
  32043. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32044. */
  32045. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32046. /** Callback called when a pointer move is detected */
  32047. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32048. /** Callback called when a pointer down is detected */
  32049. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32050. /** Callback called when a pointer up is detected */
  32051. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32052. /** Callback called when a pointer pick is detected */
  32053. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32054. /**
  32055. * 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).
  32056. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32057. */
  32058. onPrePointerObservable: Observable<PointerInfoPre>;
  32059. /**
  32060. * Observable event triggered each time an input event is received from the rendering canvas
  32061. */
  32062. onPointerObservable: Observable<PointerInfo>;
  32063. /**
  32064. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32065. */
  32066. readonly unTranslatedPointer: Vector2;
  32067. /**
  32068. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32069. */
  32070. static DragMovementThreshold: number;
  32071. /**
  32072. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32073. */
  32074. static LongPressDelay: number;
  32075. /**
  32076. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32077. */
  32078. static DoubleClickDelay: number;
  32079. /** If you need to check double click without raising a single click at first click, enable this flag */
  32080. static ExclusiveDoubleClickMode: boolean;
  32081. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32082. /**
  32083. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32084. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32085. */
  32086. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32087. /**
  32088. * Observable event triggered each time an keyboard event is received from the hosting window
  32089. */
  32090. onKeyboardObservable: Observable<KeyboardInfo>;
  32091. private _useRightHandedSystem;
  32092. /**
  32093. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32094. */
  32095. useRightHandedSystem: boolean;
  32096. private _timeAccumulator;
  32097. private _currentStepId;
  32098. private _currentInternalStep;
  32099. /**
  32100. * Sets the step Id used by deterministic lock step
  32101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32102. * @param newStepId defines the step Id
  32103. */
  32104. setStepId(newStepId: number): void;
  32105. /**
  32106. * Gets the step Id used by deterministic lock step
  32107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32108. * @returns the step Id
  32109. */
  32110. getStepId(): number;
  32111. /**
  32112. * Gets the internal step used by deterministic lock step
  32113. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32114. * @returns the internal step
  32115. */
  32116. getInternalStep(): number;
  32117. private _fogEnabled;
  32118. /**
  32119. * Gets or sets a boolean indicating if fog is enabled on this scene
  32120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32121. * (Default is true)
  32122. */
  32123. fogEnabled: boolean;
  32124. private _fogMode;
  32125. /**
  32126. * Gets or sets the fog mode to use
  32127. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32128. * | mode | value |
  32129. * | --- | --- |
  32130. * | FOGMODE_NONE | 0 |
  32131. * | FOGMODE_EXP | 1 |
  32132. * | FOGMODE_EXP2 | 2 |
  32133. * | FOGMODE_LINEAR | 3 |
  32134. */
  32135. fogMode: number;
  32136. /**
  32137. * Gets or sets the fog color to use
  32138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32139. * (Default is Color3(0.2, 0.2, 0.3))
  32140. */
  32141. fogColor: Color3;
  32142. /**
  32143. * Gets or sets the fog density to use
  32144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32145. * (Default is 0.1)
  32146. */
  32147. fogDensity: number;
  32148. /**
  32149. * Gets or sets the fog start distance to use
  32150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32151. * (Default is 0)
  32152. */
  32153. fogStart: number;
  32154. /**
  32155. * Gets or sets the fog end distance to use
  32156. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32157. * (Default is 1000)
  32158. */
  32159. fogEnd: number;
  32160. private _shadowsEnabled;
  32161. /**
  32162. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32163. */
  32164. shadowsEnabled: boolean;
  32165. private _lightsEnabled;
  32166. /**
  32167. * Gets or sets a boolean indicating if lights are enabled on this scene
  32168. */
  32169. lightsEnabled: boolean;
  32170. /** All of the active cameras added to this scene. */
  32171. activeCameras: Camera[];
  32172. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32173. /** Gets or sets the current active camera */
  32174. activeCamera: Nullable<Camera>;
  32175. private _defaultMaterial;
  32176. /** The default material used on meshes when no material is affected */
  32177. /** The default material used on meshes when no material is affected */
  32178. defaultMaterial: Material;
  32179. private _texturesEnabled;
  32180. /**
  32181. * Gets or sets a boolean indicating if textures are enabled on this scene
  32182. */
  32183. texturesEnabled: boolean;
  32184. /**
  32185. * Gets or sets a boolean indicating if particles are enabled on this scene
  32186. */
  32187. particlesEnabled: boolean;
  32188. /**
  32189. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32190. */
  32191. spritesEnabled: boolean;
  32192. private _skeletonsEnabled;
  32193. /**
  32194. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32195. */
  32196. skeletonsEnabled: boolean;
  32197. /**
  32198. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32199. */
  32200. lensFlaresEnabled: boolean;
  32201. /**
  32202. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32203. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32204. */
  32205. collisionsEnabled: boolean;
  32206. private _collisionCoordinator;
  32207. /** @hidden */
  32208. readonly collisionCoordinator: ICollisionCoordinator;
  32209. /**
  32210. * Defines the gravity applied to this scene (used only for collisions)
  32211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32212. */
  32213. gravity: Vector3;
  32214. /**
  32215. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32216. */
  32217. postProcessesEnabled: boolean;
  32218. /**
  32219. * The list of postprocesses added to the scene
  32220. */
  32221. postProcesses: PostProcess[];
  32222. /**
  32223. * Gets the current postprocess manager
  32224. */
  32225. postProcessManager: PostProcessManager;
  32226. /**
  32227. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32228. */
  32229. renderTargetsEnabled: boolean;
  32230. /**
  32231. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32232. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32233. */
  32234. dumpNextRenderTargets: boolean;
  32235. /**
  32236. * The list of user defined render targets added to the scene
  32237. */
  32238. customRenderTargets: RenderTargetTexture[];
  32239. /**
  32240. * Defines if texture loading must be delayed
  32241. * If true, textures will only be loaded when they need to be rendered
  32242. */
  32243. useDelayedTextureLoading: boolean;
  32244. /**
  32245. * Gets the list of meshes imported to the scene through SceneLoader
  32246. */
  32247. importedMeshesFiles: String[];
  32248. /**
  32249. * Gets or sets a boolean indicating if probes are enabled on this scene
  32250. */
  32251. probesEnabled: boolean;
  32252. /**
  32253. * Gets or sets the current offline provider to use to store scene data
  32254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32255. */
  32256. offlineProvider: IOfflineProvider;
  32257. /**
  32258. * Gets or sets the action manager associated with the scene
  32259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32260. */
  32261. actionManager: AbstractActionManager;
  32262. private _meshesForIntersections;
  32263. /**
  32264. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32265. */
  32266. proceduralTexturesEnabled: boolean;
  32267. private _engine;
  32268. private _totalVertices;
  32269. /** @hidden */ private _activeIndices: PerfCounter;
  32270. /** @hidden */ private _activeParticles: PerfCounter;
  32271. /** @hidden */ private _activeBones: PerfCounter;
  32272. private _animationRatio;
  32273. /** @hidden */ private _animationTimeLast: number;
  32274. /** @hidden */ private _animationTime: number;
  32275. /**
  32276. * Gets or sets a general scale for animation speed
  32277. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32278. */
  32279. animationTimeScale: number;
  32280. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32281. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32282. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32283. private _renderId;
  32284. private _frameId;
  32285. private _executeWhenReadyTimeoutId;
  32286. private _intermediateRendering;
  32287. private _viewUpdateFlag;
  32288. private _projectionUpdateFlag;
  32289. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32290. private _activeRequests;
  32291. /** @hidden */ private _pendingData: any[];
  32292. private _isDisposed;
  32293. /**
  32294. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32295. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32296. */
  32297. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32298. private _activeMeshes;
  32299. private _processedMaterials;
  32300. private _renderTargets;
  32301. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32302. private _activeSkeletons;
  32303. private _softwareSkinnedMeshes;
  32304. private _renderingManager;
  32305. /** @hidden */ private _activeAnimatables: Animatable[];
  32306. private _transformMatrix;
  32307. private _sceneUbo;
  32308. /** @hidden */ private _viewMatrix: Matrix;
  32309. private _projectionMatrix;
  32310. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32311. /** @hidden */ private _frustumPlanes: Plane[];
  32312. /**
  32313. * Gets the list of frustum planes (built from the active camera)
  32314. */
  32315. readonly frustumPlanes: Plane[];
  32316. /**
  32317. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32318. * This is useful if there are more lights that the maximum simulteanous authorized
  32319. */
  32320. requireLightSorting: boolean;
  32321. /** @hidden */
  32322. readonly useMaterialMeshMap: boolean;
  32323. /** @hidden */
  32324. readonly useClonedMeshhMap: boolean;
  32325. private _externalData;
  32326. private _uid;
  32327. /**
  32328. * @hidden
  32329. * Backing store of defined scene components.
  32330. */ private _components: ISceneComponent[];
  32331. /**
  32332. * @hidden
  32333. * Backing store of defined scene components.
  32334. */ private _serializableComponents: ISceneSerializableComponent[];
  32335. /**
  32336. * List of components to register on the next registration step.
  32337. */
  32338. private _transientComponents;
  32339. /**
  32340. * Registers the transient components if needed.
  32341. */
  32342. private _registerTransientComponents;
  32343. /**
  32344. * @hidden
  32345. * Add a component to the scene.
  32346. * Note that the ccomponent could be registered on th next frame if this is called after
  32347. * the register component stage.
  32348. * @param component Defines the component to add to the scene
  32349. */ private _addComponent(component: ISceneComponent): void;
  32350. /**
  32351. * @hidden
  32352. * Gets a component from the scene.
  32353. * @param name defines the name of the component to retrieve
  32354. * @returns the component or null if not present
  32355. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32356. /**
  32357. * @hidden
  32358. * Defines the actions happening before camera updates.
  32359. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32360. /**
  32361. * @hidden
  32362. * Defines the actions happening before clear the canvas.
  32363. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32364. /**
  32365. * @hidden
  32366. * Defines the actions when collecting render targets for the frame.
  32367. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32368. /**
  32369. * @hidden
  32370. * Defines the actions happening for one camera in the frame.
  32371. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32372. /**
  32373. * @hidden
  32374. * Defines the actions happening during the per mesh ready checks.
  32375. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32376. /**
  32377. * @hidden
  32378. * Defines the actions happening before evaluate active mesh checks.
  32379. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32380. /**
  32381. * @hidden
  32382. * Defines the actions happening during the evaluate sub mesh checks.
  32383. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32384. /**
  32385. * @hidden
  32386. * Defines the actions happening during the active mesh stage.
  32387. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32388. /**
  32389. * @hidden
  32390. * Defines the actions happening during the per camera render target step.
  32391. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32392. /**
  32393. * @hidden
  32394. * Defines the actions happening just before the active camera is drawing.
  32395. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32396. /**
  32397. * @hidden
  32398. * Defines the actions happening just before a render target is drawing.
  32399. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32400. /**
  32401. * @hidden
  32402. * Defines the actions happening just before a rendering group is drawing.
  32403. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32404. /**
  32405. * @hidden
  32406. * Defines the actions happening just before a mesh is drawing.
  32407. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32408. /**
  32409. * @hidden
  32410. * Defines the actions happening just after a mesh has been drawn.
  32411. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32412. /**
  32413. * @hidden
  32414. * Defines the actions happening just after a rendering group has been drawn.
  32415. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32416. /**
  32417. * @hidden
  32418. * Defines the actions happening just after the active camera has been drawn.
  32419. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32420. /**
  32421. * @hidden
  32422. * Defines the actions happening just after a render target has been drawn.
  32423. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32424. /**
  32425. * @hidden
  32426. * Defines the actions happening just after rendering all cameras and computing intersections.
  32427. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32428. /**
  32429. * @hidden
  32430. * Defines the actions happening when a pointer move event happens.
  32431. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32432. /**
  32433. * @hidden
  32434. * Defines the actions happening when a pointer down event happens.
  32435. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32436. /**
  32437. * @hidden
  32438. * Defines the actions happening when a pointer up event happens.
  32439. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32440. /**
  32441. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32442. */
  32443. private geometriesByUniqueId;
  32444. /**
  32445. * Creates a new Scene
  32446. * @param engine defines the engine to use to render this scene
  32447. * @param options defines the scene options
  32448. */
  32449. constructor(engine: Engine, options?: SceneOptions);
  32450. /**
  32451. * Gets a string idenfifying the name of the class
  32452. * @returns "Scene" string
  32453. */
  32454. getClassName(): string;
  32455. private _defaultMeshCandidates;
  32456. /**
  32457. * @hidden
  32458. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32459. private _defaultSubMeshCandidates;
  32460. /**
  32461. * @hidden
  32462. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32463. /**
  32464. * Sets the default candidate providers for the scene.
  32465. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32466. * and getCollidingSubMeshCandidates to their default function
  32467. */
  32468. setDefaultCandidateProviders(): void;
  32469. /**
  32470. * Gets the mesh that is currently under the pointer
  32471. */
  32472. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32473. /**
  32474. * Gets or sets the current on-screen X position of the pointer
  32475. */
  32476. pointerX: number;
  32477. /**
  32478. * Gets or sets the current on-screen Y position of the pointer
  32479. */
  32480. pointerY: number;
  32481. /**
  32482. * Gets the cached material (ie. the latest rendered one)
  32483. * @returns the cached material
  32484. */
  32485. getCachedMaterial(): Nullable<Material>;
  32486. /**
  32487. * Gets the cached effect (ie. the latest rendered one)
  32488. * @returns the cached effect
  32489. */
  32490. getCachedEffect(): Nullable<Effect>;
  32491. /**
  32492. * Gets the cached visibility state (ie. the latest rendered one)
  32493. * @returns the cached visibility state
  32494. */
  32495. getCachedVisibility(): Nullable<number>;
  32496. /**
  32497. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32498. * @param material defines the current material
  32499. * @param effect defines the current effect
  32500. * @param visibility defines the current visibility state
  32501. * @returns true if one parameter is not cached
  32502. */
  32503. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32504. /**
  32505. * Gets the engine associated with the scene
  32506. * @returns an Engine
  32507. */
  32508. getEngine(): Engine;
  32509. /**
  32510. * Gets the total number of vertices rendered per frame
  32511. * @returns the total number of vertices rendered per frame
  32512. */
  32513. getTotalVertices(): number;
  32514. /**
  32515. * Gets the performance counter for total vertices
  32516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32517. */
  32518. readonly totalVerticesPerfCounter: PerfCounter;
  32519. /**
  32520. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32521. * @returns the total number of active indices rendered per frame
  32522. */
  32523. getActiveIndices(): number;
  32524. /**
  32525. * Gets the performance counter for active indices
  32526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32527. */
  32528. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32529. /**
  32530. * Gets the total number of active particles rendered per frame
  32531. * @returns the total number of active particles rendered per frame
  32532. */
  32533. getActiveParticles(): number;
  32534. /**
  32535. * Gets the performance counter for active particles
  32536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32537. */
  32538. readonly activeParticlesPerfCounter: PerfCounter;
  32539. /**
  32540. * Gets the total number of active bones rendered per frame
  32541. * @returns the total number of active bones rendered per frame
  32542. */
  32543. getActiveBones(): number;
  32544. /**
  32545. * Gets the performance counter for active bones
  32546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32547. */
  32548. readonly activeBonesPerfCounter: PerfCounter;
  32549. /**
  32550. * Gets the array of active meshes
  32551. * @returns an array of AbstractMesh
  32552. */
  32553. getActiveMeshes(): SmartArray<AbstractMesh>;
  32554. /**
  32555. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32556. * @returns a number
  32557. */
  32558. getAnimationRatio(): number;
  32559. /**
  32560. * Gets an unique Id for the current render phase
  32561. * @returns a number
  32562. */
  32563. getRenderId(): number;
  32564. /**
  32565. * Gets an unique Id for the current frame
  32566. * @returns a number
  32567. */
  32568. getFrameId(): number;
  32569. /** Call this function if you want to manually increment the render Id*/
  32570. incrementRenderId(): void;
  32571. private _createUbo;
  32572. /**
  32573. * Use this method to simulate a pointer move on a mesh
  32574. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32575. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32576. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32577. * @returns the current scene
  32578. */
  32579. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32580. /**
  32581. * Use this method to simulate a pointer down on a mesh
  32582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32585. * @returns the current scene
  32586. */
  32587. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32588. /**
  32589. * Use this method to simulate a pointer up on a mesh
  32590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32593. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32594. * @returns the current scene
  32595. */
  32596. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32597. /**
  32598. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32599. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32600. * @returns true if the pointer was captured
  32601. */
  32602. isPointerCaptured(pointerId?: number): boolean;
  32603. /**
  32604. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32605. * @param attachUp defines if you want to attach events to pointerup
  32606. * @param attachDown defines if you want to attach events to pointerdown
  32607. * @param attachMove defines if you want to attach events to pointermove
  32608. */
  32609. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32610. /** Detaches all event handlers*/
  32611. detachControl(): void;
  32612. /**
  32613. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32614. * Delay loaded resources are not taking in account
  32615. * @return true if all required resources are ready
  32616. */
  32617. isReady(): boolean;
  32618. /** Resets all cached information relative to material (including effect and visibility) */
  32619. resetCachedMaterial(): void;
  32620. /**
  32621. * Registers a function to be called before every frame render
  32622. * @param func defines the function to register
  32623. */
  32624. registerBeforeRender(func: () => void): void;
  32625. /**
  32626. * Unregisters a function called before every frame render
  32627. * @param func defines the function to unregister
  32628. */
  32629. unregisterBeforeRender(func: () => void): void;
  32630. /**
  32631. * Registers a function to be called after every frame render
  32632. * @param func defines the function to register
  32633. */
  32634. registerAfterRender(func: () => void): void;
  32635. /**
  32636. * Unregisters a function called after every frame render
  32637. * @param func defines the function to unregister
  32638. */
  32639. unregisterAfterRender(func: () => void): void;
  32640. private _executeOnceBeforeRender;
  32641. /**
  32642. * The provided function will run before render once and will be disposed afterwards.
  32643. * A timeout delay can be provided so that the function will be executed in N ms.
  32644. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32645. * @param func The function to be executed.
  32646. * @param timeout optional delay in ms
  32647. */
  32648. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32649. /** @hidden */ private _addPendingData(data: any): void;
  32650. /** @hidden */ private _removePendingData(data: any): void;
  32651. /**
  32652. * Returns the number of items waiting to be loaded
  32653. * @returns the number of items waiting to be loaded
  32654. */
  32655. getWaitingItemsCount(): number;
  32656. /**
  32657. * Returns a boolean indicating if the scene is still loading data
  32658. */
  32659. readonly isLoading: boolean;
  32660. /**
  32661. * Registers a function to be executed when the scene is ready
  32662. * @param {Function} func - the function to be executed
  32663. */
  32664. executeWhenReady(func: () => void): void;
  32665. /**
  32666. * Returns a promise that resolves when the scene is ready
  32667. * @returns A promise that resolves when the scene is ready
  32668. */
  32669. whenReadyAsync(): Promise<void>;
  32670. /** @hidden */ private _checkIsReady(): void;
  32671. /**
  32672. * Gets all animatable attached to the scene
  32673. */
  32674. readonly animatables: Animatable[];
  32675. /**
  32676. * Resets the last animation time frame.
  32677. * Useful to override when animations start running when loading a scene for the first time.
  32678. */
  32679. resetLastAnimationTimeFrame(): void;
  32680. /**
  32681. * Gets the current view matrix
  32682. * @returns a Matrix
  32683. */
  32684. getViewMatrix(): Matrix;
  32685. /**
  32686. * Gets the current projection matrix
  32687. * @returns a Matrix
  32688. */
  32689. getProjectionMatrix(): Matrix;
  32690. /**
  32691. * Gets the current transform matrix
  32692. * @returns a Matrix made of View * Projection
  32693. */
  32694. getTransformMatrix(): Matrix;
  32695. /**
  32696. * Sets the current transform matrix
  32697. * @param viewL defines the View matrix to use
  32698. * @param projectionL defines the Projection matrix to use
  32699. * @param viewR defines the right View matrix to use (if provided)
  32700. * @param projectionR defines the right Projection matrix to use (if provided)
  32701. */
  32702. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32703. /**
  32704. * Gets the uniform buffer used to store scene data
  32705. * @returns a UniformBuffer
  32706. */
  32707. getSceneUniformBuffer(): UniformBuffer;
  32708. /**
  32709. * Gets an unique (relatively to the current scene) Id
  32710. * @returns an unique number for the scene
  32711. */
  32712. getUniqueId(): number;
  32713. /**
  32714. * Add a mesh to the list of scene's meshes
  32715. * @param newMesh defines the mesh to add
  32716. * @param recursive if all child meshes should also be added to the scene
  32717. */
  32718. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32719. /**
  32720. * Remove a mesh for the list of scene's meshes
  32721. * @param toRemove defines the mesh to remove
  32722. * @param recursive if all child meshes should also be removed from the scene
  32723. * @returns the index where the mesh was in the mesh list
  32724. */
  32725. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32726. /**
  32727. * Add a transform node to the list of scene's transform nodes
  32728. * @param newTransformNode defines the transform node to add
  32729. */
  32730. addTransformNode(newTransformNode: TransformNode): void;
  32731. /**
  32732. * Remove a transform node for the list of scene's transform nodes
  32733. * @param toRemove defines the transform node to remove
  32734. * @returns the index where the transform node was in the transform node list
  32735. */
  32736. removeTransformNode(toRemove: TransformNode): number;
  32737. /**
  32738. * Remove a skeleton for the list of scene's skeletons
  32739. * @param toRemove defines the skeleton to remove
  32740. * @returns the index where the skeleton was in the skeleton list
  32741. */
  32742. removeSkeleton(toRemove: Skeleton): number;
  32743. /**
  32744. * Remove a morph target for the list of scene's morph targets
  32745. * @param toRemove defines the morph target to remove
  32746. * @returns the index where the morph target was in the morph target list
  32747. */
  32748. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32749. /**
  32750. * Remove a light for the list of scene's lights
  32751. * @param toRemove defines the light to remove
  32752. * @returns the index where the light was in the light list
  32753. */
  32754. removeLight(toRemove: Light): number;
  32755. /**
  32756. * Remove a camera for the list of scene's cameras
  32757. * @param toRemove defines the camera to remove
  32758. * @returns the index where the camera was in the camera list
  32759. */
  32760. removeCamera(toRemove: Camera): number;
  32761. /**
  32762. * Remove a particle system for the list of scene's particle systems
  32763. * @param toRemove defines the particle system to remove
  32764. * @returns the index where the particle system was in the particle system list
  32765. */
  32766. removeParticleSystem(toRemove: IParticleSystem): number;
  32767. /**
  32768. * Remove a animation for the list of scene's animations
  32769. * @param toRemove defines the animation to remove
  32770. * @returns the index where the animation was in the animation list
  32771. */
  32772. removeAnimation(toRemove: Animation): number;
  32773. /**
  32774. * Will stop the animation of the given target
  32775. * @param target - the target
  32776. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32777. * @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)
  32778. */
  32779. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32780. /**
  32781. * Removes the given animation group from this scene.
  32782. * @param toRemove The animation group to remove
  32783. * @returns The index of the removed animation group
  32784. */
  32785. removeAnimationGroup(toRemove: AnimationGroup): number;
  32786. /**
  32787. * Removes the given multi-material from this scene.
  32788. * @param toRemove The multi-material to remove
  32789. * @returns The index of the removed multi-material
  32790. */
  32791. removeMultiMaterial(toRemove: MultiMaterial): number;
  32792. /**
  32793. * Removes the given material from this scene.
  32794. * @param toRemove The material to remove
  32795. * @returns The index of the removed material
  32796. */
  32797. removeMaterial(toRemove: Material): number;
  32798. /**
  32799. * Removes the given action manager from this scene.
  32800. * @param toRemove The action manager to remove
  32801. * @returns The index of the removed action manager
  32802. */
  32803. removeActionManager(toRemove: AbstractActionManager): number;
  32804. /**
  32805. * Removes the given texture from this scene.
  32806. * @param toRemove The texture to remove
  32807. * @returns The index of the removed texture
  32808. */
  32809. removeTexture(toRemove: BaseTexture): number;
  32810. /**
  32811. * Adds the given light to this scene
  32812. * @param newLight The light to add
  32813. */
  32814. addLight(newLight: Light): void;
  32815. /**
  32816. * Sorts the list list based on light priorities
  32817. */
  32818. sortLightsByPriority(): void;
  32819. /**
  32820. * Adds the given camera to this scene
  32821. * @param newCamera The camera to add
  32822. */
  32823. addCamera(newCamera: Camera): void;
  32824. /**
  32825. * Adds the given skeleton to this scene
  32826. * @param newSkeleton The skeleton to add
  32827. */
  32828. addSkeleton(newSkeleton: Skeleton): void;
  32829. /**
  32830. * Adds the given particle system to this scene
  32831. * @param newParticleSystem The particle system to add
  32832. */
  32833. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32834. /**
  32835. * Adds the given animation to this scene
  32836. * @param newAnimation The animation to add
  32837. */
  32838. addAnimation(newAnimation: Animation): void;
  32839. /**
  32840. * Adds the given animation group to this scene.
  32841. * @param newAnimationGroup The animation group to add
  32842. */
  32843. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32844. /**
  32845. * Adds the given multi-material to this scene
  32846. * @param newMultiMaterial The multi-material to add
  32847. */
  32848. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32849. /**
  32850. * Adds the given material to this scene
  32851. * @param newMaterial The material to add
  32852. */
  32853. addMaterial(newMaterial: Material): void;
  32854. /**
  32855. * Adds the given morph target to this scene
  32856. * @param newMorphTargetManager The morph target to add
  32857. */
  32858. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32859. /**
  32860. * Adds the given geometry to this scene
  32861. * @param newGeometry The geometry to add
  32862. */
  32863. addGeometry(newGeometry: Geometry): void;
  32864. /**
  32865. * Adds the given action manager to this scene
  32866. * @param newActionManager The action manager to add
  32867. */
  32868. addActionManager(newActionManager: AbstractActionManager): void;
  32869. /**
  32870. * Adds the given texture to this scene.
  32871. * @param newTexture The texture to add
  32872. */
  32873. addTexture(newTexture: BaseTexture): void;
  32874. /**
  32875. * Switch active camera
  32876. * @param newCamera defines the new active camera
  32877. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32878. */
  32879. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32880. /**
  32881. * sets the active camera of the scene using its ID
  32882. * @param id defines the camera's ID
  32883. * @return the new active camera or null if none found.
  32884. */
  32885. setActiveCameraByID(id: string): Nullable<Camera>;
  32886. /**
  32887. * sets the active camera of the scene using its name
  32888. * @param name defines the camera's name
  32889. * @returns the new active camera or null if none found.
  32890. */
  32891. setActiveCameraByName(name: string): Nullable<Camera>;
  32892. /**
  32893. * get an animation group using its name
  32894. * @param name defines the material's name
  32895. * @return the animation group or null if none found.
  32896. */
  32897. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32898. /**
  32899. * Get a material using its unique id
  32900. * @param uniqueId defines the material's unique id
  32901. * @return the material or null if none found.
  32902. */
  32903. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32904. /**
  32905. * get a material using its id
  32906. * @param id defines the material's ID
  32907. * @return the material or null if none found.
  32908. */
  32909. getMaterialByID(id: string): Nullable<Material>;
  32910. /**
  32911. * Gets a the last added material using a given id
  32912. * @param id defines the material's ID
  32913. * @return the last material with the given id or null if none found.
  32914. */
  32915. getLastMaterialByID(id: string): Nullable<Material>;
  32916. /**
  32917. * Gets a material using its name
  32918. * @param name defines the material's name
  32919. * @return the material or null if none found.
  32920. */
  32921. getMaterialByName(name: string): Nullable<Material>;
  32922. /**
  32923. * Gets a camera using its id
  32924. * @param id defines the id to look for
  32925. * @returns the camera or null if not found
  32926. */
  32927. getCameraByID(id: string): Nullable<Camera>;
  32928. /**
  32929. * Gets a camera using its unique id
  32930. * @param uniqueId defines the unique id to look for
  32931. * @returns the camera or null if not found
  32932. */
  32933. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32934. /**
  32935. * Gets a camera using its name
  32936. * @param name defines the camera's name
  32937. * @return the camera or null if none found.
  32938. */
  32939. getCameraByName(name: string): Nullable<Camera>;
  32940. /**
  32941. * Gets a bone using its id
  32942. * @param id defines the bone's id
  32943. * @return the bone or null if not found
  32944. */
  32945. getBoneByID(id: string): Nullable<Bone>;
  32946. /**
  32947. * Gets a bone using its id
  32948. * @param name defines the bone's name
  32949. * @return the bone or null if not found
  32950. */
  32951. getBoneByName(name: string): Nullable<Bone>;
  32952. /**
  32953. * Gets a light node using its name
  32954. * @param name defines the the light's name
  32955. * @return the light or null if none found.
  32956. */
  32957. getLightByName(name: string): Nullable<Light>;
  32958. /**
  32959. * Gets a light node using its id
  32960. * @param id defines the light's id
  32961. * @return the light or null if none found.
  32962. */
  32963. getLightByID(id: string): Nullable<Light>;
  32964. /**
  32965. * Gets a light node using its scene-generated unique ID
  32966. * @param uniqueId defines the light's unique id
  32967. * @return the light or null if none found.
  32968. */
  32969. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32970. /**
  32971. * Gets a particle system by id
  32972. * @param id defines the particle system id
  32973. * @return the corresponding system or null if none found
  32974. */
  32975. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32976. /**
  32977. * Gets a geometry using its ID
  32978. * @param id defines the geometry's id
  32979. * @return the geometry or null if none found.
  32980. */
  32981. getGeometryByID(id: string): Nullable<Geometry>;
  32982. private _getGeometryByUniqueID;
  32983. /**
  32984. * Add a new geometry to this scene
  32985. * @param geometry defines the geometry to be added to the scene.
  32986. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32987. * @return a boolean defining if the geometry was added or not
  32988. */
  32989. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32990. /**
  32991. * Removes an existing geometry
  32992. * @param geometry defines the geometry to be removed from the scene
  32993. * @return a boolean defining if the geometry was removed or not
  32994. */
  32995. removeGeometry(geometry: Geometry): boolean;
  32996. /**
  32997. * Gets the list of geometries attached to the scene
  32998. * @returns an array of Geometry
  32999. */
  33000. getGeometries(): Geometry[];
  33001. /**
  33002. * Gets the first added mesh found of a given ID
  33003. * @param id defines the id to search for
  33004. * @return the mesh found or null if not found at all
  33005. */
  33006. getMeshByID(id: string): Nullable<AbstractMesh>;
  33007. /**
  33008. * Gets a list of meshes using their id
  33009. * @param id defines the id to search for
  33010. * @returns a list of meshes
  33011. */
  33012. getMeshesByID(id: string): Array<AbstractMesh>;
  33013. /**
  33014. * Gets the first added transform node found of a given ID
  33015. * @param id defines the id to search for
  33016. * @return the found transform node or null if not found at all.
  33017. */
  33018. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33019. /**
  33020. * Gets a transform node with its auto-generated unique id
  33021. * @param uniqueId efines the unique id to search for
  33022. * @return the found transform node or null if not found at all.
  33023. */
  33024. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33025. /**
  33026. * Gets a list of transform nodes using their id
  33027. * @param id defines the id to search for
  33028. * @returns a list of transform nodes
  33029. */
  33030. getTransformNodesByID(id: string): Array<TransformNode>;
  33031. /**
  33032. * Gets a mesh with its auto-generated unique id
  33033. * @param uniqueId defines the unique id to search for
  33034. * @return the found mesh or null if not found at all.
  33035. */
  33036. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33037. /**
  33038. * Gets a the last added mesh using a given id
  33039. * @param id defines the id to search for
  33040. * @return the found mesh or null if not found at all.
  33041. */
  33042. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33043. /**
  33044. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33045. * @param id defines the id to search for
  33046. * @return the found node or null if not found at all
  33047. */
  33048. getLastEntryByID(id: string): Nullable<Node>;
  33049. /**
  33050. * Gets a node (Mesh, Camera, Light) using a given id
  33051. * @param id defines the id to search for
  33052. * @return the found node or null if not found at all
  33053. */
  33054. getNodeByID(id: string): Nullable<Node>;
  33055. /**
  33056. * Gets a node (Mesh, Camera, Light) using a given name
  33057. * @param name defines the name to search for
  33058. * @return the found node or null if not found at all.
  33059. */
  33060. getNodeByName(name: string): Nullable<Node>;
  33061. /**
  33062. * Gets a mesh using a given name
  33063. * @param name defines the name to search for
  33064. * @return the found mesh or null if not found at all.
  33065. */
  33066. getMeshByName(name: string): Nullable<AbstractMesh>;
  33067. /**
  33068. * Gets a transform node using a given name
  33069. * @param name defines the name to search for
  33070. * @return the found transform node or null if not found at all.
  33071. */
  33072. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33073. /**
  33074. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33075. * @param id defines the id to search for
  33076. * @return the found skeleton or null if not found at all.
  33077. */
  33078. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33079. /**
  33080. * Gets a skeleton using a given auto generated unique id
  33081. * @param uniqueId defines the unique id to search for
  33082. * @return the found skeleton or null if not found at all.
  33083. */
  33084. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33085. /**
  33086. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33087. * @param id defines the id to search for
  33088. * @return the found skeleton or null if not found at all.
  33089. */
  33090. getSkeletonById(id: string): Nullable<Skeleton>;
  33091. /**
  33092. * Gets a skeleton using a given name
  33093. * @param name defines the name to search for
  33094. * @return the found skeleton or null if not found at all.
  33095. */
  33096. getSkeletonByName(name: string): Nullable<Skeleton>;
  33097. /**
  33098. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33099. * @param id defines the id to search for
  33100. * @return the found morph target manager or null if not found at all.
  33101. */
  33102. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33103. /**
  33104. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33105. * @param id defines the id to search for
  33106. * @return the found morph target or null if not found at all.
  33107. */
  33108. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33109. /**
  33110. * Gets a boolean indicating if the given mesh is active
  33111. * @param mesh defines the mesh to look for
  33112. * @returns true if the mesh is in the active list
  33113. */
  33114. isActiveMesh(mesh: AbstractMesh): boolean;
  33115. /**
  33116. * Return a unique id as a string which can serve as an identifier for the scene
  33117. */
  33118. readonly uid: string;
  33119. /**
  33120. * Add an externaly attached data from its key.
  33121. * This method call will fail and return false, if such key already exists.
  33122. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33123. * @param key the unique key that identifies the data
  33124. * @param data the data object to associate to the key for this Engine instance
  33125. * @return true if no such key were already present and the data was added successfully, false otherwise
  33126. */
  33127. addExternalData<T>(key: string, data: T): boolean;
  33128. /**
  33129. * Get an externaly attached data from its key
  33130. * @param key the unique key that identifies the data
  33131. * @return the associated data, if present (can be null), or undefined if not present
  33132. */
  33133. getExternalData<T>(key: string): Nullable<T>;
  33134. /**
  33135. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33136. * @param key the unique key that identifies the data
  33137. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33138. * @return the associated data, can be null if the factory returned null.
  33139. */
  33140. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33141. /**
  33142. * Remove an externaly attached data from the Engine instance
  33143. * @param key the unique key that identifies the data
  33144. * @return true if the data was successfully removed, false if it doesn't exist
  33145. */
  33146. removeExternalData(key: string): boolean;
  33147. private _evaluateSubMesh;
  33148. /**
  33149. * Clear the processed materials smart array preventing retention point in material dispose.
  33150. */
  33151. freeProcessedMaterials(): void;
  33152. private _preventFreeActiveMeshesAndRenderingGroups;
  33153. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33154. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33155. * when disposing several meshes in a row or a hierarchy of meshes.
  33156. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33157. */
  33158. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33159. /**
  33160. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33161. */
  33162. freeActiveMeshes(): void;
  33163. /**
  33164. * Clear the info related to rendering groups preventing retention points during dispose.
  33165. */
  33166. freeRenderingGroups(): void;
  33167. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33168. /**
  33169. * Lambda returning the list of potentially active meshes.
  33170. */
  33171. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33172. /**
  33173. * Lambda returning the list of potentially active sub meshes.
  33174. */
  33175. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33176. /**
  33177. * Lambda returning the list of potentially intersecting sub meshes.
  33178. */
  33179. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33180. /**
  33181. * Lambda returning the list of potentially colliding sub meshes.
  33182. */
  33183. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33184. private _activeMeshesFrozen;
  33185. /**
  33186. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33187. * @returns the current scene
  33188. */
  33189. freezeActiveMeshes(): Scene;
  33190. /**
  33191. * Use this function to restart evaluating active meshes on every frame
  33192. * @returns the current scene
  33193. */
  33194. unfreezeActiveMeshes(): Scene;
  33195. private _evaluateActiveMeshes;
  33196. private _activeMesh;
  33197. /**
  33198. * Update the transform matrix to update from the current active camera
  33199. * @param force defines a boolean used to force the update even if cache is up to date
  33200. */
  33201. updateTransformMatrix(force?: boolean): void;
  33202. private _bindFrameBuffer;
  33203. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33204. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33205. private _processSubCameras;
  33206. private _checkIntersections;
  33207. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33208. /**
  33209. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33210. */
  33211. getDeterministicFrameTime: () => number;
  33212. /** @hidden */ private _animate(): void;
  33213. /** Execute all animations (for a frame) */
  33214. animate(): void;
  33215. /**
  33216. * Render the scene
  33217. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33218. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33219. */
  33220. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33221. /**
  33222. * Freeze all materials
  33223. * A frozen material will not be updatable but should be faster to render
  33224. */
  33225. freezeMaterials(): void;
  33226. /**
  33227. * Unfreeze all materials
  33228. * A frozen material will not be updatable but should be faster to render
  33229. */
  33230. unfreezeMaterials(): void;
  33231. /**
  33232. * Releases all held ressources
  33233. */
  33234. dispose(): void;
  33235. /**
  33236. * Gets if the scene is already disposed
  33237. */
  33238. readonly isDisposed: boolean;
  33239. /**
  33240. * Call this function to reduce memory footprint of the scene.
  33241. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33242. */
  33243. clearCachedVertexData(): void;
  33244. /**
  33245. * This function will remove the local cached buffer data from texture.
  33246. * It will save memory but will prevent the texture from being rebuilt
  33247. */
  33248. cleanCachedTextureBuffer(): void;
  33249. /**
  33250. * Get the world extend vectors with an optional filter
  33251. *
  33252. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33253. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33254. */
  33255. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33256. min: Vector3;
  33257. max: Vector3;
  33258. };
  33259. /**
  33260. * Creates a ray that can be used to pick in the scene
  33261. * @param x defines the x coordinate of the origin (on-screen)
  33262. * @param y defines the y coordinate of the origin (on-screen)
  33263. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33264. * @param camera defines the camera to use for the picking
  33265. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33266. * @returns a Ray
  33267. */
  33268. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33269. /**
  33270. * Creates a ray that can be used to pick in the scene
  33271. * @param x defines the x coordinate of the origin (on-screen)
  33272. * @param y defines the y coordinate of the origin (on-screen)
  33273. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33274. * @param result defines the ray where to store the picking ray
  33275. * @param camera defines the camera to use for the picking
  33276. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33277. * @returns the current scene
  33278. */
  33279. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33280. /**
  33281. * Creates a ray that can be used to pick in the scene
  33282. * @param x defines the x coordinate of the origin (on-screen)
  33283. * @param y defines the y coordinate of the origin (on-screen)
  33284. * @param camera defines the camera to use for the picking
  33285. * @returns a Ray
  33286. */
  33287. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33288. /**
  33289. * Creates a ray that can be used to pick in the scene
  33290. * @param x defines the x coordinate of the origin (on-screen)
  33291. * @param y defines the y coordinate of the origin (on-screen)
  33292. * @param result defines the ray where to store the picking ray
  33293. * @param camera defines the camera to use for the picking
  33294. * @returns the current scene
  33295. */
  33296. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33297. /** Launch a ray to try to pick a mesh in the scene
  33298. * @param x position on screen
  33299. * @param y position on screen
  33300. * @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
  33301. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33302. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33303. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33304. * @returns a PickingInfo
  33305. */
  33306. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33307. /** Use the given ray to pick a mesh in the scene
  33308. * @param ray The ray to use to pick meshes
  33309. * @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
  33310. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33311. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33312. * @returns a PickingInfo
  33313. */
  33314. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33315. /**
  33316. * Launch a ray to try to pick a mesh in the scene
  33317. * @param x X position on screen
  33318. * @param y Y position on screen
  33319. * @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
  33320. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33321. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33322. * @returns an array of PickingInfo
  33323. */
  33324. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33325. /**
  33326. * Launch a ray to try to pick a mesh in the scene
  33327. * @param ray Ray to use
  33328. * @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
  33329. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33330. * @returns an array of PickingInfo
  33331. */
  33332. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33333. /**
  33334. * Force the value of meshUnderPointer
  33335. * @param mesh defines the mesh to use
  33336. */
  33337. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33338. /**
  33339. * Gets the mesh under the pointer
  33340. * @returns a Mesh or null if no mesh is under the pointer
  33341. */
  33342. getPointerOverMesh(): Nullable<AbstractMesh>;
  33343. /** @hidden */ private _rebuildGeometries(): void;
  33344. /** @hidden */ private _rebuildTextures(): void;
  33345. private _getByTags;
  33346. /**
  33347. * Get a list of meshes by tags
  33348. * @param tagsQuery defines the tags query to use
  33349. * @param forEach defines a predicate used to filter results
  33350. * @returns an array of Mesh
  33351. */
  33352. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33353. /**
  33354. * Get a list of cameras by tags
  33355. * @param tagsQuery defines the tags query to use
  33356. * @param forEach defines a predicate used to filter results
  33357. * @returns an array of Camera
  33358. */
  33359. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33360. /**
  33361. * Get a list of lights by tags
  33362. * @param tagsQuery defines the tags query to use
  33363. * @param forEach defines a predicate used to filter results
  33364. * @returns an array of Light
  33365. */
  33366. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33367. /**
  33368. * Get a list of materials by tags
  33369. * @param tagsQuery defines the tags query to use
  33370. * @param forEach defines a predicate used to filter results
  33371. * @returns an array of Material
  33372. */
  33373. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33374. /**
  33375. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33376. * This allowed control for front to back rendering or reversly depending of the special needs.
  33377. *
  33378. * @param renderingGroupId The rendering group id corresponding to its index
  33379. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33380. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33381. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33382. */
  33383. 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;
  33384. /**
  33385. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33386. *
  33387. * @param renderingGroupId The rendering group id corresponding to its index
  33388. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33389. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33390. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33391. */
  33392. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33393. /**
  33394. * Gets the current auto clear configuration for one rendering group of the rendering
  33395. * manager.
  33396. * @param index the rendering group index to get the information for
  33397. * @returns The auto clear setup for the requested rendering group
  33398. */
  33399. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33400. private _blockMaterialDirtyMechanism;
  33401. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33402. blockMaterialDirtyMechanism: boolean;
  33403. /**
  33404. * Will flag all materials as dirty to trigger new shader compilation
  33405. * @param flag defines the flag used to specify which material part must be marked as dirty
  33406. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33407. */
  33408. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33409. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33410. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33411. }
  33412. }
  33413. declare module BABYLON {
  33414. /**
  33415. * Set of assets to keep when moving a scene into an asset container.
  33416. */
  33417. export class KeepAssets extends AbstractScene {
  33418. }
  33419. /**
  33420. * Container with a set of assets that can be added or removed from a scene.
  33421. */
  33422. export class AssetContainer extends AbstractScene {
  33423. /**
  33424. * The scene the AssetContainer belongs to.
  33425. */
  33426. scene: Scene;
  33427. /**
  33428. * Instantiates an AssetContainer.
  33429. * @param scene The scene the AssetContainer belongs to.
  33430. */
  33431. constructor(scene: Scene);
  33432. /**
  33433. * Adds all the assets from the container to the scene.
  33434. */
  33435. addAllToScene(): void;
  33436. /**
  33437. * Removes all the assets in the container from the scene
  33438. */
  33439. removeAllFromScene(): void;
  33440. /**
  33441. * Disposes all the assets in the container
  33442. */
  33443. dispose(): void;
  33444. private _moveAssets;
  33445. /**
  33446. * Removes all the assets contained in the scene and adds them to the container.
  33447. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33448. */
  33449. moveAllFromScene(keepAssets?: KeepAssets): void;
  33450. /**
  33451. * 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.
  33452. * @returns the root mesh
  33453. */
  33454. createRootMesh(): Mesh;
  33455. }
  33456. }
  33457. declare module BABYLON {
  33458. /**
  33459. * Defines how the parser contract is defined.
  33460. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33461. */
  33462. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33463. /**
  33464. * Defines how the individual parser contract is defined.
  33465. * These parser can parse an individual asset
  33466. */
  33467. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33468. /**
  33469. * Base class of the scene acting as a container for the different elements composing a scene.
  33470. * This class is dynamically extended by the different components of the scene increasing
  33471. * flexibility and reducing coupling
  33472. */
  33473. export abstract class AbstractScene {
  33474. /**
  33475. * Stores the list of available parsers in the application.
  33476. */
  33477. private static _BabylonFileParsers;
  33478. /**
  33479. * Stores the list of available individual parsers in the application.
  33480. */
  33481. private static _IndividualBabylonFileParsers;
  33482. /**
  33483. * Adds a parser in the list of available ones
  33484. * @param name Defines the name of the parser
  33485. * @param parser Defines the parser to add
  33486. */
  33487. static AddParser(name: string, parser: BabylonFileParser): void;
  33488. /**
  33489. * Gets a general parser from the list of avaialble ones
  33490. * @param name Defines the name of the parser
  33491. * @returns the requested parser or null
  33492. */
  33493. static GetParser(name: string): Nullable<BabylonFileParser>;
  33494. /**
  33495. * Adds n individual parser in the list of available ones
  33496. * @param name Defines the name of the parser
  33497. * @param parser Defines the parser to add
  33498. */
  33499. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33500. /**
  33501. * Gets an individual parser from the list of avaialble ones
  33502. * @param name Defines the name of the parser
  33503. * @returns the requested parser or null
  33504. */
  33505. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33506. /**
  33507. * Parser json data and populate both a scene and its associated container object
  33508. * @param jsonData Defines the data to parse
  33509. * @param scene Defines the scene to parse the data for
  33510. * @param container Defines the container attached to the parsing sequence
  33511. * @param rootUrl Defines the root url of the data
  33512. */
  33513. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33514. /**
  33515. * Gets the list of root nodes (ie. nodes with no parent)
  33516. */
  33517. rootNodes: Node[];
  33518. /** All of the cameras added to this scene
  33519. * @see http://doc.babylonjs.com/babylon101/cameras
  33520. */
  33521. cameras: Camera[];
  33522. /**
  33523. * All of the lights added to this scene
  33524. * @see http://doc.babylonjs.com/babylon101/lights
  33525. */
  33526. lights: Light[];
  33527. /**
  33528. * All of the (abstract) meshes added to this scene
  33529. */
  33530. meshes: AbstractMesh[];
  33531. /**
  33532. * The list of skeletons added to the scene
  33533. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33534. */
  33535. skeletons: Skeleton[];
  33536. /**
  33537. * All of the particle systems added to this scene
  33538. * @see http://doc.babylonjs.com/babylon101/particles
  33539. */
  33540. particleSystems: IParticleSystem[];
  33541. /**
  33542. * Gets a list of Animations associated with the scene
  33543. */
  33544. animations: Animation[];
  33545. /**
  33546. * All of the animation groups added to this scene
  33547. * @see http://doc.babylonjs.com/how_to/group
  33548. */
  33549. animationGroups: AnimationGroup[];
  33550. /**
  33551. * All of the multi-materials added to this scene
  33552. * @see http://doc.babylonjs.com/how_to/multi_materials
  33553. */
  33554. multiMaterials: MultiMaterial[];
  33555. /**
  33556. * All of the materials added to this scene
  33557. * In the context of a Scene, it is not supposed to be modified manually.
  33558. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33559. * Note also that the order of the Material wihin the array is not significant and might change.
  33560. * @see http://doc.babylonjs.com/babylon101/materials
  33561. */
  33562. materials: Material[];
  33563. /**
  33564. * The list of morph target managers added to the scene
  33565. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33566. */
  33567. morphTargetManagers: MorphTargetManager[];
  33568. /**
  33569. * The list of geometries used in the scene.
  33570. */
  33571. geometries: Geometry[];
  33572. /**
  33573. * All of the tranform nodes added to this scene
  33574. * In the context of a Scene, it is not supposed to be modified manually.
  33575. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33576. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33577. * @see http://doc.babylonjs.com/how_to/transformnode
  33578. */
  33579. transformNodes: TransformNode[];
  33580. /**
  33581. * ActionManagers available on the scene.
  33582. */
  33583. actionManagers: AbstractActionManager[];
  33584. /**
  33585. * Textures to keep.
  33586. */
  33587. textures: BaseTexture[];
  33588. /**
  33589. * Environment texture for the scene
  33590. */
  33591. environmentTexture: Nullable<BaseTexture>;
  33592. }
  33593. }
  33594. declare module BABYLON {
  33595. /**
  33596. * Interface used to define options for Sound class
  33597. */
  33598. export interface ISoundOptions {
  33599. /**
  33600. * Does the sound autoplay once loaded.
  33601. */
  33602. autoplay?: boolean;
  33603. /**
  33604. * Does the sound loop after it finishes playing once.
  33605. */
  33606. loop?: boolean;
  33607. /**
  33608. * Sound's volume
  33609. */
  33610. volume?: number;
  33611. /**
  33612. * Is it a spatial sound?
  33613. */
  33614. spatialSound?: boolean;
  33615. /**
  33616. * Maximum distance to hear that sound
  33617. */
  33618. maxDistance?: number;
  33619. /**
  33620. * Uses user defined attenuation function
  33621. */
  33622. useCustomAttenuation?: boolean;
  33623. /**
  33624. * Define the roll off factor of spatial sounds.
  33625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33626. */
  33627. rolloffFactor?: number;
  33628. /**
  33629. * Define the reference distance the sound should be heard perfectly.
  33630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33631. */
  33632. refDistance?: number;
  33633. /**
  33634. * Define the distance attenuation model the sound will follow.
  33635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33636. */
  33637. distanceModel?: string;
  33638. /**
  33639. * Defines the playback speed (1 by default)
  33640. */
  33641. playbackRate?: number;
  33642. /**
  33643. * Defines if the sound is from a streaming source
  33644. */
  33645. streaming?: boolean;
  33646. /**
  33647. * Defines an optional length (in seconds) inside the sound file
  33648. */
  33649. length?: number;
  33650. /**
  33651. * Defines an optional offset (in seconds) inside the sound file
  33652. */
  33653. offset?: number;
  33654. /**
  33655. * If true, URLs will not be required to state the audio file codec to use.
  33656. */
  33657. skipCodecCheck?: boolean;
  33658. }
  33659. /**
  33660. * Defines a sound that can be played in the application.
  33661. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33663. */
  33664. export class Sound {
  33665. /**
  33666. * The name of the sound in the scene.
  33667. */
  33668. name: string;
  33669. /**
  33670. * Does the sound autoplay once loaded.
  33671. */
  33672. autoplay: boolean;
  33673. /**
  33674. * Does the sound loop after it finishes playing once.
  33675. */
  33676. loop: boolean;
  33677. /**
  33678. * Does the sound use a custom attenuation curve to simulate the falloff
  33679. * happening when the source gets further away from the camera.
  33680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33681. */
  33682. useCustomAttenuation: boolean;
  33683. /**
  33684. * The sound track id this sound belongs to.
  33685. */
  33686. soundTrackId: number;
  33687. /**
  33688. * Is this sound currently played.
  33689. */
  33690. isPlaying: boolean;
  33691. /**
  33692. * Is this sound currently paused.
  33693. */
  33694. isPaused: boolean;
  33695. /**
  33696. * Does this sound enables spatial sound.
  33697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33698. */
  33699. spatialSound: boolean;
  33700. /**
  33701. * Define the reference distance the sound should be heard perfectly.
  33702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33703. */
  33704. refDistance: number;
  33705. /**
  33706. * Define the roll off factor of spatial sounds.
  33707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33708. */
  33709. rolloffFactor: number;
  33710. /**
  33711. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33713. */
  33714. maxDistance: number;
  33715. /**
  33716. * Define the distance attenuation model the sound will follow.
  33717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33718. */
  33719. distanceModel: string;
  33720. /**
  33721. * @hidden
  33722. * Back Compat
  33723. **/
  33724. onended: () => any;
  33725. /**
  33726. * Observable event when the current playing sound finishes.
  33727. */
  33728. onEndedObservable: Observable<Sound>;
  33729. private _panningModel;
  33730. private _playbackRate;
  33731. private _streaming;
  33732. private _startTime;
  33733. private _startOffset;
  33734. private _position;
  33735. /** @hidden */ private _positionInEmitterSpace: boolean;
  33736. private _localDirection;
  33737. private _volume;
  33738. private _isReadyToPlay;
  33739. private _isDirectional;
  33740. private _readyToPlayCallback;
  33741. private _audioBuffer;
  33742. private _soundSource;
  33743. private _streamingSource;
  33744. private _soundPanner;
  33745. private _soundGain;
  33746. private _inputAudioNode;
  33747. private _outputAudioNode;
  33748. private _coneInnerAngle;
  33749. private _coneOuterAngle;
  33750. private _coneOuterGain;
  33751. private _scene;
  33752. private _connectedTransformNode;
  33753. private _customAttenuationFunction;
  33754. private _registerFunc;
  33755. private _isOutputConnected;
  33756. private _htmlAudioElement;
  33757. private _urlType;
  33758. private _length?;
  33759. private _offset?;
  33760. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33761. /**
  33762. * Create a sound and attach it to a scene
  33763. * @param name Name of your sound
  33764. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33765. * @param scene defines the scene the sound belongs to
  33766. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33767. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33768. */
  33769. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  33770. /**
  33771. * Release the sound and its associated resources
  33772. */
  33773. dispose(): void;
  33774. /**
  33775. * Gets if the sounds is ready to be played or not.
  33776. * @returns true if ready, otherwise false
  33777. */
  33778. isReady(): boolean;
  33779. private _soundLoaded;
  33780. /**
  33781. * Sets the data of the sound from an audiobuffer
  33782. * @param audioBuffer The audioBuffer containing the data
  33783. */
  33784. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33785. /**
  33786. * Updates the current sounds options such as maxdistance, loop...
  33787. * @param options A JSON object containing values named as the object properties
  33788. */
  33789. updateOptions(options: ISoundOptions): void;
  33790. private _createSpatialParameters;
  33791. private _updateSpatialParameters;
  33792. /**
  33793. * Switch the panning model to HRTF:
  33794. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33796. */
  33797. switchPanningModelToHRTF(): void;
  33798. /**
  33799. * Switch the panning model to Equal Power:
  33800. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33802. */
  33803. switchPanningModelToEqualPower(): void;
  33804. private _switchPanningModel;
  33805. /**
  33806. * Connect this sound to a sound track audio node like gain...
  33807. * @param soundTrackAudioNode the sound track audio node to connect to
  33808. */
  33809. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33810. /**
  33811. * Transform this sound into a directional source
  33812. * @param coneInnerAngle Size of the inner cone in degree
  33813. * @param coneOuterAngle Size of the outer cone in degree
  33814. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33815. */
  33816. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33817. /**
  33818. * Gets or sets the inner angle for the directional cone.
  33819. */
  33820. /**
  33821. * Gets or sets the inner angle for the directional cone.
  33822. */
  33823. directionalConeInnerAngle: number;
  33824. /**
  33825. * Gets or sets the outer angle for the directional cone.
  33826. */
  33827. /**
  33828. * Gets or sets the outer angle for the directional cone.
  33829. */
  33830. directionalConeOuterAngle: number;
  33831. /**
  33832. * Sets the position of the emitter if spatial sound is enabled
  33833. * @param newPosition Defines the new posisiton
  33834. */
  33835. setPosition(newPosition: Vector3): void;
  33836. /**
  33837. * Sets the local direction of the emitter if spatial sound is enabled
  33838. * @param newLocalDirection Defines the new local direction
  33839. */
  33840. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33841. private _updateDirection;
  33842. /** @hidden */
  33843. updateDistanceFromListener(): void;
  33844. /**
  33845. * Sets a new custom attenuation function for the sound.
  33846. * @param callback Defines the function used for the attenuation
  33847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33848. */
  33849. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33850. /**
  33851. * Play the sound
  33852. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33853. * @param offset (optional) Start the sound at a specific time in seconds
  33854. * @param length (optional) Sound duration (in seconds)
  33855. */
  33856. play(time?: number, offset?: number, length?: number): void;
  33857. private _onended;
  33858. /**
  33859. * Stop the sound
  33860. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33861. */
  33862. stop(time?: number): void;
  33863. /**
  33864. * Put the sound in pause
  33865. */
  33866. pause(): void;
  33867. /**
  33868. * Sets a dedicated volume for this sounds
  33869. * @param newVolume Define the new volume of the sound
  33870. * @param time Define time for gradual change to new volume
  33871. */
  33872. setVolume(newVolume: number, time?: number): void;
  33873. /**
  33874. * Set the sound play back rate
  33875. * @param newPlaybackRate Define the playback rate the sound should be played at
  33876. */
  33877. setPlaybackRate(newPlaybackRate: number): void;
  33878. /**
  33879. * Gets the volume of the sound.
  33880. * @returns the volume of the sound
  33881. */
  33882. getVolume(): number;
  33883. /**
  33884. * Attach the sound to a dedicated mesh
  33885. * @param transformNode The transform node to connect the sound with
  33886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33887. */
  33888. attachToMesh(transformNode: TransformNode): void;
  33889. /**
  33890. * Detach the sound from the previously attached mesh
  33891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33892. */
  33893. detachFromMesh(): void;
  33894. private _onRegisterAfterWorldMatrixUpdate;
  33895. /**
  33896. * Clone the current sound in the scene.
  33897. * @returns the new sound clone
  33898. */
  33899. clone(): Nullable<Sound>;
  33900. /**
  33901. * Gets the current underlying audio buffer containing the data
  33902. * @returns the audio buffer
  33903. */
  33904. getAudioBuffer(): Nullable<AudioBuffer>;
  33905. /**
  33906. * Serializes the Sound in a JSON representation
  33907. * @returns the JSON representation of the sound
  33908. */
  33909. serialize(): any;
  33910. /**
  33911. * Parse a JSON representation of a sound to innstantiate in a given scene
  33912. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33913. * @param scene Define the scene the new parsed sound should be created in
  33914. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33915. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33916. * @returns the newly parsed sound
  33917. */
  33918. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33919. }
  33920. }
  33921. declare module BABYLON {
  33922. /**
  33923. * This defines an action helpful to play a defined sound on a triggered action.
  33924. */
  33925. export class PlaySoundAction extends Action {
  33926. private _sound;
  33927. /**
  33928. * Instantiate the action
  33929. * @param triggerOptions defines the trigger options
  33930. * @param sound defines the sound to play
  33931. * @param condition defines the trigger related conditions
  33932. */
  33933. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33934. /** @hidden */ private _prepare(): void;
  33935. /**
  33936. * Execute the action and play the sound.
  33937. */
  33938. execute(): void;
  33939. /**
  33940. * Serializes the actions and its related information.
  33941. * @param parent defines the object to serialize in
  33942. * @returns the serialized object
  33943. */
  33944. serialize(parent: any): any;
  33945. }
  33946. /**
  33947. * This defines an action helpful to stop a defined sound on a triggered action.
  33948. */
  33949. export class StopSoundAction extends Action {
  33950. private _sound;
  33951. /**
  33952. * Instantiate the action
  33953. * @param triggerOptions defines the trigger options
  33954. * @param sound defines the sound to stop
  33955. * @param condition defines the trigger related conditions
  33956. */
  33957. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33958. /** @hidden */ private _prepare(): void;
  33959. /**
  33960. * Execute the action and stop the sound.
  33961. */
  33962. execute(): void;
  33963. /**
  33964. * Serializes the actions and its related information.
  33965. * @param parent defines the object to serialize in
  33966. * @returns the serialized object
  33967. */
  33968. serialize(parent: any): any;
  33969. }
  33970. }
  33971. declare module BABYLON {
  33972. /**
  33973. * This defines an action responsible to change the value of a property
  33974. * by interpolating between its current value and the newly set one once triggered.
  33975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33976. */
  33977. export class InterpolateValueAction extends Action {
  33978. /**
  33979. * Defines the path of the property where the value should be interpolated
  33980. */
  33981. propertyPath: string;
  33982. /**
  33983. * Defines the target value at the end of the interpolation.
  33984. */
  33985. value: any;
  33986. /**
  33987. * Defines the time it will take for the property to interpolate to the value.
  33988. */
  33989. duration: number;
  33990. /**
  33991. * Defines if the other scene animations should be stopped when the action has been triggered
  33992. */
  33993. stopOtherAnimations?: boolean;
  33994. /**
  33995. * Defines a callback raised once the interpolation animation has been done.
  33996. */
  33997. onInterpolationDone?: () => void;
  33998. /**
  33999. * Observable triggered once the interpolation animation has been done.
  34000. */
  34001. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34002. private _target;
  34003. private _effectiveTarget;
  34004. private _property;
  34005. /**
  34006. * Instantiate the action
  34007. * @param triggerOptions defines the trigger options
  34008. * @param target defines the object containing the value to interpolate
  34009. * @param propertyPath defines the path to the property in the target object
  34010. * @param value defines the target value at the end of the interpolation
  34011. * @param duration deines the time it will take for the property to interpolate to the value.
  34012. * @param condition defines the trigger related conditions
  34013. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34014. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34015. */
  34016. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34017. /** @hidden */ private _prepare(): void;
  34018. /**
  34019. * Execute the action starts the value interpolation.
  34020. */
  34021. execute(): void;
  34022. /**
  34023. * Serializes the actions and its related information.
  34024. * @param parent defines the object to serialize in
  34025. * @returns the serialized object
  34026. */
  34027. serialize(parent: any): any;
  34028. }
  34029. }
  34030. declare module BABYLON {
  34031. /**
  34032. * Options allowed during the creation of a sound track.
  34033. */
  34034. export interface ISoundTrackOptions {
  34035. /**
  34036. * The volume the sound track should take during creation
  34037. */
  34038. volume?: number;
  34039. /**
  34040. * Define if the sound track is the main sound track of the scene
  34041. */
  34042. mainTrack?: boolean;
  34043. }
  34044. /**
  34045. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34046. * It will be also used in a future release to apply effects on a specific track.
  34047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34048. */
  34049. export class SoundTrack {
  34050. /**
  34051. * The unique identifier of the sound track in the scene.
  34052. */
  34053. id: number;
  34054. /**
  34055. * The list of sounds included in the sound track.
  34056. */
  34057. soundCollection: Array<Sound>;
  34058. private _outputAudioNode;
  34059. private _scene;
  34060. private _isMainTrack;
  34061. private _connectedAnalyser;
  34062. private _options;
  34063. private _isInitialized;
  34064. /**
  34065. * Creates a new sound track.
  34066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34067. * @param scene Define the scene the sound track belongs to
  34068. * @param options
  34069. */
  34070. constructor(scene: Scene, options?: ISoundTrackOptions);
  34071. private _initializeSoundTrackAudioGraph;
  34072. /**
  34073. * Release the sound track and its associated resources
  34074. */
  34075. dispose(): void;
  34076. /**
  34077. * Adds a sound to this sound track
  34078. * @param sound define the cound to add
  34079. * @ignoreNaming
  34080. */
  34081. AddSound(sound: Sound): void;
  34082. /**
  34083. * Removes a sound to this sound track
  34084. * @param sound define the cound to remove
  34085. * @ignoreNaming
  34086. */
  34087. RemoveSound(sound: Sound): void;
  34088. /**
  34089. * Set a global volume for the full sound track.
  34090. * @param newVolume Define the new volume of the sound track
  34091. */
  34092. setVolume(newVolume: number): void;
  34093. /**
  34094. * Switch the panning model to HRTF:
  34095. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34097. */
  34098. switchPanningModelToHRTF(): void;
  34099. /**
  34100. * Switch the panning model to Equal Power:
  34101. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34103. */
  34104. switchPanningModelToEqualPower(): void;
  34105. /**
  34106. * Connect the sound track to an audio analyser allowing some amazing
  34107. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34109. * @param analyser The analyser to connect to the engine
  34110. */
  34111. connectToAnalyser(analyser: Analyser): void;
  34112. }
  34113. }
  34114. declare module BABYLON {
  34115. interface AbstractScene {
  34116. /**
  34117. * The list of sounds used in the scene.
  34118. */
  34119. sounds: Nullable<Array<Sound>>;
  34120. }
  34121. interface Scene {
  34122. /**
  34123. * @hidden
  34124. * Backing field
  34125. */ private _mainSoundTrack: SoundTrack;
  34126. /**
  34127. * The main sound track played by the scene.
  34128. * It cotains your primary collection of sounds.
  34129. */
  34130. mainSoundTrack: SoundTrack;
  34131. /**
  34132. * The list of sound tracks added to the scene
  34133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34134. */
  34135. soundTracks: Nullable<Array<SoundTrack>>;
  34136. /**
  34137. * Gets a sound using a given name
  34138. * @param name defines the name to search for
  34139. * @return the found sound or null if not found at all.
  34140. */
  34141. getSoundByName(name: string): Nullable<Sound>;
  34142. /**
  34143. * Gets or sets if audio support is enabled
  34144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34145. */
  34146. audioEnabled: boolean;
  34147. /**
  34148. * Gets or sets if audio will be output to headphones
  34149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34150. */
  34151. headphone: boolean;
  34152. }
  34153. /**
  34154. * Defines the sound scene component responsible to manage any sounds
  34155. * in a given scene.
  34156. */
  34157. export class AudioSceneComponent implements ISceneSerializableComponent {
  34158. /**
  34159. * The component name helpfull to identify the component in the list of scene components.
  34160. */
  34161. readonly name: string;
  34162. /**
  34163. * The scene the component belongs to.
  34164. */
  34165. scene: Scene;
  34166. private _audioEnabled;
  34167. /**
  34168. * Gets whether audio is enabled or not.
  34169. * Please use related enable/disable method to switch state.
  34170. */
  34171. readonly audioEnabled: boolean;
  34172. private _headphone;
  34173. /**
  34174. * Gets whether audio is outputing to headphone or not.
  34175. * Please use the according Switch methods to change output.
  34176. */
  34177. readonly headphone: boolean;
  34178. /**
  34179. * Creates a new instance of the component for the given scene
  34180. * @param scene Defines the scene to register the component in
  34181. */
  34182. constructor(scene: Scene);
  34183. /**
  34184. * Registers the component in a given scene
  34185. */
  34186. register(): void;
  34187. /**
  34188. * Rebuilds the elements related to this component in case of
  34189. * context lost for instance.
  34190. */
  34191. rebuild(): void;
  34192. /**
  34193. * Serializes the component data to the specified json object
  34194. * @param serializationObject The object to serialize to
  34195. */
  34196. serialize(serializationObject: any): void;
  34197. /**
  34198. * Adds all the elements from the container to the scene
  34199. * @param container the container holding the elements
  34200. */
  34201. addFromContainer(container: AbstractScene): void;
  34202. /**
  34203. * Removes all the elements in the container from the scene
  34204. * @param container contains the elements to remove
  34205. * @param dispose if the removed element should be disposed (default: false)
  34206. */
  34207. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34208. /**
  34209. * Disposes the component and the associated ressources.
  34210. */
  34211. dispose(): void;
  34212. /**
  34213. * Disables audio in the associated scene.
  34214. */
  34215. disableAudio(): void;
  34216. /**
  34217. * Enables audio in the associated scene.
  34218. */
  34219. enableAudio(): void;
  34220. /**
  34221. * Switch audio to headphone output.
  34222. */
  34223. switchAudioModeForHeadphones(): void;
  34224. /**
  34225. * Switch audio to normal speakers.
  34226. */
  34227. switchAudioModeForNormalSpeakers(): void;
  34228. private _afterRender;
  34229. }
  34230. }
  34231. declare module BABYLON {
  34232. /**
  34233. * Wraps one or more Sound objects and selects one with random weight for playback.
  34234. */
  34235. export class WeightedSound {
  34236. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34237. loop: boolean;
  34238. private _coneInnerAngle;
  34239. private _coneOuterAngle;
  34240. private _volume;
  34241. /** A Sound is currently playing. */
  34242. isPlaying: boolean;
  34243. /** A Sound is currently paused. */
  34244. isPaused: boolean;
  34245. private _sounds;
  34246. private _weights;
  34247. private _currentIndex?;
  34248. /**
  34249. * Creates a new WeightedSound from the list of sounds given.
  34250. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34251. * @param sounds Array of Sounds that will be selected from.
  34252. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34253. */
  34254. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34255. /**
  34256. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34257. */
  34258. /**
  34259. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34260. */
  34261. directionalConeInnerAngle: number;
  34262. /**
  34263. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34264. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34265. */
  34266. /**
  34267. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34268. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34269. */
  34270. directionalConeOuterAngle: number;
  34271. /**
  34272. * Playback volume.
  34273. */
  34274. /**
  34275. * Playback volume.
  34276. */
  34277. volume: number;
  34278. private _onended;
  34279. /**
  34280. * Suspend playback
  34281. */
  34282. pause(): void;
  34283. /**
  34284. * Stop playback
  34285. */
  34286. stop(): void;
  34287. /**
  34288. * Start playback.
  34289. * @param startOffset Position the clip head at a specific time in seconds.
  34290. */
  34291. play(startOffset?: number): void;
  34292. }
  34293. }
  34294. declare module BABYLON {
  34295. /**
  34296. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34298. */
  34299. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34300. /**
  34301. * Gets the name of the behavior.
  34302. */
  34303. readonly name: string;
  34304. /**
  34305. * The easing function used by animations
  34306. */
  34307. static EasingFunction: BackEase;
  34308. /**
  34309. * The easing mode used by animations
  34310. */
  34311. static EasingMode: number;
  34312. /**
  34313. * The duration of the animation, in milliseconds
  34314. */
  34315. transitionDuration: number;
  34316. /**
  34317. * Length of the distance animated by the transition when lower radius is reached
  34318. */
  34319. lowerRadiusTransitionRange: number;
  34320. /**
  34321. * Length of the distance animated by the transition when upper radius is reached
  34322. */
  34323. upperRadiusTransitionRange: number;
  34324. private _autoTransitionRange;
  34325. /**
  34326. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34327. */
  34328. /**
  34329. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34330. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34331. */
  34332. autoTransitionRange: boolean;
  34333. private _attachedCamera;
  34334. private _onAfterCheckInputsObserver;
  34335. private _onMeshTargetChangedObserver;
  34336. /**
  34337. * Initializes the behavior.
  34338. */
  34339. init(): void;
  34340. /**
  34341. * Attaches the behavior to its arc rotate camera.
  34342. * @param camera Defines the camera to attach the behavior to
  34343. */
  34344. attach(camera: ArcRotateCamera): void;
  34345. /**
  34346. * Detaches the behavior from its current arc rotate camera.
  34347. */
  34348. detach(): void;
  34349. private _radiusIsAnimating;
  34350. private _radiusBounceTransition;
  34351. private _animatables;
  34352. private _cachedWheelPrecision;
  34353. /**
  34354. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34355. * @param radiusLimit The limit to check against.
  34356. * @return Bool to indicate if at limit.
  34357. */
  34358. private _isRadiusAtLimit;
  34359. /**
  34360. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34361. * @param radiusDelta The delta by which to animate to. Can be negative.
  34362. */
  34363. private _applyBoundRadiusAnimation;
  34364. /**
  34365. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34366. */
  34367. protected _clearAnimationLocks(): void;
  34368. /**
  34369. * Stops and removes all animations that have been applied to the camera
  34370. */
  34371. stopAllAnimations(): void;
  34372. }
  34373. }
  34374. declare module BABYLON {
  34375. /**
  34376. * 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.
  34377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34378. */
  34379. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34380. /**
  34381. * Gets the name of the behavior.
  34382. */
  34383. readonly name: string;
  34384. private _mode;
  34385. private _radiusScale;
  34386. private _positionScale;
  34387. private _defaultElevation;
  34388. private _elevationReturnTime;
  34389. private _elevationReturnWaitTime;
  34390. private _zoomStopsAnimation;
  34391. private _framingTime;
  34392. /**
  34393. * The easing function used by animations
  34394. */
  34395. static EasingFunction: ExponentialEase;
  34396. /**
  34397. * The easing mode used by animations
  34398. */
  34399. static EasingMode: number;
  34400. /**
  34401. * Sets the current mode used by the behavior
  34402. */
  34403. /**
  34404. * Gets current mode used by the behavior.
  34405. */
  34406. mode: number;
  34407. /**
  34408. * Sets the scale applied to the radius (1 by default)
  34409. */
  34410. /**
  34411. * Gets the scale applied to the radius
  34412. */
  34413. radiusScale: number;
  34414. /**
  34415. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34416. */
  34417. /**
  34418. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34419. */
  34420. positionScale: number;
  34421. /**
  34422. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34423. * behaviour is triggered, in radians.
  34424. */
  34425. /**
  34426. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34427. * behaviour is triggered, in radians.
  34428. */
  34429. defaultElevation: number;
  34430. /**
  34431. * Sets the time (in milliseconds) taken to return to the default beta position.
  34432. * Negative value indicates camera should not return to default.
  34433. */
  34434. /**
  34435. * Gets the time (in milliseconds) taken to return to the default beta position.
  34436. * Negative value indicates camera should not return to default.
  34437. */
  34438. elevationReturnTime: number;
  34439. /**
  34440. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34441. */
  34442. /**
  34443. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34444. */
  34445. elevationReturnWaitTime: number;
  34446. /**
  34447. * Sets the flag that indicates if user zooming should stop animation.
  34448. */
  34449. /**
  34450. * Gets the flag that indicates if user zooming should stop animation.
  34451. */
  34452. zoomStopsAnimation: boolean;
  34453. /**
  34454. * Sets the transition time when framing the mesh, in milliseconds
  34455. */
  34456. /**
  34457. * Gets the transition time when framing the mesh, in milliseconds
  34458. */
  34459. framingTime: number;
  34460. /**
  34461. * Define if the behavior should automatically change the configured
  34462. * camera limits and sensibilities.
  34463. */
  34464. autoCorrectCameraLimitsAndSensibility: boolean;
  34465. private _onPrePointerObservableObserver;
  34466. private _onAfterCheckInputsObserver;
  34467. private _onMeshTargetChangedObserver;
  34468. private _attachedCamera;
  34469. private _isPointerDown;
  34470. private _lastInteractionTime;
  34471. /**
  34472. * Initializes the behavior.
  34473. */
  34474. init(): void;
  34475. /**
  34476. * Attaches the behavior to its arc rotate camera.
  34477. * @param camera Defines the camera to attach the behavior to
  34478. */
  34479. attach(camera: ArcRotateCamera): void;
  34480. /**
  34481. * Detaches the behavior from its current arc rotate camera.
  34482. */
  34483. detach(): void;
  34484. private _animatables;
  34485. private _betaIsAnimating;
  34486. private _betaTransition;
  34487. private _radiusTransition;
  34488. private _vectorTransition;
  34489. /**
  34490. * Targets the given mesh and updates zoom level accordingly.
  34491. * @param mesh The mesh to target.
  34492. * @param radius Optional. If a cached radius position already exists, overrides default.
  34493. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34494. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34495. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34496. */
  34497. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34498. /**
  34499. * Targets the given mesh with its children and updates zoom level accordingly.
  34500. * @param mesh The mesh to target.
  34501. * @param radius Optional. If a cached radius position already exists, overrides default.
  34502. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34503. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34504. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34505. */
  34506. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34507. /**
  34508. * Targets the given meshes with their children and updates zoom level accordingly.
  34509. * @param meshes The mesh to target.
  34510. * @param radius Optional. If a cached radius position already exists, overrides default.
  34511. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34512. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34513. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34514. */
  34515. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34516. /**
  34517. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34518. * @param minimumWorld Determines the smaller position of the bounding box extend
  34519. * @param maximumWorld Determines the bigger position of the bounding box extend
  34520. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34521. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34522. */
  34523. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34524. /**
  34525. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34526. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34527. * frustum width.
  34528. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34529. * to fully enclose the mesh in the viewing frustum.
  34530. */
  34531. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34532. /**
  34533. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34534. * is automatically returned to its default position (expected to be above ground plane).
  34535. */
  34536. private _maintainCameraAboveGround;
  34537. /**
  34538. * Returns the frustum slope based on the canvas ratio and camera FOV
  34539. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34540. */
  34541. private _getFrustumSlope;
  34542. /**
  34543. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34544. */
  34545. private _clearAnimationLocks;
  34546. /**
  34547. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34548. */
  34549. private _applyUserInteraction;
  34550. /**
  34551. * Stops and removes all animations that have been applied to the camera
  34552. */
  34553. stopAllAnimations(): void;
  34554. /**
  34555. * Gets a value indicating if the user is moving the camera
  34556. */
  34557. readonly isUserIsMoving: boolean;
  34558. /**
  34559. * The camera can move all the way towards the mesh.
  34560. */
  34561. static IgnoreBoundsSizeMode: number;
  34562. /**
  34563. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34564. */
  34565. static FitFrustumSidesMode: number;
  34566. }
  34567. }
  34568. declare module BABYLON {
  34569. /**
  34570. * Base class for Camera Pointer Inputs.
  34571. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34572. * for example usage.
  34573. */
  34574. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34575. /**
  34576. * Defines the camera the input is attached to.
  34577. */
  34578. abstract camera: Camera;
  34579. /**
  34580. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34581. */
  34582. protected _altKey: boolean;
  34583. protected _ctrlKey: boolean;
  34584. protected _metaKey: boolean;
  34585. protected _shiftKey: boolean;
  34586. /**
  34587. * Which mouse buttons were pressed at time of last mouse event.
  34588. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34589. */
  34590. protected _buttonsPressed: number;
  34591. /**
  34592. * Defines the buttons associated with the input to handle camera move.
  34593. */
  34594. buttons: number[];
  34595. /**
  34596. * Attach the input controls to a specific dom element to get the input from.
  34597. * @param element Defines the element the controls should be listened from
  34598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34599. */
  34600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34601. /**
  34602. * Detach the current controls from the specified dom element.
  34603. * @param element Defines the element to stop listening the inputs from
  34604. */
  34605. detachControl(element: Nullable<HTMLElement>): void;
  34606. /**
  34607. * Gets the class name of the current input.
  34608. * @returns the class name
  34609. */
  34610. getClassName(): string;
  34611. /**
  34612. * Get the friendly name associated with the input class.
  34613. * @returns the input friendly name
  34614. */
  34615. getSimpleName(): string;
  34616. /**
  34617. * Called on pointer POINTERDOUBLETAP event.
  34618. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34619. */
  34620. protected onDoubleTap(type: string): void;
  34621. /**
  34622. * Called on pointer POINTERMOVE event if only a single touch is active.
  34623. * Override this method to provide functionality.
  34624. */
  34625. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34626. /**
  34627. * Called on pointer POINTERMOVE event if multiple touches are active.
  34628. * Override this method to provide functionality.
  34629. */
  34630. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34631. /**
  34632. * Called on JS contextmenu event.
  34633. * Override this method to provide functionality.
  34634. */
  34635. protected onContextMenu(evt: PointerEvent): void;
  34636. /**
  34637. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34638. * press.
  34639. * Override this method to provide functionality.
  34640. */
  34641. protected onButtonDown(evt: PointerEvent): void;
  34642. /**
  34643. * Called each time a new POINTERUP event occurs. Ie, for each button
  34644. * release.
  34645. * Override this method to provide functionality.
  34646. */
  34647. protected onButtonUp(evt: PointerEvent): void;
  34648. /**
  34649. * Called when window becomes inactive.
  34650. * Override this method to provide functionality.
  34651. */
  34652. protected onLostFocus(): void;
  34653. private _pointerInput;
  34654. private _observer;
  34655. private _onLostFocus;
  34656. private pointA;
  34657. private pointB;
  34658. }
  34659. }
  34660. declare module BABYLON {
  34661. /**
  34662. * Manage the pointers inputs to control an arc rotate camera.
  34663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34664. */
  34665. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34666. /**
  34667. * Defines the camera the input is attached to.
  34668. */
  34669. camera: ArcRotateCamera;
  34670. /**
  34671. * Gets the class name of the current input.
  34672. * @returns the class name
  34673. */
  34674. getClassName(): string;
  34675. /**
  34676. * Defines the buttons associated with the input to handle camera move.
  34677. */
  34678. buttons: number[];
  34679. /**
  34680. * Defines the pointer angular sensibility along the X axis or how fast is
  34681. * the camera rotating.
  34682. */
  34683. angularSensibilityX: number;
  34684. /**
  34685. * Defines the pointer angular sensibility along the Y axis or how fast is
  34686. * the camera rotating.
  34687. */
  34688. angularSensibilityY: number;
  34689. /**
  34690. * Defines the pointer pinch precision or how fast is the camera zooming.
  34691. */
  34692. pinchPrecision: number;
  34693. /**
  34694. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34695. * from 0.
  34696. * It defines the percentage of current camera.radius to use as delta when
  34697. * pinch zoom is used.
  34698. */
  34699. pinchDeltaPercentage: number;
  34700. /**
  34701. * Defines the pointer panning sensibility or how fast is the camera moving.
  34702. */
  34703. panningSensibility: number;
  34704. /**
  34705. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34706. */
  34707. multiTouchPanning: boolean;
  34708. /**
  34709. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34710. * zoom (pinch) through multitouch.
  34711. */
  34712. multiTouchPanAndZoom: boolean;
  34713. /**
  34714. * Revers pinch action direction.
  34715. */
  34716. pinchInwards: boolean;
  34717. private _isPanClick;
  34718. private _twoFingerActivityCount;
  34719. private _isPinching;
  34720. /**
  34721. * Called on pointer POINTERMOVE event if only a single touch is active.
  34722. */
  34723. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34724. /**
  34725. * Called on pointer POINTERDOUBLETAP event.
  34726. */
  34727. protected onDoubleTap(type: string): void;
  34728. /**
  34729. * Called on pointer POINTERMOVE event if multiple touches are active.
  34730. */
  34731. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34732. /**
  34733. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34734. * press.
  34735. */
  34736. protected onButtonDown(evt: PointerEvent): void;
  34737. /**
  34738. * Called each time a new POINTERUP event occurs. Ie, for each button
  34739. * release.
  34740. */
  34741. protected onButtonUp(evt: PointerEvent): void;
  34742. /**
  34743. * Called when window becomes inactive.
  34744. */
  34745. protected onLostFocus(): void;
  34746. }
  34747. }
  34748. declare module BABYLON {
  34749. /**
  34750. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34752. */
  34753. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34754. /**
  34755. * Defines the camera the input is attached to.
  34756. */
  34757. camera: ArcRotateCamera;
  34758. /**
  34759. * Defines the list of key codes associated with the up action (increase alpha)
  34760. */
  34761. keysUp: number[];
  34762. /**
  34763. * Defines the list of key codes associated with the down action (decrease alpha)
  34764. */
  34765. keysDown: number[];
  34766. /**
  34767. * Defines the list of key codes associated with the left action (increase beta)
  34768. */
  34769. keysLeft: number[];
  34770. /**
  34771. * Defines the list of key codes associated with the right action (decrease beta)
  34772. */
  34773. keysRight: number[];
  34774. /**
  34775. * Defines the list of key codes associated with the reset action.
  34776. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34777. */
  34778. keysReset: number[];
  34779. /**
  34780. * Defines the panning sensibility of the inputs.
  34781. * (How fast is the camera paning)
  34782. */
  34783. panningSensibility: number;
  34784. /**
  34785. * Defines the zooming sensibility of the inputs.
  34786. * (How fast is the camera zooming)
  34787. */
  34788. zoomingSensibility: number;
  34789. /**
  34790. * Defines wether maintaining the alt key down switch the movement mode from
  34791. * orientation to zoom.
  34792. */
  34793. useAltToZoom: boolean;
  34794. /**
  34795. * Rotation speed of the camera
  34796. */
  34797. angularSpeed: number;
  34798. private _keys;
  34799. private _ctrlPressed;
  34800. private _altPressed;
  34801. private _onCanvasBlurObserver;
  34802. private _onKeyboardObserver;
  34803. private _engine;
  34804. private _scene;
  34805. /**
  34806. * Attach the input controls to a specific dom element to get the input from.
  34807. * @param element Defines the element the controls should be listened from
  34808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34809. */
  34810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34811. /**
  34812. * Detach the current controls from the specified dom element.
  34813. * @param element Defines the element to stop listening the inputs from
  34814. */
  34815. detachControl(element: Nullable<HTMLElement>): void;
  34816. /**
  34817. * Update the current camera state depending on the inputs that have been used this frame.
  34818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34819. */
  34820. checkInputs(): void;
  34821. /**
  34822. * Gets the class name of the current intput.
  34823. * @returns the class name
  34824. */
  34825. getClassName(): string;
  34826. /**
  34827. * Get the friendly name associated with the input class.
  34828. * @returns the input friendly name
  34829. */
  34830. getSimpleName(): string;
  34831. }
  34832. }
  34833. declare module BABYLON {
  34834. /**
  34835. * Manage the mouse wheel inputs to control an arc rotate camera.
  34836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34837. */
  34838. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34839. /**
  34840. * Defines the camera the input is attached to.
  34841. */
  34842. camera: ArcRotateCamera;
  34843. /**
  34844. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34845. */
  34846. wheelPrecision: number;
  34847. /**
  34848. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34849. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34850. */
  34851. wheelDeltaPercentage: number;
  34852. private _wheel;
  34853. private _observer;
  34854. private computeDeltaFromMouseWheelLegacyEvent;
  34855. /**
  34856. * Attach the input controls to a specific dom element to get the input from.
  34857. * @param element Defines the element the controls should be listened from
  34858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34859. */
  34860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34861. /**
  34862. * Detach the current controls from the specified dom element.
  34863. * @param element Defines the element to stop listening the inputs from
  34864. */
  34865. detachControl(element: Nullable<HTMLElement>): void;
  34866. /**
  34867. * Gets the class name of the current intput.
  34868. * @returns the class name
  34869. */
  34870. getClassName(): string;
  34871. /**
  34872. * Get the friendly name associated with the input class.
  34873. * @returns the input friendly name
  34874. */
  34875. getSimpleName(): string;
  34876. }
  34877. }
  34878. declare module BABYLON {
  34879. /**
  34880. * Default Inputs manager for the ArcRotateCamera.
  34881. * It groups all the default supported inputs for ease of use.
  34882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34883. */
  34884. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34885. /**
  34886. * Instantiates a new ArcRotateCameraInputsManager.
  34887. * @param camera Defines the camera the inputs belong to
  34888. */
  34889. constructor(camera: ArcRotateCamera);
  34890. /**
  34891. * Add mouse wheel input support to the input manager.
  34892. * @returns the current input manager
  34893. */
  34894. addMouseWheel(): ArcRotateCameraInputsManager;
  34895. /**
  34896. * Add pointers input support to the input manager.
  34897. * @returns the current input manager
  34898. */
  34899. addPointers(): ArcRotateCameraInputsManager;
  34900. /**
  34901. * Add keyboard input support to the input manager.
  34902. * @returns the current input manager
  34903. */
  34904. addKeyboard(): ArcRotateCameraInputsManager;
  34905. }
  34906. }
  34907. declare module BABYLON {
  34908. /**
  34909. * This represents an orbital type of camera.
  34910. *
  34911. * 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.
  34912. * 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.
  34913. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34914. */
  34915. export class ArcRotateCamera extends TargetCamera {
  34916. /**
  34917. * Defines the rotation angle of the camera along the longitudinal axis.
  34918. */
  34919. alpha: number;
  34920. /**
  34921. * Defines the rotation angle of the camera along the latitudinal axis.
  34922. */
  34923. beta: number;
  34924. /**
  34925. * Defines the radius of the camera from it s target point.
  34926. */
  34927. radius: number;
  34928. protected _target: Vector3;
  34929. protected _targetHost: Nullable<AbstractMesh>;
  34930. /**
  34931. * Defines the target point of the camera.
  34932. * The camera looks towards it form the radius distance.
  34933. */
  34934. target: Vector3;
  34935. /**
  34936. * Define the current local position of the camera in the scene
  34937. */
  34938. position: Vector3;
  34939. protected _upVector: Vector3;
  34940. protected _upToYMatrix: Matrix;
  34941. protected _YToUpMatrix: Matrix;
  34942. /**
  34943. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34944. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34945. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34946. */
  34947. upVector: Vector3;
  34948. /**
  34949. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34950. */
  34951. setMatUp(): void;
  34952. /**
  34953. * Current inertia value on the longitudinal axis.
  34954. * The bigger this number the longer it will take for the camera to stop.
  34955. */
  34956. inertialAlphaOffset: number;
  34957. /**
  34958. * Current inertia value on the latitudinal axis.
  34959. * The bigger this number the longer it will take for the camera to stop.
  34960. */
  34961. inertialBetaOffset: number;
  34962. /**
  34963. * Current inertia value on the radius axis.
  34964. * The bigger this number the longer it will take for the camera to stop.
  34965. */
  34966. inertialRadiusOffset: number;
  34967. /**
  34968. * Minimum allowed angle on the longitudinal axis.
  34969. * This can help limiting how the Camera is able to move in the scene.
  34970. */
  34971. lowerAlphaLimit: Nullable<number>;
  34972. /**
  34973. * Maximum allowed angle on the longitudinal axis.
  34974. * This can help limiting how the Camera is able to move in the scene.
  34975. */
  34976. upperAlphaLimit: Nullable<number>;
  34977. /**
  34978. * Minimum allowed angle on the latitudinal axis.
  34979. * This can help limiting how the Camera is able to move in the scene.
  34980. */
  34981. lowerBetaLimit: number;
  34982. /**
  34983. * Maximum allowed angle on the latitudinal axis.
  34984. * This can help limiting how the Camera is able to move in the scene.
  34985. */
  34986. upperBetaLimit: number;
  34987. /**
  34988. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34989. * This can help limiting how the Camera is able to move in the scene.
  34990. */
  34991. lowerRadiusLimit: Nullable<number>;
  34992. /**
  34993. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34994. * This can help limiting how the Camera is able to move in the scene.
  34995. */
  34996. upperRadiusLimit: Nullable<number>;
  34997. /**
  34998. * Defines the current inertia value used during panning of the camera along the X axis.
  34999. */
  35000. inertialPanningX: number;
  35001. /**
  35002. * Defines the current inertia value used during panning of the camera along the Y axis.
  35003. */
  35004. inertialPanningY: number;
  35005. /**
  35006. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35007. * Basically if your fingers moves away from more than this distance you will be considered
  35008. * in pinch mode.
  35009. */
  35010. pinchToPanMaxDistance: number;
  35011. /**
  35012. * Defines the maximum distance the camera can pan.
  35013. * This could help keeping the cammera always in your scene.
  35014. */
  35015. panningDistanceLimit: Nullable<number>;
  35016. /**
  35017. * Defines the target of the camera before paning.
  35018. */
  35019. panningOriginTarget: Vector3;
  35020. /**
  35021. * Defines the value of the inertia used during panning.
  35022. * 0 would mean stop inertia and one would mean no decelleration at all.
  35023. */
  35024. panningInertia: number;
  35025. /**
  35026. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35027. */
  35028. angularSensibilityX: number;
  35029. /**
  35030. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35031. */
  35032. angularSensibilityY: number;
  35033. /**
  35034. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35035. */
  35036. pinchPrecision: number;
  35037. /**
  35038. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35039. * It will be used instead of pinchDeltaPrecision if different from 0.
  35040. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35041. */
  35042. pinchDeltaPercentage: number;
  35043. /**
  35044. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35045. */
  35046. panningSensibility: number;
  35047. /**
  35048. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35049. */
  35050. keysUp: number[];
  35051. /**
  35052. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35053. */
  35054. keysDown: number[];
  35055. /**
  35056. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35057. */
  35058. keysLeft: number[];
  35059. /**
  35060. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35061. */
  35062. keysRight: number[];
  35063. /**
  35064. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35065. */
  35066. wheelPrecision: number;
  35067. /**
  35068. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35069. * It will be used instead of pinchDeltaPrecision if different from 0.
  35070. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35071. */
  35072. wheelDeltaPercentage: number;
  35073. /**
  35074. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35075. */
  35076. zoomOnFactor: number;
  35077. /**
  35078. * Defines a screen offset for the camera position.
  35079. */
  35080. targetScreenOffset: Vector2;
  35081. /**
  35082. * Allows the camera to be completely reversed.
  35083. * If false the camera can not arrive upside down.
  35084. */
  35085. allowUpsideDown: boolean;
  35086. /**
  35087. * Define if double tap/click is used to restore the previously saved state of the camera.
  35088. */
  35089. useInputToRestoreState: boolean;
  35090. /** @hidden */ private _viewMatrix: Matrix;
  35091. /** @hidden */ private _useCtrlForPanning: boolean;
  35092. /** @hidden */ private _panningMouseButton: number;
  35093. /**
  35094. * Defines the input associated to the camera.
  35095. */
  35096. inputs: ArcRotateCameraInputsManager;
  35097. /** @hidden */ private _reset: () => void;
  35098. /**
  35099. * Defines the allowed panning axis.
  35100. */
  35101. panningAxis: Vector3;
  35102. protected _localDirection: Vector3;
  35103. protected _transformedDirection: Vector3;
  35104. private _bouncingBehavior;
  35105. /**
  35106. * Gets the bouncing behavior of the camera if it has been enabled.
  35107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35108. */
  35109. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35110. /**
  35111. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35113. */
  35114. useBouncingBehavior: boolean;
  35115. private _framingBehavior;
  35116. /**
  35117. * Gets the framing behavior of the camera if it has been enabled.
  35118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35119. */
  35120. readonly framingBehavior: Nullable<FramingBehavior>;
  35121. /**
  35122. * Defines if the framing behavior of the camera is enabled on the camera.
  35123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35124. */
  35125. useFramingBehavior: boolean;
  35126. private _autoRotationBehavior;
  35127. /**
  35128. * Gets the auto rotation behavior of the camera if it has been enabled.
  35129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35130. */
  35131. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35132. /**
  35133. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35134. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35135. */
  35136. useAutoRotationBehavior: boolean;
  35137. /**
  35138. * Observable triggered when the mesh target has been changed on the camera.
  35139. */
  35140. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35141. /**
  35142. * Event raised when the camera is colliding with a mesh.
  35143. */
  35144. onCollide: (collidedMesh: AbstractMesh) => void;
  35145. /**
  35146. * Defines whether the camera should check collision with the objects oh the scene.
  35147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35148. */
  35149. checkCollisions: boolean;
  35150. /**
  35151. * Defines the collision radius of the camera.
  35152. * This simulates a sphere around the camera.
  35153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35154. */
  35155. collisionRadius: Vector3;
  35156. protected _collider: Collider;
  35157. protected _previousPosition: Vector3;
  35158. protected _collisionVelocity: Vector3;
  35159. protected _newPosition: Vector3;
  35160. protected _previousAlpha: number;
  35161. protected _previousBeta: number;
  35162. protected _previousRadius: number;
  35163. protected _collisionTriggered: boolean;
  35164. protected _targetBoundingCenter: Nullable<Vector3>;
  35165. private _computationVector;
  35166. /**
  35167. * Instantiates a new ArcRotateCamera in a given scene
  35168. * @param name Defines the name of the camera
  35169. * @param alpha Defines the camera rotation along the logitudinal axis
  35170. * @param beta Defines the camera rotation along the latitudinal axis
  35171. * @param radius Defines the camera distance from its target
  35172. * @param target Defines the camera target
  35173. * @param scene Defines the scene the camera belongs to
  35174. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35175. */
  35176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35177. /** @hidden */ private _initCache(): void;
  35178. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35179. protected _getTargetPosition(): Vector3;
  35180. private _storedAlpha;
  35181. private _storedBeta;
  35182. private _storedRadius;
  35183. private _storedTarget;
  35184. /**
  35185. * Stores the current state of the camera (alpha, beta, radius and target)
  35186. * @returns the camera itself
  35187. */
  35188. storeState(): Camera;
  35189. /**
  35190. * @hidden
  35191. * Restored camera state. You must call storeState() first
  35192. */ private _restoreStateValues(): boolean;
  35193. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35194. /**
  35195. * Attached controls to the current camera.
  35196. * @param element Defines the element the controls should be listened from
  35197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35198. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35199. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35200. */
  35201. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35202. /**
  35203. * Detach the current controls from the camera.
  35204. * The camera will stop reacting to inputs.
  35205. * @param element Defines the element to stop listening the inputs from
  35206. */
  35207. detachControl(element: HTMLElement): void;
  35208. /** @hidden */ private _checkInputs(): void;
  35209. protected _checkLimits(): void;
  35210. /**
  35211. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35212. */
  35213. rebuildAnglesAndRadius(): void;
  35214. /**
  35215. * Use a position to define the current camera related information like aplha, beta and radius
  35216. * @param position Defines the position to set the camera at
  35217. */
  35218. setPosition(position: Vector3): void;
  35219. /**
  35220. * Defines the target the camera should look at.
  35221. * This will automatically adapt alpha beta and radius to fit within the new target.
  35222. * @param target Defines the new target as a Vector or a mesh
  35223. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35224. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35225. */
  35226. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35227. /** @hidden */ private _getViewMatrix(): Matrix;
  35228. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35229. /**
  35230. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35231. * @param meshes Defines the mesh to zoom on
  35232. * @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)
  35233. */
  35234. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35235. /**
  35236. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35237. * The target will be changed but the radius
  35238. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35239. * @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)
  35240. */
  35241. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35242. min: Vector3;
  35243. max: Vector3;
  35244. distance: number;
  35245. }, doNotUpdateMaxZ?: boolean): void;
  35246. /**
  35247. * @override
  35248. * Override Camera.createRigCamera
  35249. */
  35250. createRigCamera(name: string, cameraIndex: number): Camera;
  35251. /**
  35252. * @hidden
  35253. * @override
  35254. * Override Camera._updateRigCameras
  35255. */ private _updateRigCameras(): void;
  35256. /**
  35257. * Destroy the camera and release the current resources hold by it.
  35258. */
  35259. dispose(): void;
  35260. /**
  35261. * Gets the current object class name.
  35262. * @return the class name
  35263. */
  35264. getClassName(): string;
  35265. }
  35266. }
  35267. declare module BABYLON {
  35268. /**
  35269. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35270. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35271. */
  35272. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35273. /**
  35274. * Gets the name of the behavior.
  35275. */
  35276. readonly name: string;
  35277. private _zoomStopsAnimation;
  35278. private _idleRotationSpeed;
  35279. private _idleRotationWaitTime;
  35280. private _idleRotationSpinupTime;
  35281. /**
  35282. * Sets the flag that indicates if user zooming should stop animation.
  35283. */
  35284. /**
  35285. * Gets the flag that indicates if user zooming should stop animation.
  35286. */
  35287. zoomStopsAnimation: boolean;
  35288. /**
  35289. * Sets the default speed at which the camera rotates around the model.
  35290. */
  35291. /**
  35292. * Gets the default speed at which the camera rotates around the model.
  35293. */
  35294. idleRotationSpeed: number;
  35295. /**
  35296. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35297. */
  35298. /**
  35299. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35300. */
  35301. idleRotationWaitTime: number;
  35302. /**
  35303. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35304. */
  35305. /**
  35306. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35307. */
  35308. idleRotationSpinupTime: number;
  35309. /**
  35310. * Gets a value indicating if the camera is currently rotating because of this behavior
  35311. */
  35312. readonly rotationInProgress: boolean;
  35313. private _onPrePointerObservableObserver;
  35314. private _onAfterCheckInputsObserver;
  35315. private _attachedCamera;
  35316. private _isPointerDown;
  35317. private _lastFrameTime;
  35318. private _lastInteractionTime;
  35319. private _cameraRotationSpeed;
  35320. /**
  35321. * Initializes the behavior.
  35322. */
  35323. init(): void;
  35324. /**
  35325. * Attaches the behavior to its arc rotate camera.
  35326. * @param camera Defines the camera to attach the behavior to
  35327. */
  35328. attach(camera: ArcRotateCamera): void;
  35329. /**
  35330. * Detaches the behavior from its current arc rotate camera.
  35331. */
  35332. detach(): void;
  35333. /**
  35334. * Returns true if user is scrolling.
  35335. * @return true if user is scrolling.
  35336. */
  35337. private _userIsZooming;
  35338. private _lastFrameRadius;
  35339. private _shouldAnimationStopForInteraction;
  35340. /**
  35341. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35342. */
  35343. private _applyUserInteraction;
  35344. private _userIsMoving;
  35345. }
  35346. }
  35347. declare module BABYLON {
  35348. /**
  35349. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35350. */
  35351. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35352. private ui;
  35353. /**
  35354. * The name of the behavior
  35355. */
  35356. name: string;
  35357. /**
  35358. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35359. */
  35360. distanceAwayFromFace: number;
  35361. /**
  35362. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35363. */
  35364. distanceAwayFromBottomOfFace: number;
  35365. private _faceVectors;
  35366. private _target;
  35367. private _scene;
  35368. private _onRenderObserver;
  35369. private _tmpMatrix;
  35370. private _tmpVector;
  35371. /**
  35372. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35373. * @param ui The transform node that should be attched to the mesh
  35374. */
  35375. constructor(ui: TransformNode);
  35376. /**
  35377. * Initializes the behavior
  35378. */
  35379. init(): void;
  35380. private _closestFace;
  35381. private _zeroVector;
  35382. private _lookAtTmpMatrix;
  35383. private _lookAtToRef;
  35384. /**
  35385. * Attaches the AttachToBoxBehavior to the passed in mesh
  35386. * @param target The mesh that the specified node will be attached to
  35387. */
  35388. attach(target: Mesh): void;
  35389. /**
  35390. * Detaches the behavior from the mesh
  35391. */
  35392. detach(): void;
  35393. }
  35394. }
  35395. declare module BABYLON {
  35396. /**
  35397. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35398. */
  35399. export class FadeInOutBehavior implements Behavior<Mesh> {
  35400. /**
  35401. * Time in milliseconds to delay before fading in (Default: 0)
  35402. */
  35403. delay: number;
  35404. /**
  35405. * Time in milliseconds for the mesh to fade in (Default: 300)
  35406. */
  35407. fadeInTime: number;
  35408. private _millisecondsPerFrame;
  35409. private _hovered;
  35410. private _hoverValue;
  35411. private _ownerNode;
  35412. /**
  35413. * Instatiates the FadeInOutBehavior
  35414. */
  35415. constructor();
  35416. /**
  35417. * The name of the behavior
  35418. */
  35419. readonly name: string;
  35420. /**
  35421. * Initializes the behavior
  35422. */
  35423. init(): void;
  35424. /**
  35425. * Attaches the fade behavior on the passed in mesh
  35426. * @param ownerNode The mesh that will be faded in/out once attached
  35427. */
  35428. attach(ownerNode: Mesh): void;
  35429. /**
  35430. * Detaches the behavior from the mesh
  35431. */
  35432. detach(): void;
  35433. /**
  35434. * Triggers the mesh to begin fading in or out
  35435. * @param value if the object should fade in or out (true to fade in)
  35436. */
  35437. fadeIn(value: boolean): void;
  35438. private _update;
  35439. private _setAllVisibility;
  35440. }
  35441. }
  35442. declare module BABYLON {
  35443. /**
  35444. * Class containing a set of static utilities functions for managing Pivots
  35445. * @hidden
  35446. */
  35447. export class PivotTools {
  35448. private static _PivotCached;
  35449. private static _OldPivotPoint;
  35450. private static _PivotTranslation;
  35451. private static _PivotTmpVector;
  35452. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35453. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35454. }
  35455. }
  35456. declare module BABYLON {
  35457. /**
  35458. * Class containing static functions to help procedurally build meshes
  35459. */
  35460. export class PlaneBuilder {
  35461. /**
  35462. * Creates a plane mesh
  35463. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35464. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35465. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35469. * @param name defines the name of the mesh
  35470. * @param options defines the options used to create the mesh
  35471. * @param scene defines the hosting scene
  35472. * @returns the plane mesh
  35473. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35474. */
  35475. static CreatePlane(name: string, options: {
  35476. size?: number;
  35477. width?: number;
  35478. height?: number;
  35479. sideOrientation?: number;
  35480. frontUVs?: Vector4;
  35481. backUVs?: Vector4;
  35482. updatable?: boolean;
  35483. sourcePlane?: Plane;
  35484. }, scene?: Nullable<Scene>): Mesh;
  35485. }
  35486. }
  35487. declare module BABYLON {
  35488. /**
  35489. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35490. */
  35491. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35492. private static _AnyMouseID;
  35493. /**
  35494. * Abstract mesh the behavior is set on
  35495. */
  35496. attachedNode: AbstractMesh;
  35497. private _dragPlane;
  35498. private _scene;
  35499. private _pointerObserver;
  35500. private _beforeRenderObserver;
  35501. private static _planeScene;
  35502. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35503. /**
  35504. * 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)
  35505. */
  35506. maxDragAngle: number;
  35507. /**
  35508. * @hidden
  35509. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35510. /**
  35511. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35512. */
  35513. currentDraggingPointerID: number;
  35514. /**
  35515. * The last position where the pointer hit the drag plane in world space
  35516. */
  35517. lastDragPosition: Vector3;
  35518. /**
  35519. * If the behavior is currently in a dragging state
  35520. */
  35521. dragging: boolean;
  35522. /**
  35523. * 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)
  35524. */
  35525. dragDeltaRatio: number;
  35526. /**
  35527. * If the drag plane orientation should be updated during the dragging (Default: true)
  35528. */
  35529. updateDragPlane: boolean;
  35530. private _debugMode;
  35531. private _moving;
  35532. /**
  35533. * Fires each time the attached mesh is dragged with the pointer
  35534. * * delta between last drag position and current drag position in world space
  35535. * * dragDistance along the drag axis
  35536. * * dragPlaneNormal normal of the current drag plane used during the drag
  35537. * * dragPlanePoint in world space where the drag intersects the drag plane
  35538. */
  35539. onDragObservable: Observable<{
  35540. delta: Vector3;
  35541. dragPlanePoint: Vector3;
  35542. dragPlaneNormal: Vector3;
  35543. dragDistance: number;
  35544. pointerId: number;
  35545. }>;
  35546. /**
  35547. * Fires each time a drag begins (eg. mouse down on mesh)
  35548. */
  35549. onDragStartObservable: Observable<{
  35550. dragPlanePoint: Vector3;
  35551. pointerId: number;
  35552. }>;
  35553. /**
  35554. * Fires each time a drag ends (eg. mouse release after drag)
  35555. */
  35556. onDragEndObservable: Observable<{
  35557. dragPlanePoint: Vector3;
  35558. pointerId: number;
  35559. }>;
  35560. /**
  35561. * If the attached mesh should be moved when dragged
  35562. */
  35563. moveAttached: boolean;
  35564. /**
  35565. * If the drag behavior will react to drag events (Default: true)
  35566. */
  35567. enabled: boolean;
  35568. /**
  35569. * If pointer events should start and release the drag (Default: true)
  35570. */
  35571. startAndReleaseDragOnPointerEvents: boolean;
  35572. /**
  35573. * If camera controls should be detached during the drag
  35574. */
  35575. detachCameraControls: boolean;
  35576. /**
  35577. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35578. */
  35579. useObjectOrienationForDragging: boolean;
  35580. private _options;
  35581. /**
  35582. * Creates a pointer drag behavior that can be attached to a mesh
  35583. * @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)
  35584. */
  35585. constructor(options?: {
  35586. dragAxis?: Vector3;
  35587. dragPlaneNormal?: Vector3;
  35588. });
  35589. /**
  35590. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35591. */
  35592. validateDrag: (targetPosition: Vector3) => boolean;
  35593. /**
  35594. * The name of the behavior
  35595. */
  35596. readonly name: string;
  35597. /**
  35598. * Initializes the behavior
  35599. */
  35600. init(): void;
  35601. private _tmpVector;
  35602. private _alternatePickedPoint;
  35603. private _worldDragAxis;
  35604. private _targetPosition;
  35605. private _attachedElement;
  35606. /**
  35607. * Attaches the drag behavior the passed in mesh
  35608. * @param ownerNode The mesh that will be dragged around once attached
  35609. */
  35610. attach(ownerNode: AbstractMesh): void;
  35611. /**
  35612. * Force relase the drag action by code.
  35613. */
  35614. releaseDrag(): void;
  35615. private _startDragRay;
  35616. private _lastPointerRay;
  35617. /**
  35618. * Simulates the start of a pointer drag event on the behavior
  35619. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35620. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35621. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35622. */
  35623. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35624. private _startDrag;
  35625. private _dragDelta;
  35626. private _moveDrag;
  35627. private _pickWithRayOnDragPlane;
  35628. private _pointA;
  35629. private _pointB;
  35630. private _pointC;
  35631. private _lineA;
  35632. private _lineB;
  35633. private _localAxis;
  35634. private _lookAt;
  35635. private _updateDragPlanePosition;
  35636. /**
  35637. * Detaches the behavior from the mesh
  35638. */
  35639. detach(): void;
  35640. }
  35641. }
  35642. declare module BABYLON {
  35643. /**
  35644. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35645. */
  35646. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35647. private _dragBehaviorA;
  35648. private _dragBehaviorB;
  35649. private _startDistance;
  35650. private _initialScale;
  35651. private _targetScale;
  35652. private _ownerNode;
  35653. private _sceneRenderObserver;
  35654. /**
  35655. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35656. */
  35657. constructor();
  35658. /**
  35659. * The name of the behavior
  35660. */
  35661. readonly name: string;
  35662. /**
  35663. * Initializes the behavior
  35664. */
  35665. init(): void;
  35666. private _getCurrentDistance;
  35667. /**
  35668. * Attaches the scale behavior the passed in mesh
  35669. * @param ownerNode The mesh that will be scaled around once attached
  35670. */
  35671. attach(ownerNode: Mesh): void;
  35672. /**
  35673. * Detaches the behavior from the mesh
  35674. */
  35675. detach(): void;
  35676. }
  35677. }
  35678. declare module BABYLON {
  35679. /**
  35680. * 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
  35681. */
  35682. export class SixDofDragBehavior implements Behavior<Mesh> {
  35683. private static _virtualScene;
  35684. private _ownerNode;
  35685. private _sceneRenderObserver;
  35686. private _scene;
  35687. private _targetPosition;
  35688. private _virtualOriginMesh;
  35689. private _virtualDragMesh;
  35690. private _pointerObserver;
  35691. private _moving;
  35692. private _startingOrientation;
  35693. /**
  35694. * 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)
  35695. */
  35696. private zDragFactor;
  35697. /**
  35698. * If the object should rotate to face the drag origin
  35699. */
  35700. rotateDraggedObject: boolean;
  35701. /**
  35702. * If the behavior is currently in a dragging state
  35703. */
  35704. dragging: boolean;
  35705. /**
  35706. * 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)
  35707. */
  35708. dragDeltaRatio: number;
  35709. /**
  35710. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35711. */
  35712. currentDraggingPointerID: number;
  35713. /**
  35714. * If camera controls should be detached during the drag
  35715. */
  35716. detachCameraControls: boolean;
  35717. /**
  35718. * Fires each time a drag starts
  35719. */
  35720. onDragStartObservable: Observable<{}>;
  35721. /**
  35722. * Fires each time a drag ends (eg. mouse release after drag)
  35723. */
  35724. onDragEndObservable: Observable<{}>;
  35725. /**
  35726. * 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
  35727. */
  35728. constructor();
  35729. /**
  35730. * The name of the behavior
  35731. */
  35732. readonly name: string;
  35733. /**
  35734. * Initializes the behavior
  35735. */
  35736. init(): void;
  35737. /**
  35738. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  35739. */
  35740. private readonly _pointerCamera;
  35741. /**
  35742. * Attaches the scale behavior the passed in mesh
  35743. * @param ownerNode The mesh that will be scaled around once attached
  35744. */
  35745. attach(ownerNode: Mesh): void;
  35746. /**
  35747. * Detaches the behavior from the mesh
  35748. */
  35749. detach(): void;
  35750. }
  35751. }
  35752. declare module BABYLON {
  35753. /**
  35754. * Class used to apply inverse kinematics to bones
  35755. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35756. */
  35757. export class BoneIKController {
  35758. private static _tmpVecs;
  35759. private static _tmpQuat;
  35760. private static _tmpMats;
  35761. /**
  35762. * Gets or sets the target mesh
  35763. */
  35764. targetMesh: AbstractMesh;
  35765. /** Gets or sets the mesh used as pole */
  35766. poleTargetMesh: AbstractMesh;
  35767. /**
  35768. * Gets or sets the bone used as pole
  35769. */
  35770. poleTargetBone: Nullable<Bone>;
  35771. /**
  35772. * Gets or sets the target position
  35773. */
  35774. targetPosition: Vector3;
  35775. /**
  35776. * Gets or sets the pole target position
  35777. */
  35778. poleTargetPosition: Vector3;
  35779. /**
  35780. * Gets or sets the pole target local offset
  35781. */
  35782. poleTargetLocalOffset: Vector3;
  35783. /**
  35784. * Gets or sets the pole angle
  35785. */
  35786. poleAngle: number;
  35787. /**
  35788. * Gets or sets the mesh associated with the controller
  35789. */
  35790. mesh: AbstractMesh;
  35791. /**
  35792. * 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)
  35793. */
  35794. slerpAmount: number;
  35795. private _bone1Quat;
  35796. private _bone1Mat;
  35797. private _bone2Ang;
  35798. private _bone1;
  35799. private _bone2;
  35800. private _bone1Length;
  35801. private _bone2Length;
  35802. private _maxAngle;
  35803. private _maxReach;
  35804. private _rightHandedSystem;
  35805. private _bendAxis;
  35806. private _slerping;
  35807. private _adjustRoll;
  35808. /**
  35809. * Gets or sets maximum allowed angle
  35810. */
  35811. maxAngle: number;
  35812. /**
  35813. * Creates a new BoneIKController
  35814. * @param mesh defines the mesh to control
  35815. * @param bone defines the bone to control
  35816. * @param options defines options to set up the controller
  35817. */
  35818. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35819. targetMesh?: AbstractMesh;
  35820. poleTargetMesh?: AbstractMesh;
  35821. poleTargetBone?: Bone;
  35822. poleTargetLocalOffset?: Vector3;
  35823. poleAngle?: number;
  35824. bendAxis?: Vector3;
  35825. maxAngle?: number;
  35826. slerpAmount?: number;
  35827. });
  35828. private _setMaxAngle;
  35829. /**
  35830. * Force the controller to update the bones
  35831. */
  35832. update(): void;
  35833. }
  35834. }
  35835. declare module BABYLON {
  35836. /**
  35837. * Class used to make a bone look toward a point in space
  35838. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35839. */
  35840. export class BoneLookController {
  35841. private static _tmpVecs;
  35842. private static _tmpQuat;
  35843. private static _tmpMats;
  35844. /**
  35845. * The target Vector3 that the bone will look at
  35846. */
  35847. target: Vector3;
  35848. /**
  35849. * The mesh that the bone is attached to
  35850. */
  35851. mesh: AbstractMesh;
  35852. /**
  35853. * The bone that will be looking to the target
  35854. */
  35855. bone: Bone;
  35856. /**
  35857. * The up axis of the coordinate system that is used when the bone is rotated
  35858. */
  35859. upAxis: Vector3;
  35860. /**
  35861. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35862. */
  35863. upAxisSpace: Space;
  35864. /**
  35865. * Used to make an adjustment to the yaw of the bone
  35866. */
  35867. adjustYaw: number;
  35868. /**
  35869. * Used to make an adjustment to the pitch of the bone
  35870. */
  35871. adjustPitch: number;
  35872. /**
  35873. * Used to make an adjustment to the roll of the bone
  35874. */
  35875. adjustRoll: number;
  35876. /**
  35877. * 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)
  35878. */
  35879. slerpAmount: number;
  35880. private _minYaw;
  35881. private _maxYaw;
  35882. private _minPitch;
  35883. private _maxPitch;
  35884. private _minYawSin;
  35885. private _minYawCos;
  35886. private _maxYawSin;
  35887. private _maxYawCos;
  35888. private _midYawConstraint;
  35889. private _minPitchTan;
  35890. private _maxPitchTan;
  35891. private _boneQuat;
  35892. private _slerping;
  35893. private _transformYawPitch;
  35894. private _transformYawPitchInv;
  35895. private _firstFrameSkipped;
  35896. private _yawRange;
  35897. private _fowardAxis;
  35898. /**
  35899. * Gets or sets the minimum yaw angle that the bone can look to
  35900. */
  35901. minYaw: number;
  35902. /**
  35903. * Gets or sets the maximum yaw angle that the bone can look to
  35904. */
  35905. maxYaw: number;
  35906. /**
  35907. * Gets or sets the minimum pitch angle that the bone can look to
  35908. */
  35909. minPitch: number;
  35910. /**
  35911. * Gets or sets the maximum pitch angle that the bone can look to
  35912. */
  35913. maxPitch: number;
  35914. /**
  35915. * Create a BoneLookController
  35916. * @param mesh the mesh that the bone belongs to
  35917. * @param bone the bone that will be looking to the target
  35918. * @param target the target Vector3 to look at
  35919. * @param options optional settings:
  35920. * * maxYaw: the maximum angle the bone will yaw to
  35921. * * minYaw: the minimum angle the bone will yaw to
  35922. * * maxPitch: the maximum angle the bone will pitch to
  35923. * * minPitch: the minimum angle the bone will yaw to
  35924. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35925. * * upAxis: the up axis of the coordinate system
  35926. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35927. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35928. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35929. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35930. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35931. * * adjustRoll: used to make an adjustment to the roll of the bone
  35932. **/
  35933. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35934. maxYaw?: number;
  35935. minYaw?: number;
  35936. maxPitch?: number;
  35937. minPitch?: number;
  35938. slerpAmount?: number;
  35939. upAxis?: Vector3;
  35940. upAxisSpace?: Space;
  35941. yawAxis?: Vector3;
  35942. pitchAxis?: Vector3;
  35943. adjustYaw?: number;
  35944. adjustPitch?: number;
  35945. adjustRoll?: number;
  35946. });
  35947. /**
  35948. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35949. */
  35950. update(): void;
  35951. private _getAngleDiff;
  35952. private _getAngleBetween;
  35953. private _isAngleBetween;
  35954. }
  35955. }
  35956. declare module BABYLON {
  35957. /**
  35958. * Manage the gamepad inputs to control an arc rotate camera.
  35959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35960. */
  35961. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35962. /**
  35963. * Defines the camera the input is attached to.
  35964. */
  35965. camera: ArcRotateCamera;
  35966. /**
  35967. * Defines the gamepad the input is gathering event from.
  35968. */
  35969. gamepad: Nullable<Gamepad>;
  35970. /**
  35971. * Defines the gamepad rotation sensiblity.
  35972. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35973. */
  35974. gamepadRotationSensibility: number;
  35975. /**
  35976. * Defines the gamepad move sensiblity.
  35977. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35978. */
  35979. gamepadMoveSensibility: number;
  35980. private _onGamepadConnectedObserver;
  35981. private _onGamepadDisconnectedObserver;
  35982. /**
  35983. * Attach the input controls to a specific dom element to get the input from.
  35984. * @param element Defines the element the controls should be listened from
  35985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35986. */
  35987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35988. /**
  35989. * Detach the current controls from the specified dom element.
  35990. * @param element Defines the element to stop listening the inputs from
  35991. */
  35992. detachControl(element: Nullable<HTMLElement>): void;
  35993. /**
  35994. * Update the current camera state depending on the inputs that have been used this frame.
  35995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35996. */
  35997. checkInputs(): void;
  35998. /**
  35999. * Gets the class name of the current intput.
  36000. * @returns the class name
  36001. */
  36002. getClassName(): string;
  36003. /**
  36004. * Get the friendly name associated with the input class.
  36005. * @returns the input friendly name
  36006. */
  36007. getSimpleName(): string;
  36008. }
  36009. }
  36010. declare module BABYLON {
  36011. interface ArcRotateCameraInputsManager {
  36012. /**
  36013. * Add orientation input support to the input manager.
  36014. * @returns the current input manager
  36015. */
  36016. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36017. }
  36018. /**
  36019. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36021. */
  36022. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36023. /**
  36024. * Defines the camera the input is attached to.
  36025. */
  36026. camera: ArcRotateCamera;
  36027. /**
  36028. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36029. */
  36030. alphaCorrection: number;
  36031. /**
  36032. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36033. */
  36034. gammaCorrection: number;
  36035. private _alpha;
  36036. private _gamma;
  36037. private _dirty;
  36038. private _deviceOrientationHandler;
  36039. /**
  36040. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36041. */
  36042. constructor();
  36043. /**
  36044. * Attach the input controls to a specific dom element to get the input from.
  36045. * @param element Defines the element the controls should be listened from
  36046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36047. */
  36048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36049. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36050. /**
  36051. * Update the current camera state depending on the inputs that have been used this frame.
  36052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36053. */
  36054. checkInputs(): void;
  36055. /**
  36056. * Detach the current controls from the specified dom element.
  36057. * @param element Defines the element to stop listening the inputs from
  36058. */
  36059. detachControl(element: Nullable<HTMLElement>): void;
  36060. /**
  36061. * Gets the class name of the current intput.
  36062. * @returns the class name
  36063. */
  36064. getClassName(): string;
  36065. /**
  36066. * Get the friendly name associated with the input class.
  36067. * @returns the input friendly name
  36068. */
  36069. getSimpleName(): string;
  36070. }
  36071. }
  36072. declare module BABYLON {
  36073. /**
  36074. * Listen to mouse events to control the camera.
  36075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36076. */
  36077. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36078. /**
  36079. * Defines the camera the input is attached to.
  36080. */
  36081. camera: FlyCamera;
  36082. /**
  36083. * Defines if touch is enabled. (Default is true.)
  36084. */
  36085. touchEnabled: boolean;
  36086. /**
  36087. * Defines the buttons associated with the input to handle camera rotation.
  36088. */
  36089. buttons: number[];
  36090. /**
  36091. * Assign buttons for Yaw control.
  36092. */
  36093. buttonsYaw: number[];
  36094. /**
  36095. * Assign buttons for Pitch control.
  36096. */
  36097. buttonsPitch: number[];
  36098. /**
  36099. * Assign buttons for Roll control.
  36100. */
  36101. buttonsRoll: number[];
  36102. /**
  36103. * Detect if any button is being pressed while mouse is moved.
  36104. * -1 = Mouse locked.
  36105. * 0 = Left button.
  36106. * 1 = Middle Button.
  36107. * 2 = Right Button.
  36108. */
  36109. activeButton: number;
  36110. /**
  36111. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36112. * Higher values reduce its sensitivity.
  36113. */
  36114. angularSensibility: number;
  36115. private _mousemoveCallback;
  36116. private _observer;
  36117. private _rollObserver;
  36118. private previousPosition;
  36119. private noPreventDefault;
  36120. private element;
  36121. /**
  36122. * Listen to mouse events to control the camera.
  36123. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36125. */
  36126. constructor(touchEnabled?: boolean);
  36127. /**
  36128. * Attach the mouse control to the HTML DOM element.
  36129. * @param element Defines the element that listens to the input events.
  36130. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36131. */
  36132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36133. /**
  36134. * Detach the current controls from the specified dom element.
  36135. * @param element Defines the element to stop listening the inputs from
  36136. */
  36137. detachControl(element: Nullable<HTMLElement>): void;
  36138. /**
  36139. * Gets the class name of the current input.
  36140. * @returns the class name.
  36141. */
  36142. getClassName(): string;
  36143. /**
  36144. * Get the friendly name associated with the input class.
  36145. * @returns the input's friendly name.
  36146. */
  36147. getSimpleName(): string;
  36148. private _pointerInput;
  36149. private _onMouseMove;
  36150. /**
  36151. * Rotate camera by mouse offset.
  36152. */
  36153. private rotateCamera;
  36154. }
  36155. }
  36156. declare module BABYLON {
  36157. /**
  36158. * Default Inputs manager for the FlyCamera.
  36159. * It groups all the default supported inputs for ease of use.
  36160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36161. */
  36162. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36163. /**
  36164. * Instantiates a new FlyCameraInputsManager.
  36165. * @param camera Defines the camera the inputs belong to.
  36166. */
  36167. constructor(camera: FlyCamera);
  36168. /**
  36169. * Add keyboard input support to the input manager.
  36170. * @returns the new FlyCameraKeyboardMoveInput().
  36171. */
  36172. addKeyboard(): FlyCameraInputsManager;
  36173. /**
  36174. * Add mouse input support to the input manager.
  36175. * @param touchEnabled Enable touch screen support.
  36176. * @returns the new FlyCameraMouseInput().
  36177. */
  36178. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36179. }
  36180. }
  36181. declare module BABYLON {
  36182. /**
  36183. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36184. * such as in a 3D Space Shooter or a Flight Simulator.
  36185. */
  36186. export class FlyCamera extends TargetCamera {
  36187. /**
  36188. * Define the collision ellipsoid of the camera.
  36189. * This is helpful for simulating a camera body, like a player's body.
  36190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36191. */
  36192. ellipsoid: Vector3;
  36193. /**
  36194. * Define an offset for the position of the ellipsoid around the camera.
  36195. * This can be helpful if the camera is attached away from the player's body center,
  36196. * such as at its head.
  36197. */
  36198. ellipsoidOffset: Vector3;
  36199. /**
  36200. * Enable or disable collisions of the camera with the rest of the scene objects.
  36201. */
  36202. checkCollisions: boolean;
  36203. /**
  36204. * Enable or disable gravity on the camera.
  36205. */
  36206. applyGravity: boolean;
  36207. /**
  36208. * Define the current direction the camera is moving to.
  36209. */
  36210. cameraDirection: Vector3;
  36211. /**
  36212. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36213. * This overrides and empties cameraRotation.
  36214. */
  36215. rotationQuaternion: Quaternion;
  36216. /**
  36217. * Track Roll to maintain the wanted Rolling when looking around.
  36218. */ private _trackRoll: number;
  36219. /**
  36220. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36221. */
  36222. rollCorrect: number;
  36223. /**
  36224. * Mimic a banked turn, Rolling the camera when Yawing.
  36225. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36226. */
  36227. bankedTurn: boolean;
  36228. /**
  36229. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36230. */
  36231. bankedTurnLimit: number;
  36232. /**
  36233. * Value of 0 disables the banked Roll.
  36234. * Value of 1 is equal to the Yaw angle in radians.
  36235. */
  36236. bankedTurnMultiplier: number;
  36237. /**
  36238. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36239. */
  36240. inputs: FlyCameraInputsManager;
  36241. /**
  36242. * Gets the input sensibility for mouse input.
  36243. * Higher values reduce sensitivity.
  36244. */
  36245. /**
  36246. * Sets the input sensibility for a mouse input.
  36247. * Higher values reduce sensitivity.
  36248. */
  36249. angularSensibility: number;
  36250. /**
  36251. * Get the keys for camera movement forward.
  36252. */
  36253. /**
  36254. * Set the keys for camera movement forward.
  36255. */
  36256. keysForward: number[];
  36257. /**
  36258. * Get the keys for camera movement backward.
  36259. */
  36260. keysBackward: number[];
  36261. /**
  36262. * Get the keys for camera movement up.
  36263. */
  36264. /**
  36265. * Set the keys for camera movement up.
  36266. */
  36267. keysUp: number[];
  36268. /**
  36269. * Get the keys for camera movement down.
  36270. */
  36271. /**
  36272. * Set the keys for camera movement down.
  36273. */
  36274. keysDown: number[];
  36275. /**
  36276. * Get the keys for camera movement left.
  36277. */
  36278. /**
  36279. * Set the keys for camera movement left.
  36280. */
  36281. keysLeft: number[];
  36282. /**
  36283. * Set the keys for camera movement right.
  36284. */
  36285. /**
  36286. * Set the keys for camera movement right.
  36287. */
  36288. keysRight: number[];
  36289. /**
  36290. * Event raised when the camera collides with a mesh in the scene.
  36291. */
  36292. onCollide: (collidedMesh: AbstractMesh) => void;
  36293. private _collider;
  36294. private _needMoveForGravity;
  36295. private _oldPosition;
  36296. private _diffPosition;
  36297. private _newPosition;
  36298. /** @hidden */ private _localDirection: Vector3;
  36299. /** @hidden */ private _transformedDirection: Vector3;
  36300. /**
  36301. * Instantiates a FlyCamera.
  36302. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36303. * such as in a 3D Space Shooter or a Flight Simulator.
  36304. * @param name Define the name of the camera in the scene.
  36305. * @param position Define the starting position of the camera in the scene.
  36306. * @param scene Define the scene the camera belongs to.
  36307. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36308. */
  36309. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36310. /**
  36311. * Attach a control to the HTML DOM element.
  36312. * @param element Defines the element that listens to the input events.
  36313. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36314. */
  36315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36316. /**
  36317. * Detach a control from the HTML DOM element.
  36318. * The camera will stop reacting to that input.
  36319. * @param element Defines the element that listens to the input events.
  36320. */
  36321. detachControl(element: HTMLElement): void;
  36322. private _collisionMask;
  36323. /**
  36324. * Get the mask that the camera ignores in collision events.
  36325. */
  36326. /**
  36327. * Set the mask that the camera ignores in collision events.
  36328. */
  36329. collisionMask: number;
  36330. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36331. /** @hidden */
  36332. private _onCollisionPositionChange;
  36333. /** @hidden */ private _checkInputs(): void;
  36334. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36335. /** @hidden */ private _updatePosition(): void;
  36336. /**
  36337. * Restore the Roll to its target value at the rate specified.
  36338. * @param rate - Higher means slower restoring.
  36339. * @hidden
  36340. */
  36341. restoreRoll(rate: number): void;
  36342. /**
  36343. * Destroy the camera and release the current resources held by it.
  36344. */
  36345. dispose(): void;
  36346. /**
  36347. * Get the current object class name.
  36348. * @returns the class name.
  36349. */
  36350. getClassName(): string;
  36351. }
  36352. }
  36353. declare module BABYLON {
  36354. /**
  36355. * Listen to keyboard events to control the camera.
  36356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36357. */
  36358. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36359. /**
  36360. * Defines the camera the input is attached to.
  36361. */
  36362. camera: FlyCamera;
  36363. /**
  36364. * The list of keyboard keys used to control the forward move of the camera.
  36365. */
  36366. keysForward: number[];
  36367. /**
  36368. * The list of keyboard keys used to control the backward move of the camera.
  36369. */
  36370. keysBackward: number[];
  36371. /**
  36372. * The list of keyboard keys used to control the forward move of the camera.
  36373. */
  36374. keysUp: number[];
  36375. /**
  36376. * The list of keyboard keys used to control the backward move of the camera.
  36377. */
  36378. keysDown: number[];
  36379. /**
  36380. * The list of keyboard keys used to control the right strafe move of the camera.
  36381. */
  36382. keysRight: number[];
  36383. /**
  36384. * The list of keyboard keys used to control the left strafe move of the camera.
  36385. */
  36386. keysLeft: number[];
  36387. private _keys;
  36388. private _onCanvasBlurObserver;
  36389. private _onKeyboardObserver;
  36390. private _engine;
  36391. private _scene;
  36392. /**
  36393. * Attach the input controls to a specific dom element to get the input from.
  36394. * @param element Defines the element the controls should be listened from
  36395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36396. */
  36397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36398. /**
  36399. * Detach the current controls from the specified dom element.
  36400. * @param element Defines the element to stop listening the inputs from
  36401. */
  36402. detachControl(element: Nullable<HTMLElement>): void;
  36403. /**
  36404. * Gets the class name of the current intput.
  36405. * @returns the class name
  36406. */
  36407. getClassName(): string;
  36408. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36409. /**
  36410. * Get the friendly name associated with the input class.
  36411. * @returns the input friendly name
  36412. */
  36413. getSimpleName(): string;
  36414. /**
  36415. * Update the current camera state depending on the inputs that have been used this frame.
  36416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36417. */
  36418. checkInputs(): void;
  36419. }
  36420. }
  36421. declare module BABYLON {
  36422. /**
  36423. * Manage the mouse wheel inputs to control a follow camera.
  36424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36425. */
  36426. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36427. /**
  36428. * Defines the camera the input is attached to.
  36429. */
  36430. camera: FollowCamera;
  36431. /**
  36432. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36433. */
  36434. axisControlRadius: boolean;
  36435. /**
  36436. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36437. */
  36438. axisControlHeight: boolean;
  36439. /**
  36440. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36441. */
  36442. axisControlRotation: boolean;
  36443. /**
  36444. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36445. * relation to mouseWheel events.
  36446. */
  36447. wheelPrecision: number;
  36448. /**
  36449. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36450. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36451. */
  36452. wheelDeltaPercentage: number;
  36453. private _wheel;
  36454. private _observer;
  36455. /**
  36456. * Attach the input controls to a specific dom element to get the input from.
  36457. * @param element Defines the element the controls should be listened from
  36458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36459. */
  36460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36461. /**
  36462. * Detach the current controls from the specified dom element.
  36463. * @param element Defines the element to stop listening the inputs from
  36464. */
  36465. detachControl(element: Nullable<HTMLElement>): void;
  36466. /**
  36467. * Gets the class name of the current intput.
  36468. * @returns the class name
  36469. */
  36470. getClassName(): string;
  36471. /**
  36472. * Get the friendly name associated with the input class.
  36473. * @returns the input friendly name
  36474. */
  36475. getSimpleName(): string;
  36476. }
  36477. }
  36478. declare module BABYLON {
  36479. /**
  36480. * Manage the pointers inputs to control an follow camera.
  36481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36482. */
  36483. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36484. /**
  36485. * Defines the camera the input is attached to.
  36486. */
  36487. camera: FollowCamera;
  36488. /**
  36489. * Gets the class name of the current input.
  36490. * @returns the class name
  36491. */
  36492. getClassName(): string;
  36493. /**
  36494. * Defines the pointer angular sensibility along the X axis or how fast is
  36495. * the camera rotating.
  36496. * A negative number will reverse the axis direction.
  36497. */
  36498. angularSensibilityX: number;
  36499. /**
  36500. * Defines the pointer angular sensibility along the Y axis or how fast is
  36501. * the camera rotating.
  36502. * A negative number will reverse the axis direction.
  36503. */
  36504. angularSensibilityY: number;
  36505. /**
  36506. * Defines the pointer pinch precision or how fast is the camera zooming.
  36507. * A negative number will reverse the axis direction.
  36508. */
  36509. pinchPrecision: number;
  36510. /**
  36511. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36512. * from 0.
  36513. * It defines the percentage of current camera.radius to use as delta when
  36514. * pinch zoom is used.
  36515. */
  36516. pinchDeltaPercentage: number;
  36517. /**
  36518. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36519. */
  36520. axisXControlRadius: boolean;
  36521. /**
  36522. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36523. */
  36524. axisXControlHeight: boolean;
  36525. /**
  36526. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36527. */
  36528. axisXControlRotation: boolean;
  36529. /**
  36530. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36531. */
  36532. axisYControlRadius: boolean;
  36533. /**
  36534. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36535. */
  36536. axisYControlHeight: boolean;
  36537. /**
  36538. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36539. */
  36540. axisYControlRotation: boolean;
  36541. /**
  36542. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36543. */
  36544. axisPinchControlRadius: boolean;
  36545. /**
  36546. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36547. */
  36548. axisPinchControlHeight: boolean;
  36549. /**
  36550. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36551. */
  36552. axisPinchControlRotation: boolean;
  36553. /**
  36554. * Log error messages if basic misconfiguration has occurred.
  36555. */
  36556. warningEnable: boolean;
  36557. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36558. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36559. private _warningCounter;
  36560. private _warning;
  36561. }
  36562. }
  36563. declare module BABYLON {
  36564. /**
  36565. * Default Inputs manager for the FollowCamera.
  36566. * It groups all the default supported inputs for ease of use.
  36567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36568. */
  36569. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36570. /**
  36571. * Instantiates a new FollowCameraInputsManager.
  36572. * @param camera Defines the camera the inputs belong to
  36573. */
  36574. constructor(camera: FollowCamera);
  36575. /**
  36576. * Add keyboard input support to the input manager.
  36577. * @returns the current input manager
  36578. */
  36579. addKeyboard(): FollowCameraInputsManager;
  36580. /**
  36581. * Add mouse wheel input support to the input manager.
  36582. * @returns the current input manager
  36583. */
  36584. addMouseWheel(): FollowCameraInputsManager;
  36585. /**
  36586. * Add pointers input support to the input manager.
  36587. * @returns the current input manager
  36588. */
  36589. addPointers(): FollowCameraInputsManager;
  36590. /**
  36591. * Add orientation input support to the input manager.
  36592. * @returns the current input manager
  36593. */
  36594. addVRDeviceOrientation(): FollowCameraInputsManager;
  36595. }
  36596. }
  36597. declare module BABYLON {
  36598. /**
  36599. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36600. * an arc rotate version arcFollowCamera are available.
  36601. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36602. */
  36603. export class FollowCamera extends TargetCamera {
  36604. /**
  36605. * Distance the follow camera should follow an object at
  36606. */
  36607. radius: number;
  36608. /**
  36609. * Minimum allowed distance of the camera to the axis of rotation
  36610. * (The camera can not get closer).
  36611. * This can help limiting how the Camera is able to move in the scene.
  36612. */
  36613. lowerRadiusLimit: Nullable<number>;
  36614. /**
  36615. * Maximum allowed distance of the camera to the axis of rotation
  36616. * (The camera can not get further).
  36617. * This can help limiting how the Camera is able to move in the scene.
  36618. */
  36619. upperRadiusLimit: Nullable<number>;
  36620. /**
  36621. * Define a rotation offset between the camera and the object it follows
  36622. */
  36623. rotationOffset: number;
  36624. /**
  36625. * Minimum allowed angle to camera position relative to target object.
  36626. * This can help limiting how the Camera is able to move in the scene.
  36627. */
  36628. lowerRotationOffsetLimit: Nullable<number>;
  36629. /**
  36630. * Maximum allowed angle to camera position relative to target object.
  36631. * This can help limiting how the Camera is able to move in the scene.
  36632. */
  36633. upperRotationOffsetLimit: Nullable<number>;
  36634. /**
  36635. * Define a height offset between the camera and the object it follows.
  36636. * It can help following an object from the top (like a car chaing a plane)
  36637. */
  36638. heightOffset: number;
  36639. /**
  36640. * Minimum allowed height of camera position relative to target object.
  36641. * This can help limiting how the Camera is able to move in the scene.
  36642. */
  36643. lowerHeightOffsetLimit: Nullable<number>;
  36644. /**
  36645. * Maximum allowed height of camera position relative to target object.
  36646. * This can help limiting how the Camera is able to move in the scene.
  36647. */
  36648. upperHeightOffsetLimit: Nullable<number>;
  36649. /**
  36650. * Define how fast the camera can accelerate to follow it s target.
  36651. */
  36652. cameraAcceleration: number;
  36653. /**
  36654. * Define the speed limit of the camera following an object.
  36655. */
  36656. maxCameraSpeed: number;
  36657. /**
  36658. * Define the target of the camera.
  36659. */
  36660. lockedTarget: Nullable<AbstractMesh>;
  36661. /**
  36662. * Defines the input associated with the camera.
  36663. */
  36664. inputs: FollowCameraInputsManager;
  36665. /**
  36666. * Instantiates the follow camera.
  36667. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36668. * @param name Define the name of the camera in the scene
  36669. * @param position Define the position of the camera
  36670. * @param scene Define the scene the camera belong to
  36671. * @param lockedTarget Define the target of the camera
  36672. */
  36673. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36674. private _follow;
  36675. /**
  36676. * Attached controls to the current camera.
  36677. * @param element Defines the element the controls should be listened from
  36678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36679. */
  36680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36681. /**
  36682. * Detach the current controls from the camera.
  36683. * The camera will stop reacting to inputs.
  36684. * @param element Defines the element to stop listening the inputs from
  36685. */
  36686. detachControl(element: HTMLElement): void;
  36687. /** @hidden */ private _checkInputs(): void;
  36688. private _checkLimits;
  36689. /**
  36690. * Gets the camera class name.
  36691. * @returns the class name
  36692. */
  36693. getClassName(): string;
  36694. }
  36695. /**
  36696. * Arc Rotate version of the follow camera.
  36697. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36698. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36699. */
  36700. export class ArcFollowCamera extends TargetCamera {
  36701. /** The longitudinal angle of the camera */
  36702. alpha: number;
  36703. /** The latitudinal angle of the camera */
  36704. beta: number;
  36705. /** The radius of the camera from its target */
  36706. radius: number;
  36707. /** Define the camera target (the messh it should follow) */
  36708. target: Nullable<AbstractMesh>;
  36709. private _cartesianCoordinates;
  36710. /**
  36711. * Instantiates a new ArcFollowCamera
  36712. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36713. * @param name Define the name of the camera
  36714. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36715. * @param beta Define the rotation angle of the camera around the elevation axis
  36716. * @param radius Define the radius of the camera from its target point
  36717. * @param target Define the target of the camera
  36718. * @param scene Define the scene the camera belongs to
  36719. */
  36720. constructor(name: string,
  36721. /** The longitudinal angle of the camera */
  36722. alpha: number,
  36723. /** The latitudinal angle of the camera */
  36724. beta: number,
  36725. /** The radius of the camera from its target */
  36726. radius: number,
  36727. /** Define the camera target (the messh it should follow) */
  36728. target: Nullable<AbstractMesh>, scene: Scene);
  36729. private _follow;
  36730. /** @hidden */ private _checkInputs(): void;
  36731. /**
  36732. * Returns the class name of the object.
  36733. * It is mostly used internally for serialization purposes.
  36734. */
  36735. getClassName(): string;
  36736. }
  36737. }
  36738. declare module BABYLON {
  36739. /**
  36740. * Manage the keyboard inputs to control the movement of a follow camera.
  36741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36742. */
  36743. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36744. /**
  36745. * Defines the camera the input is attached to.
  36746. */
  36747. camera: FollowCamera;
  36748. /**
  36749. * Defines the list of key codes associated with the up action (increase heightOffset)
  36750. */
  36751. keysHeightOffsetIncr: number[];
  36752. /**
  36753. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36754. */
  36755. keysHeightOffsetDecr: number[];
  36756. /**
  36757. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36758. */
  36759. keysHeightOffsetModifierAlt: boolean;
  36760. /**
  36761. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36762. */
  36763. keysHeightOffsetModifierCtrl: boolean;
  36764. /**
  36765. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36766. */
  36767. keysHeightOffsetModifierShift: boolean;
  36768. /**
  36769. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36770. */
  36771. keysRotationOffsetIncr: number[];
  36772. /**
  36773. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36774. */
  36775. keysRotationOffsetDecr: number[];
  36776. /**
  36777. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36778. */
  36779. keysRotationOffsetModifierAlt: boolean;
  36780. /**
  36781. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36782. */
  36783. keysRotationOffsetModifierCtrl: boolean;
  36784. /**
  36785. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36786. */
  36787. keysRotationOffsetModifierShift: boolean;
  36788. /**
  36789. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36790. */
  36791. keysRadiusIncr: number[];
  36792. /**
  36793. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36794. */
  36795. keysRadiusDecr: number[];
  36796. /**
  36797. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36798. */
  36799. keysRadiusModifierAlt: boolean;
  36800. /**
  36801. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36802. */
  36803. keysRadiusModifierCtrl: boolean;
  36804. /**
  36805. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36806. */
  36807. keysRadiusModifierShift: boolean;
  36808. /**
  36809. * Defines the rate of change of heightOffset.
  36810. */
  36811. heightSensibility: number;
  36812. /**
  36813. * Defines the rate of change of rotationOffset.
  36814. */
  36815. rotationSensibility: number;
  36816. /**
  36817. * Defines the rate of change of radius.
  36818. */
  36819. radiusSensibility: number;
  36820. private _keys;
  36821. private _ctrlPressed;
  36822. private _altPressed;
  36823. private _shiftPressed;
  36824. private _onCanvasBlurObserver;
  36825. private _onKeyboardObserver;
  36826. private _engine;
  36827. private _scene;
  36828. /**
  36829. * Attach the input controls to a specific dom element to get the input from.
  36830. * @param element Defines the element the controls should be listened from
  36831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36832. */
  36833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36834. /**
  36835. * Detach the current controls from the specified dom element.
  36836. * @param element Defines the element to stop listening the inputs from
  36837. */
  36838. detachControl(element: Nullable<HTMLElement>): void;
  36839. /**
  36840. * Update the current camera state depending on the inputs that have been used this frame.
  36841. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36842. */
  36843. checkInputs(): void;
  36844. /**
  36845. * Gets the class name of the current input.
  36846. * @returns the class name
  36847. */
  36848. getClassName(): string;
  36849. /**
  36850. * Get the friendly name associated with the input class.
  36851. * @returns the input friendly name
  36852. */
  36853. getSimpleName(): string;
  36854. /**
  36855. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36856. * allow modification of the heightOffset value.
  36857. */
  36858. private _modifierHeightOffset;
  36859. /**
  36860. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36861. * allow modification of the rotationOffset value.
  36862. */
  36863. private _modifierRotationOffset;
  36864. /**
  36865. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36866. * allow modification of the radius value.
  36867. */
  36868. private _modifierRadius;
  36869. }
  36870. }
  36871. declare module BABYLON {
  36872. interface FreeCameraInputsManager {
  36873. /**
  36874. * @hidden
  36875. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36876. /**
  36877. * Add orientation input support to the input manager.
  36878. * @returns the current input manager
  36879. */
  36880. addDeviceOrientation(): FreeCameraInputsManager;
  36881. }
  36882. /**
  36883. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36884. * Screen rotation is taken into account.
  36885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36886. */
  36887. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36888. private _camera;
  36889. private _screenOrientationAngle;
  36890. private _constantTranform;
  36891. private _screenQuaternion;
  36892. private _alpha;
  36893. private _beta;
  36894. private _gamma;
  36895. /**
  36896. * Can be used to detect if a device orientation sensor is availible on a device
  36897. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  36898. * @returns a promise that will resolve on orientation change
  36899. */
  36900. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  36901. /**
  36902. * @hidden
  36903. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  36904. /**
  36905. * Instantiates a new input
  36906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36907. */
  36908. constructor();
  36909. /**
  36910. * Define the camera controlled by the input.
  36911. */
  36912. camera: FreeCamera;
  36913. /**
  36914. * Attach the input controls to a specific dom element to get the input from.
  36915. * @param element Defines the element the controls should be listened from
  36916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36917. */
  36918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36919. private _orientationChanged;
  36920. private _deviceOrientation;
  36921. /**
  36922. * Detach the current controls from the specified dom element.
  36923. * @param element Defines the element to stop listening the inputs from
  36924. */
  36925. detachControl(element: Nullable<HTMLElement>): void;
  36926. /**
  36927. * Update the current camera state depending on the inputs that have been used this frame.
  36928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36929. */
  36930. checkInputs(): void;
  36931. /**
  36932. * Gets the class name of the current intput.
  36933. * @returns the class name
  36934. */
  36935. getClassName(): string;
  36936. /**
  36937. * Get the friendly name associated with the input class.
  36938. * @returns the input friendly name
  36939. */
  36940. getSimpleName(): string;
  36941. }
  36942. }
  36943. declare module BABYLON {
  36944. /**
  36945. * Manage the gamepad inputs to control a free camera.
  36946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36947. */
  36948. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36949. /**
  36950. * Define the camera the input is attached to.
  36951. */
  36952. camera: FreeCamera;
  36953. /**
  36954. * Define the Gamepad controlling the input
  36955. */
  36956. gamepad: Nullable<Gamepad>;
  36957. /**
  36958. * Defines the gamepad rotation sensiblity.
  36959. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36960. */
  36961. gamepadAngularSensibility: number;
  36962. /**
  36963. * Defines the gamepad move sensiblity.
  36964. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36965. */
  36966. gamepadMoveSensibility: number;
  36967. private _onGamepadConnectedObserver;
  36968. private _onGamepadDisconnectedObserver;
  36969. private _cameraTransform;
  36970. private _deltaTransform;
  36971. private _vector3;
  36972. private _vector2;
  36973. /**
  36974. * Attach the input controls to a specific dom element to get the input from.
  36975. * @param element Defines the element the controls should be listened from
  36976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36977. */
  36978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36979. /**
  36980. * Detach the current controls from the specified dom element.
  36981. * @param element Defines the element to stop listening the inputs from
  36982. */
  36983. detachControl(element: Nullable<HTMLElement>): void;
  36984. /**
  36985. * Update the current camera state depending on the inputs that have been used this frame.
  36986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36987. */
  36988. checkInputs(): void;
  36989. /**
  36990. * Gets the class name of the current intput.
  36991. * @returns the class name
  36992. */
  36993. getClassName(): string;
  36994. /**
  36995. * Get the friendly name associated with the input class.
  36996. * @returns the input friendly name
  36997. */
  36998. getSimpleName(): string;
  36999. }
  37000. }
  37001. declare module BABYLON {
  37002. /**
  37003. * Defines the potential axis of a Joystick
  37004. */
  37005. export enum JoystickAxis {
  37006. /** X axis */
  37007. X = 0,
  37008. /** Y axis */
  37009. Y = 1,
  37010. /** Z axis */
  37011. Z = 2
  37012. }
  37013. /**
  37014. * Class used to define virtual joystick (used in touch mode)
  37015. */
  37016. export class VirtualJoystick {
  37017. /**
  37018. * Gets or sets a boolean indicating that left and right values must be inverted
  37019. */
  37020. reverseLeftRight: boolean;
  37021. /**
  37022. * Gets or sets a boolean indicating that up and down values must be inverted
  37023. */
  37024. reverseUpDown: boolean;
  37025. /**
  37026. * Gets the offset value for the position (ie. the change of the position value)
  37027. */
  37028. deltaPosition: Vector3;
  37029. /**
  37030. * Gets a boolean indicating if the virtual joystick was pressed
  37031. */
  37032. pressed: boolean;
  37033. /**
  37034. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37035. */
  37036. static Canvas: Nullable<HTMLCanvasElement>;
  37037. private static _globalJoystickIndex;
  37038. private static vjCanvasContext;
  37039. private static vjCanvasWidth;
  37040. private static vjCanvasHeight;
  37041. private static halfWidth;
  37042. private _action;
  37043. private _axisTargetedByLeftAndRight;
  37044. private _axisTargetedByUpAndDown;
  37045. private _joystickSensibility;
  37046. private _inversedSensibility;
  37047. private _joystickPointerID;
  37048. private _joystickColor;
  37049. private _joystickPointerPos;
  37050. private _joystickPreviousPointerPos;
  37051. private _joystickPointerStartPos;
  37052. private _deltaJoystickVector;
  37053. private _leftJoystick;
  37054. private _touches;
  37055. private _onPointerDownHandlerRef;
  37056. private _onPointerMoveHandlerRef;
  37057. private _onPointerUpHandlerRef;
  37058. private _onResize;
  37059. /**
  37060. * Creates a new virtual joystick
  37061. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37062. */
  37063. constructor(leftJoystick?: boolean);
  37064. /**
  37065. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37066. * @param newJoystickSensibility defines the new sensibility
  37067. */
  37068. setJoystickSensibility(newJoystickSensibility: number): void;
  37069. private _onPointerDown;
  37070. private _onPointerMove;
  37071. private _onPointerUp;
  37072. /**
  37073. * Change the color of the virtual joystick
  37074. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37075. */
  37076. setJoystickColor(newColor: string): void;
  37077. /**
  37078. * Defines a callback to call when the joystick is touched
  37079. * @param action defines the callback
  37080. */
  37081. setActionOnTouch(action: () => any): void;
  37082. /**
  37083. * Defines which axis you'd like to control for left & right
  37084. * @param axis defines the axis to use
  37085. */
  37086. setAxisForLeftRight(axis: JoystickAxis): void;
  37087. /**
  37088. * Defines which axis you'd like to control for up & down
  37089. * @param axis defines the axis to use
  37090. */
  37091. setAxisForUpDown(axis: JoystickAxis): void;
  37092. private _drawVirtualJoystick;
  37093. /**
  37094. * Release internal HTML canvas
  37095. */
  37096. releaseCanvas(): void;
  37097. }
  37098. }
  37099. declare module BABYLON {
  37100. interface FreeCameraInputsManager {
  37101. /**
  37102. * Add virtual joystick input support to the input manager.
  37103. * @returns the current input manager
  37104. */
  37105. addVirtualJoystick(): FreeCameraInputsManager;
  37106. }
  37107. /**
  37108. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37110. */
  37111. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37112. /**
  37113. * Defines the camera the input is attached to.
  37114. */
  37115. camera: FreeCamera;
  37116. private _leftjoystick;
  37117. private _rightjoystick;
  37118. /**
  37119. * Gets the left stick of the virtual joystick.
  37120. * @returns The virtual Joystick
  37121. */
  37122. getLeftJoystick(): VirtualJoystick;
  37123. /**
  37124. * Gets the right stick of the virtual joystick.
  37125. * @returns The virtual Joystick
  37126. */
  37127. getRightJoystick(): VirtualJoystick;
  37128. /**
  37129. * Update the current camera state depending on the inputs that have been used this frame.
  37130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37131. */
  37132. checkInputs(): void;
  37133. /**
  37134. * Attach the input controls to a specific dom element to get the input from.
  37135. * @param element Defines the element the controls should be listened from
  37136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37137. */
  37138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37139. /**
  37140. * Detach the current controls from the specified dom element.
  37141. * @param element Defines the element to stop listening the inputs from
  37142. */
  37143. detachControl(element: Nullable<HTMLElement>): void;
  37144. /**
  37145. * Gets the class name of the current intput.
  37146. * @returns the class name
  37147. */
  37148. getClassName(): string;
  37149. /**
  37150. * Get the friendly name associated with the input class.
  37151. * @returns the input friendly name
  37152. */
  37153. getSimpleName(): string;
  37154. }
  37155. }
  37156. declare module BABYLON {
  37157. /**
  37158. * This represents a FPS type of camera controlled by touch.
  37159. * This is like a universal camera minus the Gamepad controls.
  37160. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37161. */
  37162. export class TouchCamera extends FreeCamera {
  37163. /**
  37164. * Defines the touch sensibility for rotation.
  37165. * The higher the faster.
  37166. */
  37167. touchAngularSensibility: number;
  37168. /**
  37169. * Defines the touch sensibility for move.
  37170. * The higher the faster.
  37171. */
  37172. touchMoveSensibility: number;
  37173. /**
  37174. * Instantiates a new touch camera.
  37175. * This represents a FPS type of camera controlled by touch.
  37176. * This is like a universal camera minus the Gamepad controls.
  37177. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37178. * @param name Define the name of the camera in the scene
  37179. * @param position Define the start position of the camera in the scene
  37180. * @param scene Define the scene the camera belongs to
  37181. */
  37182. constructor(name: string, position: Vector3, scene: Scene);
  37183. /**
  37184. * Gets the current object class name.
  37185. * @return the class name
  37186. */
  37187. getClassName(): string;
  37188. /** @hidden */ private _setupInputs(): void;
  37189. }
  37190. }
  37191. declare module BABYLON {
  37192. /**
  37193. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37194. * being tilted forward or back and left or right.
  37195. */
  37196. export class DeviceOrientationCamera extends FreeCamera {
  37197. private _initialQuaternion;
  37198. private _quaternionCache;
  37199. private _tmpDragQuaternion;
  37200. /**
  37201. * Creates a new device orientation camera
  37202. * @param name The name of the camera
  37203. * @param position The start position camera
  37204. * @param scene The scene the camera belongs to
  37205. */
  37206. constructor(name: string, position: Vector3, scene: Scene);
  37207. /**
  37208. * @hidden
  37209. * Disabled pointer input on first orientation sensor update (Default: true)
  37210. */ private _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37211. private _dragFactor;
  37212. /**
  37213. * Enabled turning on the y axis when the orientation sensor is active
  37214. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37215. */
  37216. enableHorizontalDragging(dragFactor?: number): void;
  37217. /**
  37218. * Gets the current instance class name ("DeviceOrientationCamera").
  37219. * This helps avoiding instanceof at run time.
  37220. * @returns the class name
  37221. */
  37222. getClassName(): string;
  37223. /**
  37224. * @hidden
  37225. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37226. */ private _checkInputs(): void;
  37227. /**
  37228. * Reset the camera to its default orientation on the specified axis only.
  37229. * @param axis The axis to reset
  37230. */
  37231. resetToCurrentRotation(axis?: Axis): void;
  37232. }
  37233. }
  37234. declare module BABYLON {
  37235. /**
  37236. * Defines supported buttons for XBox360 compatible gamepads
  37237. */
  37238. export enum Xbox360Button {
  37239. /** A */
  37240. A = 0,
  37241. /** B */
  37242. B = 1,
  37243. /** X */
  37244. X = 2,
  37245. /** Y */
  37246. Y = 3,
  37247. /** Start */
  37248. Start = 4,
  37249. /** Back */
  37250. Back = 5,
  37251. /** Left button */
  37252. LB = 6,
  37253. /** Right button */
  37254. RB = 7,
  37255. /** Left stick */
  37256. LeftStick = 8,
  37257. /** Right stick */
  37258. RightStick = 9
  37259. }
  37260. /** Defines values for XBox360 DPad */
  37261. export enum Xbox360Dpad {
  37262. /** Up */
  37263. Up = 0,
  37264. /** Down */
  37265. Down = 1,
  37266. /** Left */
  37267. Left = 2,
  37268. /** Right */
  37269. Right = 3
  37270. }
  37271. /**
  37272. * Defines a XBox360 gamepad
  37273. */
  37274. export class Xbox360Pad extends Gamepad {
  37275. private _leftTrigger;
  37276. private _rightTrigger;
  37277. private _onlefttriggerchanged;
  37278. private _onrighttriggerchanged;
  37279. private _onbuttondown;
  37280. private _onbuttonup;
  37281. private _ondpaddown;
  37282. private _ondpadup;
  37283. /** Observable raised when a button is pressed */
  37284. onButtonDownObservable: Observable<Xbox360Button>;
  37285. /** Observable raised when a button is released */
  37286. onButtonUpObservable: Observable<Xbox360Button>;
  37287. /** Observable raised when a pad is pressed */
  37288. onPadDownObservable: Observable<Xbox360Dpad>;
  37289. /** Observable raised when a pad is released */
  37290. onPadUpObservable: Observable<Xbox360Dpad>;
  37291. private _buttonA;
  37292. private _buttonB;
  37293. private _buttonX;
  37294. private _buttonY;
  37295. private _buttonBack;
  37296. private _buttonStart;
  37297. private _buttonLB;
  37298. private _buttonRB;
  37299. private _buttonLeftStick;
  37300. private _buttonRightStick;
  37301. private _dPadUp;
  37302. private _dPadDown;
  37303. private _dPadLeft;
  37304. private _dPadRight;
  37305. private _isXboxOnePad;
  37306. /**
  37307. * Creates a new XBox360 gamepad object
  37308. * @param id defines the id of this gamepad
  37309. * @param index defines its index
  37310. * @param gamepad defines the internal HTML gamepad object
  37311. * @param xboxOne defines if it is a XBox One gamepad
  37312. */
  37313. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37314. /**
  37315. * Defines the callback to call when left trigger is pressed
  37316. * @param callback defines the callback to use
  37317. */
  37318. onlefttriggerchanged(callback: (value: number) => void): void;
  37319. /**
  37320. * Defines the callback to call when right trigger is pressed
  37321. * @param callback defines the callback to use
  37322. */
  37323. onrighttriggerchanged(callback: (value: number) => void): void;
  37324. /**
  37325. * Gets the left trigger value
  37326. */
  37327. /**
  37328. * Sets the left trigger value
  37329. */
  37330. leftTrigger: number;
  37331. /**
  37332. * Gets the right trigger value
  37333. */
  37334. /**
  37335. * Sets the right trigger value
  37336. */
  37337. rightTrigger: number;
  37338. /**
  37339. * Defines the callback to call when a button is pressed
  37340. * @param callback defines the callback to use
  37341. */
  37342. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37343. /**
  37344. * Defines the callback to call when a button is released
  37345. * @param callback defines the callback to use
  37346. */
  37347. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37348. /**
  37349. * Defines the callback to call when a pad is pressed
  37350. * @param callback defines the callback to use
  37351. */
  37352. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37353. /**
  37354. * Defines the callback to call when a pad is released
  37355. * @param callback defines the callback to use
  37356. */
  37357. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37358. private _setButtonValue;
  37359. private _setDPadValue;
  37360. /**
  37361. * Gets the value of the `A` button
  37362. */
  37363. /**
  37364. * Sets the value of the `A` button
  37365. */
  37366. buttonA: number;
  37367. /**
  37368. * Gets the value of the `B` button
  37369. */
  37370. /**
  37371. * Sets the value of the `B` button
  37372. */
  37373. buttonB: number;
  37374. /**
  37375. * Gets the value of the `X` button
  37376. */
  37377. /**
  37378. * Sets the value of the `X` button
  37379. */
  37380. buttonX: number;
  37381. /**
  37382. * Gets the value of the `Y` button
  37383. */
  37384. /**
  37385. * Sets the value of the `Y` button
  37386. */
  37387. buttonY: number;
  37388. /**
  37389. * Gets the value of the `Start` button
  37390. */
  37391. /**
  37392. * Sets the value of the `Start` button
  37393. */
  37394. buttonStart: number;
  37395. /**
  37396. * Gets the value of the `Back` button
  37397. */
  37398. /**
  37399. * Sets the value of the `Back` button
  37400. */
  37401. buttonBack: number;
  37402. /**
  37403. * Gets the value of the `Left` button
  37404. */
  37405. /**
  37406. * Sets the value of the `Left` button
  37407. */
  37408. buttonLB: number;
  37409. /**
  37410. * Gets the value of the `Right` button
  37411. */
  37412. /**
  37413. * Sets the value of the `Right` button
  37414. */
  37415. buttonRB: number;
  37416. /**
  37417. * Gets the value of the Left joystick
  37418. */
  37419. /**
  37420. * Sets the value of the Left joystick
  37421. */
  37422. buttonLeftStick: number;
  37423. /**
  37424. * Gets the value of the Right joystick
  37425. */
  37426. /**
  37427. * Sets the value of the Right joystick
  37428. */
  37429. buttonRightStick: number;
  37430. /**
  37431. * Gets the value of D-pad up
  37432. */
  37433. /**
  37434. * Sets the value of D-pad up
  37435. */
  37436. dPadUp: number;
  37437. /**
  37438. * Gets the value of D-pad down
  37439. */
  37440. /**
  37441. * Sets the value of D-pad down
  37442. */
  37443. dPadDown: number;
  37444. /**
  37445. * Gets the value of D-pad left
  37446. */
  37447. /**
  37448. * Sets the value of D-pad left
  37449. */
  37450. dPadLeft: number;
  37451. /**
  37452. * Gets the value of D-pad right
  37453. */
  37454. /**
  37455. * Sets the value of D-pad right
  37456. */
  37457. dPadRight: number;
  37458. /**
  37459. * Force the gamepad to synchronize with device values
  37460. */
  37461. update(): void;
  37462. /**
  37463. * Disposes the gamepad
  37464. */
  37465. dispose(): void;
  37466. }
  37467. }
  37468. declare module BABYLON {
  37469. /**
  37470. * Manager for handling gamepads
  37471. */
  37472. export class GamepadManager {
  37473. private _scene?;
  37474. private _babylonGamepads;
  37475. private _oneGamepadConnected;
  37476. /** @hidden */ private _isMonitoring: boolean;
  37477. private _gamepadEventSupported;
  37478. private _gamepadSupport;
  37479. /**
  37480. * observable to be triggered when the gamepad controller has been connected
  37481. */
  37482. onGamepadConnectedObservable: Observable<Gamepad>;
  37483. /**
  37484. * observable to be triggered when the gamepad controller has been disconnected
  37485. */
  37486. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37487. private _onGamepadConnectedEvent;
  37488. private _onGamepadDisconnectedEvent;
  37489. /**
  37490. * Initializes the gamepad manager
  37491. * @param _scene BabylonJS scene
  37492. */
  37493. constructor(_scene?: Scene | undefined);
  37494. /**
  37495. * The gamepads in the game pad manager
  37496. */
  37497. readonly gamepads: Gamepad[];
  37498. /**
  37499. * Get the gamepad controllers based on type
  37500. * @param type The type of gamepad controller
  37501. * @returns Nullable gamepad
  37502. */
  37503. getGamepadByType(type?: number): Nullable<Gamepad>;
  37504. /**
  37505. * Disposes the gamepad manager
  37506. */
  37507. dispose(): void;
  37508. private _addNewGamepad;
  37509. private _startMonitoringGamepads;
  37510. private _stopMonitoringGamepads;
  37511. /** @hidden */ private _checkGamepadsStatus(): void;
  37512. private _updateGamepadObjects;
  37513. }
  37514. }
  37515. declare module BABYLON {
  37516. interface Scene {
  37517. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  37518. /**
  37519. * Gets the gamepad manager associated with the scene
  37520. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37521. */
  37522. gamepadManager: GamepadManager;
  37523. }
  37524. /**
  37525. * Interface representing a free camera inputs manager
  37526. */
  37527. interface FreeCameraInputsManager {
  37528. /**
  37529. * Adds gamepad input support to the FreeCameraInputsManager.
  37530. * @returns the FreeCameraInputsManager
  37531. */
  37532. addGamepad(): FreeCameraInputsManager;
  37533. }
  37534. /**
  37535. * Interface representing an arc rotate camera inputs manager
  37536. */
  37537. interface ArcRotateCameraInputsManager {
  37538. /**
  37539. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37540. * @returns the camera inputs manager
  37541. */
  37542. addGamepad(): ArcRotateCameraInputsManager;
  37543. }
  37544. /**
  37545. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37546. */
  37547. export class GamepadSystemSceneComponent implements ISceneComponent {
  37548. /**
  37549. * The component name helpfull to identify the component in the list of scene components.
  37550. */
  37551. readonly name: string;
  37552. /**
  37553. * The scene the component belongs to.
  37554. */
  37555. scene: Scene;
  37556. /**
  37557. * Creates a new instance of the component for the given scene
  37558. * @param scene Defines the scene to register the component in
  37559. */
  37560. constructor(scene: Scene);
  37561. /**
  37562. * Registers the component in a given scene
  37563. */
  37564. register(): void;
  37565. /**
  37566. * Rebuilds the elements related to this component in case of
  37567. * context lost for instance.
  37568. */
  37569. rebuild(): void;
  37570. /**
  37571. * Disposes the component and the associated ressources
  37572. */
  37573. dispose(): void;
  37574. private _beforeCameraUpdate;
  37575. }
  37576. }
  37577. declare module BABYLON {
  37578. /**
  37579. * 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,
  37580. * which still works and will still be found in many Playgrounds.
  37581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37582. */
  37583. export class UniversalCamera extends TouchCamera {
  37584. /**
  37585. * Defines the gamepad rotation sensiblity.
  37586. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37587. */
  37588. gamepadAngularSensibility: number;
  37589. /**
  37590. * Defines the gamepad move sensiblity.
  37591. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37592. */
  37593. gamepadMoveSensibility: number;
  37594. /**
  37595. * 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,
  37596. * which still works and will still be found in many Playgrounds.
  37597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37598. * @param name Define the name of the camera in the scene
  37599. * @param position Define the start position of the camera in the scene
  37600. * @param scene Define the scene the camera belongs to
  37601. */
  37602. constructor(name: string, position: Vector3, scene: Scene);
  37603. /**
  37604. * Gets the current object class name.
  37605. * @return the class name
  37606. */
  37607. getClassName(): string;
  37608. }
  37609. }
  37610. declare module BABYLON {
  37611. /**
  37612. * This represents a FPS type of camera. This is only here for back compat purpose.
  37613. * Please use the UniversalCamera instead as both are identical.
  37614. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37615. */
  37616. export class GamepadCamera extends UniversalCamera {
  37617. /**
  37618. * Instantiates a new Gamepad Camera
  37619. * This represents a FPS type of camera. This is only here for back compat purpose.
  37620. * Please use the UniversalCamera instead as both are identical.
  37621. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37622. * @param name Define the name of the camera in the scene
  37623. * @param position Define the start position of the camera in the scene
  37624. * @param scene Define the scene the camera belongs to
  37625. */
  37626. constructor(name: string, position: Vector3, scene: Scene);
  37627. /**
  37628. * Gets the current object class name.
  37629. * @return the class name
  37630. */
  37631. getClassName(): string;
  37632. }
  37633. }
  37634. declare module BABYLON {
  37635. /** @hidden */
  37636. export var passPixelShader: {
  37637. name: string;
  37638. shader: string;
  37639. };
  37640. }
  37641. declare module BABYLON {
  37642. /** @hidden */
  37643. export var passCubePixelShader: {
  37644. name: string;
  37645. shader: string;
  37646. };
  37647. }
  37648. declare module BABYLON {
  37649. /**
  37650. * PassPostProcess which produces an output the same as it's input
  37651. */
  37652. export class PassPostProcess extends PostProcess {
  37653. /**
  37654. * Creates the PassPostProcess
  37655. * @param name The name of the effect.
  37656. * @param options The required width/height ratio to downsize to before computing the render pass.
  37657. * @param camera The camera to apply the render pass to.
  37658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37659. * @param engine The engine which the post process will be applied. (default: current engine)
  37660. * @param reusable If the post process can be reused on the same frame. (default: false)
  37661. * @param textureType The type of texture to be used when performing the post processing.
  37662. * @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)
  37663. */
  37664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37665. }
  37666. /**
  37667. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37668. */
  37669. export class PassCubePostProcess extends PostProcess {
  37670. private _face;
  37671. /**
  37672. * Gets or sets the cube face to display.
  37673. * * 0 is +X
  37674. * * 1 is -X
  37675. * * 2 is +Y
  37676. * * 3 is -Y
  37677. * * 4 is +Z
  37678. * * 5 is -Z
  37679. */
  37680. face: number;
  37681. /**
  37682. * Creates the PassCubePostProcess
  37683. * @param name The name of the effect.
  37684. * @param options The required width/height ratio to downsize to before computing the render pass.
  37685. * @param camera The camera to apply the render pass to.
  37686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37687. * @param engine The engine which the post process will be applied. (default: current engine)
  37688. * @param reusable If the post process can be reused on the same frame. (default: false)
  37689. * @param textureType The type of texture to be used when performing the post processing.
  37690. * @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)
  37691. */
  37692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37693. }
  37694. }
  37695. declare module BABYLON {
  37696. /** @hidden */
  37697. export var anaglyphPixelShader: {
  37698. name: string;
  37699. shader: string;
  37700. };
  37701. }
  37702. declare module BABYLON {
  37703. /**
  37704. * Postprocess used to generate anaglyphic rendering
  37705. */
  37706. export class AnaglyphPostProcess extends PostProcess {
  37707. private _passedProcess;
  37708. /**
  37709. * Creates a new AnaglyphPostProcess
  37710. * @param name defines postprocess name
  37711. * @param options defines creation options or target ratio scale
  37712. * @param rigCameras defines cameras using this postprocess
  37713. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37714. * @param engine defines hosting engine
  37715. * @param reusable defines if the postprocess will be reused multiple times per frame
  37716. */
  37717. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37718. }
  37719. }
  37720. declare module BABYLON {
  37721. /**
  37722. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37723. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37724. */
  37725. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37726. /**
  37727. * Creates a new AnaglyphArcRotateCamera
  37728. * @param name defines camera name
  37729. * @param alpha defines alpha angle (in radians)
  37730. * @param beta defines beta angle (in radians)
  37731. * @param radius defines radius
  37732. * @param target defines camera target
  37733. * @param interaxialDistance defines distance between each color axis
  37734. * @param scene defines the hosting scene
  37735. */
  37736. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37737. /**
  37738. * Gets camera class name
  37739. * @returns AnaglyphArcRotateCamera
  37740. */
  37741. getClassName(): string;
  37742. }
  37743. }
  37744. declare module BABYLON {
  37745. /**
  37746. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37747. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37748. */
  37749. export class AnaglyphFreeCamera extends FreeCamera {
  37750. /**
  37751. * Creates a new AnaglyphFreeCamera
  37752. * @param name defines camera name
  37753. * @param position defines initial position
  37754. * @param interaxialDistance defines distance between each color axis
  37755. * @param scene defines the hosting scene
  37756. */
  37757. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37758. /**
  37759. * Gets camera class name
  37760. * @returns AnaglyphFreeCamera
  37761. */
  37762. getClassName(): string;
  37763. }
  37764. }
  37765. declare module BABYLON {
  37766. /**
  37767. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37768. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37769. */
  37770. export class AnaglyphGamepadCamera extends GamepadCamera {
  37771. /**
  37772. * Creates a new AnaglyphGamepadCamera
  37773. * @param name defines camera name
  37774. * @param position defines initial position
  37775. * @param interaxialDistance defines distance between each color axis
  37776. * @param scene defines the hosting scene
  37777. */
  37778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37779. /**
  37780. * Gets camera class name
  37781. * @returns AnaglyphGamepadCamera
  37782. */
  37783. getClassName(): string;
  37784. }
  37785. }
  37786. declare module BABYLON {
  37787. /**
  37788. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37789. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37790. */
  37791. export class AnaglyphUniversalCamera extends UniversalCamera {
  37792. /**
  37793. * Creates a new AnaglyphUniversalCamera
  37794. * @param name defines camera name
  37795. * @param position defines initial position
  37796. * @param interaxialDistance defines distance between each color axis
  37797. * @param scene defines the hosting scene
  37798. */
  37799. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37800. /**
  37801. * Gets camera class name
  37802. * @returns AnaglyphUniversalCamera
  37803. */
  37804. getClassName(): string;
  37805. }
  37806. }
  37807. declare module BABYLON {
  37808. /** @hidden */
  37809. export var stereoscopicInterlacePixelShader: {
  37810. name: string;
  37811. shader: string;
  37812. };
  37813. }
  37814. declare module BABYLON {
  37815. /**
  37816. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37817. */
  37818. export class StereoscopicInterlacePostProcess extends PostProcess {
  37819. private _stepSize;
  37820. private _passedProcess;
  37821. /**
  37822. * Initializes a StereoscopicInterlacePostProcess
  37823. * @param name The name of the effect.
  37824. * @param rigCameras The rig cameras to be appled to the post process
  37825. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37827. * @param engine The engine which the post process will be applied. (default: current engine)
  37828. * @param reusable If the post process can be reused on the same frame. (default: false)
  37829. */
  37830. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37831. }
  37832. }
  37833. declare module BABYLON {
  37834. /**
  37835. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37836. * @see http://doc.babylonjs.com/features/cameras
  37837. */
  37838. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37839. /**
  37840. * Creates a new StereoscopicArcRotateCamera
  37841. * @param name defines camera name
  37842. * @param alpha defines alpha angle (in radians)
  37843. * @param beta defines beta angle (in radians)
  37844. * @param radius defines radius
  37845. * @param target defines camera target
  37846. * @param interaxialDistance defines distance between each color axis
  37847. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37848. * @param scene defines the hosting scene
  37849. */
  37850. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37851. /**
  37852. * Gets camera class name
  37853. * @returns StereoscopicArcRotateCamera
  37854. */
  37855. getClassName(): string;
  37856. }
  37857. }
  37858. declare module BABYLON {
  37859. /**
  37860. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37861. * @see http://doc.babylonjs.com/features/cameras
  37862. */
  37863. export class StereoscopicFreeCamera extends FreeCamera {
  37864. /**
  37865. * Creates a new StereoscopicFreeCamera
  37866. * @param name defines camera name
  37867. * @param position defines initial position
  37868. * @param interaxialDistance defines distance between each color axis
  37869. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37870. * @param scene defines the hosting scene
  37871. */
  37872. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37873. /**
  37874. * Gets camera class name
  37875. * @returns StereoscopicFreeCamera
  37876. */
  37877. getClassName(): string;
  37878. }
  37879. }
  37880. declare module BABYLON {
  37881. /**
  37882. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37883. * @see http://doc.babylonjs.com/features/cameras
  37884. */
  37885. export class StereoscopicGamepadCamera extends GamepadCamera {
  37886. /**
  37887. * Creates a new StereoscopicGamepadCamera
  37888. * @param name defines camera name
  37889. * @param position defines initial position
  37890. * @param interaxialDistance defines distance between each color axis
  37891. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37892. * @param scene defines the hosting scene
  37893. */
  37894. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37895. /**
  37896. * Gets camera class name
  37897. * @returns StereoscopicGamepadCamera
  37898. */
  37899. getClassName(): string;
  37900. }
  37901. }
  37902. declare module BABYLON {
  37903. /**
  37904. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37905. * @see http://doc.babylonjs.com/features/cameras
  37906. */
  37907. export class StereoscopicUniversalCamera extends UniversalCamera {
  37908. /**
  37909. * Creates a new StereoscopicUniversalCamera
  37910. * @param name defines camera name
  37911. * @param position defines initial position
  37912. * @param interaxialDistance defines distance between each color axis
  37913. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37914. * @param scene defines the hosting scene
  37915. */
  37916. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37917. /**
  37918. * Gets camera class name
  37919. * @returns StereoscopicUniversalCamera
  37920. */
  37921. getClassName(): string;
  37922. }
  37923. }
  37924. declare module BABYLON {
  37925. /**
  37926. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37927. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37928. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37929. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37930. */
  37931. export class VirtualJoysticksCamera extends FreeCamera {
  37932. /**
  37933. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37934. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37935. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37936. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37937. * @param name Define the name of the camera in the scene
  37938. * @param position Define the start position of the camera in the scene
  37939. * @param scene Define the scene the camera belongs to
  37940. */
  37941. constructor(name: string, position: Vector3, scene: Scene);
  37942. /**
  37943. * Gets the current object class name.
  37944. * @return the class name
  37945. */
  37946. getClassName(): string;
  37947. }
  37948. }
  37949. declare module BABYLON {
  37950. /**
  37951. * This represents all the required metrics to create a VR camera.
  37952. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37953. */
  37954. export class VRCameraMetrics {
  37955. /**
  37956. * Define the horizontal resolution off the screen.
  37957. */
  37958. hResolution: number;
  37959. /**
  37960. * Define the vertical resolution off the screen.
  37961. */
  37962. vResolution: number;
  37963. /**
  37964. * Define the horizontal screen size.
  37965. */
  37966. hScreenSize: number;
  37967. /**
  37968. * Define the vertical screen size.
  37969. */
  37970. vScreenSize: number;
  37971. /**
  37972. * Define the vertical screen center position.
  37973. */
  37974. vScreenCenter: number;
  37975. /**
  37976. * Define the distance of the eyes to the screen.
  37977. */
  37978. eyeToScreenDistance: number;
  37979. /**
  37980. * Define the distance between both lenses
  37981. */
  37982. lensSeparationDistance: number;
  37983. /**
  37984. * Define the distance between both viewer's eyes.
  37985. */
  37986. interpupillaryDistance: number;
  37987. /**
  37988. * Define the distortion factor of the VR postprocess.
  37989. * Please, touch with care.
  37990. */
  37991. distortionK: number[];
  37992. /**
  37993. * Define the chromatic aberration correction factors for the VR post process.
  37994. */
  37995. chromaAbCorrection: number[];
  37996. /**
  37997. * Define the scale factor of the post process.
  37998. * The smaller the better but the slower.
  37999. */
  38000. postProcessScaleFactor: number;
  38001. /**
  38002. * Define an offset for the lens center.
  38003. */
  38004. lensCenterOffset: number;
  38005. /**
  38006. * Define if the current vr camera should compensate the distortion of the lense or not.
  38007. */
  38008. compensateDistortion: boolean;
  38009. /**
  38010. * Defines if multiview should be enabled when rendering (Default: false)
  38011. */
  38012. multiviewEnabled: boolean;
  38013. /**
  38014. * Gets the rendering aspect ratio based on the provided resolutions.
  38015. */
  38016. readonly aspectRatio: number;
  38017. /**
  38018. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38019. */
  38020. readonly aspectRatioFov: number;
  38021. /**
  38022. * @hidden
  38023. */
  38024. readonly leftHMatrix: Matrix;
  38025. /**
  38026. * @hidden
  38027. */
  38028. readonly rightHMatrix: Matrix;
  38029. /**
  38030. * @hidden
  38031. */
  38032. readonly leftPreViewMatrix: Matrix;
  38033. /**
  38034. * @hidden
  38035. */
  38036. readonly rightPreViewMatrix: Matrix;
  38037. /**
  38038. * Get the default VRMetrics based on the most generic setup.
  38039. * @returns the default vr metrics
  38040. */
  38041. static GetDefault(): VRCameraMetrics;
  38042. }
  38043. }
  38044. declare module BABYLON {
  38045. /** @hidden */
  38046. export var vrDistortionCorrectionPixelShader: {
  38047. name: string;
  38048. shader: string;
  38049. };
  38050. }
  38051. declare module BABYLON {
  38052. /**
  38053. * VRDistortionCorrectionPostProcess used for mobile VR
  38054. */
  38055. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38056. private _isRightEye;
  38057. private _distortionFactors;
  38058. private _postProcessScaleFactor;
  38059. private _lensCenterOffset;
  38060. private _scaleIn;
  38061. private _scaleFactor;
  38062. private _lensCenter;
  38063. /**
  38064. * Initializes the VRDistortionCorrectionPostProcess
  38065. * @param name The name of the effect.
  38066. * @param camera The camera to apply the render pass to.
  38067. * @param isRightEye If this is for the right eye distortion
  38068. * @param vrMetrics All the required metrics for the VR camera
  38069. */
  38070. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38071. }
  38072. }
  38073. declare module BABYLON {
  38074. /**
  38075. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38076. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38077. */
  38078. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38079. /**
  38080. * Creates a new VRDeviceOrientationArcRotateCamera
  38081. * @param name defines camera name
  38082. * @param alpha defines the camera rotation along the logitudinal axis
  38083. * @param beta defines the camera rotation along the latitudinal axis
  38084. * @param radius defines the camera distance from its target
  38085. * @param target defines the camera target
  38086. * @param scene defines the scene the camera belongs to
  38087. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38088. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38089. */
  38090. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38091. /**
  38092. * Gets camera class name
  38093. * @returns VRDeviceOrientationArcRotateCamera
  38094. */
  38095. getClassName(): string;
  38096. }
  38097. }
  38098. declare module BABYLON {
  38099. /**
  38100. * Camera used to simulate VR rendering (based on FreeCamera)
  38101. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38102. */
  38103. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38104. /**
  38105. * Creates a new VRDeviceOrientationFreeCamera
  38106. * @param name defines camera name
  38107. * @param position defines the start position of the camera
  38108. * @param scene defines the scene the camera belongs to
  38109. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38110. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38111. */
  38112. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38113. /**
  38114. * Gets camera class name
  38115. * @returns VRDeviceOrientationFreeCamera
  38116. */
  38117. getClassName(): string;
  38118. }
  38119. }
  38120. declare module BABYLON {
  38121. /**
  38122. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38123. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38124. */
  38125. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38126. /**
  38127. * Creates a new VRDeviceOrientationGamepadCamera
  38128. * @param name defines camera name
  38129. * @param position defines the start position of the camera
  38130. * @param scene defines the scene the camera belongs to
  38131. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38132. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38133. */
  38134. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38135. /**
  38136. * Gets camera class name
  38137. * @returns VRDeviceOrientationGamepadCamera
  38138. */
  38139. getClassName(): string;
  38140. }
  38141. }
  38142. declare module BABYLON {
  38143. /**
  38144. * Base class of materials working in push mode in babylon JS
  38145. * @hidden
  38146. */
  38147. export class PushMaterial extends Material {
  38148. protected _activeEffect: Effect;
  38149. protected _normalMatrix: Matrix;
  38150. /**
  38151. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38152. * This means that the material can keep using a previous shader while a new one is being compiled.
  38153. * This is mostly used when shader parallel compilation is supported (true by default)
  38154. */
  38155. allowShaderHotSwapping: boolean;
  38156. constructor(name: string, scene: Scene);
  38157. getEffect(): Effect;
  38158. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38159. /**
  38160. * Binds the given world matrix to the active effect
  38161. *
  38162. * @param world the matrix to bind
  38163. */
  38164. bindOnlyWorldMatrix(world: Matrix): void;
  38165. /**
  38166. * Binds the given normal matrix to the active effect
  38167. *
  38168. * @param normalMatrix the matrix to bind
  38169. */
  38170. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38171. bind(world: Matrix, mesh?: Mesh): void;
  38172. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38173. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38174. }
  38175. }
  38176. declare module BABYLON {
  38177. /**
  38178. * This groups all the flags used to control the materials channel.
  38179. */
  38180. export class MaterialFlags {
  38181. private static _DiffuseTextureEnabled;
  38182. /**
  38183. * Are diffuse textures enabled in the application.
  38184. */
  38185. static DiffuseTextureEnabled: boolean;
  38186. private static _AmbientTextureEnabled;
  38187. /**
  38188. * Are ambient textures enabled in the application.
  38189. */
  38190. static AmbientTextureEnabled: boolean;
  38191. private static _OpacityTextureEnabled;
  38192. /**
  38193. * Are opacity textures enabled in the application.
  38194. */
  38195. static OpacityTextureEnabled: boolean;
  38196. private static _ReflectionTextureEnabled;
  38197. /**
  38198. * Are reflection textures enabled in the application.
  38199. */
  38200. static ReflectionTextureEnabled: boolean;
  38201. private static _EmissiveTextureEnabled;
  38202. /**
  38203. * Are emissive textures enabled in the application.
  38204. */
  38205. static EmissiveTextureEnabled: boolean;
  38206. private static _SpecularTextureEnabled;
  38207. /**
  38208. * Are specular textures enabled in the application.
  38209. */
  38210. static SpecularTextureEnabled: boolean;
  38211. private static _BumpTextureEnabled;
  38212. /**
  38213. * Are bump textures enabled in the application.
  38214. */
  38215. static BumpTextureEnabled: boolean;
  38216. private static _LightmapTextureEnabled;
  38217. /**
  38218. * Are lightmap textures enabled in the application.
  38219. */
  38220. static LightmapTextureEnabled: boolean;
  38221. private static _RefractionTextureEnabled;
  38222. /**
  38223. * Are refraction textures enabled in the application.
  38224. */
  38225. static RefractionTextureEnabled: boolean;
  38226. private static _ColorGradingTextureEnabled;
  38227. /**
  38228. * Are color grading textures enabled in the application.
  38229. */
  38230. static ColorGradingTextureEnabled: boolean;
  38231. private static _FresnelEnabled;
  38232. /**
  38233. * Are fresnels enabled in the application.
  38234. */
  38235. static FresnelEnabled: boolean;
  38236. private static _ClearCoatTextureEnabled;
  38237. /**
  38238. * Are clear coat textures enabled in the application.
  38239. */
  38240. static ClearCoatTextureEnabled: boolean;
  38241. private static _ClearCoatBumpTextureEnabled;
  38242. /**
  38243. * Are clear coat bump textures enabled in the application.
  38244. */
  38245. static ClearCoatBumpTextureEnabled: boolean;
  38246. private static _ClearCoatTintTextureEnabled;
  38247. /**
  38248. * Are clear coat tint textures enabled in the application.
  38249. */
  38250. static ClearCoatTintTextureEnabled: boolean;
  38251. private static _SheenTextureEnabled;
  38252. /**
  38253. * Are sheen textures enabled in the application.
  38254. */
  38255. static SheenTextureEnabled: boolean;
  38256. private static _AnisotropicTextureEnabled;
  38257. /**
  38258. * Are anisotropic textures enabled in the application.
  38259. */
  38260. static AnisotropicTextureEnabled: boolean;
  38261. private static _ThicknessTextureEnabled;
  38262. /**
  38263. * Are thickness textures enabled in the application.
  38264. */
  38265. static ThicknessTextureEnabled: boolean;
  38266. }
  38267. }
  38268. declare module BABYLON {
  38269. /** @hidden */
  38270. export var defaultFragmentDeclaration: {
  38271. name: string;
  38272. shader: string;
  38273. };
  38274. }
  38275. declare module BABYLON {
  38276. /** @hidden */
  38277. export var defaultUboDeclaration: {
  38278. name: string;
  38279. shader: string;
  38280. };
  38281. }
  38282. declare module BABYLON {
  38283. /** @hidden */
  38284. export var lightFragmentDeclaration: {
  38285. name: string;
  38286. shader: string;
  38287. };
  38288. }
  38289. declare module BABYLON {
  38290. /** @hidden */
  38291. export var lightUboDeclaration: {
  38292. name: string;
  38293. shader: string;
  38294. };
  38295. }
  38296. declare module BABYLON {
  38297. /** @hidden */
  38298. export var lightsFragmentFunctions: {
  38299. name: string;
  38300. shader: string;
  38301. };
  38302. }
  38303. declare module BABYLON {
  38304. /** @hidden */
  38305. export var shadowsFragmentFunctions: {
  38306. name: string;
  38307. shader: string;
  38308. };
  38309. }
  38310. declare module BABYLON {
  38311. /** @hidden */
  38312. export var fresnelFunction: {
  38313. name: string;
  38314. shader: string;
  38315. };
  38316. }
  38317. declare module BABYLON {
  38318. /** @hidden */
  38319. export var reflectionFunction: {
  38320. name: string;
  38321. shader: string;
  38322. };
  38323. }
  38324. declare module BABYLON {
  38325. /** @hidden */
  38326. export var bumpFragmentFunctions: {
  38327. name: string;
  38328. shader: string;
  38329. };
  38330. }
  38331. declare module BABYLON {
  38332. /** @hidden */
  38333. export var logDepthDeclaration: {
  38334. name: string;
  38335. shader: string;
  38336. };
  38337. }
  38338. declare module BABYLON {
  38339. /** @hidden */
  38340. export var bumpFragment: {
  38341. name: string;
  38342. shader: string;
  38343. };
  38344. }
  38345. declare module BABYLON {
  38346. /** @hidden */
  38347. export var depthPrePass: {
  38348. name: string;
  38349. shader: string;
  38350. };
  38351. }
  38352. declare module BABYLON {
  38353. /** @hidden */
  38354. export var lightFragment: {
  38355. name: string;
  38356. shader: string;
  38357. };
  38358. }
  38359. declare module BABYLON {
  38360. /** @hidden */
  38361. export var logDepthFragment: {
  38362. name: string;
  38363. shader: string;
  38364. };
  38365. }
  38366. declare module BABYLON {
  38367. /** @hidden */
  38368. export var defaultPixelShader: {
  38369. name: string;
  38370. shader: string;
  38371. };
  38372. }
  38373. declare module BABYLON {
  38374. /** @hidden */
  38375. export var defaultVertexDeclaration: {
  38376. name: string;
  38377. shader: string;
  38378. };
  38379. }
  38380. declare module BABYLON {
  38381. /** @hidden */
  38382. export var bumpVertexDeclaration: {
  38383. name: string;
  38384. shader: string;
  38385. };
  38386. }
  38387. declare module BABYLON {
  38388. /** @hidden */
  38389. export var bumpVertex: {
  38390. name: string;
  38391. shader: string;
  38392. };
  38393. }
  38394. declare module BABYLON {
  38395. /** @hidden */
  38396. export var fogVertex: {
  38397. name: string;
  38398. shader: string;
  38399. };
  38400. }
  38401. declare module BABYLON {
  38402. /** @hidden */
  38403. export var shadowsVertex: {
  38404. name: string;
  38405. shader: string;
  38406. };
  38407. }
  38408. declare module BABYLON {
  38409. /** @hidden */
  38410. export var pointCloudVertex: {
  38411. name: string;
  38412. shader: string;
  38413. };
  38414. }
  38415. declare module BABYLON {
  38416. /** @hidden */
  38417. export var logDepthVertex: {
  38418. name: string;
  38419. shader: string;
  38420. };
  38421. }
  38422. declare module BABYLON {
  38423. /** @hidden */
  38424. export var defaultVertexShader: {
  38425. name: string;
  38426. shader: string;
  38427. };
  38428. }
  38429. declare module BABYLON {
  38430. /** @hidden */
  38431. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38432. MAINUV1: boolean;
  38433. MAINUV2: boolean;
  38434. DIFFUSE: boolean;
  38435. DIFFUSEDIRECTUV: number;
  38436. AMBIENT: boolean;
  38437. AMBIENTDIRECTUV: number;
  38438. OPACITY: boolean;
  38439. OPACITYDIRECTUV: number;
  38440. OPACITYRGB: boolean;
  38441. REFLECTION: boolean;
  38442. EMISSIVE: boolean;
  38443. EMISSIVEDIRECTUV: number;
  38444. SPECULAR: boolean;
  38445. SPECULARDIRECTUV: number;
  38446. BUMP: boolean;
  38447. BUMPDIRECTUV: number;
  38448. PARALLAX: boolean;
  38449. PARALLAXOCCLUSION: boolean;
  38450. SPECULAROVERALPHA: boolean;
  38451. CLIPPLANE: boolean;
  38452. CLIPPLANE2: boolean;
  38453. CLIPPLANE3: boolean;
  38454. CLIPPLANE4: boolean;
  38455. ALPHATEST: boolean;
  38456. DEPTHPREPASS: boolean;
  38457. ALPHAFROMDIFFUSE: boolean;
  38458. POINTSIZE: boolean;
  38459. FOG: boolean;
  38460. SPECULARTERM: boolean;
  38461. DIFFUSEFRESNEL: boolean;
  38462. OPACITYFRESNEL: boolean;
  38463. REFLECTIONFRESNEL: boolean;
  38464. REFRACTIONFRESNEL: boolean;
  38465. EMISSIVEFRESNEL: boolean;
  38466. FRESNEL: boolean;
  38467. NORMAL: boolean;
  38468. UV1: boolean;
  38469. UV2: boolean;
  38470. VERTEXCOLOR: boolean;
  38471. VERTEXALPHA: boolean;
  38472. NUM_BONE_INFLUENCERS: number;
  38473. BonesPerMesh: number;
  38474. BONETEXTURE: boolean;
  38475. INSTANCES: boolean;
  38476. GLOSSINESS: boolean;
  38477. ROUGHNESS: boolean;
  38478. EMISSIVEASILLUMINATION: boolean;
  38479. LINKEMISSIVEWITHDIFFUSE: boolean;
  38480. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38481. LIGHTMAP: boolean;
  38482. LIGHTMAPDIRECTUV: number;
  38483. OBJECTSPACE_NORMALMAP: boolean;
  38484. USELIGHTMAPASSHADOWMAP: boolean;
  38485. REFLECTIONMAP_3D: boolean;
  38486. REFLECTIONMAP_SPHERICAL: boolean;
  38487. REFLECTIONMAP_PLANAR: boolean;
  38488. REFLECTIONMAP_CUBIC: boolean;
  38489. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38490. REFLECTIONMAP_PROJECTION: boolean;
  38491. REFLECTIONMAP_SKYBOX: boolean;
  38492. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38493. REFLECTIONMAP_EXPLICIT: boolean;
  38494. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38495. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38496. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38497. INVERTCUBICMAP: boolean;
  38498. LOGARITHMICDEPTH: boolean;
  38499. REFRACTION: boolean;
  38500. REFRACTIONMAP_3D: boolean;
  38501. REFLECTIONOVERALPHA: boolean;
  38502. TWOSIDEDLIGHTING: boolean;
  38503. SHADOWFLOAT: boolean;
  38504. MORPHTARGETS: boolean;
  38505. MORPHTARGETS_NORMAL: boolean;
  38506. MORPHTARGETS_TANGENT: boolean;
  38507. MORPHTARGETS_UV: boolean;
  38508. NUM_MORPH_INFLUENCERS: number;
  38509. NONUNIFORMSCALING: boolean;
  38510. PREMULTIPLYALPHA: boolean;
  38511. IMAGEPROCESSING: boolean;
  38512. VIGNETTE: boolean;
  38513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38514. VIGNETTEBLENDMODEOPAQUE: boolean;
  38515. TONEMAPPING: boolean;
  38516. TONEMAPPING_ACES: boolean;
  38517. CONTRAST: boolean;
  38518. COLORCURVES: boolean;
  38519. COLORGRADING: boolean;
  38520. COLORGRADING3D: boolean;
  38521. SAMPLER3DGREENDEPTH: boolean;
  38522. SAMPLER3DBGRMAP: boolean;
  38523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38524. MULTIVIEW: boolean;
  38525. /**
  38526. * If the reflection texture on this material is in linear color space
  38527. * @hidden
  38528. */
  38529. IS_REFLECTION_LINEAR: boolean;
  38530. /**
  38531. * If the refraction texture on this material is in linear color space
  38532. * @hidden
  38533. */
  38534. IS_REFRACTION_LINEAR: boolean;
  38535. EXPOSURE: boolean;
  38536. constructor();
  38537. setReflectionMode(modeToEnable: string): void;
  38538. }
  38539. /**
  38540. * This is the default material used in Babylon. It is the best trade off between quality
  38541. * and performances.
  38542. * @see http://doc.babylonjs.com/babylon101/materials
  38543. */
  38544. export class StandardMaterial extends PushMaterial {
  38545. private _diffuseTexture;
  38546. /**
  38547. * The basic texture of the material as viewed under a light.
  38548. */
  38549. diffuseTexture: Nullable<BaseTexture>;
  38550. private _ambientTexture;
  38551. /**
  38552. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38553. */
  38554. ambientTexture: Nullable<BaseTexture>;
  38555. private _opacityTexture;
  38556. /**
  38557. * Define the transparency of the material from a texture.
  38558. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38559. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38560. */
  38561. opacityTexture: Nullable<BaseTexture>;
  38562. private _reflectionTexture;
  38563. /**
  38564. * Define the texture used to display the reflection.
  38565. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38566. */
  38567. reflectionTexture: Nullable<BaseTexture>;
  38568. private _emissiveTexture;
  38569. /**
  38570. * Define texture of the material as if self lit.
  38571. * This will be mixed in the final result even in the absence of light.
  38572. */
  38573. emissiveTexture: Nullable<BaseTexture>;
  38574. private _specularTexture;
  38575. /**
  38576. * Define how the color and intensity of the highlight given by the light in the material.
  38577. */
  38578. specularTexture: Nullable<BaseTexture>;
  38579. private _bumpTexture;
  38580. /**
  38581. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38582. * 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.
  38583. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38584. */
  38585. bumpTexture: Nullable<BaseTexture>;
  38586. private _lightmapTexture;
  38587. /**
  38588. * Complex lighting can be computationally expensive to compute at runtime.
  38589. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38590. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38591. */
  38592. lightmapTexture: Nullable<BaseTexture>;
  38593. private _refractionTexture;
  38594. /**
  38595. * Define the texture used to display the refraction.
  38596. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38597. */
  38598. refractionTexture: Nullable<BaseTexture>;
  38599. /**
  38600. * The color of the material lit by the environmental background lighting.
  38601. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38602. */
  38603. ambientColor: Color3;
  38604. /**
  38605. * The basic color of the material as viewed under a light.
  38606. */
  38607. diffuseColor: Color3;
  38608. /**
  38609. * Define how the color and intensity of the highlight given by the light in the material.
  38610. */
  38611. specularColor: Color3;
  38612. /**
  38613. * Define the color of the material as if self lit.
  38614. * This will be mixed in the final result even in the absence of light.
  38615. */
  38616. emissiveColor: Color3;
  38617. /**
  38618. * Defines how sharp are the highlights in the material.
  38619. * The bigger the value the sharper giving a more glossy feeling to the result.
  38620. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38621. */
  38622. specularPower: number;
  38623. private _useAlphaFromDiffuseTexture;
  38624. /**
  38625. * Does the transparency come from the diffuse texture alpha channel.
  38626. */
  38627. useAlphaFromDiffuseTexture: boolean;
  38628. private _useEmissiveAsIllumination;
  38629. /**
  38630. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38631. */
  38632. useEmissiveAsIllumination: boolean;
  38633. private _linkEmissiveWithDiffuse;
  38634. /**
  38635. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38636. * the emissive level when the final color is close to one.
  38637. */
  38638. linkEmissiveWithDiffuse: boolean;
  38639. private _useSpecularOverAlpha;
  38640. /**
  38641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38643. */
  38644. useSpecularOverAlpha: boolean;
  38645. private _useReflectionOverAlpha;
  38646. /**
  38647. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38648. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38649. */
  38650. useReflectionOverAlpha: boolean;
  38651. private _disableLighting;
  38652. /**
  38653. * Does lights from the scene impacts this material.
  38654. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38655. */
  38656. disableLighting: boolean;
  38657. private _useObjectSpaceNormalMap;
  38658. /**
  38659. * Allows using an object space normal map (instead of tangent space).
  38660. */
  38661. useObjectSpaceNormalMap: boolean;
  38662. private _useParallax;
  38663. /**
  38664. * Is parallax enabled or not.
  38665. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38666. */
  38667. useParallax: boolean;
  38668. private _useParallaxOcclusion;
  38669. /**
  38670. * Is parallax occlusion enabled or not.
  38671. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38673. */
  38674. useParallaxOcclusion: boolean;
  38675. /**
  38676. * 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.
  38677. */
  38678. parallaxScaleBias: number;
  38679. private _roughness;
  38680. /**
  38681. * Helps to define how blurry the reflections should appears in the material.
  38682. */
  38683. roughness: number;
  38684. /**
  38685. * In case of refraction, define the value of the index of refraction.
  38686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38687. */
  38688. indexOfRefraction: number;
  38689. /**
  38690. * Invert the refraction texture alongside the y axis.
  38691. * It can be useful with procedural textures or probe for instance.
  38692. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38693. */
  38694. invertRefractionY: boolean;
  38695. /**
  38696. * Defines the alpha limits in alpha test mode.
  38697. */
  38698. alphaCutOff: number;
  38699. private _useLightmapAsShadowmap;
  38700. /**
  38701. * In case of light mapping, define whether the map contains light or shadow informations.
  38702. */
  38703. useLightmapAsShadowmap: boolean;
  38704. private _diffuseFresnelParameters;
  38705. /**
  38706. * Define the diffuse fresnel parameters of the material.
  38707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38708. */
  38709. diffuseFresnelParameters: FresnelParameters;
  38710. private _opacityFresnelParameters;
  38711. /**
  38712. * Define the opacity fresnel parameters of the material.
  38713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38714. */
  38715. opacityFresnelParameters: FresnelParameters;
  38716. private _reflectionFresnelParameters;
  38717. /**
  38718. * Define the reflection fresnel parameters of the material.
  38719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38720. */
  38721. reflectionFresnelParameters: FresnelParameters;
  38722. private _refractionFresnelParameters;
  38723. /**
  38724. * Define the refraction fresnel parameters of the material.
  38725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38726. */
  38727. refractionFresnelParameters: FresnelParameters;
  38728. private _emissiveFresnelParameters;
  38729. /**
  38730. * Define the emissive fresnel parameters of the material.
  38731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38732. */
  38733. emissiveFresnelParameters: FresnelParameters;
  38734. private _useReflectionFresnelFromSpecular;
  38735. /**
  38736. * If true automatically deducts the fresnels values from the material specularity.
  38737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38738. */
  38739. useReflectionFresnelFromSpecular: boolean;
  38740. private _useGlossinessFromSpecularMapAlpha;
  38741. /**
  38742. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38743. */
  38744. useGlossinessFromSpecularMapAlpha: boolean;
  38745. private _maxSimultaneousLights;
  38746. /**
  38747. * Defines the maximum number of lights that can be used in the material
  38748. */
  38749. maxSimultaneousLights: number;
  38750. private _invertNormalMapX;
  38751. /**
  38752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38753. */
  38754. invertNormalMapX: boolean;
  38755. private _invertNormalMapY;
  38756. /**
  38757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38758. */
  38759. invertNormalMapY: boolean;
  38760. private _twoSidedLighting;
  38761. /**
  38762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38763. */
  38764. twoSidedLighting: boolean;
  38765. /**
  38766. * Default configuration related to image processing available in the standard Material.
  38767. */
  38768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38769. /**
  38770. * Gets the image processing configuration used either in this material.
  38771. */
  38772. /**
  38773. * Sets the Default image processing configuration used either in the this material.
  38774. *
  38775. * If sets to null, the scene one is in use.
  38776. */
  38777. imageProcessingConfiguration: ImageProcessingConfiguration;
  38778. /**
  38779. * Keep track of the image processing observer to allow dispose and replace.
  38780. */
  38781. private _imageProcessingObserver;
  38782. /**
  38783. * Attaches a new image processing configuration to the Standard Material.
  38784. * @param configuration
  38785. */
  38786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38787. /**
  38788. * Gets wether the color curves effect is enabled.
  38789. */
  38790. /**
  38791. * Sets wether the color curves effect is enabled.
  38792. */
  38793. cameraColorCurvesEnabled: boolean;
  38794. /**
  38795. * Gets wether the color grading effect is enabled.
  38796. */
  38797. /**
  38798. * Gets wether the color grading effect is enabled.
  38799. */
  38800. cameraColorGradingEnabled: boolean;
  38801. /**
  38802. * Gets wether tonemapping is enabled or not.
  38803. */
  38804. /**
  38805. * Sets wether tonemapping is enabled or not
  38806. */
  38807. cameraToneMappingEnabled: boolean;
  38808. /**
  38809. * The camera exposure used on this material.
  38810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38811. * This corresponds to a photographic exposure.
  38812. */
  38813. /**
  38814. * The camera exposure used on this material.
  38815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38816. * This corresponds to a photographic exposure.
  38817. */
  38818. cameraExposure: number;
  38819. /**
  38820. * Gets The camera contrast used on this material.
  38821. */
  38822. /**
  38823. * Sets The camera contrast used on this material.
  38824. */
  38825. cameraContrast: number;
  38826. /**
  38827. * Gets the Color Grading 2D Lookup Texture.
  38828. */
  38829. /**
  38830. * Sets the Color Grading 2D Lookup Texture.
  38831. */
  38832. cameraColorGradingTexture: Nullable<BaseTexture>;
  38833. /**
  38834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38836. * 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;
  38837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38838. */
  38839. /**
  38840. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38841. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38842. * 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;
  38843. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38844. */
  38845. cameraColorCurves: Nullable<ColorCurves>;
  38846. /**
  38847. * Custom callback helping to override the default shader used in the material.
  38848. */
  38849. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38850. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38851. protected _worldViewProjectionMatrix: Matrix;
  38852. protected _globalAmbientColor: Color3;
  38853. protected _useLogarithmicDepth: boolean;
  38854. /**
  38855. * Instantiates a new standard material.
  38856. * This is the default material used in Babylon. It is the best trade off between quality
  38857. * and performances.
  38858. * @see http://doc.babylonjs.com/babylon101/materials
  38859. * @param name Define the name of the material in the scene
  38860. * @param scene Define the scene the material belong to
  38861. */
  38862. constructor(name: string, scene: Scene);
  38863. /**
  38864. * Gets a boolean indicating that current material needs to register RTT
  38865. */
  38866. readonly hasRenderTargetTextures: boolean;
  38867. /**
  38868. * Gets the current class name of the material e.g. "StandardMaterial"
  38869. * Mainly use in serialization.
  38870. * @returns the class name
  38871. */
  38872. getClassName(): string;
  38873. /**
  38874. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38875. * You can try switching to logarithmic depth.
  38876. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38877. */
  38878. useLogarithmicDepth: boolean;
  38879. /**
  38880. * Specifies if the material will require alpha blending
  38881. * @returns a boolean specifying if alpha blending is needed
  38882. */
  38883. needAlphaBlending(): boolean;
  38884. /**
  38885. * Specifies if this material should be rendered in alpha test mode
  38886. * @returns a boolean specifying if an alpha test is needed.
  38887. */
  38888. needAlphaTesting(): boolean;
  38889. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38890. /**
  38891. * Get the texture used for alpha test purpose.
  38892. * @returns the diffuse texture in case of the standard material.
  38893. */
  38894. getAlphaTestTexture(): Nullable<BaseTexture>;
  38895. /**
  38896. * Get if the submesh is ready to be used and all its information available.
  38897. * Child classes can use it to update shaders
  38898. * @param mesh defines the mesh to check
  38899. * @param subMesh defines which submesh to check
  38900. * @param useInstances specifies that instances should be used
  38901. * @returns a boolean indicating that the submesh is ready or not
  38902. */
  38903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38904. /**
  38905. * Builds the material UBO layouts.
  38906. * Used internally during the effect preparation.
  38907. */
  38908. buildUniformLayout(): void;
  38909. /**
  38910. * Unbinds the material from the mesh
  38911. */
  38912. unbind(): void;
  38913. /**
  38914. * Binds the submesh to this material by preparing the effect and shader to draw
  38915. * @param world defines the world transformation matrix
  38916. * @param mesh defines the mesh containing the submesh
  38917. * @param subMesh defines the submesh to bind the material to
  38918. */
  38919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38920. /**
  38921. * Get the list of animatables in the material.
  38922. * @returns the list of animatables object used in the material
  38923. */
  38924. getAnimatables(): IAnimatable[];
  38925. /**
  38926. * Gets the active textures from the material
  38927. * @returns an array of textures
  38928. */
  38929. getActiveTextures(): BaseTexture[];
  38930. /**
  38931. * Specifies if the material uses a texture
  38932. * @param texture defines the texture to check against the material
  38933. * @returns a boolean specifying if the material uses the texture
  38934. */
  38935. hasTexture(texture: BaseTexture): boolean;
  38936. /**
  38937. * Disposes the material
  38938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38940. */
  38941. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38942. /**
  38943. * Makes a duplicate of the material, and gives it a new name
  38944. * @param name defines the new name for the duplicated material
  38945. * @returns the cloned material
  38946. */
  38947. clone(name: string): StandardMaterial;
  38948. /**
  38949. * Serializes this material in a JSON representation
  38950. * @returns the serialized material object
  38951. */
  38952. serialize(): any;
  38953. /**
  38954. * Creates a standard material from parsed material data
  38955. * @param source defines the JSON representation of the material
  38956. * @param scene defines the hosting scene
  38957. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38958. * @returns a new standard material
  38959. */
  38960. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38961. /**
  38962. * Are diffuse textures enabled in the application.
  38963. */
  38964. static DiffuseTextureEnabled: boolean;
  38965. /**
  38966. * Are ambient textures enabled in the application.
  38967. */
  38968. static AmbientTextureEnabled: boolean;
  38969. /**
  38970. * Are opacity textures enabled in the application.
  38971. */
  38972. static OpacityTextureEnabled: boolean;
  38973. /**
  38974. * Are reflection textures enabled in the application.
  38975. */
  38976. static ReflectionTextureEnabled: boolean;
  38977. /**
  38978. * Are emissive textures enabled in the application.
  38979. */
  38980. static EmissiveTextureEnabled: boolean;
  38981. /**
  38982. * Are specular textures enabled in the application.
  38983. */
  38984. static SpecularTextureEnabled: boolean;
  38985. /**
  38986. * Are bump textures enabled in the application.
  38987. */
  38988. static BumpTextureEnabled: boolean;
  38989. /**
  38990. * Are lightmap textures enabled in the application.
  38991. */
  38992. static LightmapTextureEnabled: boolean;
  38993. /**
  38994. * Are refraction textures enabled in the application.
  38995. */
  38996. static RefractionTextureEnabled: boolean;
  38997. /**
  38998. * Are color grading textures enabled in the application.
  38999. */
  39000. static ColorGradingTextureEnabled: boolean;
  39001. /**
  39002. * Are fresnels enabled in the application.
  39003. */
  39004. static FresnelEnabled: boolean;
  39005. }
  39006. }
  39007. declare module BABYLON {
  39008. /**
  39009. * A class extending Texture allowing drawing on a texture
  39010. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39011. */
  39012. export class DynamicTexture extends Texture {
  39013. private _generateMipMaps;
  39014. private _canvas;
  39015. private _context;
  39016. private _engine;
  39017. /**
  39018. * Creates a DynamicTexture
  39019. * @param name defines the name of the texture
  39020. * @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
  39021. * @param scene defines the scene where you want the texture
  39022. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39023. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39024. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39025. */
  39026. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39027. /**
  39028. * Get the current class name of the texture useful for serialization or dynamic coding.
  39029. * @returns "DynamicTexture"
  39030. */
  39031. getClassName(): string;
  39032. /**
  39033. * Gets the current state of canRescale
  39034. */
  39035. readonly canRescale: boolean;
  39036. private _recreate;
  39037. /**
  39038. * Scales the texture
  39039. * @param ratio the scale factor to apply to both width and height
  39040. */
  39041. scale(ratio: number): void;
  39042. /**
  39043. * Resizes the texture
  39044. * @param width the new width
  39045. * @param height the new height
  39046. */
  39047. scaleTo(width: number, height: number): void;
  39048. /**
  39049. * Gets the context of the canvas used by the texture
  39050. * @returns the canvas context of the dynamic texture
  39051. */
  39052. getContext(): CanvasRenderingContext2D;
  39053. /**
  39054. * Clears the texture
  39055. */
  39056. clear(): void;
  39057. /**
  39058. * Updates the texture
  39059. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39060. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39061. */
  39062. update(invertY?: boolean, premulAlpha?: boolean): void;
  39063. /**
  39064. * Draws text onto the texture
  39065. * @param text defines the text to be drawn
  39066. * @param x defines the placement of the text from the left
  39067. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39068. * @param font defines the font to be used with font-style, font-size, font-name
  39069. * @param color defines the color used for the text
  39070. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39071. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39072. * @param update defines whether texture is immediately update (default is true)
  39073. */
  39074. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39075. /**
  39076. * Clones the texture
  39077. * @returns the clone of the texture.
  39078. */
  39079. clone(): DynamicTexture;
  39080. /**
  39081. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39082. * @returns a serialized dynamic texture object
  39083. */
  39084. serialize(): any;
  39085. /** @hidden */ private _rebuild(): void;
  39086. }
  39087. }
  39088. declare module BABYLON {
  39089. /** @hidden */
  39090. export var imageProcessingPixelShader: {
  39091. name: string;
  39092. shader: string;
  39093. };
  39094. }
  39095. declare module BABYLON {
  39096. /**
  39097. * ImageProcessingPostProcess
  39098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39099. */
  39100. export class ImageProcessingPostProcess extends PostProcess {
  39101. /**
  39102. * Default configuration related to image processing available in the PBR Material.
  39103. */
  39104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39105. /**
  39106. * Gets the image processing configuration used either in this material.
  39107. */
  39108. /**
  39109. * Sets the Default image processing configuration used either in the this material.
  39110. *
  39111. * If sets to null, the scene one is in use.
  39112. */
  39113. imageProcessingConfiguration: ImageProcessingConfiguration;
  39114. /**
  39115. * Keep track of the image processing observer to allow dispose and replace.
  39116. */
  39117. private _imageProcessingObserver;
  39118. /**
  39119. * Attaches a new image processing configuration to the PBR Material.
  39120. * @param configuration
  39121. */
  39122. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39123. /**
  39124. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39125. */
  39126. /**
  39127. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39128. */
  39129. colorCurves: Nullable<ColorCurves>;
  39130. /**
  39131. * Gets wether the color curves effect is enabled.
  39132. */
  39133. /**
  39134. * Sets wether the color curves effect is enabled.
  39135. */
  39136. colorCurvesEnabled: boolean;
  39137. /**
  39138. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39139. */
  39140. /**
  39141. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39142. */
  39143. colorGradingTexture: Nullable<BaseTexture>;
  39144. /**
  39145. * Gets wether the color grading effect is enabled.
  39146. */
  39147. /**
  39148. * Gets wether the color grading effect is enabled.
  39149. */
  39150. colorGradingEnabled: boolean;
  39151. /**
  39152. * Gets exposure used in the effect.
  39153. */
  39154. /**
  39155. * Sets exposure used in the effect.
  39156. */
  39157. exposure: number;
  39158. /**
  39159. * Gets wether tonemapping is enabled or not.
  39160. */
  39161. /**
  39162. * Sets wether tonemapping is enabled or not
  39163. */
  39164. toneMappingEnabled: boolean;
  39165. /**
  39166. * Gets the type of tone mapping effect.
  39167. */
  39168. /**
  39169. * Sets the type of tone mapping effect.
  39170. */
  39171. toneMappingType: number;
  39172. /**
  39173. * Gets contrast used in the effect.
  39174. */
  39175. /**
  39176. * Sets contrast used in the effect.
  39177. */
  39178. contrast: number;
  39179. /**
  39180. * Gets Vignette stretch size.
  39181. */
  39182. /**
  39183. * Sets Vignette stretch size.
  39184. */
  39185. vignetteStretch: number;
  39186. /**
  39187. * Gets Vignette centre X Offset.
  39188. */
  39189. /**
  39190. * Sets Vignette centre X Offset.
  39191. */
  39192. vignetteCentreX: number;
  39193. /**
  39194. * Gets Vignette centre Y Offset.
  39195. */
  39196. /**
  39197. * Sets Vignette centre Y Offset.
  39198. */
  39199. vignetteCentreY: number;
  39200. /**
  39201. * Gets Vignette weight or intensity of the vignette effect.
  39202. */
  39203. /**
  39204. * Sets Vignette weight or intensity of the vignette effect.
  39205. */
  39206. vignetteWeight: number;
  39207. /**
  39208. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39209. * if vignetteEnabled is set to true.
  39210. */
  39211. /**
  39212. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39213. * if vignetteEnabled is set to true.
  39214. */
  39215. vignetteColor: Color4;
  39216. /**
  39217. * Gets Camera field of view used by the Vignette effect.
  39218. */
  39219. /**
  39220. * Sets Camera field of view used by the Vignette effect.
  39221. */
  39222. vignetteCameraFov: number;
  39223. /**
  39224. * Gets the vignette blend mode allowing different kind of effect.
  39225. */
  39226. /**
  39227. * Sets the vignette blend mode allowing different kind of effect.
  39228. */
  39229. vignetteBlendMode: number;
  39230. /**
  39231. * Gets wether the vignette effect is enabled.
  39232. */
  39233. /**
  39234. * Sets wether the vignette effect is enabled.
  39235. */
  39236. vignetteEnabled: boolean;
  39237. private _fromLinearSpace;
  39238. /**
  39239. * Gets wether the input of the processing is in Gamma or Linear Space.
  39240. */
  39241. /**
  39242. * Sets wether the input of the processing is in Gamma or Linear Space.
  39243. */
  39244. fromLinearSpace: boolean;
  39245. /**
  39246. * Defines cache preventing GC.
  39247. */
  39248. private _defines;
  39249. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39250. /**
  39251. * "ImageProcessingPostProcess"
  39252. * @returns "ImageProcessingPostProcess"
  39253. */
  39254. getClassName(): string;
  39255. protected _updateParameters(): void;
  39256. dispose(camera?: Camera): void;
  39257. }
  39258. }
  39259. declare module BABYLON {
  39260. /**
  39261. * Class containing static functions to help procedurally build meshes
  39262. */
  39263. export class GroundBuilder {
  39264. /**
  39265. * Creates a ground mesh
  39266. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39267. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39269. * @param name defines the name of the mesh
  39270. * @param options defines the options used to create the mesh
  39271. * @param scene defines the hosting scene
  39272. * @returns the ground mesh
  39273. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39274. */
  39275. static CreateGround(name: string, options: {
  39276. width?: number;
  39277. height?: number;
  39278. subdivisions?: number;
  39279. subdivisionsX?: number;
  39280. subdivisionsY?: number;
  39281. updatable?: boolean;
  39282. }, scene: any): Mesh;
  39283. /**
  39284. * Creates a tiled ground mesh
  39285. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39286. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39287. * * 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
  39288. * * 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
  39289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39290. * @param name defines the name of the mesh
  39291. * @param options defines the options used to create the mesh
  39292. * @param scene defines the hosting scene
  39293. * @returns the tiled ground mesh
  39294. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39295. */
  39296. static CreateTiledGround(name: string, options: {
  39297. xmin: number;
  39298. zmin: number;
  39299. xmax: number;
  39300. zmax: number;
  39301. subdivisions?: {
  39302. w: number;
  39303. h: number;
  39304. };
  39305. precision?: {
  39306. w: number;
  39307. h: number;
  39308. };
  39309. updatable?: boolean;
  39310. }, scene?: Nullable<Scene>): Mesh;
  39311. /**
  39312. * Creates a ground mesh from a height map
  39313. * * The parameter `url` sets the URL of the height map image resource.
  39314. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39315. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39316. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39317. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39318. * * 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.
  39319. * * 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).
  39320. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39322. * @param name defines the name of the mesh
  39323. * @param url defines the url to the height map
  39324. * @param options defines the options used to create the mesh
  39325. * @param scene defines the hosting scene
  39326. * @returns the ground mesh
  39327. * @see https://doc.babylonjs.com/babylon101/height_map
  39328. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39329. */
  39330. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39331. width?: number;
  39332. height?: number;
  39333. subdivisions?: number;
  39334. minHeight?: number;
  39335. maxHeight?: number;
  39336. colorFilter?: Color3;
  39337. alphaFilter?: number;
  39338. updatable?: boolean;
  39339. onReady?: (mesh: GroundMesh) => void;
  39340. }, scene?: Nullable<Scene>): GroundMesh;
  39341. }
  39342. }
  39343. declare module BABYLON {
  39344. /**
  39345. * Class containing static functions to help procedurally build meshes
  39346. */
  39347. export class TorusBuilder {
  39348. /**
  39349. * Creates a torus mesh
  39350. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39351. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39352. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39356. * @param name defines the name of the mesh
  39357. * @param options defines the options used to create the mesh
  39358. * @param scene defines the hosting scene
  39359. * @returns the torus mesh
  39360. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39361. */
  39362. static CreateTorus(name: string, options: {
  39363. diameter?: number;
  39364. thickness?: number;
  39365. tessellation?: number;
  39366. updatable?: boolean;
  39367. sideOrientation?: number;
  39368. frontUVs?: Vector4;
  39369. backUVs?: Vector4;
  39370. }, scene: any): Mesh;
  39371. }
  39372. }
  39373. declare module BABYLON {
  39374. /**
  39375. * Class containing static functions to help procedurally build meshes
  39376. */
  39377. export class CylinderBuilder {
  39378. /**
  39379. * Creates a cylinder or a cone mesh
  39380. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39381. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39382. * * 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.
  39383. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39384. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39385. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39386. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39387. * * 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).
  39388. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39389. * * 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).
  39390. * * 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
  39391. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39392. * * 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
  39393. * * 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.
  39394. * * If `enclose` is false, a ring surface is one element.
  39395. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39396. * * 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
  39397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39400. * @param name defines the name of the mesh
  39401. * @param options defines the options used to create the mesh
  39402. * @param scene defines the hosting scene
  39403. * @returns the cylinder mesh
  39404. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39405. */
  39406. static CreateCylinder(name: string, options: {
  39407. height?: number;
  39408. diameterTop?: number;
  39409. diameterBottom?: number;
  39410. diameter?: number;
  39411. tessellation?: number;
  39412. subdivisions?: number;
  39413. arc?: number;
  39414. faceColors?: Color4[];
  39415. faceUV?: Vector4[];
  39416. updatable?: boolean;
  39417. hasRings?: boolean;
  39418. enclose?: boolean;
  39419. cap?: number;
  39420. sideOrientation?: number;
  39421. frontUVs?: Vector4;
  39422. backUVs?: Vector4;
  39423. }, scene: any): Mesh;
  39424. }
  39425. }
  39426. declare module BABYLON {
  39427. /**
  39428. * Options to modify the vr teleportation behavior.
  39429. */
  39430. export interface VRTeleportationOptions {
  39431. /**
  39432. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39433. */
  39434. floorMeshName?: string;
  39435. /**
  39436. * A list of meshes to be used as the teleportation floor. (default: empty)
  39437. */
  39438. floorMeshes?: Mesh[];
  39439. }
  39440. /**
  39441. * Options to modify the vr experience helper's behavior.
  39442. */
  39443. export interface VRExperienceHelperOptions extends WebVROptions {
  39444. /**
  39445. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39446. */
  39447. createDeviceOrientationCamera?: boolean;
  39448. /**
  39449. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39450. */
  39451. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39452. /**
  39453. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39454. */
  39455. laserToggle?: boolean;
  39456. /**
  39457. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39458. */
  39459. floorMeshes?: Mesh[];
  39460. /**
  39461. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39462. */
  39463. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39464. }
  39465. /**
  39466. * Event containing information after VR has been entered
  39467. */
  39468. export class OnAfterEnteringVRObservableEvent {
  39469. /**
  39470. * If entering vr was successful
  39471. */
  39472. success: boolean;
  39473. }
  39474. /**
  39475. * Helps to quickly add VR support to an existing scene.
  39476. * See http://doc.babylonjs.com/how_to/webvr_helper
  39477. */
  39478. export class VRExperienceHelper {
  39479. /** Options to modify the vr experience helper's behavior. */
  39480. webVROptions: VRExperienceHelperOptions;
  39481. private _scene;
  39482. private _position;
  39483. private _btnVR;
  39484. private _btnVRDisplayed;
  39485. private _webVRsupported;
  39486. private _webVRready;
  39487. private _webVRrequesting;
  39488. private _webVRpresenting;
  39489. private _hasEnteredVR;
  39490. private _fullscreenVRpresenting;
  39491. private _canvas;
  39492. private _webVRCamera;
  39493. private _vrDeviceOrientationCamera;
  39494. private _deviceOrientationCamera;
  39495. private _existingCamera;
  39496. private _onKeyDown;
  39497. private _onVrDisplayPresentChange;
  39498. private _onVRDisplayChanged;
  39499. private _onVRRequestPresentStart;
  39500. private _onVRRequestPresentComplete;
  39501. /**
  39502. * Observable raised right before entering VR.
  39503. */
  39504. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39505. /**
  39506. * Observable raised when entering VR has completed.
  39507. */
  39508. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39509. /**
  39510. * Observable raised when exiting VR.
  39511. */
  39512. onExitingVRObservable: Observable<VRExperienceHelper>;
  39513. /**
  39514. * Observable raised when controller mesh is loaded.
  39515. */
  39516. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39517. /** Return this.onEnteringVRObservable
  39518. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39519. */
  39520. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39521. /** Return this.onExitingVRObservable
  39522. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39523. */
  39524. readonly onExitingVR: Observable<VRExperienceHelper>;
  39525. /** Return this.onControllerMeshLoadedObservable
  39526. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39527. */
  39528. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39529. private _rayLength;
  39530. private _useCustomVRButton;
  39531. private _teleportationRequested;
  39532. private _teleportActive;
  39533. private _floorMeshName;
  39534. private _floorMeshesCollection;
  39535. private _rotationAllowed;
  39536. private _teleportBackwardsVector;
  39537. private _teleportationTarget;
  39538. private _isDefaultTeleportationTarget;
  39539. private _postProcessMove;
  39540. private _teleportationFillColor;
  39541. private _teleportationBorderColor;
  39542. private _rotationAngle;
  39543. private _haloCenter;
  39544. private _cameraGazer;
  39545. private _padSensibilityUp;
  39546. private _padSensibilityDown;
  39547. private _leftController;
  39548. private _rightController;
  39549. /**
  39550. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39551. */
  39552. onNewMeshSelected: Observable<AbstractMesh>;
  39553. /**
  39554. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39555. */
  39556. onNewMeshPicked: Observable<PickingInfo>;
  39557. private _circleEase;
  39558. /**
  39559. * Observable raised before camera teleportation
  39560. */
  39561. onBeforeCameraTeleport: Observable<Vector3>;
  39562. /**
  39563. * Observable raised after camera teleportation
  39564. */
  39565. onAfterCameraTeleport: Observable<Vector3>;
  39566. /**
  39567. * Observable raised when current selected mesh gets unselected
  39568. */
  39569. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39570. private _raySelectionPredicate;
  39571. /**
  39572. * To be optionaly changed by user to define custom ray selection
  39573. */
  39574. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39575. /**
  39576. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39577. */
  39578. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39579. /**
  39580. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39581. */
  39582. teleportationEnabled: boolean;
  39583. private _defaultHeight;
  39584. private _teleportationInitialized;
  39585. private _interactionsEnabled;
  39586. private _interactionsRequested;
  39587. private _displayGaze;
  39588. private _displayLaserPointer;
  39589. /**
  39590. * The mesh used to display where the user is going to teleport.
  39591. */
  39592. /**
  39593. * Sets the mesh to be used to display where the user is going to teleport.
  39594. */
  39595. teleportationTarget: Mesh;
  39596. /**
  39597. * 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
  39598. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39599. * See http://doc.babylonjs.com/resources/baking_transformations
  39600. */
  39601. gazeTrackerMesh: Mesh;
  39602. /**
  39603. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39604. */
  39605. updateGazeTrackerScale: boolean;
  39606. /**
  39607. * If the gaze trackers color should be updated when selecting meshes
  39608. */
  39609. updateGazeTrackerColor: boolean;
  39610. /**
  39611. * The gaze tracking mesh corresponding to the left controller
  39612. */
  39613. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39614. /**
  39615. * The gaze tracking mesh corresponding to the right controller
  39616. */
  39617. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39618. /**
  39619. * If the ray of the gaze should be displayed.
  39620. */
  39621. /**
  39622. * Sets if the ray of the gaze should be displayed.
  39623. */
  39624. displayGaze: boolean;
  39625. /**
  39626. * If the ray of the LaserPointer should be displayed.
  39627. */
  39628. /**
  39629. * Sets if the ray of the LaserPointer should be displayed.
  39630. */
  39631. displayLaserPointer: boolean;
  39632. /**
  39633. * The deviceOrientationCamera used as the camera when not in VR.
  39634. */
  39635. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39636. /**
  39637. * Based on the current WebVR support, returns the current VR camera used.
  39638. */
  39639. readonly currentVRCamera: Nullable<Camera>;
  39640. /**
  39641. * The webVRCamera which is used when in VR.
  39642. */
  39643. readonly webVRCamera: WebVRFreeCamera;
  39644. /**
  39645. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39646. */
  39647. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39648. private readonly _teleportationRequestInitiated;
  39649. /**
  39650. * Defines wether or not Pointer lock should be requested when switching to
  39651. * full screen.
  39652. */
  39653. requestPointerLockOnFullScreen: boolean;
  39654. /**
  39655. * Instantiates a VRExperienceHelper.
  39656. * Helps to quickly add VR support to an existing scene.
  39657. * @param scene The scene the VRExperienceHelper belongs to.
  39658. * @param webVROptions Options to modify the vr experience helper's behavior.
  39659. */
  39660. constructor(scene: Scene,
  39661. /** Options to modify the vr experience helper's behavior. */
  39662. webVROptions?: VRExperienceHelperOptions);
  39663. private _onDefaultMeshLoaded;
  39664. private _onResize;
  39665. private _onFullscreenChange;
  39666. /**
  39667. * Gets a value indicating if we are currently in VR mode.
  39668. */
  39669. readonly isInVRMode: boolean;
  39670. private onVrDisplayPresentChange;
  39671. private onVRDisplayChanged;
  39672. private moveButtonToBottomRight;
  39673. private displayVRButton;
  39674. private updateButtonVisibility;
  39675. private _cachedAngularSensibility;
  39676. /**
  39677. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39678. * Otherwise, will use the fullscreen API.
  39679. */
  39680. enterVR(): void;
  39681. /**
  39682. * Attempt to exit VR, or fullscreen.
  39683. */
  39684. exitVR(): void;
  39685. /**
  39686. * The position of the vr experience helper.
  39687. */
  39688. /**
  39689. * Sets the position of the vr experience helper.
  39690. */
  39691. position: Vector3;
  39692. /**
  39693. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39694. */
  39695. enableInteractions(): void;
  39696. private readonly _noControllerIsActive;
  39697. private beforeRender;
  39698. private _isTeleportationFloor;
  39699. /**
  39700. * Adds a floor mesh to be used for teleportation.
  39701. * @param floorMesh the mesh to be used for teleportation.
  39702. */
  39703. addFloorMesh(floorMesh: Mesh): void;
  39704. /**
  39705. * Removes a floor mesh from being used for teleportation.
  39706. * @param floorMesh the mesh to be removed.
  39707. */
  39708. removeFloorMesh(floorMesh: Mesh): void;
  39709. /**
  39710. * Enables interactions and teleportation using the VR controllers and gaze.
  39711. * @param vrTeleportationOptions options to modify teleportation behavior.
  39712. */
  39713. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39714. private _onNewGamepadConnected;
  39715. private _tryEnableInteractionOnController;
  39716. private _onNewGamepadDisconnected;
  39717. private _enableInteractionOnController;
  39718. private _checkTeleportWithRay;
  39719. private _checkRotate;
  39720. private _checkTeleportBackwards;
  39721. private _enableTeleportationOnController;
  39722. private _createTeleportationCircles;
  39723. private _displayTeleportationTarget;
  39724. private _hideTeleportationTarget;
  39725. private _rotateCamera;
  39726. private _moveTeleportationSelectorTo;
  39727. private _workingVector;
  39728. private _workingQuaternion;
  39729. private _workingMatrix;
  39730. /**
  39731. * Teleports the users feet to the desired location
  39732. * @param location The location where the user's feet should be placed
  39733. */
  39734. teleportCamera(location: Vector3): void;
  39735. private _convertNormalToDirectionOfRay;
  39736. private _castRayAndSelectObject;
  39737. private _notifySelectedMeshUnselected;
  39738. /**
  39739. * Sets the color of the laser ray from the vr controllers.
  39740. * @param color new color for the ray.
  39741. */
  39742. changeLaserColor(color: Color3): void;
  39743. /**
  39744. * Sets the color of the ray from the vr headsets gaze.
  39745. * @param color new color for the ray.
  39746. */
  39747. changeGazeColor(color: Color3): void;
  39748. /**
  39749. * Exits VR and disposes of the vr experience helper
  39750. */
  39751. dispose(): void;
  39752. /**
  39753. * Gets the name of the VRExperienceHelper class
  39754. * @returns "VRExperienceHelper"
  39755. */
  39756. getClassName(): string;
  39757. }
  39758. }
  39759. declare module BABYLON {
  39760. /**
  39761. * Manages an XRSession
  39762. * @see https://doc.babylonjs.com/how_to/webxr
  39763. */
  39764. export class WebXRSessionManager implements IDisposable {
  39765. private scene;
  39766. /**
  39767. * Fires every time a new xrFrame arrives which can be used to update the camera
  39768. */
  39769. onXRFrameObservable: Observable<any>;
  39770. /**
  39771. * Fires when the xr session is ended either by the device or manually done
  39772. */
  39773. onXRSessionEnded: Observable<any>;
  39774. /** @hidden */ private _xrSession: XRSession;
  39775. /** @hidden */ private _frameOfReference: XRFrameOfReference;
  39776. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39777. /** @hidden */ private _currentXRFrame: Nullable<XRFrame>;
  39778. private _xrNavigator;
  39779. private _xrDevice;
  39780. private _tmpMatrix;
  39781. /**
  39782. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39783. * @param scene The scene which the session should be created for
  39784. */
  39785. constructor(scene: Scene);
  39786. /**
  39787. * Initializes the manager
  39788. * After initialization enterXR can be called to start an XR session
  39789. * @returns Promise which resolves after it is initialized
  39790. */
  39791. initializeAsync(): Promise<void>;
  39792. /**
  39793. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39794. * @param sessionCreationOptions xr options to create the session with
  39795. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39796. * @returns Promise which resolves after it enters XR
  39797. */
  39798. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39799. /**
  39800. * Stops the xrSession and restores the renderloop
  39801. * @returns Promise which resolves after it exits XR
  39802. */
  39803. exitXRAsync(): Promise<void>;
  39804. /**
  39805. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39806. * @param ray ray to cast into the environment
  39807. * @returns Promise which resolves with a collision point in the environment if it exists
  39808. */
  39809. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39810. /**
  39811. * Checks if a session would be supported for the creation options specified
  39812. * @param options creation options to check if they are supported
  39813. * @returns true if supported
  39814. */
  39815. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39816. /**
  39817. * @hidden
  39818. * Converts the render layer of xrSession to a render target
  39819. * @param session session to create render target for
  39820. * @param scene scene the new render target should be created for
  39821. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39822. /**
  39823. * Disposes of the session manager
  39824. */
  39825. dispose(): void;
  39826. }
  39827. }
  39828. declare module BABYLON {
  39829. /**
  39830. * WebXR Camera which holds the views for the xrSession
  39831. * @see https://doc.babylonjs.com/how_to/webxr
  39832. */
  39833. export class WebXRCamera extends FreeCamera {
  39834. private static _TmpMatrix;
  39835. /**
  39836. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39837. * @param name the name of the camera
  39838. * @param scene the scene to add the camera to
  39839. */
  39840. constructor(name: string, scene: Scene);
  39841. private _updateNumberOfRigCameras;
  39842. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  39843. /**
  39844. * Updates the cameras position from the current pose information of the XR session
  39845. * @param xrSessionManager the session containing pose information
  39846. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39847. */
  39848. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39849. }
  39850. }
  39851. declare module BABYLON {
  39852. /**
  39853. * States of the webXR experience
  39854. */
  39855. export enum WebXRState {
  39856. /**
  39857. * Transitioning to being in XR mode
  39858. */
  39859. ENTERING_XR = 0,
  39860. /**
  39861. * Transitioning to non XR mode
  39862. */
  39863. EXITING_XR = 1,
  39864. /**
  39865. * In XR mode and presenting
  39866. */
  39867. IN_XR = 2,
  39868. /**
  39869. * Not entered XR mode
  39870. */
  39871. NOT_IN_XR = 3
  39872. }
  39873. /**
  39874. * Helper class used to enable XR
  39875. * @see https://doc.babylonjs.com/how_to/webxr
  39876. */
  39877. export class WebXRExperienceHelper implements IDisposable {
  39878. private scene;
  39879. /**
  39880. * 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
  39881. */
  39882. container: AbstractMesh;
  39883. /**
  39884. * Camera used to render xr content
  39885. */
  39886. camera: WebXRCamera;
  39887. /**
  39888. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39889. */
  39890. state: WebXRState;
  39891. private _setState;
  39892. private static _TmpVector;
  39893. /**
  39894. * Fires when the state of the experience helper has changed
  39895. */
  39896. onStateChangedObservable: Observable<WebXRState>;
  39897. /** @hidden */ private _sessionManager: WebXRSessionManager;
  39898. private _nonVRCamera;
  39899. private _originalSceneAutoClear;
  39900. private _supported;
  39901. /**
  39902. * Creates the experience helper
  39903. * @param scene the scene to attach the experience helper to
  39904. * @returns a promise for the experience helper
  39905. */
  39906. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39907. /**
  39908. * Creates a WebXRExperienceHelper
  39909. * @param scene The scene the helper should be created in
  39910. */
  39911. private constructor();
  39912. /**
  39913. * Exits XR mode and returns the scene to its original state
  39914. * @returns promise that resolves after xr mode has exited
  39915. */
  39916. exitXRAsync(): Promise<void>;
  39917. /**
  39918. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39919. * @param sessionCreationOptions options for the XR session
  39920. * @param frameOfReference frame of reference of the XR session
  39921. * @returns promise that resolves after xr mode has entered
  39922. */
  39923. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39924. /**
  39925. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39926. * @param ray ray to cast into the environment
  39927. * @returns Promise which resolves with a collision point in the environment if it exists
  39928. */
  39929. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39930. /**
  39931. * Updates the global position of the camera by moving the camera's container
  39932. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39933. * @param position The desired global position of the camera
  39934. */
  39935. setPositionOfCameraUsingContainer(position: Vector3): void;
  39936. /**
  39937. * Rotates the xr camera by rotating the camera's container around the camera's position
  39938. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39939. * @param rotation the desired quaternion rotation to apply to the camera
  39940. */
  39941. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39942. /**
  39943. * Checks if the creation options are supported by the xr session
  39944. * @param options creation options
  39945. * @returns true if supported
  39946. */
  39947. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39948. /**
  39949. * Disposes of the experience helper
  39950. */
  39951. dispose(): void;
  39952. }
  39953. }
  39954. declare module BABYLON {
  39955. /**
  39956. * Button which can be used to enter a different mode of XR
  39957. */
  39958. export class WebXREnterExitUIButton {
  39959. /** button element */
  39960. element: HTMLElement;
  39961. /** XR initialization options for the button */
  39962. initializationOptions: XRSessionCreationOptions;
  39963. /**
  39964. * Creates a WebXREnterExitUIButton
  39965. * @param element button element
  39966. * @param initializationOptions XR initialization options for the button
  39967. */
  39968. constructor(
  39969. /** button element */
  39970. element: HTMLElement,
  39971. /** XR initialization options for the button */
  39972. initializationOptions: XRSessionCreationOptions);
  39973. /**
  39974. * Overwritable function which can be used to update the button's visuals when the state changes
  39975. * @param activeButton the current active button in the UI
  39976. */
  39977. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39978. }
  39979. /**
  39980. * Options to create the webXR UI
  39981. */
  39982. export class WebXREnterExitUIOptions {
  39983. /**
  39984. * Context to enter xr with
  39985. */
  39986. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39987. /**
  39988. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39989. */
  39990. customButtons?: Array<WebXREnterExitUIButton>;
  39991. }
  39992. /**
  39993. * UI to allow the user to enter/exit XR mode
  39994. */
  39995. export class WebXREnterExitUI implements IDisposable {
  39996. private scene;
  39997. private _overlay;
  39998. private _buttons;
  39999. private _activeButton;
  40000. /**
  40001. * Fired every time the active button is changed.
  40002. *
  40003. * When xr is entered via a button that launches xr that button will be the callback parameter
  40004. *
  40005. * When exiting xr the callback parameter will be null)
  40006. */
  40007. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40008. /**
  40009. * Creates UI to allow the user to enter/exit XR mode
  40010. * @param scene the scene to add the ui to
  40011. * @param helper the xr experience helper to enter/exit xr with
  40012. * @param options options to configure the UI
  40013. * @returns the created ui
  40014. */
  40015. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40016. private constructor();
  40017. private _updateButtons;
  40018. /**
  40019. * Disposes of the object
  40020. */
  40021. dispose(): void;
  40022. }
  40023. }
  40024. declare module BABYLON {
  40025. /**
  40026. * Represents an XR input
  40027. */
  40028. export class WebXRController {
  40029. /**
  40030. * 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
  40031. */
  40032. grip?: AbstractMesh;
  40033. /**
  40034. * Pointer which can be used to select objects or attach a visible laser to
  40035. */
  40036. pointer: AbstractMesh;
  40037. /**
  40038. * Creates the controller
  40039. * @see https://doc.babylonjs.com/how_to/webxr
  40040. * @param scene the scene which the controller should be associated to
  40041. */
  40042. constructor(scene: Scene);
  40043. /**
  40044. * Disposes of the object
  40045. */
  40046. dispose(): void;
  40047. }
  40048. /**
  40049. * XR input used to track XR inputs such as controllers/rays
  40050. */
  40051. export class WebXRInput implements IDisposable {
  40052. private helper;
  40053. /**
  40054. * XR controllers being tracked
  40055. */
  40056. controllers: Array<WebXRController>;
  40057. private _tmpMatrix;
  40058. private _frameObserver;
  40059. /**
  40060. * Initializes the WebXRInput
  40061. * @param helper experience helper which the input should be created for
  40062. */
  40063. constructor(helper: WebXRExperienceHelper);
  40064. /**
  40065. * Disposes of the object
  40066. */
  40067. dispose(): void;
  40068. }
  40069. }
  40070. declare module BABYLON {
  40071. /**
  40072. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40073. */
  40074. export class WebXRManagedOutputCanvas implements IDisposable {
  40075. private _canvas;
  40076. /**
  40077. * xrpresent context of the canvas which can be used to display/mirror xr content
  40078. */
  40079. canvasContext: Nullable<WebGLRenderingContext>;
  40080. /**
  40081. * Initializes the canvas to be added/removed upon entering/exiting xr
  40082. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40083. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40084. */
  40085. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40086. /**
  40087. * Disposes of the object
  40088. */
  40089. dispose(): void;
  40090. private _setManagedOutputCanvas;
  40091. private _addCanvas;
  40092. private _removeCanvas;
  40093. }
  40094. }
  40095. declare module BABYLON {
  40096. /**
  40097. * Contains an array of blocks representing the octree
  40098. */
  40099. export interface IOctreeContainer<T> {
  40100. /**
  40101. * Blocks within the octree
  40102. */
  40103. blocks: Array<OctreeBlock<T>>;
  40104. }
  40105. /**
  40106. * Class used to store a cell in an octree
  40107. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40108. */
  40109. export class OctreeBlock<T> {
  40110. /**
  40111. * Gets the content of the current block
  40112. */
  40113. entries: T[];
  40114. /**
  40115. * Gets the list of block children
  40116. */
  40117. blocks: Array<OctreeBlock<T>>;
  40118. private _depth;
  40119. private _maxDepth;
  40120. private _capacity;
  40121. private _minPoint;
  40122. private _maxPoint;
  40123. private _boundingVectors;
  40124. private _creationFunc;
  40125. /**
  40126. * Creates a new block
  40127. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40128. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40129. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40130. * @param depth defines the current depth of this block in the octree
  40131. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40132. * @param creationFunc defines a callback to call when an element is added to the block
  40133. */
  40134. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40135. /**
  40136. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40137. */
  40138. readonly capacity: number;
  40139. /**
  40140. * Gets the minimum vector (in world space) of the block's bounding box
  40141. */
  40142. readonly minPoint: Vector3;
  40143. /**
  40144. * Gets the maximum vector (in world space) of the block's bounding box
  40145. */
  40146. readonly maxPoint: Vector3;
  40147. /**
  40148. * Add a new element to this block
  40149. * @param entry defines the element to add
  40150. */
  40151. addEntry(entry: T): void;
  40152. /**
  40153. * Remove an element from this block
  40154. * @param entry defines the element to remove
  40155. */
  40156. removeEntry(entry: T): void;
  40157. /**
  40158. * Add an array of elements to this block
  40159. * @param entries defines the array of elements to add
  40160. */
  40161. addEntries(entries: T[]): void;
  40162. /**
  40163. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40164. * @param frustumPlanes defines the frustum planes to test
  40165. * @param selection defines the array to store current content if selection is positive
  40166. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40167. */
  40168. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40169. /**
  40170. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40171. * @param sphereCenter defines the bounding sphere center
  40172. * @param sphereRadius defines the bounding sphere radius
  40173. * @param selection defines the array to store current content if selection is positive
  40174. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40175. */
  40176. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40177. /**
  40178. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40179. * @param ray defines the ray to test with
  40180. * @param selection defines the array to store current content if selection is positive
  40181. */
  40182. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40183. /**
  40184. * Subdivide the content into child blocks (this block will then be empty)
  40185. */
  40186. createInnerBlocks(): void;
  40187. /**
  40188. * @hidden
  40189. */ private 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;
  40190. }
  40191. }
  40192. declare module BABYLON {
  40193. /**
  40194. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40195. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40196. */
  40197. export class Octree<T> {
  40198. /** 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.) */
  40199. maxDepth: number;
  40200. /**
  40201. * Blocks within the octree containing objects
  40202. */
  40203. blocks: Array<OctreeBlock<T>>;
  40204. /**
  40205. * Content stored in the octree
  40206. */
  40207. dynamicContent: T[];
  40208. private _maxBlockCapacity;
  40209. private _selectionContent;
  40210. private _creationFunc;
  40211. /**
  40212. * Creates a octree
  40213. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40214. * @param creationFunc function to be used to instatiate the octree
  40215. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40216. * @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.)
  40217. */
  40218. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40219. /** 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.) */
  40220. maxDepth?: number);
  40221. /**
  40222. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40223. * @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);
  40224. * @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);
  40225. * @param entries meshes to be added to the octree blocks
  40226. */
  40227. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40228. /**
  40229. * Adds a mesh to the octree
  40230. * @param entry Mesh to add to the octree
  40231. */
  40232. addMesh(entry: T): void;
  40233. /**
  40234. * Remove an element from the octree
  40235. * @param entry defines the element to remove
  40236. */
  40237. removeMesh(entry: T): void;
  40238. /**
  40239. * Selects an array of meshes within the frustum
  40240. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40241. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40242. * @returns array of meshes within the frustum
  40243. */
  40244. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40245. /**
  40246. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40247. * @param sphereCenter defines the bounding sphere center
  40248. * @param sphereRadius defines the bounding sphere radius
  40249. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40250. * @returns an array of objects that intersect the sphere
  40251. */
  40252. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40253. /**
  40254. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40255. * @param ray defines the ray to test with
  40256. * @returns array of intersected objects
  40257. */
  40258. intersectsRay(ray: Ray): SmartArray<T>;
  40259. /**
  40260. * Adds a mesh into the octree block if it intersects the block
  40261. */
  40262. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40263. /**
  40264. * Adds a submesh into the octree block if it intersects the block
  40265. */
  40266. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40267. }
  40268. }
  40269. declare module BABYLON {
  40270. interface Scene {
  40271. /**
  40272. * @hidden
  40273. * Backing Filed
  40274. */ private _selectionOctree: Octree<AbstractMesh>;
  40275. /**
  40276. * Gets the octree used to boost mesh selection (picking)
  40277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40278. */
  40279. selectionOctree: Octree<AbstractMesh>;
  40280. /**
  40281. * Creates or updates the octree used to boost selection (picking)
  40282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40283. * @param maxCapacity defines the maximum capacity per leaf
  40284. * @param maxDepth defines the maximum depth of the octree
  40285. * @returns an octree of AbstractMesh
  40286. */
  40287. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40288. }
  40289. interface AbstractMesh {
  40290. /**
  40291. * @hidden
  40292. * Backing Field
  40293. */ private _submeshesOctree: Octree<SubMesh>;
  40294. /**
  40295. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40296. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40297. * @param maxCapacity defines the maximum size of each block (64 by default)
  40298. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40299. * @returns the new octree
  40300. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40302. */
  40303. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40304. }
  40305. /**
  40306. * Defines the octree scene component responsible to manage any octrees
  40307. * in a given scene.
  40308. */
  40309. export class OctreeSceneComponent {
  40310. /**
  40311. * The component name help to identify the component in the list of scene components.
  40312. */
  40313. readonly name: string;
  40314. /**
  40315. * The scene the component belongs to.
  40316. */
  40317. scene: Scene;
  40318. /**
  40319. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40320. */
  40321. readonly checksIsEnabled: boolean;
  40322. /**
  40323. * Creates a new instance of the component for the given scene
  40324. * @param scene Defines the scene to register the component in
  40325. */
  40326. constructor(scene: Scene);
  40327. /**
  40328. * Registers the component in a given scene
  40329. */
  40330. register(): void;
  40331. /**
  40332. * Return the list of active meshes
  40333. * @returns the list of active meshes
  40334. */
  40335. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40336. /**
  40337. * Return the list of active sub meshes
  40338. * @param mesh The mesh to get the candidates sub meshes from
  40339. * @returns the list of active sub meshes
  40340. */
  40341. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40342. private _tempRay;
  40343. /**
  40344. * Return the list of sub meshes intersecting with a given local ray
  40345. * @param mesh defines the mesh to find the submesh for
  40346. * @param localRay defines the ray in local space
  40347. * @returns the list of intersecting sub meshes
  40348. */
  40349. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40350. /**
  40351. * Return the list of sub meshes colliding with a collider
  40352. * @param mesh defines the mesh to find the submesh for
  40353. * @param collider defines the collider to evaluate the collision against
  40354. * @returns the list of colliding sub meshes
  40355. */
  40356. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40357. /**
  40358. * Rebuilds the elements related to this component in case of
  40359. * context lost for instance.
  40360. */
  40361. rebuild(): void;
  40362. /**
  40363. * Disposes the component and the associated ressources.
  40364. */
  40365. dispose(): void;
  40366. }
  40367. }
  40368. declare module BABYLON {
  40369. /**
  40370. * Renders a layer on top of an existing scene
  40371. */
  40372. export class UtilityLayerRenderer implements IDisposable {
  40373. /** the original scene that will be rendered on top of */
  40374. originalScene: Scene;
  40375. private _pointerCaptures;
  40376. private _lastPointerEvents;
  40377. private static _DefaultUtilityLayer;
  40378. private static _DefaultKeepDepthUtilityLayer;
  40379. private _sharedGizmoLight;
  40380. private _renderCamera;
  40381. /**
  40382. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  40383. * @returns the camera that is used when rendering the utility layer
  40384. */
  40385. getRenderCamera(): Nullable<Camera>;
  40386. /**
  40387. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  40388. * @param cam the camera that should be used when rendering the utility layer
  40389. */
  40390. setRenderCamera(cam: Nullable<Camera>): void;
  40391. /**
  40392. * @hidden
  40393. * Light which used by gizmos to get light shading
  40394. */ private _getSharedGizmoLight(): HemisphericLight;
  40395. /**
  40396. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40397. */
  40398. pickUtilitySceneFirst: boolean;
  40399. /**
  40400. * 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)
  40401. */
  40402. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40403. /**
  40404. * 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)
  40405. */
  40406. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40407. /**
  40408. * The scene that is rendered on top of the original scene
  40409. */
  40410. utilityLayerScene: Scene;
  40411. /**
  40412. * If the utility layer should automatically be rendered on top of existing scene
  40413. */
  40414. shouldRender: boolean;
  40415. /**
  40416. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40417. */
  40418. onlyCheckPointerDownEvents: boolean;
  40419. /**
  40420. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40421. */
  40422. processAllEvents: boolean;
  40423. /**
  40424. * Observable raised when the pointer move from the utility layer scene to the main scene
  40425. */
  40426. onPointerOutObservable: Observable<number>;
  40427. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40428. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40429. private _afterRenderObserver;
  40430. private _sceneDisposeObserver;
  40431. private _originalPointerObserver;
  40432. /**
  40433. * Instantiates a UtilityLayerRenderer
  40434. * @param originalScene the original scene that will be rendered on top of
  40435. * @param handleEvents boolean indicating if the utility layer should handle events
  40436. */
  40437. constructor(
  40438. /** the original scene that will be rendered on top of */
  40439. originalScene: Scene, handleEvents?: boolean);
  40440. private _notifyObservers;
  40441. /**
  40442. * Renders the utility layers scene on top of the original scene
  40443. */
  40444. render(): void;
  40445. /**
  40446. * Disposes of the renderer
  40447. */
  40448. dispose(): void;
  40449. private _updateCamera;
  40450. }
  40451. }
  40452. declare module BABYLON {
  40453. /**
  40454. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40455. */
  40456. export class Gizmo implements IDisposable {
  40457. /** The utility layer the gizmo will be added to */
  40458. gizmoLayer: UtilityLayerRenderer;
  40459. /**
  40460. * The root mesh of the gizmo
  40461. */ private _rootMesh: Mesh;
  40462. private _attachedMesh;
  40463. /**
  40464. * Ratio for the scale of the gizmo (Default: 1)
  40465. */
  40466. scaleRatio: number;
  40467. /**
  40468. * If a custom mesh has been set (Default: false)
  40469. */
  40470. protected _customMeshSet: boolean;
  40471. /**
  40472. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40473. * * When set, interactions will be enabled
  40474. */
  40475. attachedMesh: Nullable<AbstractMesh>;
  40476. /**
  40477. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40478. * @param mesh The mesh to replace the default mesh of the gizmo
  40479. */
  40480. setCustomMesh(mesh: Mesh): void;
  40481. /**
  40482. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40483. */
  40484. updateGizmoRotationToMatchAttachedMesh: boolean;
  40485. /**
  40486. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40487. */
  40488. updateGizmoPositionToMatchAttachedMesh: boolean;
  40489. /**
  40490. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40491. */
  40492. protected _updateScale: boolean;
  40493. protected _interactionsEnabled: boolean;
  40494. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40495. private _beforeRenderObserver;
  40496. private _tempVector;
  40497. /**
  40498. * Creates a gizmo
  40499. * @param gizmoLayer The utility layer the gizmo will be added to
  40500. */
  40501. constructor(
  40502. /** The utility layer the gizmo will be added to */
  40503. gizmoLayer?: UtilityLayerRenderer);
  40504. /**
  40505. * Updates the gizmo to match the attached mesh's position/rotation
  40506. */
  40507. protected _update(): void;
  40508. /**
  40509. * Disposes of the gizmo
  40510. */
  40511. dispose(): void;
  40512. }
  40513. }
  40514. declare module BABYLON {
  40515. /**
  40516. * Single plane drag gizmo
  40517. */
  40518. export class PlaneDragGizmo extends Gizmo {
  40519. /**
  40520. * Drag behavior responsible for the gizmos dragging interactions
  40521. */
  40522. dragBehavior: PointerDragBehavior;
  40523. private _pointerObserver;
  40524. /**
  40525. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40526. */
  40527. snapDistance: number;
  40528. /**
  40529. * Event that fires each time the gizmo snaps to a new location.
  40530. * * snapDistance is the the change in distance
  40531. */
  40532. onSnapObservable: Observable<{
  40533. snapDistance: number;
  40534. }>;
  40535. private _plane;
  40536. private _coloredMaterial;
  40537. private _hoverMaterial;
  40538. private _isEnabled;
  40539. private _parent;
  40540. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  40541. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40542. /**
  40543. * Creates a PlaneDragGizmo
  40544. * @param gizmoLayer The utility layer the gizmo will be added to
  40545. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  40546. * @param color The color of the gizmo
  40547. */
  40548. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  40549. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40550. /**
  40551. * If the gizmo is enabled
  40552. */
  40553. isEnabled: boolean;
  40554. /**
  40555. * Disposes of the gizmo
  40556. */
  40557. dispose(): void;
  40558. }
  40559. }
  40560. declare module BABYLON {
  40561. /**
  40562. * Gizmo that enables dragging a mesh along 3 axis
  40563. */
  40564. export class PositionGizmo extends Gizmo {
  40565. /**
  40566. * Internal gizmo used for interactions on the x axis
  40567. */
  40568. xGizmo: AxisDragGizmo;
  40569. /**
  40570. * Internal gizmo used for interactions on the y axis
  40571. */
  40572. yGizmo: AxisDragGizmo;
  40573. /**
  40574. * Internal gizmo used for interactions on the z axis
  40575. */
  40576. zGizmo: AxisDragGizmo;
  40577. /**
  40578. * Internal gizmo used for interactions on the yz plane
  40579. */
  40580. xPlaneGizmo: PlaneDragGizmo;
  40581. /**
  40582. * Internal gizmo used for interactions on the xz plane
  40583. */
  40584. yPlaneGizmo: PlaneDragGizmo;
  40585. /**
  40586. * Internal gizmo used for interactions on the xy plane
  40587. */
  40588. zPlaneGizmo: PlaneDragGizmo;
  40589. /**
  40590. * private variables
  40591. */
  40592. private _meshAttached;
  40593. private _updateGizmoRotationToMatchAttachedMesh;
  40594. private _snapDistance;
  40595. private _scaleRatio;
  40596. /** Fires an event when any of it's sub gizmos are dragged */
  40597. onDragStartObservable: Observable<unknown>;
  40598. /** Fires an event when any of it's sub gizmos are released from dragging */
  40599. onDragEndObservable: Observable<unknown>;
  40600. /**
  40601. * If set to true, planar drag is enabled
  40602. */
  40603. private _planarGizmoEnabled;
  40604. attachedMesh: Nullable<AbstractMesh>;
  40605. /**
  40606. * Creates a PositionGizmo
  40607. * @param gizmoLayer The utility layer the gizmo will be added to
  40608. */
  40609. constructor(gizmoLayer?: UtilityLayerRenderer);
  40610. /**
  40611. * If the planar drag gizmo is enabled
  40612. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  40613. */
  40614. planarGizmoEnabled: boolean;
  40615. updateGizmoRotationToMatchAttachedMesh: boolean;
  40616. /**
  40617. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40618. */
  40619. snapDistance: number;
  40620. /**
  40621. * Ratio for the scale of the gizmo (Default: 1)
  40622. */
  40623. scaleRatio: number;
  40624. /**
  40625. * Disposes of the gizmo
  40626. */
  40627. dispose(): void;
  40628. /**
  40629. * CustomMeshes are not supported by this gizmo
  40630. * @param mesh The mesh to replace the default mesh of the gizmo
  40631. */
  40632. setCustomMesh(mesh: Mesh): void;
  40633. }
  40634. }
  40635. declare module BABYLON {
  40636. /**
  40637. * Single axis drag gizmo
  40638. */
  40639. export class AxisDragGizmo extends Gizmo {
  40640. /**
  40641. * Drag behavior responsible for the gizmos dragging interactions
  40642. */
  40643. dragBehavior: PointerDragBehavior;
  40644. private _pointerObserver;
  40645. /**
  40646. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40647. */
  40648. snapDistance: number;
  40649. /**
  40650. * Event that fires each time the gizmo snaps to a new location.
  40651. * * snapDistance is the the change in distance
  40652. */
  40653. onSnapObservable: Observable<{
  40654. snapDistance: number;
  40655. }>;
  40656. private _isEnabled;
  40657. private _parent;
  40658. private _arrow;
  40659. private _coloredMaterial;
  40660. private _hoverMaterial;
  40661. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40662. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40663. /**
  40664. * Creates an AxisDragGizmo
  40665. * @param gizmoLayer The utility layer the gizmo will be added to
  40666. * @param dragAxis The axis which the gizmo will be able to drag on
  40667. * @param color The color of the gizmo
  40668. */
  40669. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  40670. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40671. /**
  40672. * If the gizmo is enabled
  40673. */
  40674. isEnabled: boolean;
  40675. /**
  40676. * Disposes of the gizmo
  40677. */
  40678. dispose(): void;
  40679. }
  40680. }
  40681. declare module BABYLON.Debug {
  40682. /**
  40683. * The Axes viewer will show 3 axes in a specific point in space
  40684. */
  40685. export class AxesViewer {
  40686. private _xAxis;
  40687. private _yAxis;
  40688. private _zAxis;
  40689. private _scaleLinesFactor;
  40690. private _instanced;
  40691. /**
  40692. * Gets the hosting scene
  40693. */
  40694. scene: Scene;
  40695. /**
  40696. * Gets or sets a number used to scale line length
  40697. */
  40698. scaleLines: number;
  40699. /** Gets the node hierarchy used to render x-axis */
  40700. readonly xAxis: TransformNode;
  40701. /** Gets the node hierarchy used to render y-axis */
  40702. readonly yAxis: TransformNode;
  40703. /** Gets the node hierarchy used to render z-axis */
  40704. readonly zAxis: TransformNode;
  40705. /**
  40706. * Creates a new AxesViewer
  40707. * @param scene defines the hosting scene
  40708. * @param scaleLines defines a number used to scale line length (1 by default)
  40709. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40710. * @param xAxis defines the node hierarchy used to render the x-axis
  40711. * @param yAxis defines the node hierarchy used to render the y-axis
  40712. * @param zAxis defines the node hierarchy used to render the z-axis
  40713. */
  40714. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40715. /**
  40716. * Force the viewer to update
  40717. * @param position defines the position of the viewer
  40718. * @param xaxis defines the x axis of the viewer
  40719. * @param yaxis defines the y axis of the viewer
  40720. * @param zaxis defines the z axis of the viewer
  40721. */
  40722. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40723. /**
  40724. * Creates an instance of this axes viewer.
  40725. * @returns a new axes viewer with instanced meshes
  40726. */
  40727. createInstance(): AxesViewer;
  40728. /** Releases resources */
  40729. dispose(): void;
  40730. private static _SetRenderingGroupId;
  40731. }
  40732. }
  40733. declare module BABYLON.Debug {
  40734. /**
  40735. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40736. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40737. */
  40738. export class BoneAxesViewer extends AxesViewer {
  40739. /**
  40740. * Gets or sets the target mesh where to display the axes viewer
  40741. */
  40742. mesh: Nullable<Mesh>;
  40743. /**
  40744. * Gets or sets the target bone where to display the axes viewer
  40745. */
  40746. bone: Nullable<Bone>;
  40747. /** Gets current position */
  40748. pos: Vector3;
  40749. /** Gets direction of X axis */
  40750. xaxis: Vector3;
  40751. /** Gets direction of Y axis */
  40752. yaxis: Vector3;
  40753. /** Gets direction of Z axis */
  40754. zaxis: Vector3;
  40755. /**
  40756. * Creates a new BoneAxesViewer
  40757. * @param scene defines the hosting scene
  40758. * @param bone defines the target bone
  40759. * @param mesh defines the target mesh
  40760. * @param scaleLines defines a scaling factor for line length (1 by default)
  40761. */
  40762. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40763. /**
  40764. * Force the viewer to update
  40765. */
  40766. update(): void;
  40767. /** Releases resources */
  40768. dispose(): void;
  40769. }
  40770. }
  40771. declare module BABYLON {
  40772. /**
  40773. * Interface used to define scene explorer extensibility option
  40774. */
  40775. export interface IExplorerExtensibilityOption {
  40776. /**
  40777. * Define the option label
  40778. */
  40779. label: string;
  40780. /**
  40781. * Defines the action to execute on click
  40782. */
  40783. action: (entity: any) => void;
  40784. }
  40785. /**
  40786. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40787. */
  40788. export interface IExplorerExtensibilityGroup {
  40789. /**
  40790. * Defines a predicate to test if a given type mut be extended
  40791. */
  40792. predicate: (entity: any) => boolean;
  40793. /**
  40794. * Gets the list of options added to a type
  40795. */
  40796. entries: IExplorerExtensibilityOption[];
  40797. }
  40798. /**
  40799. * Interface used to define the options to use to create the Inspector
  40800. */
  40801. export interface IInspectorOptions {
  40802. /**
  40803. * Display in overlay mode (default: false)
  40804. */
  40805. overlay?: boolean;
  40806. /**
  40807. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40808. */
  40809. globalRoot?: HTMLElement;
  40810. /**
  40811. * Display the Scene explorer
  40812. */
  40813. showExplorer?: boolean;
  40814. /**
  40815. * Display the property inspector
  40816. */
  40817. showInspector?: boolean;
  40818. /**
  40819. * Display in embed mode (both panes on the right)
  40820. */
  40821. embedMode?: boolean;
  40822. /**
  40823. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40824. */
  40825. handleResize?: boolean;
  40826. /**
  40827. * Allow the panes to popup (default: true)
  40828. */
  40829. enablePopup?: boolean;
  40830. /**
  40831. * Allow the panes to be closed by users (default: true)
  40832. */
  40833. enableClose?: boolean;
  40834. /**
  40835. * Optional list of extensibility entries
  40836. */
  40837. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40838. /**
  40839. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40840. */
  40841. inspectorURL?: string;
  40842. }
  40843. interface Scene {
  40844. /**
  40845. * @hidden
  40846. * Backing field
  40847. */ private _debugLayer: DebugLayer;
  40848. /**
  40849. * Gets the debug layer (aka Inspector) associated with the scene
  40850. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40851. */
  40852. debugLayer: DebugLayer;
  40853. }
  40854. /**
  40855. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40856. * what is happening in your scene
  40857. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40858. */
  40859. export class DebugLayer {
  40860. /**
  40861. * Define the url to get the inspector script from.
  40862. * By default it uses the babylonjs CDN.
  40863. * @ignoreNaming
  40864. */
  40865. static InspectorURL: string;
  40866. private _scene;
  40867. private BJSINSPECTOR;
  40868. private _onPropertyChangedObservable?;
  40869. /**
  40870. * Observable triggered when a property is changed through the inspector.
  40871. */
  40872. readonly onPropertyChangedObservable: any;
  40873. /**
  40874. * Instantiates a new debug layer.
  40875. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40876. * what is happening in your scene
  40877. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40878. * @param scene Defines the scene to inspect
  40879. */
  40880. constructor(scene: Scene);
  40881. /** Creates the inspector window. */
  40882. private _createInspector;
  40883. /**
  40884. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40885. * @param entity defines the entity to select
  40886. * @param lineContainerTitle defines the specific block to highlight
  40887. */
  40888. select(entity: any, lineContainerTitle?: string): void;
  40889. /** Get the inspector from bundle or global */
  40890. private _getGlobalInspector;
  40891. /**
  40892. * Get if the inspector is visible or not.
  40893. * @returns true if visible otherwise, false
  40894. */
  40895. isVisible(): boolean;
  40896. /**
  40897. * Hide the inspector and close its window.
  40898. */
  40899. hide(): void;
  40900. /**
  40901. * Launch the debugLayer.
  40902. * @param config Define the configuration of the inspector
  40903. * @return a promise fulfilled when the debug layer is visible
  40904. */
  40905. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40906. }
  40907. }
  40908. declare module BABYLON {
  40909. /**
  40910. * Class containing static functions to help procedurally build meshes
  40911. */
  40912. export class BoxBuilder {
  40913. /**
  40914. * Creates a box mesh
  40915. * * The parameter `size` sets the size (float) of each box side (default 1)
  40916. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40917. * * 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)
  40918. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40922. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40923. * @param name defines the name of the mesh
  40924. * @param options defines the options used to create the mesh
  40925. * @param scene defines the hosting scene
  40926. * @returns the box mesh
  40927. */
  40928. static CreateBox(name: string, options: {
  40929. size?: number;
  40930. width?: number;
  40931. height?: number;
  40932. depth?: number;
  40933. faceUV?: Vector4[];
  40934. faceColors?: Color4[];
  40935. sideOrientation?: number;
  40936. frontUVs?: Vector4;
  40937. backUVs?: Vector4;
  40938. wrap?: boolean;
  40939. topBaseAt?: number;
  40940. bottomBaseAt?: number;
  40941. updatable?: boolean;
  40942. }, scene?: Nullable<Scene>): Mesh;
  40943. }
  40944. }
  40945. declare module BABYLON {
  40946. /**
  40947. * Class containing static functions to help procedurally build meshes
  40948. */
  40949. export class SphereBuilder {
  40950. /**
  40951. * Creates a sphere mesh
  40952. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40953. * * 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`)
  40954. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40955. * * 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
  40956. * * 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)
  40957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40960. * @param name defines the name of the mesh
  40961. * @param options defines the options used to create the mesh
  40962. * @param scene defines the hosting scene
  40963. * @returns the sphere mesh
  40964. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40965. */
  40966. static CreateSphere(name: string, options: {
  40967. segments?: number;
  40968. diameter?: number;
  40969. diameterX?: number;
  40970. diameterY?: number;
  40971. diameterZ?: number;
  40972. arc?: number;
  40973. slice?: number;
  40974. sideOrientation?: number;
  40975. frontUVs?: Vector4;
  40976. backUVs?: Vector4;
  40977. updatable?: boolean;
  40978. }, scene: any): Mesh;
  40979. }
  40980. }
  40981. declare module BABYLON.Debug {
  40982. /**
  40983. * Used to show the physics impostor around the specific mesh
  40984. */
  40985. export class PhysicsViewer {
  40986. /** @hidden */
  40987. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40988. /** @hidden */
  40989. protected _meshes: Array<Nullable<AbstractMesh>>;
  40990. /** @hidden */
  40991. protected _scene: Nullable<Scene>;
  40992. /** @hidden */
  40993. protected _numMeshes: number;
  40994. /** @hidden */
  40995. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40996. private _renderFunction;
  40997. private _utilityLayer;
  40998. private _debugBoxMesh;
  40999. private _debugSphereMesh;
  41000. private _debugCylinderMesh;
  41001. private _debugMaterial;
  41002. private _debugMeshMeshes;
  41003. /**
  41004. * Creates a new PhysicsViewer
  41005. * @param scene defines the hosting scene
  41006. */
  41007. constructor(scene: Scene);
  41008. /** @hidden */
  41009. protected _updateDebugMeshes(): void;
  41010. /**
  41011. * Renders a specified physic impostor
  41012. * @param impostor defines the impostor to render
  41013. * @param targetMesh defines the mesh represented by the impostor
  41014. * @returns the new debug mesh used to render the impostor
  41015. */
  41016. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41017. /**
  41018. * Hides a specified physic impostor
  41019. * @param impostor defines the impostor to hide
  41020. */
  41021. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41022. private _getDebugMaterial;
  41023. private _getDebugBoxMesh;
  41024. private _getDebugSphereMesh;
  41025. private _getDebugCylinderMesh;
  41026. private _getDebugMeshMesh;
  41027. private _getDebugMesh;
  41028. /** Releases all resources */
  41029. dispose(): void;
  41030. }
  41031. }
  41032. declare module BABYLON {
  41033. /**
  41034. * Class containing static functions to help procedurally build meshes
  41035. */
  41036. export class LinesBuilder {
  41037. /**
  41038. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41039. * * 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
  41040. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41041. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41042. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41043. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41044. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41045. * * 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
  41046. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41049. * @param name defines the name of the new line system
  41050. * @param options defines the options used to create the line system
  41051. * @param scene defines the hosting scene
  41052. * @returns a new line system mesh
  41053. */
  41054. static CreateLineSystem(name: string, options: {
  41055. lines: Vector3[][];
  41056. updatable?: boolean;
  41057. instance?: Nullable<LinesMesh>;
  41058. colors?: Nullable<Color4[][]>;
  41059. useVertexAlpha?: boolean;
  41060. }, scene: Nullable<Scene>): LinesMesh;
  41061. /**
  41062. * Creates a line mesh
  41063. * 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
  41064. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41065. * * The parameter `points` is an array successive Vector3
  41066. * * 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
  41067. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41068. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41069. * * When updating an instance, remember that only point positions can change, not the number of points
  41070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41072. * @param name defines the name of the new line system
  41073. * @param options defines the options used to create the line system
  41074. * @param scene defines the hosting scene
  41075. * @returns a new line mesh
  41076. */
  41077. static CreateLines(name: string, options: {
  41078. points: Vector3[];
  41079. updatable?: boolean;
  41080. instance?: Nullable<LinesMesh>;
  41081. colors?: Color4[];
  41082. useVertexAlpha?: boolean;
  41083. }, scene?: Nullable<Scene>): LinesMesh;
  41084. /**
  41085. * Creates a dashed line mesh
  41086. * * 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
  41087. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41088. * * The parameter `points` is an array successive Vector3
  41089. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41090. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41091. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41092. * * 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
  41093. * * When updating an instance, remember that only point positions can change, not the number of points
  41094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41095. * @param name defines the name of the mesh
  41096. * @param options defines the options used to create the mesh
  41097. * @param scene defines the hosting scene
  41098. * @returns the dashed line mesh
  41099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41100. */
  41101. static CreateDashedLines(name: string, options: {
  41102. points: Vector3[];
  41103. dashSize?: number;
  41104. gapSize?: number;
  41105. dashNb?: number;
  41106. updatable?: boolean;
  41107. instance?: LinesMesh;
  41108. }, scene?: Nullable<Scene>): LinesMesh;
  41109. }
  41110. }
  41111. declare module BABYLON {
  41112. /**
  41113. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41114. * in order to better appreciate the issue one might have.
  41115. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41116. */
  41117. export class RayHelper {
  41118. /**
  41119. * Defines the ray we are currently tryin to visualize.
  41120. */
  41121. ray: Nullable<Ray>;
  41122. private _renderPoints;
  41123. private _renderLine;
  41124. private _renderFunction;
  41125. private _scene;
  41126. private _updateToMeshFunction;
  41127. private _attachedToMesh;
  41128. private _meshSpaceDirection;
  41129. private _meshSpaceOrigin;
  41130. /**
  41131. * Helper function to create a colored helper in a scene in one line.
  41132. * @param ray Defines the ray we are currently tryin to visualize
  41133. * @param scene Defines the scene the ray is used in
  41134. * @param color Defines the color we want to see the ray in
  41135. * @returns The newly created ray helper.
  41136. */
  41137. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41138. /**
  41139. * Instantiate a new ray helper.
  41140. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41141. * in order to better appreciate the issue one might have.
  41142. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41143. * @param ray Defines the ray we are currently tryin to visualize
  41144. */
  41145. constructor(ray: Ray);
  41146. /**
  41147. * Shows the ray we are willing to debug.
  41148. * @param scene Defines the scene the ray needs to be rendered in
  41149. * @param color Defines the color the ray needs to be rendered in
  41150. */
  41151. show(scene: Scene, color?: Color3): void;
  41152. /**
  41153. * Hides the ray we are debugging.
  41154. */
  41155. hide(): void;
  41156. private _render;
  41157. /**
  41158. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41159. * @param mesh Defines the mesh we want the helper attached to
  41160. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41161. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41162. * @param length Defines the length of the ray
  41163. */
  41164. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41165. /**
  41166. * Detach the ray helper from the mesh it has previously been attached to.
  41167. */
  41168. detachFromMesh(): void;
  41169. private _updateToMesh;
  41170. /**
  41171. * Dispose the helper and release its associated resources.
  41172. */
  41173. dispose(): void;
  41174. }
  41175. }
  41176. declare module BABYLON.Debug {
  41177. /**
  41178. * Class used to render a debug view of a given skeleton
  41179. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41180. */
  41181. export class SkeletonViewer {
  41182. /** defines the skeleton to render */
  41183. skeleton: Skeleton;
  41184. /** defines the mesh attached to the skeleton */
  41185. mesh: AbstractMesh;
  41186. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41187. autoUpdateBonesMatrices: boolean;
  41188. /** defines the rendering group id to use with the viewer */
  41189. renderingGroupId: number;
  41190. /** Gets or sets the color used to render the skeleton */
  41191. color: Color3;
  41192. private _scene;
  41193. private _debugLines;
  41194. private _debugMesh;
  41195. private _isEnabled;
  41196. private _renderFunction;
  41197. private _utilityLayer;
  41198. /**
  41199. * Returns the mesh used to render the bones
  41200. */
  41201. readonly debugMesh: Nullable<LinesMesh>;
  41202. /**
  41203. * Creates a new SkeletonViewer
  41204. * @param skeleton defines the skeleton to render
  41205. * @param mesh defines the mesh attached to the skeleton
  41206. * @param scene defines the hosting scene
  41207. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41208. * @param renderingGroupId defines the rendering group id to use with the viewer
  41209. */
  41210. constructor(
  41211. /** defines the skeleton to render */
  41212. skeleton: Skeleton,
  41213. /** defines the mesh attached to the skeleton */
  41214. mesh: AbstractMesh, scene: Scene,
  41215. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41216. autoUpdateBonesMatrices?: boolean,
  41217. /** defines the rendering group id to use with the viewer */
  41218. renderingGroupId?: number);
  41219. /** Gets or sets a boolean indicating if the viewer is enabled */
  41220. isEnabled: boolean;
  41221. private _getBonePosition;
  41222. private _getLinesForBonesWithLength;
  41223. private _getLinesForBonesNoLength;
  41224. /** Update the viewer to sync with current skeleton state */
  41225. update(): void;
  41226. /** Release associated resources */
  41227. dispose(): void;
  41228. }
  41229. }
  41230. declare module BABYLON {
  41231. /**
  41232. * Options to create the null engine
  41233. */
  41234. export class NullEngineOptions {
  41235. /**
  41236. * Render width (Default: 512)
  41237. */
  41238. renderWidth: number;
  41239. /**
  41240. * Render height (Default: 256)
  41241. */
  41242. renderHeight: number;
  41243. /**
  41244. * Texture size (Default: 512)
  41245. */
  41246. textureSize: number;
  41247. /**
  41248. * If delta time between frames should be constant
  41249. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41250. */
  41251. deterministicLockstep: boolean;
  41252. /**
  41253. * Maximum about of steps between frames (Default: 4)
  41254. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41255. */
  41256. lockstepMaxSteps: number;
  41257. }
  41258. /**
  41259. * The null engine class provides support for headless version of babylon.js.
  41260. * This can be used in server side scenario or for testing purposes
  41261. */
  41262. export class NullEngine extends Engine {
  41263. private _options;
  41264. /**
  41265. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41266. */
  41267. isDeterministicLockStep(): boolean;
  41268. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41269. getLockstepMaxSteps(): number;
  41270. /**
  41271. * Sets hardware scaling, used to save performance if needed
  41272. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41273. */
  41274. getHardwareScalingLevel(): number;
  41275. constructor(options?: NullEngineOptions);
  41276. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41277. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41278. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41279. getRenderWidth(useScreen?: boolean): number;
  41280. getRenderHeight(useScreen?: boolean): number;
  41281. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41282. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41283. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41284. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41285. bindSamplers(effect: Effect): void;
  41286. enableEffect(effect: Effect): void;
  41287. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41288. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41289. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41290. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41291. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41292. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41293. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41294. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41295. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41296. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41297. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41298. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41299. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41300. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41301. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41302. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41303. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41304. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41305. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41306. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41307. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41308. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41309. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41310. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41311. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41312. bindBuffers(vertexBuffers: {
  41313. [key: string]: VertexBuffer;
  41314. }, indexBuffer: DataBuffer, effect: Effect): void;
  41315. wipeCaches(bruteForce?: boolean): void;
  41316. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41317. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41318. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41319. /** @hidden */ private _createTexture(): WebGLTexture;
  41320. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  41321. 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;
  41322. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41323. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41324. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41325. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41326. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41327. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41328. areAllEffectsReady(): boolean;
  41329. /**
  41330. * @hidden
  41331. * Get the current error code of the webGL context
  41332. * @returns the error code
  41333. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41334. */
  41335. getError(): number;
  41336. /** @hidden */ private _getUnpackAlignement(): number;
  41337. /** @hidden */ private _unpackFlipY(value: boolean): void;
  41338. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41339. /**
  41340. * Updates a dynamic vertex buffer.
  41341. * @param vertexBuffer the vertex buffer to update
  41342. * @param data the data used to update the vertex buffer
  41343. * @param byteOffset the byte offset of the data (optional)
  41344. * @param byteLength the byte length of the data (optional)
  41345. */
  41346. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41347. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  41348. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  41349. releaseEffects(): void;
  41350. displayLoadingUI(): void;
  41351. hideLoadingUI(): void;
  41352. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41353. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41354. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41355. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41356. }
  41357. }
  41358. declare module BABYLON {
  41359. /** @hidden */
  41360. export class _OcclusionDataStorage {
  41361. /** @hidden */
  41362. occlusionInternalRetryCounter: number;
  41363. /** @hidden */
  41364. isOcclusionQueryInProgress: boolean;
  41365. /** @hidden */
  41366. isOccluded: boolean;
  41367. /** @hidden */
  41368. occlusionRetryCount: number;
  41369. /** @hidden */
  41370. occlusionType: number;
  41371. /** @hidden */
  41372. occlusionQueryAlgorithmType: number;
  41373. }
  41374. interface Engine {
  41375. /**
  41376. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41377. * @return the new query
  41378. */
  41379. createQuery(): WebGLQuery;
  41380. /**
  41381. * Delete and release a webGL query
  41382. * @param query defines the query to delete
  41383. * @return the current engine
  41384. */
  41385. deleteQuery(query: WebGLQuery): Engine;
  41386. /**
  41387. * Check if a given query has resolved and got its value
  41388. * @param query defines the query to check
  41389. * @returns true if the query got its value
  41390. */
  41391. isQueryResultAvailable(query: WebGLQuery): boolean;
  41392. /**
  41393. * Gets the value of a given query
  41394. * @param query defines the query to check
  41395. * @returns the value of the query
  41396. */
  41397. getQueryResult(query: WebGLQuery): number;
  41398. /**
  41399. * Initiates an occlusion query
  41400. * @param algorithmType defines the algorithm to use
  41401. * @param query defines the query to use
  41402. * @returns the current engine
  41403. * @see http://doc.babylonjs.com/features/occlusionquery
  41404. */
  41405. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41406. /**
  41407. * Ends an occlusion query
  41408. * @see http://doc.babylonjs.com/features/occlusionquery
  41409. * @param algorithmType defines the algorithm to use
  41410. * @returns the current engine
  41411. */
  41412. endOcclusionQuery(algorithmType: number): Engine;
  41413. /**
  41414. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41415. * Please note that only one query can be issued at a time
  41416. * @returns a time token used to track the time span
  41417. */
  41418. startTimeQuery(): Nullable<_TimeToken>;
  41419. /**
  41420. * Ends a time query
  41421. * @param token defines the token used to measure the time span
  41422. * @returns the time spent (in ns)
  41423. */
  41424. endTimeQuery(token: _TimeToken): int;
  41425. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  41426. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  41427. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  41428. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  41429. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  41430. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  41431. }
  41432. interface AbstractMesh {
  41433. /**
  41434. * Backing filed
  41435. * @hidden
  41436. */ private __occlusionDataStorage: _OcclusionDataStorage;
  41437. /**
  41438. * Access property
  41439. * @hidden
  41440. */ private _occlusionDataStorage: _OcclusionDataStorage;
  41441. /**
  41442. * 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.
  41443. * The default value is -1 which means don't break the query and wait till the result
  41444. * @see http://doc.babylonjs.com/features/occlusionquery
  41445. */
  41446. occlusionRetryCount: number;
  41447. /**
  41448. * 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:
  41449. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41450. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41451. * * 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.
  41452. * @see http://doc.babylonjs.com/features/occlusionquery
  41453. */
  41454. occlusionType: number;
  41455. /**
  41456. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41457. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41458. * * 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.
  41459. * @see http://doc.babylonjs.com/features/occlusionquery
  41460. */
  41461. occlusionQueryAlgorithmType: number;
  41462. /**
  41463. * 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
  41464. * @see http://doc.babylonjs.com/features/occlusionquery
  41465. */
  41466. isOccluded: boolean;
  41467. /**
  41468. * Flag to check the progress status of the query
  41469. * @see http://doc.babylonjs.com/features/occlusionquery
  41470. */
  41471. isOcclusionQueryInProgress: boolean;
  41472. }
  41473. }
  41474. declare module BABYLON {
  41475. /** @hidden */
  41476. export var _forceTransformFeedbackToBundle: boolean;
  41477. interface Engine {
  41478. /**
  41479. * Creates a webGL transform feedback object
  41480. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41481. * @returns the webGL transform feedback object
  41482. */
  41483. createTransformFeedback(): WebGLTransformFeedback;
  41484. /**
  41485. * Delete a webGL transform feedback object
  41486. * @param value defines the webGL transform feedback object to delete
  41487. */
  41488. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41489. /**
  41490. * Bind a webGL transform feedback object to the webgl context
  41491. * @param value defines the webGL transform feedback object to bind
  41492. */
  41493. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41494. /**
  41495. * Begins a transform feedback operation
  41496. * @param usePoints defines if points or triangles must be used
  41497. */
  41498. beginTransformFeedback(usePoints: boolean): void;
  41499. /**
  41500. * Ends a transform feedback operation
  41501. */
  41502. endTransformFeedback(): void;
  41503. /**
  41504. * Specify the varyings to use with transform feedback
  41505. * @param program defines the associated webGL program
  41506. * @param value defines the list of strings representing the varying names
  41507. */
  41508. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41509. /**
  41510. * Bind a webGL buffer for a transform feedback operation
  41511. * @param value defines the webGL buffer to bind
  41512. */
  41513. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41514. }
  41515. }
  41516. declare module BABYLON {
  41517. /**
  41518. * Creation options of the multi render target texture.
  41519. */
  41520. export interface IMultiRenderTargetOptions {
  41521. /**
  41522. * Define if the texture needs to create mip maps after render.
  41523. */
  41524. generateMipMaps?: boolean;
  41525. /**
  41526. * Define the types of all the draw buffers we want to create
  41527. */
  41528. types?: number[];
  41529. /**
  41530. * Define the sampling modes of all the draw buffers we want to create
  41531. */
  41532. samplingModes?: number[];
  41533. /**
  41534. * Define if a depth buffer is required
  41535. */
  41536. generateDepthBuffer?: boolean;
  41537. /**
  41538. * Define if a stencil buffer is required
  41539. */
  41540. generateStencilBuffer?: boolean;
  41541. /**
  41542. * Define if a depth texture is required instead of a depth buffer
  41543. */
  41544. generateDepthTexture?: boolean;
  41545. /**
  41546. * Define the number of desired draw buffers
  41547. */
  41548. textureCount?: number;
  41549. /**
  41550. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41551. */
  41552. doNotChangeAspectRatio?: boolean;
  41553. /**
  41554. * Define the default type of the buffers we are creating
  41555. */
  41556. defaultType?: number;
  41557. }
  41558. /**
  41559. * A multi render target, like a render target provides the ability to render to a texture.
  41560. * Unlike the render target, it can render to several draw buffers in one draw.
  41561. * This is specially interesting in deferred rendering or for any effects requiring more than
  41562. * just one color from a single pass.
  41563. */
  41564. export class MultiRenderTarget extends RenderTargetTexture {
  41565. private _internalTextures;
  41566. private _textures;
  41567. private _multiRenderTargetOptions;
  41568. /**
  41569. * Get if draw buffers are currently supported by the used hardware and browser.
  41570. */
  41571. readonly isSupported: boolean;
  41572. /**
  41573. * Get the list of textures generated by the multi render target.
  41574. */
  41575. readonly textures: Texture[];
  41576. /**
  41577. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41578. */
  41579. readonly depthTexture: Texture;
  41580. /**
  41581. * Set the wrapping mode on U of all the textures we are rendering to.
  41582. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41583. */
  41584. wrapU: number;
  41585. /**
  41586. * Set the wrapping mode on V of all the textures we are rendering to.
  41587. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41588. */
  41589. wrapV: number;
  41590. /**
  41591. * Instantiate a new multi render target texture.
  41592. * A multi render target, like a render target provides the ability to render to a texture.
  41593. * Unlike the render target, it can render to several draw buffers in one draw.
  41594. * This is specially interesting in deferred rendering or for any effects requiring more than
  41595. * just one color from a single pass.
  41596. * @param name Define the name of the texture
  41597. * @param size Define the size of the buffers to render to
  41598. * @param count Define the number of target we are rendering into
  41599. * @param scene Define the scene the texture belongs to
  41600. * @param options Define the options used to create the multi render target
  41601. */
  41602. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41603. /** @hidden */ private _rebuild(): void;
  41604. private _createInternalTextures;
  41605. private _createTextures;
  41606. /**
  41607. * Define the number of samples used if MSAA is enabled.
  41608. */
  41609. samples: number;
  41610. /**
  41611. * Resize all the textures in the multi render target.
  41612. * Be carrefull as it will recreate all the data in the new texture.
  41613. * @param size Define the new size
  41614. */
  41615. resize(size: any): void;
  41616. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41617. /**
  41618. * Dispose the render targets and their associated resources
  41619. */
  41620. dispose(): void;
  41621. /**
  41622. * Release all the underlying texture used as draw buffers.
  41623. */
  41624. releaseInternalTextures(): void;
  41625. }
  41626. }
  41627. declare module BABYLON {
  41628. interface Engine {
  41629. /**
  41630. * Unbind a list of render target textures from the webGL context
  41631. * This is used only when drawBuffer extension or webGL2 are active
  41632. * @param textures defines the render target textures to unbind
  41633. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41634. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41635. */
  41636. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41637. /**
  41638. * Create a multi render target texture
  41639. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41640. * @param size defines the size of the texture
  41641. * @param options defines the creation options
  41642. * @returns the cube texture as an InternalTexture
  41643. */
  41644. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41645. /**
  41646. * Update the sample count for a given multiple render target texture
  41647. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41648. * @param textures defines the textures to update
  41649. * @param samples defines the sample count to set
  41650. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41651. */
  41652. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41653. }
  41654. }
  41655. declare module BABYLON {
  41656. /**
  41657. * Gather the list of clipboard event types as constants.
  41658. */
  41659. export class ClipboardEventTypes {
  41660. /**
  41661. * The clipboard event is fired when a copy command is active (pressed).
  41662. */
  41663. static readonly COPY: number;
  41664. /**
  41665. * The clipboard event is fired when a cut command is active (pressed).
  41666. */
  41667. static readonly CUT: number;
  41668. /**
  41669. * The clipboard event is fired when a paste command is active (pressed).
  41670. */
  41671. static readonly PASTE: number;
  41672. }
  41673. /**
  41674. * This class is used to store clipboard related info for the onClipboardObservable event.
  41675. */
  41676. export class ClipboardInfo {
  41677. /**
  41678. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41679. */
  41680. type: number;
  41681. /**
  41682. * Defines the related dom event
  41683. */
  41684. event: ClipboardEvent;
  41685. /**
  41686. *Creates an instance of ClipboardInfo.
  41687. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41688. * @param event Defines the related dom event
  41689. */
  41690. constructor(
  41691. /**
  41692. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41693. */
  41694. type: number,
  41695. /**
  41696. * Defines the related dom event
  41697. */
  41698. event: ClipboardEvent);
  41699. /**
  41700. * Get the clipboard event's type from the keycode.
  41701. * @param keyCode Defines the keyCode for the current keyboard event.
  41702. * @return {number}
  41703. */
  41704. static GetTypeFromCharacter(keyCode: number): number;
  41705. }
  41706. }
  41707. declare module BABYLON {
  41708. /**
  41709. * Class used to represent data loading progression
  41710. */
  41711. export class SceneLoaderProgressEvent {
  41712. /** defines if data length to load can be evaluated */
  41713. readonly lengthComputable: boolean;
  41714. /** defines the loaded data length */
  41715. readonly loaded: number;
  41716. /** defines the data length to load */
  41717. readonly total: number;
  41718. /**
  41719. * Create a new progress event
  41720. * @param lengthComputable defines if data length to load can be evaluated
  41721. * @param loaded defines the loaded data length
  41722. * @param total defines the data length to load
  41723. */
  41724. constructor(
  41725. /** defines if data length to load can be evaluated */
  41726. lengthComputable: boolean,
  41727. /** defines the loaded data length */
  41728. loaded: number,
  41729. /** defines the data length to load */
  41730. total: number);
  41731. /**
  41732. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41733. * @param event defines the source event
  41734. * @returns a new SceneLoaderProgressEvent
  41735. */
  41736. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41737. }
  41738. /**
  41739. * Interface used by SceneLoader plugins to define supported file extensions
  41740. */
  41741. export interface ISceneLoaderPluginExtensions {
  41742. /**
  41743. * Defines the list of supported extensions
  41744. */
  41745. [extension: string]: {
  41746. isBinary: boolean;
  41747. };
  41748. }
  41749. /**
  41750. * Interface used by SceneLoader plugin factory
  41751. */
  41752. export interface ISceneLoaderPluginFactory {
  41753. /**
  41754. * Defines the name of the factory
  41755. */
  41756. name: string;
  41757. /**
  41758. * Function called to create a new plugin
  41759. * @return the new plugin
  41760. */
  41761. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41762. /**
  41763. * Boolean indicating if the plugin can direct load specific data
  41764. */
  41765. canDirectLoad?: (data: string) => boolean;
  41766. }
  41767. /**
  41768. * Interface used to define a SceneLoader plugin
  41769. */
  41770. export interface ISceneLoaderPlugin {
  41771. /**
  41772. * The friendly name of this plugin.
  41773. */
  41774. name: string;
  41775. /**
  41776. * The file extensions supported by this plugin.
  41777. */
  41778. extensions: string | ISceneLoaderPluginExtensions;
  41779. /**
  41780. * Import meshes into a scene.
  41781. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41782. * @param scene The scene to import into
  41783. * @param data The data to import
  41784. * @param rootUrl The root url for scene and resources
  41785. * @param meshes The meshes array to import into
  41786. * @param particleSystems The particle systems array to import into
  41787. * @param skeletons The skeletons array to import into
  41788. * @param onError The callback when import fails
  41789. * @returns True if successful or false otherwise
  41790. */
  41791. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41792. /**
  41793. * Load into a scene.
  41794. * @param scene The scene to load into
  41795. * @param data The data to import
  41796. * @param rootUrl The root url for scene and resources
  41797. * @param onError The callback when import fails
  41798. * @returns true if successful or false otherwise
  41799. */
  41800. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41801. /**
  41802. * The callback that returns true if the data can be directly loaded.
  41803. */
  41804. canDirectLoad?: (data: string) => boolean;
  41805. /**
  41806. * The callback that allows custom handling of the root url based on the response url.
  41807. */
  41808. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41809. /**
  41810. * Load into an asset container.
  41811. * @param scene The scene to load into
  41812. * @param data The data to import
  41813. * @param rootUrl The root url for scene and resources
  41814. * @param onError The callback when import fails
  41815. * @returns The loaded asset container
  41816. */
  41817. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41818. }
  41819. /**
  41820. * Interface used to define an async SceneLoader plugin
  41821. */
  41822. export interface ISceneLoaderPluginAsync {
  41823. /**
  41824. * The friendly name of this plugin.
  41825. */
  41826. name: string;
  41827. /**
  41828. * The file extensions supported by this plugin.
  41829. */
  41830. extensions: string | ISceneLoaderPluginExtensions;
  41831. /**
  41832. * Import meshes into a scene.
  41833. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41834. * @param scene The scene to import into
  41835. * @param data The data to import
  41836. * @param rootUrl The root url for scene and resources
  41837. * @param onProgress The callback when the load progresses
  41838. * @param fileName Defines the name of the file to load
  41839. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41840. */
  41841. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41842. meshes: AbstractMesh[];
  41843. particleSystems: IParticleSystem[];
  41844. skeletons: Skeleton[];
  41845. animationGroups: AnimationGroup[];
  41846. }>;
  41847. /**
  41848. * Load into a scene.
  41849. * @param scene The scene to load into
  41850. * @param data The data to import
  41851. * @param rootUrl The root url for scene and resources
  41852. * @param onProgress The callback when the load progresses
  41853. * @param fileName Defines the name of the file to load
  41854. * @returns Nothing
  41855. */
  41856. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41857. /**
  41858. * The callback that returns true if the data can be directly loaded.
  41859. */
  41860. canDirectLoad?: (data: string) => boolean;
  41861. /**
  41862. * The callback that allows custom handling of the root url based on the response url.
  41863. */
  41864. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41865. /**
  41866. * Load into an asset container.
  41867. * @param scene The scene to load into
  41868. * @param data The data to import
  41869. * @param rootUrl The root url for scene and resources
  41870. * @param onProgress The callback when the load progresses
  41871. * @param fileName Defines the name of the file to load
  41872. * @returns The loaded asset container
  41873. */
  41874. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41875. }
  41876. /**
  41877. * Class used to load scene from various file formats using registered plugins
  41878. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41879. */
  41880. export class SceneLoader {
  41881. /**
  41882. * No logging while loading
  41883. */
  41884. static readonly NO_LOGGING: number;
  41885. /**
  41886. * Minimal logging while loading
  41887. */
  41888. static readonly MINIMAL_LOGGING: number;
  41889. /**
  41890. * Summary logging while loading
  41891. */
  41892. static readonly SUMMARY_LOGGING: number;
  41893. /**
  41894. * Detailled logging while loading
  41895. */
  41896. static readonly DETAILED_LOGGING: number;
  41897. /**
  41898. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41899. */
  41900. static ForceFullSceneLoadingForIncremental: boolean;
  41901. /**
  41902. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41903. */
  41904. static ShowLoadingScreen: boolean;
  41905. /**
  41906. * Defines the current logging level (while loading the scene)
  41907. * @ignorenaming
  41908. */
  41909. static loggingLevel: number;
  41910. /**
  41911. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41912. */
  41913. static CleanBoneMatrixWeights: boolean;
  41914. /**
  41915. * Event raised when a plugin is used to load a scene
  41916. */
  41917. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41918. private static _registeredPlugins;
  41919. private static _getDefaultPlugin;
  41920. private static _getPluginForExtension;
  41921. private static _getPluginForDirectLoad;
  41922. private static _getPluginForFilename;
  41923. private static _getDirectLoad;
  41924. private static _loadData;
  41925. private static _getFileInfo;
  41926. /**
  41927. * Gets a plugin that can load the given extension
  41928. * @param extension defines the extension to load
  41929. * @returns a plugin or null if none works
  41930. */
  41931. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41932. /**
  41933. * Gets a boolean indicating that the given extension can be loaded
  41934. * @param extension defines the extension to load
  41935. * @returns true if the extension is supported
  41936. */
  41937. static IsPluginForExtensionAvailable(extension: string): boolean;
  41938. /**
  41939. * Adds a new plugin to the list of registered plugins
  41940. * @param plugin defines the plugin to add
  41941. */
  41942. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41943. /**
  41944. * Import meshes into a scene
  41945. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41946. * @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)
  41947. * @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)
  41948. * @param scene the instance of BABYLON.Scene to append to
  41949. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41950. * @param onProgress a callback with a progress event for each file being loaded
  41951. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41952. * @param pluginExtension the extension used to determine the plugin
  41953. * @returns The loaded plugin
  41954. */
  41955. 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>;
  41956. /**
  41957. * Import meshes into a scene
  41958. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41959. * @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)
  41960. * @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)
  41961. * @param scene the instance of BABYLON.Scene to append to
  41962. * @param onProgress a callback with a progress event for each file being loaded
  41963. * @param pluginExtension the extension used to determine the plugin
  41964. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41965. */
  41966. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41967. meshes: AbstractMesh[];
  41968. particleSystems: IParticleSystem[];
  41969. skeletons: Skeleton[];
  41970. animationGroups: AnimationGroup[];
  41971. }>;
  41972. /**
  41973. * Load a scene
  41974. * @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)
  41975. * @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)
  41976. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41977. * @param onSuccess a callback with the scene when import succeeds
  41978. * @param onProgress a callback with a progress event for each file being loaded
  41979. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41980. * @param pluginExtension the extension used to determine the plugin
  41981. * @returns The loaded plugin
  41982. */
  41983. 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>;
  41984. /**
  41985. * Load a scene
  41986. * @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)
  41987. * @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)
  41988. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41989. * @param onProgress a callback with a progress event for each file being loaded
  41990. * @param pluginExtension the extension used to determine the plugin
  41991. * @returns The loaded scene
  41992. */
  41993. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41994. /**
  41995. * Append a scene
  41996. * @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)
  41997. * @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)
  41998. * @param scene is the instance of BABYLON.Scene to append to
  41999. * @param onSuccess a callback with the scene when import succeeds
  42000. * @param onProgress a callback with a progress event for each file being loaded
  42001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42002. * @param pluginExtension the extension used to determine the plugin
  42003. * @returns The loaded plugin
  42004. */
  42005. 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>;
  42006. /**
  42007. * Append a scene
  42008. * @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)
  42009. * @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)
  42010. * @param scene is the instance of BABYLON.Scene to append to
  42011. * @param onProgress a callback with a progress event for each file being loaded
  42012. * @param pluginExtension the extension used to determine the plugin
  42013. * @returns The given scene
  42014. */
  42015. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42016. /**
  42017. * Load a scene into an asset container
  42018. * @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)
  42019. * @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)
  42020. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42021. * @param onSuccess a callback with the scene when import succeeds
  42022. * @param onProgress a callback with a progress event for each file being loaded
  42023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42024. * @param pluginExtension the extension used to determine the plugin
  42025. * @returns The loaded plugin
  42026. */
  42027. 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>;
  42028. /**
  42029. * Load a scene into an asset container
  42030. * @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)
  42031. * @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)
  42032. * @param scene is the instance of Scene to append to
  42033. * @param onProgress a callback with a progress event for each file being loaded
  42034. * @param pluginExtension the extension used to determine the plugin
  42035. * @returns The loaded asset container
  42036. */
  42037. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42038. }
  42039. }
  42040. declare module BABYLON {
  42041. /**
  42042. * Google Daydream controller
  42043. */
  42044. export class DaydreamController extends WebVRController {
  42045. /**
  42046. * Base Url for the controller model.
  42047. */
  42048. static MODEL_BASE_URL: string;
  42049. /**
  42050. * File name for the controller model.
  42051. */
  42052. static MODEL_FILENAME: string;
  42053. /**
  42054. * Gamepad Id prefix used to identify Daydream Controller.
  42055. */
  42056. static readonly GAMEPAD_ID_PREFIX: string;
  42057. /**
  42058. * Creates a new DaydreamController from a gamepad
  42059. * @param vrGamepad the gamepad that the controller should be created from
  42060. */
  42061. constructor(vrGamepad: any);
  42062. /**
  42063. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42064. * @param scene scene in which to add meshes
  42065. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42066. */
  42067. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42068. /**
  42069. * Called once for each button that changed state since the last frame
  42070. * @param buttonIdx Which button index changed
  42071. * @param state New state of the button
  42072. * @param changes Which properties on the state changed since last frame
  42073. */
  42074. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42075. }
  42076. }
  42077. declare module BABYLON {
  42078. /**
  42079. * Gear VR Controller
  42080. */
  42081. export class GearVRController extends WebVRController {
  42082. /**
  42083. * Base Url for the controller model.
  42084. */
  42085. static MODEL_BASE_URL: string;
  42086. /**
  42087. * File name for the controller model.
  42088. */
  42089. static MODEL_FILENAME: string;
  42090. /**
  42091. * Gamepad Id prefix used to identify this controller.
  42092. */
  42093. static readonly GAMEPAD_ID_PREFIX: string;
  42094. private readonly _buttonIndexToObservableNameMap;
  42095. /**
  42096. * Creates a new GearVRController from a gamepad
  42097. * @param vrGamepad the gamepad that the controller should be created from
  42098. */
  42099. constructor(vrGamepad: any);
  42100. /**
  42101. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42102. * @param scene scene in which to add meshes
  42103. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42104. */
  42105. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42106. /**
  42107. * Called once for each button that changed state since the last frame
  42108. * @param buttonIdx Which button index changed
  42109. * @param state New state of the button
  42110. * @param changes Which properties on the state changed since last frame
  42111. */
  42112. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42113. }
  42114. }
  42115. declare module BABYLON {
  42116. /**
  42117. * Generic Controller
  42118. */
  42119. export class GenericController extends WebVRController {
  42120. /**
  42121. * Base Url for the controller model.
  42122. */
  42123. static readonly MODEL_BASE_URL: string;
  42124. /**
  42125. * File name for the controller model.
  42126. */
  42127. static readonly MODEL_FILENAME: string;
  42128. /**
  42129. * Creates a new GenericController from a gamepad
  42130. * @param vrGamepad the gamepad that the controller should be created from
  42131. */
  42132. constructor(vrGamepad: any);
  42133. /**
  42134. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42135. * @param scene scene in which to add meshes
  42136. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42137. */
  42138. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42139. /**
  42140. * Called once for each button that changed state since the last frame
  42141. * @param buttonIdx Which button index changed
  42142. * @param state New state of the button
  42143. * @param changes Which properties on the state changed since last frame
  42144. */
  42145. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42146. }
  42147. }
  42148. declare module BABYLON {
  42149. /**
  42150. * Oculus Touch Controller
  42151. */
  42152. export class OculusTouchController extends WebVRController {
  42153. /**
  42154. * Base Url for the controller model.
  42155. */
  42156. static MODEL_BASE_URL: string;
  42157. /**
  42158. * File name for the left controller model.
  42159. */
  42160. static MODEL_LEFT_FILENAME: string;
  42161. /**
  42162. * File name for the right controller model.
  42163. */
  42164. static MODEL_RIGHT_FILENAME: string;
  42165. /**
  42166. * Base Url for the Quest controller model.
  42167. */
  42168. static QUEST_MODEL_BASE_URL: string;
  42169. /**
  42170. * @hidden
  42171. * If the controllers are running on a device that needs the updated Quest controller models
  42172. */ private static _IsQuest: boolean;
  42173. /**
  42174. * Fired when the secondary trigger on this controller is modified
  42175. */
  42176. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42177. /**
  42178. * Fired when the thumb rest on this controller is modified
  42179. */
  42180. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42181. /**
  42182. * Creates a new OculusTouchController from a gamepad
  42183. * @param vrGamepad the gamepad that the controller should be created from
  42184. */
  42185. constructor(vrGamepad: any);
  42186. /**
  42187. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42188. * @param scene scene in which to add meshes
  42189. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42190. */
  42191. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42192. /**
  42193. * Fired when the A button on this controller is modified
  42194. */
  42195. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42196. /**
  42197. * Fired when the B button on this controller is modified
  42198. */
  42199. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42200. /**
  42201. * Fired when the X button on this controller is modified
  42202. */
  42203. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42204. /**
  42205. * Fired when the Y button on this controller is modified
  42206. */
  42207. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42208. /**
  42209. * Called once for each button that changed state since the last frame
  42210. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42211. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42212. * 2) secondary trigger (same)
  42213. * 3) A (right) X (left), touch, pressed = value
  42214. * 4) B / Y
  42215. * 5) thumb rest
  42216. * @param buttonIdx Which button index changed
  42217. * @param state New state of the button
  42218. * @param changes Which properties on the state changed since last frame
  42219. */
  42220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42221. }
  42222. }
  42223. declare module BABYLON {
  42224. /**
  42225. * Vive Controller
  42226. */
  42227. export class ViveController extends WebVRController {
  42228. /**
  42229. * Base Url for the controller model.
  42230. */
  42231. static MODEL_BASE_URL: string;
  42232. /**
  42233. * File name for the controller model.
  42234. */
  42235. static MODEL_FILENAME: string;
  42236. /**
  42237. * Creates a new ViveController from a gamepad
  42238. * @param vrGamepad the gamepad that the controller should be created from
  42239. */
  42240. constructor(vrGamepad: any);
  42241. /**
  42242. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42243. * @param scene scene in which to add meshes
  42244. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42245. */
  42246. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42247. /**
  42248. * Fired when the left button on this controller is modified
  42249. */
  42250. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42251. /**
  42252. * Fired when the right button on this controller is modified
  42253. */
  42254. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42255. /**
  42256. * Fired when the menu button on this controller is modified
  42257. */
  42258. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42259. /**
  42260. * Called once for each button that changed state since the last frame
  42261. * Vive mapping:
  42262. * 0: touchpad
  42263. * 1: trigger
  42264. * 2: left AND right buttons
  42265. * 3: menu button
  42266. * @param buttonIdx Which button index changed
  42267. * @param state New state of the button
  42268. * @param changes Which properties on the state changed since last frame
  42269. */
  42270. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42271. }
  42272. }
  42273. declare module BABYLON {
  42274. /**
  42275. * Defines the WindowsMotionController object that the state of the windows motion controller
  42276. */
  42277. export class WindowsMotionController extends WebVRController {
  42278. /**
  42279. * The base url used to load the left and right controller models
  42280. */
  42281. static MODEL_BASE_URL: string;
  42282. /**
  42283. * The name of the left controller model file
  42284. */
  42285. static MODEL_LEFT_FILENAME: string;
  42286. /**
  42287. * The name of the right controller model file
  42288. */
  42289. static MODEL_RIGHT_FILENAME: string;
  42290. /**
  42291. * The controller name prefix for this controller type
  42292. */
  42293. static readonly GAMEPAD_ID_PREFIX: string;
  42294. /**
  42295. * The controller id pattern for this controller type
  42296. */
  42297. private static readonly GAMEPAD_ID_PATTERN;
  42298. private _loadedMeshInfo;
  42299. private readonly _mapping;
  42300. /**
  42301. * Fired when the trackpad on this controller is clicked
  42302. */
  42303. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42304. /**
  42305. * Fired when the trackpad on this controller is modified
  42306. */
  42307. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42308. /**
  42309. * The current x and y values of this controller's trackpad
  42310. */
  42311. trackpad: StickValues;
  42312. /**
  42313. * Creates a new WindowsMotionController from a gamepad
  42314. * @param vrGamepad the gamepad that the controller should be created from
  42315. */
  42316. constructor(vrGamepad: any);
  42317. /**
  42318. * Fired when the trigger on this controller is modified
  42319. */
  42320. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42321. /**
  42322. * Fired when the menu button on this controller is modified
  42323. */
  42324. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42325. /**
  42326. * Fired when the grip button on this controller is modified
  42327. */
  42328. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42329. /**
  42330. * Fired when the thumbstick button on this controller is modified
  42331. */
  42332. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42333. /**
  42334. * Fired when the touchpad button on this controller is modified
  42335. */
  42336. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42337. /**
  42338. * Fired when the touchpad values on this controller are modified
  42339. */
  42340. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42341. private _updateTrackpad;
  42342. /**
  42343. * Called once per frame by the engine.
  42344. */
  42345. update(): void;
  42346. /**
  42347. * Called once for each button that changed state since the last frame
  42348. * @param buttonIdx Which button index changed
  42349. * @param state New state of the button
  42350. * @param changes Which properties on the state changed since last frame
  42351. */
  42352. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42353. /**
  42354. * Moves the buttons on the controller mesh based on their current state
  42355. * @param buttonName the name of the button to move
  42356. * @param buttonValue the value of the button which determines the buttons new position
  42357. */
  42358. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42359. /**
  42360. * Moves the axis on the controller mesh based on its current state
  42361. * @param axis the index of the axis
  42362. * @param axisValue the value of the axis which determines the meshes new position
  42363. * @hidden
  42364. */
  42365. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42366. /**
  42367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42368. * @param scene scene in which to add meshes
  42369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42370. */
  42371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42372. /**
  42373. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42374. * can be transformed by button presses and axes values, based on this._mapping.
  42375. *
  42376. * @param scene scene in which the meshes exist
  42377. * @param meshes list of meshes that make up the controller model to process
  42378. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42379. */
  42380. private processModel;
  42381. private createMeshInfo;
  42382. /**
  42383. * Gets the ray of the controller in the direction the controller is pointing
  42384. * @param length the length the resulting ray should be
  42385. * @returns a ray in the direction the controller is pointing
  42386. */
  42387. getForwardRay(length?: number): Ray;
  42388. /**
  42389. * Disposes of the controller
  42390. */
  42391. dispose(): void;
  42392. }
  42393. }
  42394. declare module BABYLON {
  42395. /**
  42396. * Class containing static functions to help procedurally build meshes
  42397. */
  42398. export class PolyhedronBuilder {
  42399. /**
  42400. * Creates a polyhedron mesh
  42401. * * 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
  42402. * * The parameter `size` (positive float, default 1) sets the polygon size
  42403. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42404. * * 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`
  42405. * * 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
  42406. * * 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)`)
  42407. * * 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
  42408. * * 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
  42409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42412. * @param name defines the name of the mesh
  42413. * @param options defines the options used to create the mesh
  42414. * @param scene defines the hosting scene
  42415. * @returns the polyhedron mesh
  42416. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42417. */
  42418. static CreatePolyhedron(name: string, options: {
  42419. type?: number;
  42420. size?: number;
  42421. sizeX?: number;
  42422. sizeY?: number;
  42423. sizeZ?: number;
  42424. custom?: any;
  42425. faceUV?: Vector4[];
  42426. faceColors?: Color4[];
  42427. flat?: boolean;
  42428. updatable?: boolean;
  42429. sideOrientation?: number;
  42430. frontUVs?: Vector4;
  42431. backUVs?: Vector4;
  42432. }, scene?: Nullable<Scene>): Mesh;
  42433. }
  42434. }
  42435. declare module BABYLON {
  42436. /**
  42437. * Gizmo that enables scaling a mesh along 3 axis
  42438. */
  42439. export class ScaleGizmo extends Gizmo {
  42440. /**
  42441. * Internal gizmo used for interactions on the x axis
  42442. */
  42443. xGizmo: AxisScaleGizmo;
  42444. /**
  42445. * Internal gizmo used for interactions on the y axis
  42446. */
  42447. yGizmo: AxisScaleGizmo;
  42448. /**
  42449. * Internal gizmo used for interactions on the z axis
  42450. */
  42451. zGizmo: AxisScaleGizmo;
  42452. /**
  42453. * Internal gizmo used to scale all axis equally
  42454. */
  42455. uniformScaleGizmo: AxisScaleGizmo;
  42456. private _meshAttached;
  42457. private _updateGizmoRotationToMatchAttachedMesh;
  42458. private _snapDistance;
  42459. private _scaleRatio;
  42460. private _uniformScalingMesh;
  42461. private _octahedron;
  42462. /** Fires an event when any of it's sub gizmos are dragged */
  42463. onDragStartObservable: Observable<unknown>;
  42464. /** Fires an event when any of it's sub gizmos are released from dragging */
  42465. onDragEndObservable: Observable<unknown>;
  42466. attachedMesh: Nullable<AbstractMesh>;
  42467. /**
  42468. * Creates a ScaleGizmo
  42469. * @param gizmoLayer The utility layer the gizmo will be added to
  42470. */
  42471. constructor(gizmoLayer?: UtilityLayerRenderer);
  42472. updateGizmoRotationToMatchAttachedMesh: boolean;
  42473. /**
  42474. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42475. */
  42476. snapDistance: number;
  42477. /**
  42478. * Ratio for the scale of the gizmo (Default: 1)
  42479. */
  42480. scaleRatio: number;
  42481. /**
  42482. * Disposes of the gizmo
  42483. */
  42484. dispose(): void;
  42485. }
  42486. }
  42487. declare module BABYLON {
  42488. /**
  42489. * Single axis scale gizmo
  42490. */
  42491. export class AxisScaleGizmo extends Gizmo {
  42492. /**
  42493. * Drag behavior responsible for the gizmos dragging interactions
  42494. */
  42495. dragBehavior: PointerDragBehavior;
  42496. private _pointerObserver;
  42497. /**
  42498. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42499. */
  42500. snapDistance: number;
  42501. /**
  42502. * Event that fires each time the gizmo snaps to a new location.
  42503. * * snapDistance is the the change in distance
  42504. */
  42505. onSnapObservable: Observable<{
  42506. snapDistance: number;
  42507. }>;
  42508. /**
  42509. * If the scaling operation should be done on all axis (default: false)
  42510. */
  42511. uniformScaling: boolean;
  42512. private _isEnabled;
  42513. private _parent;
  42514. private _arrow;
  42515. private _coloredMaterial;
  42516. private _hoverMaterial;
  42517. /**
  42518. * Creates an AxisScaleGizmo
  42519. * @param gizmoLayer The utility layer the gizmo will be added to
  42520. * @param dragAxis The axis which the gizmo will be able to scale on
  42521. * @param color The color of the gizmo
  42522. */
  42523. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  42524. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42525. /**
  42526. * If the gizmo is enabled
  42527. */
  42528. isEnabled: boolean;
  42529. /**
  42530. * Disposes of the gizmo
  42531. */
  42532. dispose(): void;
  42533. /**
  42534. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42535. * @param mesh The mesh to replace the default mesh of the gizmo
  42536. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42537. */
  42538. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42539. }
  42540. }
  42541. declare module BABYLON {
  42542. /**
  42543. * Bounding box gizmo
  42544. */
  42545. export class BoundingBoxGizmo extends Gizmo {
  42546. private _lineBoundingBox;
  42547. private _rotateSpheresParent;
  42548. private _scaleBoxesParent;
  42549. private _boundingDimensions;
  42550. private _renderObserver;
  42551. private _pointerObserver;
  42552. private _scaleDragSpeed;
  42553. private _tmpQuaternion;
  42554. private _tmpVector;
  42555. private _tmpRotationMatrix;
  42556. /**
  42557. * 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)
  42558. */
  42559. ignoreChildren: boolean;
  42560. /**
  42561. * 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)
  42562. */
  42563. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42564. /**
  42565. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42566. */
  42567. rotationSphereSize: number;
  42568. /**
  42569. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42570. */
  42571. scaleBoxSize: number;
  42572. /**
  42573. * 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)
  42574. */
  42575. fixedDragMeshScreenSize: boolean;
  42576. /**
  42577. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42578. */
  42579. fixedDragMeshScreenSizeDistanceFactor: number;
  42580. /**
  42581. * Fired when a rotation sphere or scale box is dragged
  42582. */
  42583. onDragStartObservable: Observable<{}>;
  42584. /**
  42585. * Fired when a scale box is dragged
  42586. */
  42587. onScaleBoxDragObservable: Observable<{}>;
  42588. /**
  42589. * Fired when a scale box drag is ended
  42590. */
  42591. onScaleBoxDragEndObservable: Observable<{}>;
  42592. /**
  42593. * Fired when a rotation sphere is dragged
  42594. */
  42595. onRotationSphereDragObservable: Observable<{}>;
  42596. /**
  42597. * Fired when a rotation sphere drag is ended
  42598. */
  42599. onRotationSphereDragEndObservable: Observable<{}>;
  42600. /**
  42601. * 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)
  42602. */
  42603. scalePivot: Nullable<Vector3>;
  42604. /**
  42605. * Mesh used as a pivot to rotate the attached mesh
  42606. */
  42607. private _anchorMesh;
  42608. private _existingMeshScale;
  42609. private _dragMesh;
  42610. private pointerDragBehavior;
  42611. private coloredMaterial;
  42612. private hoverColoredMaterial;
  42613. /**
  42614. * Sets the color of the bounding box gizmo
  42615. * @param color the color to set
  42616. */
  42617. setColor(color: Color3): void;
  42618. /**
  42619. * Creates an BoundingBoxGizmo
  42620. * @param gizmoLayer The utility layer the gizmo will be added to
  42621. * @param color The color of the gizmo
  42622. */
  42623. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42624. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42625. private _selectNode;
  42626. /**
  42627. * Updates the bounding box information for the Gizmo
  42628. */
  42629. updateBoundingBox(): void;
  42630. private _updateRotationSpheres;
  42631. private _updateScaleBoxes;
  42632. /**
  42633. * Enables rotation on the specified axis and disables rotation on the others
  42634. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42635. */
  42636. setEnabledRotationAxis(axis: string): void;
  42637. /**
  42638. * Enables/disables scaling
  42639. * @param enable if scaling should be enabled
  42640. */
  42641. setEnabledScaling(enable: boolean): void;
  42642. private _updateDummy;
  42643. /**
  42644. * Enables a pointer drag behavior on the bounding box of the gizmo
  42645. */
  42646. enableDragBehavior(): void;
  42647. /**
  42648. * Disposes of the gizmo
  42649. */
  42650. dispose(): void;
  42651. /**
  42652. * 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)
  42653. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42654. * @returns the bounding box mesh with the passed in mesh as a child
  42655. */
  42656. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42657. /**
  42658. * CustomMeshes are not supported by this gizmo
  42659. * @param mesh The mesh to replace the default mesh of the gizmo
  42660. */
  42661. setCustomMesh(mesh: Mesh): void;
  42662. }
  42663. }
  42664. declare module BABYLON {
  42665. /**
  42666. * Single plane rotation gizmo
  42667. */
  42668. export class PlaneRotationGizmo extends Gizmo {
  42669. /**
  42670. * Drag behavior responsible for the gizmos dragging interactions
  42671. */
  42672. dragBehavior: PointerDragBehavior;
  42673. private _pointerObserver;
  42674. /**
  42675. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42676. */
  42677. snapDistance: number;
  42678. /**
  42679. * Event that fires each time the gizmo snaps to a new location.
  42680. * * snapDistance is the the change in distance
  42681. */
  42682. onSnapObservable: Observable<{
  42683. snapDistance: number;
  42684. }>;
  42685. private _isEnabled;
  42686. private _parent;
  42687. /**
  42688. * Creates a PlaneRotationGizmo
  42689. * @param gizmoLayer The utility layer the gizmo will be added to
  42690. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42691. * @param color The color of the gizmo
  42692. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42693. */
  42694. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  42695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42696. /**
  42697. * If the gizmo is enabled
  42698. */
  42699. isEnabled: boolean;
  42700. /**
  42701. * Disposes of the gizmo
  42702. */
  42703. dispose(): void;
  42704. }
  42705. }
  42706. declare module BABYLON {
  42707. /**
  42708. * Gizmo that enables rotating a mesh along 3 axis
  42709. */
  42710. export class RotationGizmo extends Gizmo {
  42711. /**
  42712. * Internal gizmo used for interactions on the x axis
  42713. */
  42714. xGizmo: PlaneRotationGizmo;
  42715. /**
  42716. * Internal gizmo used for interactions on the y axis
  42717. */
  42718. yGizmo: PlaneRotationGizmo;
  42719. /**
  42720. * Internal gizmo used for interactions on the z axis
  42721. */
  42722. zGizmo: PlaneRotationGizmo;
  42723. /** Fires an event when any of it's sub gizmos are dragged */
  42724. onDragStartObservable: Observable<unknown>;
  42725. /** Fires an event when any of it's sub gizmos are released from dragging */
  42726. onDragEndObservable: Observable<unknown>;
  42727. private _meshAttached;
  42728. attachedMesh: Nullable<AbstractMesh>;
  42729. /**
  42730. * Creates a RotationGizmo
  42731. * @param gizmoLayer The utility layer the gizmo will be added to
  42732. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42733. */
  42734. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42735. updateGizmoRotationToMatchAttachedMesh: boolean;
  42736. /**
  42737. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42738. */
  42739. snapDistance: number;
  42740. /**
  42741. * Ratio for the scale of the gizmo (Default: 1)
  42742. */
  42743. scaleRatio: number;
  42744. /**
  42745. * Disposes of the gizmo
  42746. */
  42747. dispose(): void;
  42748. /**
  42749. * CustomMeshes are not supported by this gizmo
  42750. * @param mesh The mesh to replace the default mesh of the gizmo
  42751. */
  42752. setCustomMesh(mesh: Mesh): void;
  42753. }
  42754. }
  42755. declare module BABYLON {
  42756. /**
  42757. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42758. */
  42759. export class GizmoManager implements IDisposable {
  42760. private scene;
  42761. /**
  42762. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42763. */
  42764. gizmos: {
  42765. positionGizmo: Nullable<PositionGizmo>;
  42766. rotationGizmo: Nullable<RotationGizmo>;
  42767. scaleGizmo: Nullable<ScaleGizmo>;
  42768. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42769. };
  42770. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42771. clearGizmoOnEmptyPointerEvent: boolean;
  42772. /** Fires an event when the manager is attached to a mesh */
  42773. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42774. private _gizmosEnabled;
  42775. private _pointerObserver;
  42776. private _attachedMesh;
  42777. private _boundingBoxColor;
  42778. private _defaultUtilityLayer;
  42779. private _defaultKeepDepthUtilityLayer;
  42780. /**
  42781. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42782. */
  42783. boundingBoxDragBehavior: SixDofDragBehavior;
  42784. /**
  42785. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42786. */
  42787. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42788. /**
  42789. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42790. */
  42791. usePointerToAttachGizmos: boolean;
  42792. /**
  42793. * Utility layer that the bounding box gizmo belongs to
  42794. */
  42795. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  42796. /**
  42797. * Utility layer that all gizmos besides bounding box belong to
  42798. */
  42799. readonly utilityLayer: UtilityLayerRenderer;
  42800. /**
  42801. * Instatiates a gizmo manager
  42802. * @param scene the scene to overlay the gizmos on top of
  42803. */
  42804. constructor(scene: Scene);
  42805. /**
  42806. * Attaches a set of gizmos to the specified mesh
  42807. * @param mesh The mesh the gizmo's should be attached to
  42808. */
  42809. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42810. /**
  42811. * If the position gizmo is enabled
  42812. */
  42813. positionGizmoEnabled: boolean;
  42814. /**
  42815. * If the rotation gizmo is enabled
  42816. */
  42817. rotationGizmoEnabled: boolean;
  42818. /**
  42819. * If the scale gizmo is enabled
  42820. */
  42821. scaleGizmoEnabled: boolean;
  42822. /**
  42823. * If the boundingBox gizmo is enabled
  42824. */
  42825. boundingBoxGizmoEnabled: boolean;
  42826. /**
  42827. * Disposes of the gizmo manager
  42828. */
  42829. dispose(): void;
  42830. }
  42831. }
  42832. declare module BABYLON {
  42833. /**
  42834. * A directional light is defined by a direction (what a surprise!).
  42835. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42836. * 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.
  42837. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42838. */
  42839. export class DirectionalLight extends ShadowLight {
  42840. private _shadowFrustumSize;
  42841. /**
  42842. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42843. */
  42844. /**
  42845. * Specifies a fix frustum size for the shadow generation.
  42846. */
  42847. shadowFrustumSize: number;
  42848. private _shadowOrthoScale;
  42849. /**
  42850. * Gets the shadow projection scale against the optimal computed one.
  42851. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42852. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42853. */
  42854. /**
  42855. * Sets the shadow projection scale against the optimal computed one.
  42856. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42857. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42858. */
  42859. shadowOrthoScale: number;
  42860. /**
  42861. * Automatically compute the projection matrix to best fit (including all the casters)
  42862. * on each frame.
  42863. */
  42864. autoUpdateExtends: boolean;
  42865. private _orthoLeft;
  42866. private _orthoRight;
  42867. private _orthoTop;
  42868. private _orthoBottom;
  42869. /**
  42870. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42871. * The directional light is emitted from everywhere in the given direction.
  42872. * It can cast shadows.
  42873. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42874. * @param name The friendly name of the light
  42875. * @param direction The direction of the light
  42876. * @param scene The scene the light belongs to
  42877. */
  42878. constructor(name: string, direction: Vector3, scene: Scene);
  42879. /**
  42880. * Returns the string "DirectionalLight".
  42881. * @return The class name
  42882. */
  42883. getClassName(): string;
  42884. /**
  42885. * Returns the integer 1.
  42886. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42887. */
  42888. getTypeID(): number;
  42889. /**
  42890. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42891. * Returns the DirectionalLight Shadow projection matrix.
  42892. */
  42893. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42894. /**
  42895. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42896. * Returns the DirectionalLight Shadow projection matrix.
  42897. */
  42898. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42899. /**
  42900. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42901. * Returns the DirectionalLight Shadow projection matrix.
  42902. */
  42903. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42904. protected _buildUniformLayout(): void;
  42905. /**
  42906. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42907. * @param effect The effect to update
  42908. * @param lightIndex The index of the light in the effect to update
  42909. * @returns The directional light
  42910. */
  42911. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42912. /**
  42913. * Gets the minZ used for shadow according to both the scene and the light.
  42914. *
  42915. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42916. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42917. * @param activeCamera The camera we are returning the min for
  42918. * @returns the depth min z
  42919. */
  42920. getDepthMinZ(activeCamera: Camera): number;
  42921. /**
  42922. * Gets the maxZ used for shadow according to both the scene and the light.
  42923. *
  42924. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42925. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42926. * @param activeCamera The camera we are returning the max for
  42927. * @returns the depth max z
  42928. */
  42929. getDepthMaxZ(activeCamera: Camera): number;
  42930. /**
  42931. * Prepares the list of defines specific to the light type.
  42932. * @param defines the list of defines
  42933. * @param lightIndex defines the index of the light for the effect
  42934. */
  42935. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42936. }
  42937. }
  42938. declare module BABYLON {
  42939. /**
  42940. * Class containing static functions to help procedurally build meshes
  42941. */
  42942. export class HemisphereBuilder {
  42943. /**
  42944. * Creates a hemisphere mesh
  42945. * @param name defines the name of the mesh
  42946. * @param options defines the options used to create the mesh
  42947. * @param scene defines the hosting scene
  42948. * @returns the hemisphere mesh
  42949. */
  42950. static CreateHemisphere(name: string, options: {
  42951. segments?: number;
  42952. diameter?: number;
  42953. sideOrientation?: number;
  42954. }, scene: any): Mesh;
  42955. }
  42956. }
  42957. declare module BABYLON {
  42958. /**
  42959. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42960. * These values define a cone of light starting from the position, emitting toward the direction.
  42961. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42962. * and the exponent defines the speed of the decay of the light with distance (reach).
  42963. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42964. */
  42965. export class SpotLight extends ShadowLight {
  42966. private _angle;
  42967. private _innerAngle;
  42968. private _cosHalfAngle;
  42969. private _lightAngleScale;
  42970. private _lightAngleOffset;
  42971. /**
  42972. * Gets the cone angle of the spot light in Radians.
  42973. */
  42974. /**
  42975. * Sets the cone angle of the spot light in Radians.
  42976. */
  42977. angle: number;
  42978. /**
  42979. * Only used in gltf falloff mode, this defines the angle where
  42980. * the directional falloff will start before cutting at angle which could be seen
  42981. * as outer angle.
  42982. */
  42983. /**
  42984. * Only used in gltf falloff mode, this defines the angle where
  42985. * the directional falloff will start before cutting at angle which could be seen
  42986. * as outer angle.
  42987. */
  42988. innerAngle: number;
  42989. private _shadowAngleScale;
  42990. /**
  42991. * Allows scaling the angle of the light for shadow generation only.
  42992. */
  42993. /**
  42994. * Allows scaling the angle of the light for shadow generation only.
  42995. */
  42996. shadowAngleScale: number;
  42997. /**
  42998. * The light decay speed with the distance from the emission spot.
  42999. */
  43000. exponent: number;
  43001. private _projectionTextureMatrix;
  43002. /**
  43003. * Allows reading the projecton texture
  43004. */
  43005. readonly projectionTextureMatrix: Matrix;
  43006. protected _projectionTextureLightNear: number;
  43007. /**
  43008. * Gets the near clip of the Spotlight for texture projection.
  43009. */
  43010. /**
  43011. * Sets the near clip of the Spotlight for texture projection.
  43012. */
  43013. projectionTextureLightNear: number;
  43014. protected _projectionTextureLightFar: number;
  43015. /**
  43016. * Gets the far clip of the Spotlight for texture projection.
  43017. */
  43018. /**
  43019. * Sets the far clip of the Spotlight for texture projection.
  43020. */
  43021. projectionTextureLightFar: number;
  43022. protected _projectionTextureUpDirection: Vector3;
  43023. /**
  43024. * Gets the Up vector of the Spotlight for texture projection.
  43025. */
  43026. /**
  43027. * Sets the Up vector of the Spotlight for texture projection.
  43028. */
  43029. projectionTextureUpDirection: Vector3;
  43030. private _projectionTexture;
  43031. /**
  43032. * Gets the projection texture of the light.
  43033. */
  43034. /**
  43035. * Sets the projection texture of the light.
  43036. */
  43037. projectionTexture: Nullable<BaseTexture>;
  43038. private _projectionTextureViewLightDirty;
  43039. private _projectionTextureProjectionLightDirty;
  43040. private _projectionTextureDirty;
  43041. private _projectionTextureViewTargetVector;
  43042. private _projectionTextureViewLightMatrix;
  43043. private _projectionTextureProjectionLightMatrix;
  43044. private _projectionTextureScalingMatrix;
  43045. /**
  43046. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43047. * It can cast shadows.
  43048. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43049. * @param name The light friendly name
  43050. * @param position The position of the spot light in the scene
  43051. * @param direction The direction of the light in the scene
  43052. * @param angle The cone angle of the light in Radians
  43053. * @param exponent The light decay speed with the distance from the emission spot
  43054. * @param scene The scene the lights belongs to
  43055. */
  43056. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43057. /**
  43058. * Returns the string "SpotLight".
  43059. * @returns the class name
  43060. */
  43061. getClassName(): string;
  43062. /**
  43063. * Returns the integer 2.
  43064. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43065. */
  43066. getTypeID(): number;
  43067. /**
  43068. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43069. */
  43070. protected _setDirection(value: Vector3): void;
  43071. /**
  43072. * Overrides the position setter to recompute the projection texture view light Matrix.
  43073. */
  43074. protected _setPosition(value: Vector3): void;
  43075. /**
  43076. * 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.
  43077. * Returns the SpotLight.
  43078. */
  43079. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43080. protected _computeProjectionTextureViewLightMatrix(): void;
  43081. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43082. /**
  43083. * Main function for light texture projection matrix computing.
  43084. */
  43085. protected _computeProjectionTextureMatrix(): void;
  43086. protected _buildUniformLayout(): void;
  43087. private _computeAngleValues;
  43088. /**
  43089. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43090. * @param effect The effect to update
  43091. * @param lightIndex The index of the light in the effect to update
  43092. * @returns The spot light
  43093. */
  43094. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43095. /**
  43096. * Disposes the light and the associated resources.
  43097. */
  43098. dispose(): void;
  43099. /**
  43100. * Prepares the list of defines specific to the light type.
  43101. * @param defines the list of defines
  43102. * @param lightIndex defines the index of the light for the effect
  43103. */
  43104. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43105. }
  43106. }
  43107. declare module BABYLON {
  43108. /**
  43109. * Gizmo that enables viewing a light
  43110. */
  43111. export class LightGizmo extends Gizmo {
  43112. private _lightMesh;
  43113. private _material;
  43114. private cachedPosition;
  43115. private cachedForward;
  43116. /**
  43117. * Creates a LightGizmo
  43118. * @param gizmoLayer The utility layer the gizmo will be added to
  43119. */
  43120. constructor(gizmoLayer?: UtilityLayerRenderer);
  43121. private _light;
  43122. /**
  43123. * The light that the gizmo is attached to
  43124. */
  43125. light: Nullable<Light>;
  43126. /**
  43127. * @hidden
  43128. * Updates the gizmo to match the attached mesh's position/rotation
  43129. */
  43130. protected _update(): void;
  43131. private static _Scale;
  43132. /**
  43133. * Creates the lines for a light mesh
  43134. */
  43135. private static _createLightLines;
  43136. /**
  43137. * Disposes of the light gizmo
  43138. */
  43139. dispose(): void;
  43140. private static _CreateHemisphericLightMesh;
  43141. private static _CreatePointLightMesh;
  43142. private static _CreateSpotLightMesh;
  43143. private static _CreateDirectionalLightMesh;
  43144. }
  43145. }
  43146. declare module BABYLON {
  43147. /** @hidden */
  43148. export var backgroundFragmentDeclaration: {
  43149. name: string;
  43150. shader: string;
  43151. };
  43152. }
  43153. declare module BABYLON {
  43154. /** @hidden */
  43155. export var backgroundUboDeclaration: {
  43156. name: string;
  43157. shader: string;
  43158. };
  43159. }
  43160. declare module BABYLON {
  43161. /** @hidden */
  43162. export var backgroundPixelShader: {
  43163. name: string;
  43164. shader: string;
  43165. };
  43166. }
  43167. declare module BABYLON {
  43168. /** @hidden */
  43169. export var backgroundVertexDeclaration: {
  43170. name: string;
  43171. shader: string;
  43172. };
  43173. }
  43174. declare module BABYLON {
  43175. /** @hidden */
  43176. export var backgroundVertexShader: {
  43177. name: string;
  43178. shader: string;
  43179. };
  43180. }
  43181. declare module BABYLON {
  43182. /**
  43183. * Background material used to create an efficient environement around your scene.
  43184. */
  43185. export class BackgroundMaterial extends PushMaterial {
  43186. /**
  43187. * Standard reflectance value at parallel view angle.
  43188. */
  43189. static StandardReflectance0: number;
  43190. /**
  43191. * Standard reflectance value at grazing angle.
  43192. */
  43193. static StandardReflectance90: number;
  43194. protected _primaryColor: Color3;
  43195. /**
  43196. * Key light Color (multiply against the environement texture)
  43197. */
  43198. primaryColor: Color3;
  43199. protected __perceptualColor: Nullable<Color3>;
  43200. /**
  43201. * Experimental Internal Use Only.
  43202. *
  43203. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43204. * This acts as a helper to set the primary color to a more "human friendly" value.
  43205. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43206. * output color as close as possible from the chosen value.
  43207. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43208. * part of lighting setup.)
  43209. */ private _perceptualColor: Nullable<Color3>;
  43210. protected _primaryColorShadowLevel: float;
  43211. /**
  43212. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43213. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43214. */
  43215. primaryColorShadowLevel: float;
  43216. protected _primaryColorHighlightLevel: float;
  43217. /**
  43218. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43219. * The primary color is used at the level chosen to define what the white area would look.
  43220. */
  43221. primaryColorHighlightLevel: float;
  43222. protected _reflectionTexture: Nullable<BaseTexture>;
  43223. /**
  43224. * Reflection Texture used in the material.
  43225. * Should be author in a specific way for the best result (refer to the documentation).
  43226. */
  43227. reflectionTexture: Nullable<BaseTexture>;
  43228. protected _reflectionBlur: float;
  43229. /**
  43230. * Reflection Texture level of blur.
  43231. *
  43232. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43233. * texture twice.
  43234. */
  43235. reflectionBlur: float;
  43236. protected _diffuseTexture: Nullable<BaseTexture>;
  43237. /**
  43238. * Diffuse Texture used in the material.
  43239. * Should be author in a specific way for the best result (refer to the documentation).
  43240. */
  43241. diffuseTexture: Nullable<BaseTexture>;
  43242. protected _shadowLights: Nullable<IShadowLight[]>;
  43243. /**
  43244. * Specify the list of lights casting shadow on the material.
  43245. * All scene shadow lights will be included if null.
  43246. */
  43247. shadowLights: Nullable<IShadowLight[]>;
  43248. protected _shadowLevel: float;
  43249. /**
  43250. * Helps adjusting the shadow to a softer level if required.
  43251. * 0 means black shadows and 1 means no shadows.
  43252. */
  43253. shadowLevel: float;
  43254. protected _sceneCenter: Vector3;
  43255. /**
  43256. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43257. * It is usually zero but might be interesting to modify according to your setup.
  43258. */
  43259. sceneCenter: Vector3;
  43260. protected _opacityFresnel: boolean;
  43261. /**
  43262. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43263. * This helps ensuring a nice transition when the camera goes under the ground.
  43264. */
  43265. opacityFresnel: boolean;
  43266. protected _reflectionFresnel: boolean;
  43267. /**
  43268. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43269. * This helps adding a mirror texture on the ground.
  43270. */
  43271. reflectionFresnel: boolean;
  43272. protected _reflectionFalloffDistance: number;
  43273. /**
  43274. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43275. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43276. */
  43277. reflectionFalloffDistance: number;
  43278. protected _reflectionAmount: number;
  43279. /**
  43280. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43281. */
  43282. reflectionAmount: number;
  43283. protected _reflectionReflectance0: number;
  43284. /**
  43285. * This specifies the weight of the reflection at grazing angle.
  43286. */
  43287. reflectionReflectance0: number;
  43288. protected _reflectionReflectance90: number;
  43289. /**
  43290. * This specifies the weight of the reflection at a perpendicular point of view.
  43291. */
  43292. reflectionReflectance90: number;
  43293. /**
  43294. * Sets the reflection reflectance fresnel values according to the default standard
  43295. * empirically know to work well :-)
  43296. */
  43297. reflectionStandardFresnelWeight: number;
  43298. protected _useRGBColor: boolean;
  43299. /**
  43300. * Helps to directly use the maps channels instead of their level.
  43301. */
  43302. useRGBColor: boolean;
  43303. protected _enableNoise: boolean;
  43304. /**
  43305. * This helps reducing the banding effect that could occur on the background.
  43306. */
  43307. enableNoise: boolean;
  43308. /**
  43309. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43310. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43311. * Recommended to be keep at 1.0 except for special cases.
  43312. */
  43313. fovMultiplier: number;
  43314. private _fovMultiplier;
  43315. /**
  43316. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43317. */
  43318. useEquirectangularFOV: boolean;
  43319. private _maxSimultaneousLights;
  43320. /**
  43321. * Number of Simultaneous lights allowed on the material.
  43322. */
  43323. maxSimultaneousLights: int;
  43324. /**
  43325. * Default configuration related to image processing available in the Background Material.
  43326. */
  43327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43328. /**
  43329. * Keep track of the image processing observer to allow dispose and replace.
  43330. */
  43331. private _imageProcessingObserver;
  43332. /**
  43333. * Attaches a new image processing configuration to the PBR Material.
  43334. * @param configuration (if null the scene configuration will be use)
  43335. */
  43336. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43337. /**
  43338. * Gets the image processing configuration used either in this material.
  43339. */
  43340. /**
  43341. * Sets the Default image processing configuration used either in the this material.
  43342. *
  43343. * If sets to null, the scene one is in use.
  43344. */
  43345. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43346. /**
  43347. * Gets wether the color curves effect is enabled.
  43348. */
  43349. /**
  43350. * Sets wether the color curves effect is enabled.
  43351. */
  43352. cameraColorCurvesEnabled: boolean;
  43353. /**
  43354. * Gets wether the color grading effect is enabled.
  43355. */
  43356. /**
  43357. * Gets wether the color grading effect is enabled.
  43358. */
  43359. cameraColorGradingEnabled: boolean;
  43360. /**
  43361. * Gets wether tonemapping is enabled or not.
  43362. */
  43363. /**
  43364. * Sets wether tonemapping is enabled or not
  43365. */
  43366. cameraToneMappingEnabled: boolean;
  43367. /**
  43368. * The camera exposure used on this material.
  43369. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43370. * This corresponds to a photographic exposure.
  43371. */
  43372. /**
  43373. * The camera exposure used on this material.
  43374. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43375. * This corresponds to a photographic exposure.
  43376. */
  43377. cameraExposure: float;
  43378. /**
  43379. * Gets The camera contrast used on this material.
  43380. */
  43381. /**
  43382. * Sets The camera contrast used on this material.
  43383. */
  43384. cameraContrast: float;
  43385. /**
  43386. * Gets the Color Grading 2D Lookup Texture.
  43387. */
  43388. /**
  43389. * Sets the Color Grading 2D Lookup Texture.
  43390. */
  43391. cameraColorGradingTexture: Nullable<BaseTexture>;
  43392. /**
  43393. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43394. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43395. * 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;
  43396. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43397. */
  43398. /**
  43399. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43400. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43401. * 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;
  43402. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43403. */
  43404. cameraColorCurves: Nullable<ColorCurves>;
  43405. /**
  43406. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43407. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43408. */
  43409. switchToBGR: boolean;
  43410. private _renderTargets;
  43411. private _reflectionControls;
  43412. private _white;
  43413. private _primaryShadowColor;
  43414. private _primaryHighlightColor;
  43415. /**
  43416. * Instantiates a Background Material in the given scene
  43417. * @param name The friendly name of the material
  43418. * @param scene The scene to add the material to
  43419. */
  43420. constructor(name: string, scene: Scene);
  43421. /**
  43422. * Gets a boolean indicating that current material needs to register RTT
  43423. */
  43424. readonly hasRenderTargetTextures: boolean;
  43425. /**
  43426. * The entire material has been created in order to prevent overdraw.
  43427. * @returns false
  43428. */
  43429. needAlphaTesting(): boolean;
  43430. /**
  43431. * The entire material has been created in order to prevent overdraw.
  43432. * @returns true if blending is enable
  43433. */
  43434. needAlphaBlending(): boolean;
  43435. /**
  43436. * Checks wether the material is ready to be rendered for a given mesh.
  43437. * @param mesh The mesh to render
  43438. * @param subMesh The submesh to check against
  43439. * @param useInstances Specify wether or not the material is used with instances
  43440. * @returns true if all the dependencies are ready (Textures, Effects...)
  43441. */
  43442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43443. /**
  43444. * Compute the primary color according to the chosen perceptual color.
  43445. */
  43446. private _computePrimaryColorFromPerceptualColor;
  43447. /**
  43448. * Compute the highlights and shadow colors according to their chosen levels.
  43449. */
  43450. private _computePrimaryColors;
  43451. /**
  43452. * Build the uniform buffer used in the material.
  43453. */
  43454. buildUniformLayout(): void;
  43455. /**
  43456. * Unbind the material.
  43457. */
  43458. unbind(): void;
  43459. /**
  43460. * Bind only the world matrix to the material.
  43461. * @param world The world matrix to bind.
  43462. */
  43463. bindOnlyWorldMatrix(world: Matrix): void;
  43464. /**
  43465. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43466. * @param world The world matrix to bind.
  43467. * @param subMesh The submesh to bind for.
  43468. */
  43469. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43470. /**
  43471. * Dispose the material.
  43472. * @param forceDisposeEffect Force disposal of the associated effect.
  43473. * @param forceDisposeTextures Force disposal of the associated textures.
  43474. */
  43475. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43476. /**
  43477. * Clones the material.
  43478. * @param name The cloned name.
  43479. * @returns The cloned material.
  43480. */
  43481. clone(name: string): BackgroundMaterial;
  43482. /**
  43483. * Serializes the current material to its JSON representation.
  43484. * @returns The JSON representation.
  43485. */
  43486. serialize(): any;
  43487. /**
  43488. * Gets the class name of the material
  43489. * @returns "BackgroundMaterial"
  43490. */
  43491. getClassName(): string;
  43492. /**
  43493. * Parse a JSON input to create back a background material.
  43494. * @param source The JSON data to parse
  43495. * @param scene The scene to create the parsed material in
  43496. * @param rootUrl The root url of the assets the material depends upon
  43497. * @returns the instantiated BackgroundMaterial.
  43498. */
  43499. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43500. }
  43501. }
  43502. declare module BABYLON {
  43503. /**
  43504. * Represents the different options available during the creation of
  43505. * a Environment helper.
  43506. *
  43507. * This can control the default ground, skybox and image processing setup of your scene.
  43508. */
  43509. export interface IEnvironmentHelperOptions {
  43510. /**
  43511. * Specifies wether or not to create a ground.
  43512. * True by default.
  43513. */
  43514. createGround: boolean;
  43515. /**
  43516. * Specifies the ground size.
  43517. * 15 by default.
  43518. */
  43519. groundSize: number;
  43520. /**
  43521. * The texture used on the ground for the main color.
  43522. * Comes from the BabylonJS CDN by default.
  43523. *
  43524. * Remarks: Can be either a texture or a url.
  43525. */
  43526. groundTexture: string | BaseTexture;
  43527. /**
  43528. * The color mixed in the ground texture by default.
  43529. * BabylonJS clearColor by default.
  43530. */
  43531. groundColor: Color3;
  43532. /**
  43533. * Specifies the ground opacity.
  43534. * 1 by default.
  43535. */
  43536. groundOpacity: number;
  43537. /**
  43538. * Enables the ground to receive shadows.
  43539. * True by default.
  43540. */
  43541. enableGroundShadow: boolean;
  43542. /**
  43543. * Helps preventing the shadow to be fully black on the ground.
  43544. * 0.5 by default.
  43545. */
  43546. groundShadowLevel: number;
  43547. /**
  43548. * Creates a mirror texture attach to the ground.
  43549. * false by default.
  43550. */
  43551. enableGroundMirror: boolean;
  43552. /**
  43553. * Specifies the ground mirror size ratio.
  43554. * 0.3 by default as the default kernel is 64.
  43555. */
  43556. groundMirrorSizeRatio: number;
  43557. /**
  43558. * Specifies the ground mirror blur kernel size.
  43559. * 64 by default.
  43560. */
  43561. groundMirrorBlurKernel: number;
  43562. /**
  43563. * Specifies the ground mirror visibility amount.
  43564. * 1 by default
  43565. */
  43566. groundMirrorAmount: number;
  43567. /**
  43568. * Specifies the ground mirror reflectance weight.
  43569. * This uses the standard weight of the background material to setup the fresnel effect
  43570. * of the mirror.
  43571. * 1 by default.
  43572. */
  43573. groundMirrorFresnelWeight: number;
  43574. /**
  43575. * Specifies the ground mirror Falloff distance.
  43576. * This can helps reducing the size of the reflection.
  43577. * 0 by Default.
  43578. */
  43579. groundMirrorFallOffDistance: number;
  43580. /**
  43581. * Specifies the ground mirror texture type.
  43582. * Unsigned Int by Default.
  43583. */
  43584. groundMirrorTextureType: number;
  43585. /**
  43586. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43587. * the shown objects.
  43588. */
  43589. groundYBias: number;
  43590. /**
  43591. * Specifies wether or not to create a skybox.
  43592. * True by default.
  43593. */
  43594. createSkybox: boolean;
  43595. /**
  43596. * Specifies the skybox size.
  43597. * 20 by default.
  43598. */
  43599. skyboxSize: number;
  43600. /**
  43601. * The texture used on the skybox for the main color.
  43602. * Comes from the BabylonJS CDN by default.
  43603. *
  43604. * Remarks: Can be either a texture or a url.
  43605. */
  43606. skyboxTexture: string | BaseTexture;
  43607. /**
  43608. * The color mixed in the skybox texture by default.
  43609. * BabylonJS clearColor by default.
  43610. */
  43611. skyboxColor: Color3;
  43612. /**
  43613. * The background rotation around the Y axis of the scene.
  43614. * This helps aligning the key lights of your scene with the background.
  43615. * 0 by default.
  43616. */
  43617. backgroundYRotation: number;
  43618. /**
  43619. * Compute automatically the size of the elements to best fit with the scene.
  43620. */
  43621. sizeAuto: boolean;
  43622. /**
  43623. * Default position of the rootMesh if autoSize is not true.
  43624. */
  43625. rootPosition: Vector3;
  43626. /**
  43627. * Sets up the image processing in the scene.
  43628. * true by default.
  43629. */
  43630. setupImageProcessing: boolean;
  43631. /**
  43632. * The texture used as your environment texture in the scene.
  43633. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43634. *
  43635. * Remarks: Can be either a texture or a url.
  43636. */
  43637. environmentTexture: string | BaseTexture;
  43638. /**
  43639. * The value of the exposure to apply to the scene.
  43640. * 0.6 by default if setupImageProcessing is true.
  43641. */
  43642. cameraExposure: number;
  43643. /**
  43644. * The value of the contrast to apply to the scene.
  43645. * 1.6 by default if setupImageProcessing is true.
  43646. */
  43647. cameraContrast: number;
  43648. /**
  43649. * Specifies wether or not tonemapping should be enabled in the scene.
  43650. * true by default if setupImageProcessing is true.
  43651. */
  43652. toneMappingEnabled: boolean;
  43653. }
  43654. /**
  43655. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43656. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43657. * It also helps with the default setup of your imageProcessing configuration.
  43658. */
  43659. export class EnvironmentHelper {
  43660. /**
  43661. * Default ground texture URL.
  43662. */
  43663. private static _groundTextureCDNUrl;
  43664. /**
  43665. * Default skybox texture URL.
  43666. */
  43667. private static _skyboxTextureCDNUrl;
  43668. /**
  43669. * Default environment texture URL.
  43670. */
  43671. private static _environmentTextureCDNUrl;
  43672. /**
  43673. * Creates the default options for the helper.
  43674. */
  43675. private static _getDefaultOptions;
  43676. private _rootMesh;
  43677. /**
  43678. * Gets the root mesh created by the helper.
  43679. */
  43680. readonly rootMesh: Mesh;
  43681. private _skybox;
  43682. /**
  43683. * Gets the skybox created by the helper.
  43684. */
  43685. readonly skybox: Nullable<Mesh>;
  43686. private _skyboxTexture;
  43687. /**
  43688. * Gets the skybox texture created by the helper.
  43689. */
  43690. readonly skyboxTexture: Nullable<BaseTexture>;
  43691. private _skyboxMaterial;
  43692. /**
  43693. * Gets the skybox material created by the helper.
  43694. */
  43695. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43696. private _ground;
  43697. /**
  43698. * Gets the ground mesh created by the helper.
  43699. */
  43700. readonly ground: Nullable<Mesh>;
  43701. private _groundTexture;
  43702. /**
  43703. * Gets the ground texture created by the helper.
  43704. */
  43705. readonly groundTexture: Nullable<BaseTexture>;
  43706. private _groundMirror;
  43707. /**
  43708. * Gets the ground mirror created by the helper.
  43709. */
  43710. readonly groundMirror: Nullable<MirrorTexture>;
  43711. /**
  43712. * Gets the ground mirror render list to helps pushing the meshes
  43713. * you wish in the ground reflection.
  43714. */
  43715. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43716. private _groundMaterial;
  43717. /**
  43718. * Gets the ground material created by the helper.
  43719. */
  43720. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43721. /**
  43722. * Stores the creation options.
  43723. */
  43724. private readonly _scene;
  43725. private _options;
  43726. /**
  43727. * This observable will be notified with any error during the creation of the environment,
  43728. * mainly texture creation errors.
  43729. */
  43730. onErrorObservable: Observable<{
  43731. message?: string;
  43732. exception?: any;
  43733. }>;
  43734. /**
  43735. * constructor
  43736. * @param options Defines the options we want to customize the helper
  43737. * @param scene The scene to add the material to
  43738. */
  43739. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43740. /**
  43741. * Updates the background according to the new options
  43742. * @param options
  43743. */
  43744. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43745. /**
  43746. * Sets the primary color of all the available elements.
  43747. * @param color the main color to affect to the ground and the background
  43748. */
  43749. setMainColor(color: Color3): void;
  43750. /**
  43751. * Setup the image processing according to the specified options.
  43752. */
  43753. private _setupImageProcessing;
  43754. /**
  43755. * Setup the environment texture according to the specified options.
  43756. */
  43757. private _setupEnvironmentTexture;
  43758. /**
  43759. * Setup the background according to the specified options.
  43760. */
  43761. private _setupBackground;
  43762. /**
  43763. * Get the scene sizes according to the setup.
  43764. */
  43765. private _getSceneSize;
  43766. /**
  43767. * Setup the ground according to the specified options.
  43768. */
  43769. private _setupGround;
  43770. /**
  43771. * Setup the ground material according to the specified options.
  43772. */
  43773. private _setupGroundMaterial;
  43774. /**
  43775. * Setup the ground diffuse texture according to the specified options.
  43776. */
  43777. private _setupGroundDiffuseTexture;
  43778. /**
  43779. * Setup the ground mirror texture according to the specified options.
  43780. */
  43781. private _setupGroundMirrorTexture;
  43782. /**
  43783. * Setup the ground to receive the mirror texture.
  43784. */
  43785. private _setupMirrorInGroundMaterial;
  43786. /**
  43787. * Setup the skybox according to the specified options.
  43788. */
  43789. private _setupSkybox;
  43790. /**
  43791. * Setup the skybox material according to the specified options.
  43792. */
  43793. private _setupSkyboxMaterial;
  43794. /**
  43795. * Setup the skybox reflection texture according to the specified options.
  43796. */
  43797. private _setupSkyboxReflectionTexture;
  43798. private _errorHandler;
  43799. /**
  43800. * Dispose all the elements created by the Helper.
  43801. */
  43802. dispose(): void;
  43803. }
  43804. }
  43805. declare module BABYLON {
  43806. /**
  43807. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43808. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43809. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43810. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43811. */
  43812. export class PhotoDome extends TransformNode {
  43813. /**
  43814. * Define the image as a Monoscopic panoramic 360 image.
  43815. */
  43816. static readonly MODE_MONOSCOPIC: number;
  43817. /**
  43818. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43819. */
  43820. static readonly MODE_TOPBOTTOM: number;
  43821. /**
  43822. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43823. */
  43824. static readonly MODE_SIDEBYSIDE: number;
  43825. private _useDirectMapping;
  43826. /**
  43827. * The texture being displayed on the sphere
  43828. */
  43829. protected _photoTexture: Texture;
  43830. /**
  43831. * Gets or sets the texture being displayed on the sphere
  43832. */
  43833. photoTexture: Texture;
  43834. /**
  43835. * Observable raised when an error occured while loading the 360 image
  43836. */
  43837. onLoadErrorObservable: Observable<string>;
  43838. /**
  43839. * The skybox material
  43840. */
  43841. protected _material: BackgroundMaterial;
  43842. /**
  43843. * The surface used for the skybox
  43844. */
  43845. protected _mesh: Mesh;
  43846. /**
  43847. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43848. * Also see the options.resolution property.
  43849. */
  43850. fovMultiplier: number;
  43851. private _imageMode;
  43852. /**
  43853. * Gets or set the current video mode for the video. It can be:
  43854. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  43855. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  43856. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  43857. */
  43858. imageMode: number;
  43859. /**
  43860. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43861. * @param name Element's name, child elements will append suffixes for their own names.
  43862. * @param urlsOfPhoto defines the url of the photo to display
  43863. * @param options defines an object containing optional or exposed sub element properties
  43864. * @param onError defines a callback called when an error occured while loading the texture
  43865. */
  43866. constructor(name: string, urlOfPhoto: string, options: {
  43867. resolution?: number;
  43868. size?: number;
  43869. useDirectMapping?: boolean;
  43870. faceForward?: boolean;
  43871. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43872. private _onBeforeCameraRenderObserver;
  43873. private _changeImageMode;
  43874. /**
  43875. * Releases resources associated with this node.
  43876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43878. */
  43879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43880. }
  43881. }
  43882. declare module BABYLON {
  43883. /** @hidden */
  43884. export var rgbdDecodePixelShader: {
  43885. name: string;
  43886. shader: string;
  43887. };
  43888. }
  43889. declare module BABYLON {
  43890. /**
  43891. * Class used to host texture specific utilities
  43892. */
  43893. export class BRDFTextureTools {
  43894. /**
  43895. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43896. * @param texture the texture to expand.
  43897. */
  43898. private static _ExpandDefaultBRDFTexture;
  43899. /**
  43900. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43901. * @param scene defines the hosting scene
  43902. * @returns the environment BRDF texture
  43903. */
  43904. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43905. private static _environmentBRDFBase64Texture;
  43906. }
  43907. }
  43908. declare module BABYLON {
  43909. /**
  43910. * @hidden
  43911. */
  43912. export interface IMaterialClearCoatDefines {
  43913. CLEARCOAT: boolean;
  43914. CLEARCOAT_DEFAULTIOR: boolean;
  43915. CLEARCOAT_TEXTURE: boolean;
  43916. CLEARCOAT_TEXTUREDIRECTUV: number;
  43917. CLEARCOAT_BUMP: boolean;
  43918. CLEARCOAT_BUMPDIRECTUV: number;
  43919. CLEARCOAT_TINT: boolean;
  43920. CLEARCOAT_TINT_TEXTURE: boolean;
  43921. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43922. /** @hidden */ private _areTexturesDirty: boolean;
  43923. }
  43924. /**
  43925. * Define the code related to the clear coat parameters of the pbr material.
  43926. */
  43927. export class PBRClearCoatConfiguration {
  43928. /**
  43929. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43930. * The default fits with a polyurethane material.
  43931. */
  43932. private static readonly _DefaultIndexOfRefraction;
  43933. private _isEnabled;
  43934. /**
  43935. * Defines if the clear coat is enabled in the material.
  43936. */
  43937. isEnabled: boolean;
  43938. /**
  43939. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43940. */
  43941. intensity: number;
  43942. /**
  43943. * Defines the clear coat layer roughness.
  43944. */
  43945. roughness: number;
  43946. private _indexOfRefraction;
  43947. /**
  43948. * Defines the index of refraction of the clear coat.
  43949. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43950. * The default fits with a polyurethane material.
  43951. * Changing the default value is more performance intensive.
  43952. */
  43953. indexOfRefraction: number;
  43954. private _texture;
  43955. /**
  43956. * Stores the clear coat values in a texture.
  43957. */
  43958. texture: Nullable<BaseTexture>;
  43959. private _bumpTexture;
  43960. /**
  43961. * Define the clear coat specific bump texture.
  43962. */
  43963. bumpTexture: Nullable<BaseTexture>;
  43964. private _isTintEnabled;
  43965. /**
  43966. * Defines if the clear coat tint is enabled in the material.
  43967. */
  43968. isTintEnabled: boolean;
  43969. /**
  43970. * Defines the clear coat tint of the material.
  43971. * This is only use if tint is enabled
  43972. */
  43973. tintColor: Color3;
  43974. /**
  43975. * Defines the distance at which the tint color should be found in the
  43976. * clear coat media.
  43977. * This is only use if tint is enabled
  43978. */
  43979. tintColorAtDistance: number;
  43980. /**
  43981. * Defines the clear coat layer thickness.
  43982. * This is only use if tint is enabled
  43983. */
  43984. tintThickness: number;
  43985. private _tintTexture;
  43986. /**
  43987. * Stores the clear tint values in a texture.
  43988. * rgb is tint
  43989. * a is a thickness factor
  43990. */
  43991. tintTexture: Nullable<BaseTexture>;
  43992. /** @hidden */
  43993. private _internalMarkAllSubMeshesAsTexturesDirty;
  43994. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43995. /**
  43996. * Instantiate a new istance of clear coat configuration.
  43997. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43998. */
  43999. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44000. /**
  44001. * Gets wehter the submesh is ready to be used or not.
  44002. * @param defines the list of "defines" to update.
  44003. * @param scene defines the scene the material belongs to.
  44004. * @param engine defines the engine the material belongs to.
  44005. * @param disableBumpMap defines wether the material disables bump or not.
  44006. * @returns - boolean indicating that the submesh is ready or not.
  44007. */
  44008. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44009. /**
  44010. * Checks to see if a texture is used in the material.
  44011. * @param defines the list of "defines" to update.
  44012. * @param scene defines the scene to the material belongs to.
  44013. */
  44014. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44015. /**
  44016. * Binds the material data.
  44017. * @param uniformBuffer defines the Uniform buffer to fill in.
  44018. * @param scene defines the scene the material belongs to.
  44019. * @param engine defines the engine the material belongs to.
  44020. * @param disableBumpMap defines wether the material disables bump or not.
  44021. * @param isFrozen defines wether the material is frozen or not.
  44022. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44023. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44024. */
  44025. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44026. /**
  44027. * Checks to see if a texture is used in the material.
  44028. * @param texture - Base texture to use.
  44029. * @returns - Boolean specifying if a texture is used in the material.
  44030. */
  44031. hasTexture(texture: BaseTexture): boolean;
  44032. /**
  44033. * Returns an array of the actively used textures.
  44034. * @param activeTextures Array of BaseTextures
  44035. */
  44036. getActiveTextures(activeTextures: BaseTexture[]): void;
  44037. /**
  44038. * Returns the animatable textures.
  44039. * @param animatables Array of animatable textures.
  44040. */
  44041. getAnimatables(animatables: IAnimatable[]): void;
  44042. /**
  44043. * Disposes the resources of the material.
  44044. * @param forceDisposeTextures - Forces the disposal of all textures.
  44045. */
  44046. dispose(forceDisposeTextures?: boolean): void;
  44047. /**
  44048. * Get the current class name of the texture useful for serialization or dynamic coding.
  44049. * @returns "PBRClearCoatConfiguration"
  44050. */
  44051. getClassName(): string;
  44052. /**
  44053. * Add fallbacks to the effect fallbacks list.
  44054. * @param defines defines the Base texture to use.
  44055. * @param fallbacks defines the current fallback list.
  44056. * @param currentRank defines the current fallback rank.
  44057. * @returns the new fallback rank.
  44058. */
  44059. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44060. /**
  44061. * Add the required uniforms to the current list.
  44062. * @param uniforms defines the current uniform list.
  44063. */
  44064. static AddUniforms(uniforms: string[]): void;
  44065. /**
  44066. * Add the required samplers to the current list.
  44067. * @param samplers defines the current sampler list.
  44068. */
  44069. static AddSamplers(samplers: string[]): void;
  44070. /**
  44071. * Add the required uniforms to the current buffer.
  44072. * @param uniformBuffer defines the current uniform buffer.
  44073. */
  44074. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44075. /**
  44076. * Makes a duplicate of the current configuration into another one.
  44077. * @param clearCoatConfiguration define the config where to copy the info
  44078. */
  44079. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44080. /**
  44081. * Serializes this clear coat configuration.
  44082. * @returns - An object with the serialized config.
  44083. */
  44084. serialize(): any;
  44085. /**
  44086. * Parses a anisotropy Configuration from a serialized object.
  44087. * @param source - Serialized object.
  44088. * @param scene Defines the scene we are parsing for
  44089. * @param rootUrl Defines the rootUrl to load from
  44090. */
  44091. parse(source: any, scene: Scene, rootUrl: string): void;
  44092. }
  44093. }
  44094. declare module BABYLON {
  44095. /**
  44096. * @hidden
  44097. */
  44098. export interface IMaterialAnisotropicDefines {
  44099. ANISOTROPIC: boolean;
  44100. ANISOTROPIC_TEXTURE: boolean;
  44101. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44102. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  44103. }
  44104. /**
  44105. * Define the code related to the anisotropic parameters of the pbr material.
  44106. */
  44107. export class PBRAnisotropicConfiguration {
  44108. private _isEnabled;
  44109. /**
  44110. * Defines if the anisotropy is enabled in the material.
  44111. */
  44112. isEnabled: boolean;
  44113. /**
  44114. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44115. */
  44116. intensity: number;
  44117. /**
  44118. * Defines if the effect is along the tangents, bitangents or in between.
  44119. * By default, the effect is "strectching" the highlights along the tangents.
  44120. */
  44121. direction: Vector2;
  44122. private _texture;
  44123. /**
  44124. * Stores the anisotropy values in a texture.
  44125. * rg is direction (like normal from -1 to 1)
  44126. * b is a intensity
  44127. */
  44128. texture: Nullable<BaseTexture>;
  44129. /** @hidden */
  44130. private _internalMarkAllSubMeshesAsTexturesDirty;
  44131. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44132. /**
  44133. * Instantiate a new istance of anisotropy configuration.
  44134. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44135. */
  44136. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44137. /**
  44138. * Specifies that the submesh is ready to be used.
  44139. * @param defines the list of "defines" to update.
  44140. * @param scene defines the scene the material belongs to.
  44141. * @returns - boolean indicating that the submesh is ready or not.
  44142. */
  44143. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44144. /**
  44145. * Checks to see if a texture is used in the material.
  44146. * @param defines the list of "defines" to update.
  44147. * @param mesh the mesh we are preparing the defines for.
  44148. * @param scene defines the scene the material belongs to.
  44149. */
  44150. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44151. /**
  44152. * Binds the material data.
  44153. * @param uniformBuffer defines the Uniform buffer to fill in.
  44154. * @param scene defines the scene the material belongs to.
  44155. * @param isFrozen defines wether the material is frozen or not.
  44156. */
  44157. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44158. /**
  44159. * Checks to see if a texture is used in the material.
  44160. * @param texture - Base texture to use.
  44161. * @returns - Boolean specifying if a texture is used in the material.
  44162. */
  44163. hasTexture(texture: BaseTexture): boolean;
  44164. /**
  44165. * Returns an array of the actively used textures.
  44166. * @param activeTextures Array of BaseTextures
  44167. */
  44168. getActiveTextures(activeTextures: BaseTexture[]): void;
  44169. /**
  44170. * Returns the animatable textures.
  44171. * @param animatables Array of animatable textures.
  44172. */
  44173. getAnimatables(animatables: IAnimatable[]): void;
  44174. /**
  44175. * Disposes the resources of the material.
  44176. * @param forceDisposeTextures - Forces the disposal of all textures.
  44177. */
  44178. dispose(forceDisposeTextures?: boolean): void;
  44179. /**
  44180. * Get the current class name of the texture useful for serialization or dynamic coding.
  44181. * @returns "PBRAnisotropicConfiguration"
  44182. */
  44183. getClassName(): string;
  44184. /**
  44185. * Add fallbacks to the effect fallbacks list.
  44186. * @param defines defines the Base texture to use.
  44187. * @param fallbacks defines the current fallback list.
  44188. * @param currentRank defines the current fallback rank.
  44189. * @returns the new fallback rank.
  44190. */
  44191. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44192. /**
  44193. * Add the required uniforms to the current list.
  44194. * @param uniforms defines the current uniform list.
  44195. */
  44196. static AddUniforms(uniforms: string[]): void;
  44197. /**
  44198. * Add the required uniforms to the current buffer.
  44199. * @param uniformBuffer defines the current uniform buffer.
  44200. */
  44201. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44202. /**
  44203. * Add the required samplers to the current list.
  44204. * @param samplers defines the current sampler list.
  44205. */
  44206. static AddSamplers(samplers: string[]): void;
  44207. /**
  44208. * Makes a duplicate of the current configuration into another one.
  44209. * @param anisotropicConfiguration define the config where to copy the info
  44210. */
  44211. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44212. /**
  44213. * Serializes this anisotropy configuration.
  44214. * @returns - An object with the serialized config.
  44215. */
  44216. serialize(): any;
  44217. /**
  44218. * Parses a anisotropy Configuration from a serialized object.
  44219. * @param source - Serialized object.
  44220. * @param scene Defines the scene we are parsing for
  44221. * @param rootUrl Defines the rootUrl to load from
  44222. */
  44223. parse(source: any, scene: Scene, rootUrl: string): void;
  44224. }
  44225. }
  44226. declare module BABYLON {
  44227. /**
  44228. * @hidden
  44229. */
  44230. export interface IMaterialBRDFDefines {
  44231. BRDF_V_HEIGHT_CORRELATED: boolean;
  44232. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44233. SPHERICAL_HARMONICS: boolean;
  44234. /** @hidden */ private _areMiscDirty: boolean;
  44235. }
  44236. /**
  44237. * Define the code related to the BRDF parameters of the pbr material.
  44238. */
  44239. export class PBRBRDFConfiguration {
  44240. /**
  44241. * Default value used for the energy conservation.
  44242. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44243. */
  44244. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44245. /**
  44246. * Default value used for the Smith Visibility Height Correlated mode.
  44247. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44248. */
  44249. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44250. /**
  44251. * Default value used for the IBL diffuse part.
  44252. * This can help switching back to the polynomials mode globally which is a tiny bit
  44253. * less GPU intensive at the drawback of a lower quality.
  44254. */
  44255. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44256. private _useEnergyConservation;
  44257. /**
  44258. * Defines if the material uses energy conservation.
  44259. */
  44260. useEnergyConservation: boolean;
  44261. private _useSmithVisibilityHeightCorrelated;
  44262. /**
  44263. * LEGACY Mode set to false
  44264. * Defines if the material uses height smith correlated visibility term.
  44265. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44266. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44267. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44268. * Not relying on height correlated will also disable energy conservation.
  44269. */
  44270. useSmithVisibilityHeightCorrelated: boolean;
  44271. private _useSphericalHarmonics;
  44272. /**
  44273. * LEGACY Mode set to false
  44274. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44275. * diffuse part of the IBL.
  44276. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44277. * to the ground truth.
  44278. */
  44279. useSphericalHarmonics: boolean;
  44280. /** @hidden */
  44281. private _internalMarkAllSubMeshesAsMiscDirty;
  44282. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  44283. /**
  44284. * Instantiate a new istance of clear coat configuration.
  44285. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44286. */
  44287. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44288. /**
  44289. * Checks to see if a texture is used in the material.
  44290. * @param defines the list of "defines" to update.
  44291. */
  44292. prepareDefines(defines: IMaterialBRDFDefines): void;
  44293. /**
  44294. * Get the current class name of the texture useful for serialization or dynamic coding.
  44295. * @returns "PBRClearCoatConfiguration"
  44296. */
  44297. getClassName(): string;
  44298. /**
  44299. * Makes a duplicate of the current configuration into another one.
  44300. * @param brdfConfiguration define the config where to copy the info
  44301. */
  44302. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44303. /**
  44304. * Serializes this BRDF configuration.
  44305. * @returns - An object with the serialized config.
  44306. */
  44307. serialize(): any;
  44308. /**
  44309. * Parses a anisotropy Configuration from a serialized object.
  44310. * @param source - Serialized object.
  44311. * @param scene Defines the scene we are parsing for
  44312. * @param rootUrl Defines the rootUrl to load from
  44313. */
  44314. parse(source: any, scene: Scene, rootUrl: string): void;
  44315. }
  44316. }
  44317. declare module BABYLON {
  44318. /**
  44319. * @hidden
  44320. */
  44321. export interface IMaterialSheenDefines {
  44322. SHEEN: boolean;
  44323. SHEEN_TEXTURE: boolean;
  44324. SHEEN_TEXTUREDIRECTUV: number;
  44325. SHEEN_LINKWITHALBEDO: boolean;
  44326. /** @hidden */ private _areTexturesDirty: boolean;
  44327. }
  44328. /**
  44329. * Define the code related to the Sheen parameters of the pbr material.
  44330. */
  44331. export class PBRSheenConfiguration {
  44332. private _isEnabled;
  44333. /**
  44334. * Defines if the material uses sheen.
  44335. */
  44336. isEnabled: boolean;
  44337. private _linkSheenWithAlbedo;
  44338. /**
  44339. * Defines if the sheen is linked to the sheen color.
  44340. */
  44341. linkSheenWithAlbedo: boolean;
  44342. /**
  44343. * Defines the sheen intensity.
  44344. */
  44345. intensity: number;
  44346. /**
  44347. * Defines the sheen color.
  44348. */
  44349. color: Color3;
  44350. private _texture;
  44351. /**
  44352. * Stores the sheen tint values in a texture.
  44353. * rgb is tint
  44354. * a is a intensity
  44355. */
  44356. texture: Nullable<BaseTexture>;
  44357. /** @hidden */
  44358. private _internalMarkAllSubMeshesAsTexturesDirty;
  44359. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44360. /**
  44361. * Instantiate a new istance of clear coat configuration.
  44362. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44363. */
  44364. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44365. /**
  44366. * Specifies that the submesh is ready to be used.
  44367. * @param defines the list of "defines" to update.
  44368. * @param scene defines the scene the material belongs to.
  44369. * @returns - boolean indicating that the submesh is ready or not.
  44370. */
  44371. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44372. /**
  44373. * Checks to see if a texture is used in the material.
  44374. * @param defines the list of "defines" to update.
  44375. * @param scene defines the scene the material belongs to.
  44376. */
  44377. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44378. /**
  44379. * Binds the material data.
  44380. * @param uniformBuffer defines the Uniform buffer to fill in.
  44381. * @param scene defines the scene the material belongs to.
  44382. * @param isFrozen defines wether the material is frozen or not.
  44383. */
  44384. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44385. /**
  44386. * Checks to see if a texture is used in the material.
  44387. * @param texture - Base texture to use.
  44388. * @returns - Boolean specifying if a texture is used in the material.
  44389. */
  44390. hasTexture(texture: BaseTexture): boolean;
  44391. /**
  44392. * Returns an array of the actively used textures.
  44393. * @param activeTextures Array of BaseTextures
  44394. */
  44395. getActiveTextures(activeTextures: BaseTexture[]): void;
  44396. /**
  44397. * Returns the animatable textures.
  44398. * @param animatables Array of animatable textures.
  44399. */
  44400. getAnimatables(animatables: IAnimatable[]): void;
  44401. /**
  44402. * Disposes the resources of the material.
  44403. * @param forceDisposeTextures - Forces the disposal of all textures.
  44404. */
  44405. dispose(forceDisposeTextures?: boolean): void;
  44406. /**
  44407. * Get the current class name of the texture useful for serialization or dynamic coding.
  44408. * @returns "PBRSheenConfiguration"
  44409. */
  44410. getClassName(): string;
  44411. /**
  44412. * Add fallbacks to the effect fallbacks list.
  44413. * @param defines defines the Base texture to use.
  44414. * @param fallbacks defines the current fallback list.
  44415. * @param currentRank defines the current fallback rank.
  44416. * @returns the new fallback rank.
  44417. */
  44418. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44419. /**
  44420. * Add the required uniforms to the current list.
  44421. * @param uniforms defines the current uniform list.
  44422. */
  44423. static AddUniforms(uniforms: string[]): void;
  44424. /**
  44425. * Add the required uniforms to the current buffer.
  44426. * @param uniformBuffer defines the current uniform buffer.
  44427. */
  44428. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44429. /**
  44430. * Add the required samplers to the current list.
  44431. * @param samplers defines the current sampler list.
  44432. */
  44433. static AddSamplers(samplers: string[]): void;
  44434. /**
  44435. * Makes a duplicate of the current configuration into another one.
  44436. * @param sheenConfiguration define the config where to copy the info
  44437. */
  44438. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44439. /**
  44440. * Serializes this BRDF configuration.
  44441. * @returns - An object with the serialized config.
  44442. */
  44443. serialize(): any;
  44444. /**
  44445. * Parses a anisotropy Configuration from a serialized object.
  44446. * @param source - Serialized object.
  44447. * @param scene Defines the scene we are parsing for
  44448. * @param rootUrl Defines the rootUrl to load from
  44449. */
  44450. parse(source: any, scene: Scene, rootUrl: string): void;
  44451. }
  44452. }
  44453. declare module BABYLON {
  44454. /**
  44455. * @hidden
  44456. */
  44457. export interface IMaterialSubSurfaceDefines {
  44458. SUBSURFACE: boolean;
  44459. SS_REFRACTION: boolean;
  44460. SS_TRANSLUCENCY: boolean;
  44461. SS_SCATERRING: boolean;
  44462. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44463. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44464. SS_REFRACTIONMAP_3D: boolean;
  44465. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44466. SS_LODINREFRACTIONALPHA: boolean;
  44467. SS_GAMMAREFRACTION: boolean;
  44468. SS_RGBDREFRACTION: boolean;
  44469. SS_LINEARSPECULARREFRACTION: boolean;
  44470. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44471. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44472. /** @hidden */ private _areTexturesDirty: boolean;
  44473. }
  44474. /**
  44475. * Define the code related to the sub surface parameters of the pbr material.
  44476. */
  44477. export class PBRSubSurfaceConfiguration {
  44478. private _isRefractionEnabled;
  44479. /**
  44480. * Defines if the refraction is enabled in the material.
  44481. */
  44482. isRefractionEnabled: boolean;
  44483. private _isTranslucencyEnabled;
  44484. /**
  44485. * Defines if the translucency is enabled in the material.
  44486. */
  44487. isTranslucencyEnabled: boolean;
  44488. private _isScatteringEnabled;
  44489. /**
  44490. * Defines the refraction intensity of the material.
  44491. * The refraction when enabled replaces the Diffuse part of the material.
  44492. * The intensity helps transitionning between diffuse and refraction.
  44493. */
  44494. refractionIntensity: number;
  44495. /**
  44496. * Defines the translucency intensity of the material.
  44497. * When translucency has been enabled, this defines how much of the "translucency"
  44498. * is addded to the diffuse part of the material.
  44499. */
  44500. translucencyIntensity: number;
  44501. /**
  44502. * Defines the scattering intensity of the material.
  44503. * When scattering has been enabled, this defines how much of the "scattered light"
  44504. * is addded to the diffuse part of the material.
  44505. */
  44506. scatteringIntensity: number;
  44507. private _thicknessTexture;
  44508. /**
  44509. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44510. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44511. * 0 would mean minimumThickness
  44512. * 1 would mean maximumThickness
  44513. * The other channels might be use as a mask to vary the different effects intensity.
  44514. */
  44515. thicknessTexture: Nullable<BaseTexture>;
  44516. private _refractionTexture;
  44517. /**
  44518. * Defines the texture to use for refraction.
  44519. */
  44520. refractionTexture: Nullable<BaseTexture>;
  44521. private _indexOfRefraction;
  44522. /**
  44523. * Defines the index of refraction used in the material.
  44524. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44525. */
  44526. indexOfRefraction: number;
  44527. private _invertRefractionY;
  44528. /**
  44529. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44530. */
  44531. invertRefractionY: boolean;
  44532. private _linkRefractionWithTransparency;
  44533. /**
  44534. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44535. * Materials half opaque for instance using refraction could benefit from this control.
  44536. */
  44537. linkRefractionWithTransparency: boolean;
  44538. /**
  44539. * Defines the minimum thickness stored in the thickness map.
  44540. * If no thickness map is defined, this value will be used to simulate thickness.
  44541. */
  44542. minimumThickness: number;
  44543. /**
  44544. * Defines the maximum thickness stored in the thickness map.
  44545. */
  44546. maximumThickness: number;
  44547. /**
  44548. * Defines the volume tint of the material.
  44549. * This is used for both translucency and scattering.
  44550. */
  44551. tintColor: Color3;
  44552. /**
  44553. * Defines the distance at which the tint color should be found in the media.
  44554. * This is used for refraction only.
  44555. */
  44556. tintColorAtDistance: number;
  44557. /**
  44558. * Defines how far each channel transmit through the media.
  44559. * It is defined as a color to simplify it selection.
  44560. */
  44561. diffusionDistance: Color3;
  44562. private _useMaskFromThicknessTexture;
  44563. /**
  44564. * Stores the intensity of the different subsurface effects in the thickness texture.
  44565. * * the green channel is the translucency intensity.
  44566. * * the blue channel is the scattering intensity.
  44567. * * the alpha channel is the refraction intensity.
  44568. */
  44569. useMaskFromThicknessTexture: boolean;
  44570. /** @hidden */
  44571. private _internalMarkAllSubMeshesAsTexturesDirty;
  44572. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44573. /**
  44574. * Instantiate a new istance of sub surface configuration.
  44575. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44576. */
  44577. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44578. /**
  44579. * Gets wehter the submesh is ready to be used or not.
  44580. * @param defines the list of "defines" to update.
  44581. * @param scene defines the scene the material belongs to.
  44582. * @returns - boolean indicating that the submesh is ready or not.
  44583. */
  44584. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44585. /**
  44586. * Checks to see if a texture is used in the material.
  44587. * @param defines the list of "defines" to update.
  44588. * @param scene defines the scene to the material belongs to.
  44589. */
  44590. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44591. /**
  44592. * Binds the material data.
  44593. * @param uniformBuffer defines the Uniform buffer to fill in.
  44594. * @param scene defines the scene the material belongs to.
  44595. * @param engine defines the engine the material belongs to.
  44596. * @param isFrozen defines wether the material is frozen or not.
  44597. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44598. */
  44599. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44600. /**
  44601. * Unbinds the material from the mesh.
  44602. * @param activeEffect defines the effect that should be unbound from.
  44603. * @returns true if unbound, otherwise false
  44604. */
  44605. unbind(activeEffect: Effect): boolean;
  44606. /**
  44607. * Returns the texture used for refraction or null if none is used.
  44608. * @param scene defines the scene the material belongs to.
  44609. * @returns - Refraction texture if present. If no refraction texture and refraction
  44610. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44611. */
  44612. private _getRefractionTexture;
  44613. /**
  44614. * Returns true if alpha blending should be disabled.
  44615. */
  44616. readonly disableAlphaBlending: boolean;
  44617. /**
  44618. * Fills the list of render target textures.
  44619. * @param renderTargets the list of render targets to update
  44620. */
  44621. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44622. /**
  44623. * Checks to see if a texture is used in the material.
  44624. * @param texture - Base texture to use.
  44625. * @returns - Boolean specifying if a texture is used in the material.
  44626. */
  44627. hasTexture(texture: BaseTexture): boolean;
  44628. /**
  44629. * Gets a boolean indicating that current material needs to register RTT
  44630. * @returns true if this uses a render target otherwise false.
  44631. */
  44632. hasRenderTargetTextures(): boolean;
  44633. /**
  44634. * Returns an array of the actively used textures.
  44635. * @param activeTextures Array of BaseTextures
  44636. */
  44637. getActiveTextures(activeTextures: BaseTexture[]): void;
  44638. /**
  44639. * Returns the animatable textures.
  44640. * @param animatables Array of animatable textures.
  44641. */
  44642. getAnimatables(animatables: IAnimatable[]): void;
  44643. /**
  44644. * Disposes the resources of the material.
  44645. * @param forceDisposeTextures - Forces the disposal of all textures.
  44646. */
  44647. dispose(forceDisposeTextures?: boolean): void;
  44648. /**
  44649. * Get the current class name of the texture useful for serialization or dynamic coding.
  44650. * @returns "PBRSubSurfaceConfiguration"
  44651. */
  44652. getClassName(): string;
  44653. /**
  44654. * Add fallbacks to the effect fallbacks list.
  44655. * @param defines defines the Base texture to use.
  44656. * @param fallbacks defines the current fallback list.
  44657. * @param currentRank defines the current fallback rank.
  44658. * @returns the new fallback rank.
  44659. */
  44660. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44661. /**
  44662. * Add the required uniforms to the current list.
  44663. * @param uniforms defines the current uniform list.
  44664. */
  44665. static AddUniforms(uniforms: string[]): void;
  44666. /**
  44667. * Add the required samplers to the current list.
  44668. * @param samplers defines the current sampler list.
  44669. */
  44670. static AddSamplers(samplers: string[]): void;
  44671. /**
  44672. * Add the required uniforms to the current buffer.
  44673. * @param uniformBuffer defines the current uniform buffer.
  44674. */
  44675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44676. /**
  44677. * Makes a duplicate of the current configuration into another one.
  44678. * @param configuration define the config where to copy the info
  44679. */
  44680. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44681. /**
  44682. * Serializes this Sub Surface configuration.
  44683. * @returns - An object with the serialized config.
  44684. */
  44685. serialize(): any;
  44686. /**
  44687. * Parses a anisotropy Configuration from a serialized object.
  44688. * @param source - Serialized object.
  44689. * @param scene Defines the scene we are parsing for
  44690. * @param rootUrl Defines the rootUrl to load from
  44691. */
  44692. parse(source: any, scene: Scene, rootUrl: string): void;
  44693. }
  44694. }
  44695. declare module BABYLON {
  44696. /** @hidden */
  44697. export var pbrFragmentDeclaration: {
  44698. name: string;
  44699. shader: string;
  44700. };
  44701. }
  44702. declare module BABYLON {
  44703. /** @hidden */
  44704. export var pbrUboDeclaration: {
  44705. name: string;
  44706. shader: string;
  44707. };
  44708. }
  44709. declare module BABYLON {
  44710. /** @hidden */
  44711. export var pbrFragmentExtraDeclaration: {
  44712. name: string;
  44713. shader: string;
  44714. };
  44715. }
  44716. declare module BABYLON {
  44717. /** @hidden */
  44718. export var pbrFragmentSamplersDeclaration: {
  44719. name: string;
  44720. shader: string;
  44721. };
  44722. }
  44723. declare module BABYLON {
  44724. /** @hidden */
  44725. export var pbrHelperFunctions: {
  44726. name: string;
  44727. shader: string;
  44728. };
  44729. }
  44730. declare module BABYLON {
  44731. /** @hidden */
  44732. export var harmonicsFunctions: {
  44733. name: string;
  44734. shader: string;
  44735. };
  44736. }
  44737. declare module BABYLON {
  44738. /** @hidden */
  44739. export var pbrDirectLightingSetupFunctions: {
  44740. name: string;
  44741. shader: string;
  44742. };
  44743. }
  44744. declare module BABYLON {
  44745. /** @hidden */
  44746. export var pbrDirectLightingFalloffFunctions: {
  44747. name: string;
  44748. shader: string;
  44749. };
  44750. }
  44751. declare module BABYLON {
  44752. /** @hidden */
  44753. export var pbrBRDFFunctions: {
  44754. name: string;
  44755. shader: string;
  44756. };
  44757. }
  44758. declare module BABYLON {
  44759. /** @hidden */
  44760. export var pbrDirectLightingFunctions: {
  44761. name: string;
  44762. shader: string;
  44763. };
  44764. }
  44765. declare module BABYLON {
  44766. /** @hidden */
  44767. export var pbrIBLFunctions: {
  44768. name: string;
  44769. shader: string;
  44770. };
  44771. }
  44772. declare module BABYLON {
  44773. /** @hidden */
  44774. export var pbrDebug: {
  44775. name: string;
  44776. shader: string;
  44777. };
  44778. }
  44779. declare module BABYLON {
  44780. /** @hidden */
  44781. export var pbrPixelShader: {
  44782. name: string;
  44783. shader: string;
  44784. };
  44785. }
  44786. declare module BABYLON {
  44787. /** @hidden */
  44788. export var pbrVertexDeclaration: {
  44789. name: string;
  44790. shader: string;
  44791. };
  44792. }
  44793. declare module BABYLON {
  44794. /** @hidden */
  44795. export var pbrVertexShader: {
  44796. name: string;
  44797. shader: string;
  44798. };
  44799. }
  44800. declare module BABYLON {
  44801. /**
  44802. * Manages the defines for the PBR Material.
  44803. * @hidden
  44804. */
  44805. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44806. PBR: boolean;
  44807. MAINUV1: boolean;
  44808. MAINUV2: boolean;
  44809. UV1: boolean;
  44810. UV2: boolean;
  44811. ALBEDO: boolean;
  44812. ALBEDODIRECTUV: number;
  44813. VERTEXCOLOR: boolean;
  44814. AMBIENT: boolean;
  44815. AMBIENTDIRECTUV: number;
  44816. AMBIENTINGRAYSCALE: boolean;
  44817. OPACITY: boolean;
  44818. VERTEXALPHA: boolean;
  44819. OPACITYDIRECTUV: number;
  44820. OPACITYRGB: boolean;
  44821. ALPHATEST: boolean;
  44822. DEPTHPREPASS: boolean;
  44823. ALPHABLEND: boolean;
  44824. ALPHAFROMALBEDO: boolean;
  44825. ALPHATESTVALUE: string;
  44826. SPECULAROVERALPHA: boolean;
  44827. RADIANCEOVERALPHA: boolean;
  44828. ALPHAFRESNEL: boolean;
  44829. LINEARALPHAFRESNEL: boolean;
  44830. PREMULTIPLYALPHA: boolean;
  44831. EMISSIVE: boolean;
  44832. EMISSIVEDIRECTUV: number;
  44833. REFLECTIVITY: boolean;
  44834. REFLECTIVITYDIRECTUV: number;
  44835. SPECULARTERM: boolean;
  44836. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44837. MICROSURFACEAUTOMATIC: boolean;
  44838. LODBASEDMICROSFURACE: boolean;
  44839. MICROSURFACEMAP: boolean;
  44840. MICROSURFACEMAPDIRECTUV: number;
  44841. METALLICWORKFLOW: boolean;
  44842. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44843. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44844. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44845. AOSTOREINMETALMAPRED: boolean;
  44846. ENVIRONMENTBRDF: boolean;
  44847. ENVIRONMENTBRDF_RGBD: boolean;
  44848. NORMAL: boolean;
  44849. TANGENT: boolean;
  44850. BUMP: boolean;
  44851. BUMPDIRECTUV: number;
  44852. OBJECTSPACE_NORMALMAP: boolean;
  44853. PARALLAX: boolean;
  44854. PARALLAXOCCLUSION: boolean;
  44855. NORMALXYSCALE: boolean;
  44856. LIGHTMAP: boolean;
  44857. LIGHTMAPDIRECTUV: number;
  44858. USELIGHTMAPASSHADOWMAP: boolean;
  44859. GAMMALIGHTMAP: boolean;
  44860. REFLECTION: boolean;
  44861. REFLECTIONMAP_3D: boolean;
  44862. REFLECTIONMAP_SPHERICAL: boolean;
  44863. REFLECTIONMAP_PLANAR: boolean;
  44864. REFLECTIONMAP_CUBIC: boolean;
  44865. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44866. REFLECTIONMAP_PROJECTION: boolean;
  44867. REFLECTIONMAP_SKYBOX: boolean;
  44868. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44869. REFLECTIONMAP_EXPLICIT: boolean;
  44870. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44871. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44872. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44873. INVERTCUBICMAP: boolean;
  44874. USESPHERICALFROMREFLECTIONMAP: boolean;
  44875. USEIRRADIANCEMAP: boolean;
  44876. SPHERICAL_HARMONICS: boolean;
  44877. USESPHERICALINVERTEX: boolean;
  44878. REFLECTIONMAP_OPPOSITEZ: boolean;
  44879. LODINREFLECTIONALPHA: boolean;
  44880. GAMMAREFLECTION: boolean;
  44881. RGBDREFLECTION: boolean;
  44882. LINEARSPECULARREFLECTION: boolean;
  44883. RADIANCEOCCLUSION: boolean;
  44884. HORIZONOCCLUSION: boolean;
  44885. INSTANCES: boolean;
  44886. NUM_BONE_INFLUENCERS: number;
  44887. BonesPerMesh: number;
  44888. BONETEXTURE: boolean;
  44889. NONUNIFORMSCALING: boolean;
  44890. MORPHTARGETS: boolean;
  44891. MORPHTARGETS_NORMAL: boolean;
  44892. MORPHTARGETS_TANGENT: boolean;
  44893. MORPHTARGETS_UV: boolean;
  44894. NUM_MORPH_INFLUENCERS: number;
  44895. IMAGEPROCESSING: boolean;
  44896. VIGNETTE: boolean;
  44897. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44898. VIGNETTEBLENDMODEOPAQUE: boolean;
  44899. TONEMAPPING: boolean;
  44900. TONEMAPPING_ACES: boolean;
  44901. CONTRAST: boolean;
  44902. COLORCURVES: boolean;
  44903. COLORGRADING: boolean;
  44904. COLORGRADING3D: boolean;
  44905. SAMPLER3DGREENDEPTH: boolean;
  44906. SAMPLER3DBGRMAP: boolean;
  44907. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44908. EXPOSURE: boolean;
  44909. MULTIVIEW: boolean;
  44910. USEPHYSICALLIGHTFALLOFF: boolean;
  44911. USEGLTFLIGHTFALLOFF: boolean;
  44912. TWOSIDEDLIGHTING: boolean;
  44913. SHADOWFLOAT: boolean;
  44914. CLIPPLANE: boolean;
  44915. CLIPPLANE2: boolean;
  44916. CLIPPLANE3: boolean;
  44917. CLIPPLANE4: boolean;
  44918. POINTSIZE: boolean;
  44919. FOG: boolean;
  44920. LOGARITHMICDEPTH: boolean;
  44921. FORCENORMALFORWARD: boolean;
  44922. SPECULARAA: boolean;
  44923. CLEARCOAT: boolean;
  44924. CLEARCOAT_DEFAULTIOR: boolean;
  44925. CLEARCOAT_TEXTURE: boolean;
  44926. CLEARCOAT_TEXTUREDIRECTUV: number;
  44927. CLEARCOAT_BUMP: boolean;
  44928. CLEARCOAT_BUMPDIRECTUV: number;
  44929. CLEARCOAT_TINT: boolean;
  44930. CLEARCOAT_TINT_TEXTURE: boolean;
  44931. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44932. ANISOTROPIC: boolean;
  44933. ANISOTROPIC_TEXTURE: boolean;
  44934. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44935. BRDF_V_HEIGHT_CORRELATED: boolean;
  44936. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44937. SHEEN: boolean;
  44938. SHEEN_TEXTURE: boolean;
  44939. SHEEN_TEXTUREDIRECTUV: number;
  44940. SHEEN_LINKWITHALBEDO: boolean;
  44941. SUBSURFACE: boolean;
  44942. SS_REFRACTION: boolean;
  44943. SS_TRANSLUCENCY: boolean;
  44944. SS_SCATERRING: boolean;
  44945. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44946. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44947. SS_REFRACTIONMAP_3D: boolean;
  44948. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44949. SS_LODINREFRACTIONALPHA: boolean;
  44950. SS_GAMMAREFRACTION: boolean;
  44951. SS_RGBDREFRACTION: boolean;
  44952. SS_LINEARSPECULARREFRACTION: boolean;
  44953. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44954. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44955. UNLIT: boolean;
  44956. DEBUGMODE: number;
  44957. /**
  44958. * Initializes the PBR Material defines.
  44959. */
  44960. constructor();
  44961. /**
  44962. * Resets the PBR Material defines.
  44963. */
  44964. reset(): void;
  44965. }
  44966. /**
  44967. * The Physically based material base class of BJS.
  44968. *
  44969. * This offers the main features of a standard PBR material.
  44970. * For more information, please refer to the documentation :
  44971. * https://doc.babylonjs.com/how_to/physically_based_rendering
  44972. */
  44973. export abstract class PBRBaseMaterial extends PushMaterial {
  44974. /**
  44975. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44976. */
  44977. static readonly PBRMATERIAL_OPAQUE: number;
  44978. /**
  44979. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44980. */
  44981. static readonly PBRMATERIAL_ALPHATEST: number;
  44982. /**
  44983. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44984. */
  44985. static readonly PBRMATERIAL_ALPHABLEND: number;
  44986. /**
  44987. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44988. * They are also discarded below the alpha cutoff threshold to improve performances.
  44989. */
  44990. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44991. /**
  44992. * Defines the default value of how much AO map is occluding the analytical lights
  44993. * (point spot...).
  44994. */
  44995. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44996. /**
  44997. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44998. */
  44999. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45000. /**
  45001. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45002. * to enhance interoperability with other engines.
  45003. */
  45004. static readonly LIGHTFALLOFF_GLTF: number;
  45005. /**
  45006. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45007. * to enhance interoperability with other materials.
  45008. */
  45009. static readonly LIGHTFALLOFF_STANDARD: number;
  45010. /**
  45011. * Intensity of the direct lights e.g. the four lights available in your scene.
  45012. * This impacts both the direct diffuse and specular highlights.
  45013. */
  45014. protected _directIntensity: number;
  45015. /**
  45016. * Intensity of the emissive part of the material.
  45017. * This helps controlling the emissive effect without modifying the emissive color.
  45018. */
  45019. protected _emissiveIntensity: number;
  45020. /**
  45021. * Intensity of the environment e.g. how much the environment will light the object
  45022. * either through harmonics for rough material or through the refelction for shiny ones.
  45023. */
  45024. protected _environmentIntensity: number;
  45025. /**
  45026. * This is a special control allowing the reduction of the specular highlights coming from the
  45027. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45028. */
  45029. protected _specularIntensity: number;
  45030. /**
  45031. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45032. */
  45033. private _lightingInfos;
  45034. /**
  45035. * Debug Control allowing disabling the bump map on this material.
  45036. */
  45037. protected _disableBumpMap: boolean;
  45038. /**
  45039. * AKA Diffuse Texture in standard nomenclature.
  45040. */
  45041. protected _albedoTexture: Nullable<BaseTexture>;
  45042. /**
  45043. * AKA Occlusion Texture in other nomenclature.
  45044. */
  45045. protected _ambientTexture: Nullable<BaseTexture>;
  45046. /**
  45047. * AKA Occlusion Texture Intensity in other nomenclature.
  45048. */
  45049. protected _ambientTextureStrength: number;
  45050. /**
  45051. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45052. * 1 means it completely occludes it
  45053. * 0 mean it has no impact
  45054. */
  45055. protected _ambientTextureImpactOnAnalyticalLights: number;
  45056. /**
  45057. * Stores the alpha values in a texture.
  45058. */
  45059. protected _opacityTexture: Nullable<BaseTexture>;
  45060. /**
  45061. * Stores the reflection values in a texture.
  45062. */
  45063. protected _reflectionTexture: Nullable<BaseTexture>;
  45064. /**
  45065. * Stores the emissive values in a texture.
  45066. */
  45067. protected _emissiveTexture: Nullable<BaseTexture>;
  45068. /**
  45069. * AKA Specular texture in other nomenclature.
  45070. */
  45071. protected _reflectivityTexture: Nullable<BaseTexture>;
  45072. /**
  45073. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45074. */
  45075. protected _metallicTexture: Nullable<BaseTexture>;
  45076. /**
  45077. * Specifies the metallic scalar of the metallic/roughness workflow.
  45078. * Can also be used to scale the metalness values of the metallic texture.
  45079. */
  45080. protected _metallic: Nullable<number>;
  45081. /**
  45082. * Specifies the roughness scalar of the metallic/roughness workflow.
  45083. * Can also be used to scale the roughness values of the metallic texture.
  45084. */
  45085. protected _roughness: Nullable<number>;
  45086. /**
  45087. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45088. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45089. */
  45090. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45091. /**
  45092. * Stores surface normal data used to displace a mesh in a texture.
  45093. */
  45094. protected _bumpTexture: Nullable<BaseTexture>;
  45095. /**
  45096. * Stores the pre-calculated light information of a mesh in a texture.
  45097. */
  45098. protected _lightmapTexture: Nullable<BaseTexture>;
  45099. /**
  45100. * The color of a material in ambient lighting.
  45101. */
  45102. protected _ambientColor: Color3;
  45103. /**
  45104. * AKA Diffuse Color in other nomenclature.
  45105. */
  45106. protected _albedoColor: Color3;
  45107. /**
  45108. * AKA Specular Color in other nomenclature.
  45109. */
  45110. protected _reflectivityColor: Color3;
  45111. /**
  45112. * The color applied when light is reflected from a material.
  45113. */
  45114. protected _reflectionColor: Color3;
  45115. /**
  45116. * The color applied when light is emitted from a material.
  45117. */
  45118. protected _emissiveColor: Color3;
  45119. /**
  45120. * AKA Glossiness in other nomenclature.
  45121. */
  45122. protected _microSurface: number;
  45123. /**
  45124. * Specifies that the material will use the light map as a show map.
  45125. */
  45126. protected _useLightmapAsShadowmap: boolean;
  45127. /**
  45128. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45129. * makes the reflect vector face the model (under horizon).
  45130. */
  45131. protected _useHorizonOcclusion: boolean;
  45132. /**
  45133. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45134. * too much the area relying on ambient texture to define their ambient occlusion.
  45135. */
  45136. protected _useRadianceOcclusion: boolean;
  45137. /**
  45138. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45139. */
  45140. protected _useAlphaFromAlbedoTexture: boolean;
  45141. /**
  45142. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45143. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45144. */
  45145. protected _useSpecularOverAlpha: boolean;
  45146. /**
  45147. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45148. */
  45149. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45150. /**
  45151. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45152. */
  45153. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45154. /**
  45155. * Specifies if the metallic texture contains the roughness information in its green channel.
  45156. */
  45157. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45158. /**
  45159. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45160. */
  45161. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45162. /**
  45163. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45164. */
  45165. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45166. /**
  45167. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45168. */
  45169. protected _useAmbientInGrayScale: boolean;
  45170. /**
  45171. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45172. * The material will try to infer what glossiness each pixel should be.
  45173. */
  45174. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45175. /**
  45176. * Defines the falloff type used in this material.
  45177. * It by default is Physical.
  45178. */
  45179. protected _lightFalloff: number;
  45180. /**
  45181. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45182. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45183. */
  45184. protected _useRadianceOverAlpha: boolean;
  45185. /**
  45186. * Allows using an object space normal map (instead of tangent space).
  45187. */
  45188. protected _useObjectSpaceNormalMap: boolean;
  45189. /**
  45190. * Allows using the bump map in parallax mode.
  45191. */
  45192. protected _useParallax: boolean;
  45193. /**
  45194. * Allows using the bump map in parallax occlusion mode.
  45195. */
  45196. protected _useParallaxOcclusion: boolean;
  45197. /**
  45198. * Controls the scale bias of the parallax mode.
  45199. */
  45200. protected _parallaxScaleBias: number;
  45201. /**
  45202. * If sets to true, disables all the lights affecting the material.
  45203. */
  45204. protected _disableLighting: boolean;
  45205. /**
  45206. * Number of Simultaneous lights allowed on the material.
  45207. */
  45208. protected _maxSimultaneousLights: number;
  45209. /**
  45210. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45211. */
  45212. protected _invertNormalMapX: boolean;
  45213. /**
  45214. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45215. */
  45216. protected _invertNormalMapY: boolean;
  45217. /**
  45218. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45219. */
  45220. protected _twoSidedLighting: boolean;
  45221. /**
  45222. * Defines the alpha limits in alpha test mode.
  45223. */
  45224. protected _alphaCutOff: number;
  45225. /**
  45226. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45227. */
  45228. protected _forceAlphaTest: boolean;
  45229. /**
  45230. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45231. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45232. */
  45233. protected _useAlphaFresnel: boolean;
  45234. /**
  45235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45236. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45237. */
  45238. protected _useLinearAlphaFresnel: boolean;
  45239. /**
  45240. * The transparency mode of the material.
  45241. */
  45242. protected _transparencyMode: Nullable<number>;
  45243. /**
  45244. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45245. * from cos thetav and roughness:
  45246. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45247. */
  45248. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45249. /**
  45250. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45251. */
  45252. protected _forceIrradianceInFragment: boolean;
  45253. /**
  45254. * Force normal to face away from face.
  45255. */
  45256. protected _forceNormalForward: boolean;
  45257. /**
  45258. * Enables specular anti aliasing in the PBR shader.
  45259. * It will both interacts on the Geometry for analytical and IBL lighting.
  45260. * It also prefilter the roughness map based on the bump values.
  45261. */
  45262. protected _enableSpecularAntiAliasing: boolean;
  45263. /**
  45264. * Default configuration related to image processing available in the PBR Material.
  45265. */
  45266. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45267. /**
  45268. * Keep track of the image processing observer to allow dispose and replace.
  45269. */
  45270. private _imageProcessingObserver;
  45271. /**
  45272. * Attaches a new image processing configuration to the PBR Material.
  45273. * @param configuration
  45274. */
  45275. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45276. /**
  45277. * Stores the available render targets.
  45278. */
  45279. private _renderTargets;
  45280. /**
  45281. * Sets the global ambient color for the material used in lighting calculations.
  45282. */
  45283. private _globalAmbientColor;
  45284. /**
  45285. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45286. */
  45287. private _useLogarithmicDepth;
  45288. /**
  45289. * If set to true, no lighting calculations will be applied.
  45290. */
  45291. private _unlit;
  45292. private _debugMode;
  45293. /**
  45294. * @hidden
  45295. * This is reserved for the inspector.
  45296. * Defines the material debug mode.
  45297. * It helps seeing only some components of the material while troubleshooting.
  45298. */
  45299. debugMode: number;
  45300. /**
  45301. * @hidden
  45302. * This is reserved for the inspector.
  45303. * Specify from where on screen the debug mode should start.
  45304. * The value goes from -1 (full screen) to 1 (not visible)
  45305. * It helps with side by side comparison against the final render
  45306. * This defaults to -1
  45307. */
  45308. private debugLimit;
  45309. /**
  45310. * @hidden
  45311. * This is reserved for the inspector.
  45312. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45313. * You can use the factor to better multiply the final value.
  45314. */
  45315. private debugFactor;
  45316. /**
  45317. * Defines the clear coat layer parameters for the material.
  45318. */
  45319. readonly clearCoat: PBRClearCoatConfiguration;
  45320. /**
  45321. * Defines the anisotropic parameters for the material.
  45322. */
  45323. readonly anisotropy: PBRAnisotropicConfiguration;
  45324. /**
  45325. * Defines the BRDF parameters for the material.
  45326. */
  45327. readonly brdf: PBRBRDFConfiguration;
  45328. /**
  45329. * Defines the Sheen parameters for the material.
  45330. */
  45331. readonly sheen: PBRSheenConfiguration;
  45332. /**
  45333. * Defines the SubSurface parameters for the material.
  45334. */
  45335. readonly subSurface: PBRSubSurfaceConfiguration;
  45336. /**
  45337. * Custom callback helping to override the default shader used in the material.
  45338. */
  45339. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45340. /**
  45341. * Instantiates a new PBRMaterial instance.
  45342. *
  45343. * @param name The material name
  45344. * @param scene The scene the material will be use in.
  45345. */
  45346. constructor(name: string, scene: Scene);
  45347. /**
  45348. * Gets a boolean indicating that current material needs to register RTT
  45349. */
  45350. readonly hasRenderTargetTextures: boolean;
  45351. /**
  45352. * Gets the name of the material class.
  45353. */
  45354. getClassName(): string;
  45355. /**
  45356. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45357. */
  45358. /**
  45359. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45360. */
  45361. useLogarithmicDepth: boolean;
  45362. /**
  45363. * Gets the current transparency mode.
  45364. */
  45365. /**
  45366. * Sets the transparency mode of the material.
  45367. *
  45368. * | Value | Type | Description |
  45369. * | ----- | ----------------------------------- | ----------- |
  45370. * | 0 | OPAQUE | |
  45371. * | 1 | ALPHATEST | |
  45372. * | 2 | ALPHABLEND | |
  45373. * | 3 | ALPHATESTANDBLEND | |
  45374. *
  45375. */
  45376. transparencyMode: Nullable<number>;
  45377. /**
  45378. * Returns true if alpha blending should be disabled.
  45379. */
  45380. private readonly _disableAlphaBlending;
  45381. /**
  45382. * Specifies whether or not this material should be rendered in alpha blend mode.
  45383. */
  45384. needAlphaBlending(): boolean;
  45385. /**
  45386. * Specifies if the mesh will require alpha blending.
  45387. * @param mesh - BJS mesh.
  45388. */
  45389. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45390. /**
  45391. * Specifies whether or not this material should be rendered in alpha test mode.
  45392. */
  45393. needAlphaTesting(): boolean;
  45394. /**
  45395. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45396. */
  45397. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45398. /**
  45399. * Gets the texture used for the alpha test.
  45400. */
  45401. getAlphaTestTexture(): Nullable<BaseTexture>;
  45402. /**
  45403. * Specifies that the submesh is ready to be used.
  45404. * @param mesh - BJS mesh.
  45405. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45406. * @param useInstances - Specifies that instances should be used.
  45407. * @returns - boolean indicating that the submesh is ready or not.
  45408. */
  45409. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45410. /**
  45411. * Specifies if the material uses metallic roughness workflow.
  45412. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45413. */
  45414. isMetallicWorkflow(): boolean;
  45415. private _prepareEffect;
  45416. private _prepareDefines;
  45417. /**
  45418. * Force shader compilation
  45419. */
  45420. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45421. clipPlane: boolean;
  45422. }>): void;
  45423. /**
  45424. * Initializes the uniform buffer layout for the shader.
  45425. */
  45426. buildUniformLayout(): void;
  45427. /**
  45428. * Unbinds the material from the mesh
  45429. */
  45430. unbind(): void;
  45431. /**
  45432. * Binds the submesh data.
  45433. * @param world - The world matrix.
  45434. * @param mesh - The BJS mesh.
  45435. * @param subMesh - A submesh of the BJS mesh.
  45436. */
  45437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45438. /**
  45439. * Returns the animatable textures.
  45440. * @returns - Array of animatable textures.
  45441. */
  45442. getAnimatables(): IAnimatable[];
  45443. /**
  45444. * Returns the texture used for reflections.
  45445. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45446. */
  45447. private _getReflectionTexture;
  45448. /**
  45449. * Returns an array of the actively used textures.
  45450. * @returns - Array of BaseTextures
  45451. */
  45452. getActiveTextures(): BaseTexture[];
  45453. /**
  45454. * Checks to see if a texture is used in the material.
  45455. * @param texture - Base texture to use.
  45456. * @returns - Boolean specifying if a texture is used in the material.
  45457. */
  45458. hasTexture(texture: BaseTexture): boolean;
  45459. /**
  45460. * Disposes the resources of the material.
  45461. * @param forceDisposeEffect - Forces the disposal of effects.
  45462. * @param forceDisposeTextures - Forces the disposal of all textures.
  45463. */
  45464. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45465. }
  45466. }
  45467. declare module BABYLON {
  45468. /**
  45469. * The Physically based material of BJS.
  45470. *
  45471. * This offers the main features of a standard PBR material.
  45472. * For more information, please refer to the documentation :
  45473. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45474. */
  45475. export class PBRMaterial extends PBRBaseMaterial {
  45476. /**
  45477. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45478. */
  45479. static readonly PBRMATERIAL_OPAQUE: number;
  45480. /**
  45481. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45482. */
  45483. static readonly PBRMATERIAL_ALPHATEST: number;
  45484. /**
  45485. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45486. */
  45487. static readonly PBRMATERIAL_ALPHABLEND: number;
  45488. /**
  45489. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45490. * They are also discarded below the alpha cutoff threshold to improve performances.
  45491. */
  45492. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45493. /**
  45494. * Defines the default value of how much AO map is occluding the analytical lights
  45495. * (point spot...).
  45496. */
  45497. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45498. /**
  45499. * Intensity of the direct lights e.g. the four lights available in your scene.
  45500. * This impacts both the direct diffuse and specular highlights.
  45501. */
  45502. directIntensity: number;
  45503. /**
  45504. * Intensity of the emissive part of the material.
  45505. * This helps controlling the emissive effect without modifying the emissive color.
  45506. */
  45507. emissiveIntensity: number;
  45508. /**
  45509. * Intensity of the environment e.g. how much the environment will light the object
  45510. * either through harmonics for rough material or through the refelction for shiny ones.
  45511. */
  45512. environmentIntensity: number;
  45513. /**
  45514. * This is a special control allowing the reduction of the specular highlights coming from the
  45515. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45516. */
  45517. specularIntensity: number;
  45518. /**
  45519. * Debug Control allowing disabling the bump map on this material.
  45520. */
  45521. disableBumpMap: boolean;
  45522. /**
  45523. * AKA Diffuse Texture in standard nomenclature.
  45524. */
  45525. albedoTexture: BaseTexture;
  45526. /**
  45527. * AKA Occlusion Texture in other nomenclature.
  45528. */
  45529. ambientTexture: BaseTexture;
  45530. /**
  45531. * AKA Occlusion Texture Intensity in other nomenclature.
  45532. */
  45533. ambientTextureStrength: number;
  45534. /**
  45535. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45536. * 1 means it completely occludes it
  45537. * 0 mean it has no impact
  45538. */
  45539. ambientTextureImpactOnAnalyticalLights: number;
  45540. /**
  45541. * Stores the alpha values in a texture.
  45542. */
  45543. opacityTexture: BaseTexture;
  45544. /**
  45545. * Stores the reflection values in a texture.
  45546. */
  45547. reflectionTexture: Nullable<BaseTexture>;
  45548. /**
  45549. * Stores the emissive values in a texture.
  45550. */
  45551. emissiveTexture: BaseTexture;
  45552. /**
  45553. * AKA Specular texture in other nomenclature.
  45554. */
  45555. reflectivityTexture: BaseTexture;
  45556. /**
  45557. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45558. */
  45559. metallicTexture: BaseTexture;
  45560. /**
  45561. * Specifies the metallic scalar of the metallic/roughness workflow.
  45562. * Can also be used to scale the metalness values of the metallic texture.
  45563. */
  45564. metallic: Nullable<number>;
  45565. /**
  45566. * Specifies the roughness scalar of the metallic/roughness workflow.
  45567. * Can also be used to scale the roughness values of the metallic texture.
  45568. */
  45569. roughness: Nullable<number>;
  45570. /**
  45571. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45572. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45573. */
  45574. microSurfaceTexture: BaseTexture;
  45575. /**
  45576. * Stores surface normal data used to displace a mesh in a texture.
  45577. */
  45578. bumpTexture: BaseTexture;
  45579. /**
  45580. * Stores the pre-calculated light information of a mesh in a texture.
  45581. */
  45582. lightmapTexture: BaseTexture;
  45583. /**
  45584. * Stores the refracted light information in a texture.
  45585. */
  45586. refractionTexture: Nullable<BaseTexture>;
  45587. /**
  45588. * The color of a material in ambient lighting.
  45589. */
  45590. ambientColor: Color3;
  45591. /**
  45592. * AKA Diffuse Color in other nomenclature.
  45593. */
  45594. albedoColor: Color3;
  45595. /**
  45596. * AKA Specular Color in other nomenclature.
  45597. */
  45598. reflectivityColor: Color3;
  45599. /**
  45600. * The color reflected from the material.
  45601. */
  45602. reflectionColor: Color3;
  45603. /**
  45604. * The color emitted from the material.
  45605. */
  45606. emissiveColor: Color3;
  45607. /**
  45608. * AKA Glossiness in other nomenclature.
  45609. */
  45610. microSurface: number;
  45611. /**
  45612. * source material index of refraction (IOR)' / 'destination material IOR.
  45613. */
  45614. indexOfRefraction: number;
  45615. /**
  45616. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45617. */
  45618. invertRefractionY: boolean;
  45619. /**
  45620. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45621. * Materials half opaque for instance using refraction could benefit from this control.
  45622. */
  45623. linkRefractionWithTransparency: boolean;
  45624. /**
  45625. * If true, the light map contains occlusion information instead of lighting info.
  45626. */
  45627. useLightmapAsShadowmap: boolean;
  45628. /**
  45629. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45630. */
  45631. useAlphaFromAlbedoTexture: boolean;
  45632. /**
  45633. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45634. */
  45635. forceAlphaTest: boolean;
  45636. /**
  45637. * Defines the alpha limits in alpha test mode.
  45638. */
  45639. alphaCutOff: number;
  45640. /**
  45641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45643. */
  45644. useSpecularOverAlpha: boolean;
  45645. /**
  45646. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45647. */
  45648. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45649. /**
  45650. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45651. */
  45652. useRoughnessFromMetallicTextureAlpha: boolean;
  45653. /**
  45654. * Specifies if the metallic texture contains the roughness information in its green channel.
  45655. */
  45656. useRoughnessFromMetallicTextureGreen: boolean;
  45657. /**
  45658. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45659. */
  45660. useMetallnessFromMetallicTextureBlue: boolean;
  45661. /**
  45662. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45663. */
  45664. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45665. /**
  45666. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45667. */
  45668. useAmbientInGrayScale: boolean;
  45669. /**
  45670. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45671. * The material will try to infer what glossiness each pixel should be.
  45672. */
  45673. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45674. /**
  45675. * BJS is using an harcoded light falloff based on a manually sets up range.
  45676. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45677. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45678. */
  45679. /**
  45680. * BJS is using an harcoded light falloff based on a manually sets up range.
  45681. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45682. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45683. */
  45684. usePhysicalLightFalloff: boolean;
  45685. /**
  45686. * In order to support the falloff compatibility with gltf, a special mode has been added
  45687. * to reproduce the gltf light falloff.
  45688. */
  45689. /**
  45690. * In order to support the falloff compatibility with gltf, a special mode has been added
  45691. * to reproduce the gltf light falloff.
  45692. */
  45693. useGLTFLightFalloff: boolean;
  45694. /**
  45695. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45696. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45697. */
  45698. useRadianceOverAlpha: boolean;
  45699. /**
  45700. * Allows using an object space normal map (instead of tangent space).
  45701. */
  45702. useObjectSpaceNormalMap: boolean;
  45703. /**
  45704. * Allows using the bump map in parallax mode.
  45705. */
  45706. useParallax: boolean;
  45707. /**
  45708. * Allows using the bump map in parallax occlusion mode.
  45709. */
  45710. useParallaxOcclusion: boolean;
  45711. /**
  45712. * Controls the scale bias of the parallax mode.
  45713. */
  45714. parallaxScaleBias: number;
  45715. /**
  45716. * If sets to true, disables all the lights affecting the material.
  45717. */
  45718. disableLighting: boolean;
  45719. /**
  45720. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45721. */
  45722. forceIrradianceInFragment: boolean;
  45723. /**
  45724. * Number of Simultaneous lights allowed on the material.
  45725. */
  45726. maxSimultaneousLights: number;
  45727. /**
  45728. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45729. */
  45730. invertNormalMapX: boolean;
  45731. /**
  45732. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45733. */
  45734. invertNormalMapY: boolean;
  45735. /**
  45736. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45737. */
  45738. twoSidedLighting: boolean;
  45739. /**
  45740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45741. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45742. */
  45743. useAlphaFresnel: boolean;
  45744. /**
  45745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45746. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45747. */
  45748. useLinearAlphaFresnel: boolean;
  45749. /**
  45750. * Let user defines the brdf lookup texture used for IBL.
  45751. * A default 8bit version is embedded but you could point at :
  45752. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  45753. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45754. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  45755. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45756. */
  45757. environmentBRDFTexture: Nullable<BaseTexture>;
  45758. /**
  45759. * Force normal to face away from face.
  45760. */
  45761. forceNormalForward: boolean;
  45762. /**
  45763. * Enables specular anti aliasing in the PBR shader.
  45764. * It will both interacts on the Geometry for analytical and IBL lighting.
  45765. * It also prefilter the roughness map based on the bump values.
  45766. */
  45767. enableSpecularAntiAliasing: boolean;
  45768. /**
  45769. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45770. * makes the reflect vector face the model (under horizon).
  45771. */
  45772. useHorizonOcclusion: boolean;
  45773. /**
  45774. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45775. * too much the area relying on ambient texture to define their ambient occlusion.
  45776. */
  45777. useRadianceOcclusion: boolean;
  45778. /**
  45779. * If set to true, no lighting calculations will be applied.
  45780. */
  45781. unlit: boolean;
  45782. /**
  45783. * Gets the image processing configuration used either in this material.
  45784. */
  45785. /**
  45786. * Sets the Default image processing configuration used either in the this material.
  45787. *
  45788. * If sets to null, the scene one is in use.
  45789. */
  45790. imageProcessingConfiguration: ImageProcessingConfiguration;
  45791. /**
  45792. * Gets wether the color curves effect is enabled.
  45793. */
  45794. /**
  45795. * Sets wether the color curves effect is enabled.
  45796. */
  45797. cameraColorCurvesEnabled: boolean;
  45798. /**
  45799. * Gets wether the color grading effect is enabled.
  45800. */
  45801. /**
  45802. * Gets wether the color grading effect is enabled.
  45803. */
  45804. cameraColorGradingEnabled: boolean;
  45805. /**
  45806. * Gets wether tonemapping is enabled or not.
  45807. */
  45808. /**
  45809. * Sets wether tonemapping is enabled or not
  45810. */
  45811. cameraToneMappingEnabled: boolean;
  45812. /**
  45813. * The camera exposure used on this material.
  45814. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45815. * This corresponds to a photographic exposure.
  45816. */
  45817. /**
  45818. * The camera exposure used on this material.
  45819. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45820. * This corresponds to a photographic exposure.
  45821. */
  45822. cameraExposure: number;
  45823. /**
  45824. * Gets The camera contrast used on this material.
  45825. */
  45826. /**
  45827. * Sets The camera contrast used on this material.
  45828. */
  45829. cameraContrast: number;
  45830. /**
  45831. * Gets the Color Grading 2D Lookup Texture.
  45832. */
  45833. /**
  45834. * Sets the Color Grading 2D Lookup Texture.
  45835. */
  45836. cameraColorGradingTexture: Nullable<BaseTexture>;
  45837. /**
  45838. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45839. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45840. * 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;
  45841. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45842. */
  45843. /**
  45844. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45845. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45846. * 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;
  45847. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45848. */
  45849. cameraColorCurves: Nullable<ColorCurves>;
  45850. /**
  45851. * Instantiates a new PBRMaterial instance.
  45852. *
  45853. * @param name The material name
  45854. * @param scene The scene the material will be use in.
  45855. */
  45856. constructor(name: string, scene: Scene);
  45857. /**
  45858. * Returns the name of this material class.
  45859. */
  45860. getClassName(): string;
  45861. /**
  45862. * Makes a duplicate of the current material.
  45863. * @param name - name to use for the new material.
  45864. */
  45865. clone(name: string): PBRMaterial;
  45866. /**
  45867. * Serializes this PBR Material.
  45868. * @returns - An object with the serialized material.
  45869. */
  45870. serialize(): any;
  45871. /**
  45872. * Parses a PBR Material from a serialized object.
  45873. * @param source - Serialized object.
  45874. * @param scene - BJS scene instance.
  45875. * @param rootUrl - url for the scene object
  45876. * @returns - PBRMaterial
  45877. */
  45878. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45879. }
  45880. }
  45881. declare module BABYLON {
  45882. /**
  45883. * Direct draw surface info
  45884. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45885. */
  45886. export interface DDSInfo {
  45887. /**
  45888. * Width of the texture
  45889. */
  45890. width: number;
  45891. /**
  45892. * Width of the texture
  45893. */
  45894. height: number;
  45895. /**
  45896. * Number of Mipmaps for the texture
  45897. * @see https://en.wikipedia.org/wiki/Mipmap
  45898. */
  45899. mipmapCount: number;
  45900. /**
  45901. * If the textures format is a known fourCC format
  45902. * @see https://www.fourcc.org/
  45903. */
  45904. isFourCC: boolean;
  45905. /**
  45906. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45907. */
  45908. isRGB: boolean;
  45909. /**
  45910. * If the texture is a lumincance format
  45911. */
  45912. isLuminance: boolean;
  45913. /**
  45914. * If this is a cube texture
  45915. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45916. */
  45917. isCube: boolean;
  45918. /**
  45919. * If the texture is a compressed format eg. FOURCC_DXT1
  45920. */
  45921. isCompressed: boolean;
  45922. /**
  45923. * The dxgiFormat of the texture
  45924. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45925. */
  45926. dxgiFormat: number;
  45927. /**
  45928. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45929. */
  45930. textureType: number;
  45931. /**
  45932. * Sphericle polynomial created for the dds texture
  45933. */
  45934. sphericalPolynomial?: SphericalPolynomial;
  45935. }
  45936. /**
  45937. * Class used to provide DDS decompression tools
  45938. */
  45939. export class DDSTools {
  45940. /**
  45941. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45942. */
  45943. static StoreLODInAlphaChannel: boolean;
  45944. /**
  45945. * Gets DDS information from an array buffer
  45946. * @param arrayBuffer defines the array buffer to read data from
  45947. * @returns the DDS information
  45948. */
  45949. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45950. private static _FloatView;
  45951. private static _Int32View;
  45952. private static _ToHalfFloat;
  45953. private static _FromHalfFloat;
  45954. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45955. private static _GetHalfFloatRGBAArrayBuffer;
  45956. private static _GetFloatRGBAArrayBuffer;
  45957. private static _GetFloatAsUIntRGBAArrayBuffer;
  45958. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45959. private static _GetRGBAArrayBuffer;
  45960. private static _ExtractLongWordOrder;
  45961. private static _GetRGBArrayBuffer;
  45962. private static _GetLuminanceArrayBuffer;
  45963. /**
  45964. * Uploads DDS Levels to a Babylon Texture
  45965. * @hidden
  45966. */
  45967. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45968. }
  45969. interface Engine {
  45970. /**
  45971. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45972. * @param rootUrl defines the url where the file to load is located
  45973. * @param scene defines the current scene
  45974. * @param lodScale defines scale to apply to the mip map selection
  45975. * @param lodOffset defines offset to apply to the mip map selection
  45976. * @param onLoad defines an optional callback raised when the texture is loaded
  45977. * @param onError defines an optional callback raised if there is an issue to load the texture
  45978. * @param format defines the format of the data
  45979. * @param forcedExtension defines the extension to use to pick the right loader
  45980. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45981. * @returns the cube texture as an InternalTexture
  45982. */
  45983. 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;
  45984. }
  45985. }
  45986. declare module BABYLON {
  45987. /**
  45988. * Implementation of the DDS Texture Loader.
  45989. * @hidden
  45990. */
  45991. export class _DDSTextureLoader implements IInternalTextureLoader {
  45992. /**
  45993. * Defines wether the loader supports cascade loading the different faces.
  45994. */
  45995. readonly supportCascades: boolean;
  45996. /**
  45997. * This returns if the loader support the current file information.
  45998. * @param extension defines the file extension of the file being loaded
  45999. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46000. * @param fallback defines the fallback internal texture if any
  46001. * @param isBase64 defines whether the texture is encoded as a base64
  46002. * @param isBuffer defines whether the texture data are stored as a buffer
  46003. * @returns true if the loader can load the specified file
  46004. */
  46005. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46006. /**
  46007. * Transform the url before loading if required.
  46008. * @param rootUrl the url of the texture
  46009. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46010. * @returns the transformed texture
  46011. */
  46012. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46013. /**
  46014. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46015. * @param rootUrl the url of the texture
  46016. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46017. * @returns the fallback texture
  46018. */
  46019. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46020. /**
  46021. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46022. * @param data contains the texture data
  46023. * @param texture defines the BabylonJS internal texture
  46024. * @param createPolynomials will be true if polynomials have been requested
  46025. * @param onLoad defines the callback to trigger once the texture is ready
  46026. * @param onError defines the callback to trigger in case of error
  46027. */
  46028. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46029. /**
  46030. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46031. * @param data contains the texture data
  46032. * @param texture defines the BabylonJS internal texture
  46033. * @param callback defines the method to call once ready to upload
  46034. */
  46035. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46036. }
  46037. }
  46038. declare module BABYLON {
  46039. /** @hidden */
  46040. export var rgbdEncodePixelShader: {
  46041. name: string;
  46042. shader: string;
  46043. };
  46044. }
  46045. declare module BABYLON {
  46046. /**
  46047. * Raw texture data and descriptor sufficient for WebGL texture upload
  46048. */
  46049. export interface EnvironmentTextureInfo {
  46050. /**
  46051. * Version of the environment map
  46052. */
  46053. version: number;
  46054. /**
  46055. * Width of image
  46056. */
  46057. width: number;
  46058. /**
  46059. * Irradiance information stored in the file.
  46060. */
  46061. irradiance: any;
  46062. /**
  46063. * Specular information stored in the file.
  46064. */
  46065. specular: any;
  46066. }
  46067. /**
  46068. * Sets of helpers addressing the serialization and deserialization of environment texture
  46069. * stored in a BabylonJS env file.
  46070. * Those files are usually stored as .env files.
  46071. */
  46072. export class EnvironmentTextureTools {
  46073. /**
  46074. * Magic number identifying the env file.
  46075. */
  46076. private static _MagicBytes;
  46077. /**
  46078. * Gets the environment info from an env file.
  46079. * @param data The array buffer containing the .env bytes.
  46080. * @returns the environment file info (the json header) if successfully parsed.
  46081. */
  46082. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46083. /**
  46084. * Creates an environment texture from a loaded cube texture.
  46085. * @param texture defines the cube texture to convert in env file
  46086. * @return a promise containing the environment data if succesfull.
  46087. */
  46088. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46089. /**
  46090. * Creates a JSON representation of the spherical data.
  46091. * @param texture defines the texture containing the polynomials
  46092. * @return the JSON representation of the spherical info
  46093. */
  46094. private static _CreateEnvTextureIrradiance;
  46095. /**
  46096. * Uploads the texture info contained in the env file to the GPU.
  46097. * @param texture defines the internal texture to upload to
  46098. * @param arrayBuffer defines the buffer cotaining the data to load
  46099. * @param info defines the texture info retrieved through the GetEnvInfo method
  46100. * @returns a promise
  46101. */
  46102. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46103. /**
  46104. * Uploads the levels of image data to the GPU.
  46105. * @param texture defines the internal texture to upload to
  46106. * @param imageData defines the array buffer views of image data [mipmap][face]
  46107. * @returns a promise
  46108. */
  46109. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46110. /**
  46111. * Uploads spherical polynomials information to the texture.
  46112. * @param texture defines the texture we are trying to upload the information to
  46113. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46114. */
  46115. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46116. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46117. }
  46118. }
  46119. declare module BABYLON {
  46120. /**
  46121. * Implementation of the ENV Texture Loader.
  46122. * @hidden
  46123. */
  46124. export class _ENVTextureLoader implements IInternalTextureLoader {
  46125. /**
  46126. * Defines wether the loader supports cascade loading the different faces.
  46127. */
  46128. readonly supportCascades: boolean;
  46129. /**
  46130. * This returns if the loader support the current file information.
  46131. * @param extension defines the file extension of the file being loaded
  46132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46133. * @param fallback defines the fallback internal texture if any
  46134. * @param isBase64 defines whether the texture is encoded as a base64
  46135. * @param isBuffer defines whether the texture data are stored as a buffer
  46136. * @returns true if the loader can load the specified file
  46137. */
  46138. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46139. /**
  46140. * Transform the url before loading if required.
  46141. * @param rootUrl the url of the texture
  46142. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46143. * @returns the transformed texture
  46144. */
  46145. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46146. /**
  46147. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46148. * @param rootUrl the url of the texture
  46149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46150. * @returns the fallback texture
  46151. */
  46152. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46153. /**
  46154. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46155. * @param data contains the texture data
  46156. * @param texture defines the BabylonJS internal texture
  46157. * @param createPolynomials will be true if polynomials have been requested
  46158. * @param onLoad defines the callback to trigger once the texture is ready
  46159. * @param onError defines the callback to trigger in case of error
  46160. */
  46161. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46162. /**
  46163. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46164. * @param data contains the texture data
  46165. * @param texture defines the BabylonJS internal texture
  46166. * @param callback defines the method to call once ready to upload
  46167. */
  46168. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46169. }
  46170. }
  46171. declare module BABYLON {
  46172. /**
  46173. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46174. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46175. */
  46176. export class KhronosTextureContainer {
  46177. /** contents of the KTX container file */
  46178. arrayBuffer: any;
  46179. private static HEADER_LEN;
  46180. private static COMPRESSED_2D;
  46181. private static COMPRESSED_3D;
  46182. private static TEX_2D;
  46183. private static TEX_3D;
  46184. /**
  46185. * Gets the openGL type
  46186. */
  46187. glType: number;
  46188. /**
  46189. * Gets the openGL type size
  46190. */
  46191. glTypeSize: number;
  46192. /**
  46193. * Gets the openGL format
  46194. */
  46195. glFormat: number;
  46196. /**
  46197. * Gets the openGL internal format
  46198. */
  46199. glInternalFormat: number;
  46200. /**
  46201. * Gets the base internal format
  46202. */
  46203. glBaseInternalFormat: number;
  46204. /**
  46205. * Gets image width in pixel
  46206. */
  46207. pixelWidth: number;
  46208. /**
  46209. * Gets image height in pixel
  46210. */
  46211. pixelHeight: number;
  46212. /**
  46213. * Gets image depth in pixels
  46214. */
  46215. pixelDepth: number;
  46216. /**
  46217. * Gets the number of array elements
  46218. */
  46219. numberOfArrayElements: number;
  46220. /**
  46221. * Gets the number of faces
  46222. */
  46223. numberOfFaces: number;
  46224. /**
  46225. * Gets the number of mipmap levels
  46226. */
  46227. numberOfMipmapLevels: number;
  46228. /**
  46229. * Gets the bytes of key value data
  46230. */
  46231. bytesOfKeyValueData: number;
  46232. /**
  46233. * Gets the load type
  46234. */
  46235. loadType: number;
  46236. /**
  46237. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46238. */
  46239. isInvalid: boolean;
  46240. /**
  46241. * Creates a new KhronosTextureContainer
  46242. * @param arrayBuffer contents of the KTX container file
  46243. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46244. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46245. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46246. */
  46247. constructor(
  46248. /** contents of the KTX container file */
  46249. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46250. /**
  46251. * Uploads KTX content to a Babylon Texture.
  46252. * It is assumed that the texture has already been created & is currently bound
  46253. * @hidden
  46254. */
  46255. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46256. private _upload2DCompressedLevels;
  46257. }
  46258. }
  46259. declare module BABYLON {
  46260. /**
  46261. * Implementation of the KTX Texture Loader.
  46262. * @hidden
  46263. */
  46264. export class _KTXTextureLoader implements IInternalTextureLoader {
  46265. /**
  46266. * Defines wether the loader supports cascade loading the different faces.
  46267. */
  46268. readonly supportCascades: boolean;
  46269. /**
  46270. * This returns if the loader support the current file information.
  46271. * @param extension defines the file extension of the file being loaded
  46272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46273. * @param fallback defines the fallback internal texture if any
  46274. * @param isBase64 defines whether the texture is encoded as a base64
  46275. * @param isBuffer defines whether the texture data are stored as a buffer
  46276. * @returns true if the loader can load the specified file
  46277. */
  46278. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46279. /**
  46280. * Transform the url before loading if required.
  46281. * @param rootUrl the url of the texture
  46282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46283. * @returns the transformed texture
  46284. */
  46285. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46286. /**
  46287. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46288. * @param rootUrl the url of the texture
  46289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46290. * @returns the fallback texture
  46291. */
  46292. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46293. /**
  46294. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46295. * @param data contains the texture data
  46296. * @param texture defines the BabylonJS internal texture
  46297. * @param createPolynomials will be true if polynomials have been requested
  46298. * @param onLoad defines the callback to trigger once the texture is ready
  46299. * @param onError defines the callback to trigger in case of error
  46300. */
  46301. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46302. /**
  46303. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46304. * @param data contains the texture data
  46305. * @param texture defines the BabylonJS internal texture
  46306. * @param callback defines the method to call once ready to upload
  46307. */
  46308. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46309. }
  46310. }
  46311. declare module BABYLON {
  46312. /** @hidden */
  46313. export var _forceSceneHelpersToBundle: boolean;
  46314. interface Scene {
  46315. /**
  46316. * Creates a default light for the scene.
  46317. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46318. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46319. */
  46320. createDefaultLight(replace?: boolean): void;
  46321. /**
  46322. * Creates a default camera for the scene.
  46323. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46324. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46325. * @param replace has default false, when true replaces the active camera in the scene
  46326. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46327. */
  46328. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46329. /**
  46330. * Creates a default camera and a default light.
  46331. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46332. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46333. * @param replace has the default false, when true replaces the active camera/light in the scene
  46334. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46335. */
  46336. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46337. /**
  46338. * Creates a new sky box
  46339. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46340. * @param environmentTexture defines the texture to use as environment texture
  46341. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46342. * @param scale defines the overall scale of the skybox
  46343. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46344. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46345. * @returns a new mesh holding the sky box
  46346. */
  46347. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46348. /**
  46349. * Creates a new environment
  46350. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46351. * @param options defines the options you can use to configure the environment
  46352. * @returns the new EnvironmentHelper
  46353. */
  46354. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46355. /**
  46356. * Creates a new VREXperienceHelper
  46357. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46358. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46359. * @returns a new VREXperienceHelper
  46360. */
  46361. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46362. /**
  46363. * Creates a new XREXperienceHelper
  46364. * @see http://doc.babylonjs.com/how_to/webxr
  46365. * @returns a promise for a new XREXperienceHelper
  46366. */
  46367. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46368. }
  46369. }
  46370. declare module BABYLON {
  46371. /**
  46372. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46373. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46374. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46375. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46376. */
  46377. export class VideoDome extends TransformNode {
  46378. /**
  46379. * Define the video source as a Monoscopic panoramic 360 video.
  46380. */
  46381. static readonly MODE_MONOSCOPIC: number;
  46382. /**
  46383. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46384. */
  46385. static readonly MODE_TOPBOTTOM: number;
  46386. /**
  46387. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46388. */
  46389. static readonly MODE_SIDEBYSIDE: number;
  46390. private _useDirectMapping;
  46391. /**
  46392. * The video texture being displayed on the sphere
  46393. */
  46394. protected _videoTexture: VideoTexture;
  46395. /**
  46396. * Gets the video texture being displayed on the sphere
  46397. */
  46398. readonly videoTexture: VideoTexture;
  46399. /**
  46400. * The skybox material
  46401. */
  46402. protected _material: BackgroundMaterial;
  46403. /**
  46404. * The surface used for the skybox
  46405. */
  46406. protected _mesh: Mesh;
  46407. /**
  46408. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46409. * Also see the options.resolution property.
  46410. */
  46411. fovMultiplier: number;
  46412. private _videoMode;
  46413. /**
  46414. * Gets or set the current video mode for the video. It can be:
  46415. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46416. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46417. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46418. */
  46419. videoMode: number;
  46420. /**
  46421. * Oberserver used in Stereoscopic VR Mode.
  46422. */
  46423. private _onBeforeCameraRenderObserver;
  46424. /**
  46425. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46426. * @param name Element's name, child elements will append suffixes for their own names.
  46427. * @param urlsOrVideo defines the url(s) or the video element to use
  46428. * @param options An object containing optional or exposed sub element properties
  46429. */
  46430. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46431. resolution?: number;
  46432. clickToPlay?: boolean;
  46433. autoPlay?: boolean;
  46434. loop?: boolean;
  46435. size?: number;
  46436. poster?: string;
  46437. faceForward?: boolean;
  46438. useDirectMapping?: boolean;
  46439. }, scene: Scene);
  46440. private _changeVideoMode;
  46441. /**
  46442. * Releases resources associated with this node.
  46443. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46444. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46445. */
  46446. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46447. }
  46448. }
  46449. declare module BABYLON {
  46450. /**
  46451. * This class can be used to get instrumentation data from a Babylon engine
  46452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46453. */
  46454. export class EngineInstrumentation implements IDisposable {
  46455. /**
  46456. * Define the instrumented engine.
  46457. */
  46458. engine: Engine;
  46459. private _captureGPUFrameTime;
  46460. private _gpuFrameTimeToken;
  46461. private _gpuFrameTime;
  46462. private _captureShaderCompilationTime;
  46463. private _shaderCompilationTime;
  46464. private _onBeginFrameObserver;
  46465. private _onEndFrameObserver;
  46466. private _onBeforeShaderCompilationObserver;
  46467. private _onAfterShaderCompilationObserver;
  46468. /**
  46469. * Gets the perf counter used for GPU frame time
  46470. */
  46471. readonly gpuFrameTimeCounter: PerfCounter;
  46472. /**
  46473. * Gets the GPU frame time capture status
  46474. */
  46475. /**
  46476. * Enable or disable the GPU frame time capture
  46477. */
  46478. captureGPUFrameTime: boolean;
  46479. /**
  46480. * Gets the perf counter used for shader compilation time
  46481. */
  46482. readonly shaderCompilationTimeCounter: PerfCounter;
  46483. /**
  46484. * Gets the shader compilation time capture status
  46485. */
  46486. /**
  46487. * Enable or disable the shader compilation time capture
  46488. */
  46489. captureShaderCompilationTime: boolean;
  46490. /**
  46491. * Instantiates a new engine instrumentation.
  46492. * This class can be used to get instrumentation data from a Babylon engine
  46493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46494. * @param engine Defines the engine to instrument
  46495. */
  46496. constructor(
  46497. /**
  46498. * Define the instrumented engine.
  46499. */
  46500. engine: Engine);
  46501. /**
  46502. * Dispose and release associated resources.
  46503. */
  46504. dispose(): void;
  46505. }
  46506. }
  46507. declare module BABYLON {
  46508. /**
  46509. * This class can be used to get instrumentation data from a Babylon engine
  46510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46511. */
  46512. export class SceneInstrumentation implements IDisposable {
  46513. /**
  46514. * Defines the scene to instrument
  46515. */
  46516. scene: Scene;
  46517. private _captureActiveMeshesEvaluationTime;
  46518. private _activeMeshesEvaluationTime;
  46519. private _captureRenderTargetsRenderTime;
  46520. private _renderTargetsRenderTime;
  46521. private _captureFrameTime;
  46522. private _frameTime;
  46523. private _captureRenderTime;
  46524. private _renderTime;
  46525. private _captureInterFrameTime;
  46526. private _interFrameTime;
  46527. private _captureParticlesRenderTime;
  46528. private _particlesRenderTime;
  46529. private _captureSpritesRenderTime;
  46530. private _spritesRenderTime;
  46531. private _capturePhysicsTime;
  46532. private _physicsTime;
  46533. private _captureAnimationsTime;
  46534. private _animationsTime;
  46535. private _captureCameraRenderTime;
  46536. private _cameraRenderTime;
  46537. private _onBeforeActiveMeshesEvaluationObserver;
  46538. private _onAfterActiveMeshesEvaluationObserver;
  46539. private _onBeforeRenderTargetsRenderObserver;
  46540. private _onAfterRenderTargetsRenderObserver;
  46541. private _onAfterRenderObserver;
  46542. private _onBeforeDrawPhaseObserver;
  46543. private _onAfterDrawPhaseObserver;
  46544. private _onBeforeAnimationsObserver;
  46545. private _onBeforeParticlesRenderingObserver;
  46546. private _onAfterParticlesRenderingObserver;
  46547. private _onBeforeSpritesRenderingObserver;
  46548. private _onAfterSpritesRenderingObserver;
  46549. private _onBeforePhysicsObserver;
  46550. private _onAfterPhysicsObserver;
  46551. private _onAfterAnimationsObserver;
  46552. private _onBeforeCameraRenderObserver;
  46553. private _onAfterCameraRenderObserver;
  46554. /**
  46555. * Gets the perf counter used for active meshes evaluation time
  46556. */
  46557. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46558. /**
  46559. * Gets the active meshes evaluation time capture status
  46560. */
  46561. /**
  46562. * Enable or disable the active meshes evaluation time capture
  46563. */
  46564. captureActiveMeshesEvaluationTime: boolean;
  46565. /**
  46566. * Gets the perf counter used for render targets render time
  46567. */
  46568. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46569. /**
  46570. * Gets the render targets render time capture status
  46571. */
  46572. /**
  46573. * Enable or disable the render targets render time capture
  46574. */
  46575. captureRenderTargetsRenderTime: boolean;
  46576. /**
  46577. * Gets the perf counter used for particles render time
  46578. */
  46579. readonly particlesRenderTimeCounter: PerfCounter;
  46580. /**
  46581. * Gets the particles render time capture status
  46582. */
  46583. /**
  46584. * Enable or disable the particles render time capture
  46585. */
  46586. captureParticlesRenderTime: boolean;
  46587. /**
  46588. * Gets the perf counter used for sprites render time
  46589. */
  46590. readonly spritesRenderTimeCounter: PerfCounter;
  46591. /**
  46592. * Gets the sprites render time capture status
  46593. */
  46594. /**
  46595. * Enable or disable the sprites render time capture
  46596. */
  46597. captureSpritesRenderTime: boolean;
  46598. /**
  46599. * Gets the perf counter used for physics time
  46600. */
  46601. readonly physicsTimeCounter: PerfCounter;
  46602. /**
  46603. * Gets the physics time capture status
  46604. */
  46605. /**
  46606. * Enable or disable the physics time capture
  46607. */
  46608. capturePhysicsTime: boolean;
  46609. /**
  46610. * Gets the perf counter used for animations time
  46611. */
  46612. readonly animationsTimeCounter: PerfCounter;
  46613. /**
  46614. * Gets the animations time capture status
  46615. */
  46616. /**
  46617. * Enable or disable the animations time capture
  46618. */
  46619. captureAnimationsTime: boolean;
  46620. /**
  46621. * Gets the perf counter used for frame time capture
  46622. */
  46623. readonly frameTimeCounter: PerfCounter;
  46624. /**
  46625. * Gets the frame time capture status
  46626. */
  46627. /**
  46628. * Enable or disable the frame time capture
  46629. */
  46630. captureFrameTime: boolean;
  46631. /**
  46632. * Gets the perf counter used for inter-frames time capture
  46633. */
  46634. readonly interFrameTimeCounter: PerfCounter;
  46635. /**
  46636. * Gets the inter-frames time capture status
  46637. */
  46638. /**
  46639. * Enable or disable the inter-frames time capture
  46640. */
  46641. captureInterFrameTime: boolean;
  46642. /**
  46643. * Gets the perf counter used for render time capture
  46644. */
  46645. readonly renderTimeCounter: PerfCounter;
  46646. /**
  46647. * Gets the render time capture status
  46648. */
  46649. /**
  46650. * Enable or disable the render time capture
  46651. */
  46652. captureRenderTime: boolean;
  46653. /**
  46654. * Gets the perf counter used for camera render time capture
  46655. */
  46656. readonly cameraRenderTimeCounter: PerfCounter;
  46657. /**
  46658. * Gets the camera render time capture status
  46659. */
  46660. /**
  46661. * Enable or disable the camera render time capture
  46662. */
  46663. captureCameraRenderTime: boolean;
  46664. /**
  46665. * Gets the perf counter used for draw calls
  46666. */
  46667. readonly drawCallsCounter: PerfCounter;
  46668. /**
  46669. * Instantiates a new scene instrumentation.
  46670. * This class can be used to get instrumentation data from a Babylon engine
  46671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46672. * @param scene Defines the scene to instrument
  46673. */
  46674. constructor(
  46675. /**
  46676. * Defines the scene to instrument
  46677. */
  46678. scene: Scene);
  46679. /**
  46680. * Dispose and release associated resources.
  46681. */
  46682. dispose(): void;
  46683. }
  46684. }
  46685. declare module BABYLON {
  46686. /** @hidden */
  46687. export var glowMapGenerationPixelShader: {
  46688. name: string;
  46689. shader: string;
  46690. };
  46691. }
  46692. declare module BABYLON {
  46693. /** @hidden */
  46694. export var glowMapGenerationVertexShader: {
  46695. name: string;
  46696. shader: string;
  46697. };
  46698. }
  46699. declare module BABYLON {
  46700. /**
  46701. * Effect layer options. This helps customizing the behaviour
  46702. * of the effect layer.
  46703. */
  46704. export interface IEffectLayerOptions {
  46705. /**
  46706. * Multiplication factor apply to the canvas size to compute the render target size
  46707. * used to generated the objects (the smaller the faster).
  46708. */
  46709. mainTextureRatio: number;
  46710. /**
  46711. * Enforces a fixed size texture to ensure effect stability across devices.
  46712. */
  46713. mainTextureFixedSize?: number;
  46714. /**
  46715. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46716. */
  46717. alphaBlendingMode: number;
  46718. /**
  46719. * The camera attached to the layer.
  46720. */
  46721. camera: Nullable<Camera>;
  46722. /**
  46723. * The rendering group to draw the layer in.
  46724. */
  46725. renderingGroupId: number;
  46726. }
  46727. /**
  46728. * The effect layer Helps adding post process effect blended with the main pass.
  46729. *
  46730. * This can be for instance use to generate glow or higlight effects on the scene.
  46731. *
  46732. * The effect layer class can not be used directly and is intented to inherited from to be
  46733. * customized per effects.
  46734. */
  46735. export abstract class EffectLayer {
  46736. private _vertexBuffers;
  46737. private _indexBuffer;
  46738. private _cachedDefines;
  46739. private _effectLayerMapGenerationEffect;
  46740. private _effectLayerOptions;
  46741. private _mergeEffect;
  46742. protected _scene: Scene;
  46743. protected _engine: Engine;
  46744. protected _maxSize: number;
  46745. protected _mainTextureDesiredSize: ISize;
  46746. protected _mainTexture: RenderTargetTexture;
  46747. protected _shouldRender: boolean;
  46748. protected _postProcesses: PostProcess[];
  46749. protected _textures: BaseTexture[];
  46750. protected _emissiveTextureAndColor: {
  46751. texture: Nullable<BaseTexture>;
  46752. color: Color4;
  46753. };
  46754. /**
  46755. * The name of the layer
  46756. */
  46757. name: string;
  46758. /**
  46759. * The clear color of the texture used to generate the glow map.
  46760. */
  46761. neutralColor: Color4;
  46762. /**
  46763. * Specifies wether the highlight layer is enabled or not.
  46764. */
  46765. isEnabled: boolean;
  46766. /**
  46767. * Gets the camera attached to the layer.
  46768. */
  46769. readonly camera: Nullable<Camera>;
  46770. /**
  46771. * Gets the rendering group id the layer should render in.
  46772. */
  46773. renderingGroupId: number;
  46774. /**
  46775. * An event triggered when the effect layer has been disposed.
  46776. */
  46777. onDisposeObservable: Observable<EffectLayer>;
  46778. /**
  46779. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46780. */
  46781. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46782. /**
  46783. * An event triggered when the generated texture is being merged in the scene.
  46784. */
  46785. onBeforeComposeObservable: Observable<EffectLayer>;
  46786. /**
  46787. * An event triggered when the generated texture has been merged in the scene.
  46788. */
  46789. onAfterComposeObservable: Observable<EffectLayer>;
  46790. /**
  46791. * An event triggered when the efffect layer changes its size.
  46792. */
  46793. onSizeChangedObservable: Observable<EffectLayer>;
  46794. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46795. /**
  46796. * Instantiates a new effect Layer and references it in the scene.
  46797. * @param name The name of the layer
  46798. * @param scene The scene to use the layer in
  46799. */
  46800. constructor(
  46801. /** The Friendly of the effect in the scene */
  46802. name: string, scene: Scene);
  46803. /**
  46804. * Get the effect name of the layer.
  46805. * @return The effect name
  46806. */
  46807. abstract getEffectName(): string;
  46808. /**
  46809. * Checks for the readiness of the element composing the layer.
  46810. * @param subMesh the mesh to check for
  46811. * @param useInstances specify wether or not to use instances to render the mesh
  46812. * @return true if ready otherwise, false
  46813. */
  46814. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46815. /**
  46816. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46817. * @returns true if the effect requires stencil during the main canvas render pass.
  46818. */
  46819. abstract needStencil(): boolean;
  46820. /**
  46821. * Create the merge effect. This is the shader use to blit the information back
  46822. * to the main canvas at the end of the scene rendering.
  46823. * @returns The effect containing the shader used to merge the effect on the main canvas
  46824. */
  46825. protected abstract _createMergeEffect(): Effect;
  46826. /**
  46827. * Creates the render target textures and post processes used in the effect layer.
  46828. */
  46829. protected abstract _createTextureAndPostProcesses(): void;
  46830. /**
  46831. * Implementation specific of rendering the generating effect on the main canvas.
  46832. * @param effect The effect used to render through
  46833. */
  46834. protected abstract _internalRender(effect: Effect): void;
  46835. /**
  46836. * Sets the required values for both the emissive texture and and the main color.
  46837. */
  46838. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46839. /**
  46840. * Free any resources and references associated to a mesh.
  46841. * Internal use
  46842. * @param mesh The mesh to free.
  46843. */
  46844. abstract _disposeMesh(mesh: Mesh): void;
  46845. /**
  46846. * Serializes this layer (Glow or Highlight for example)
  46847. * @returns a serialized layer object
  46848. */
  46849. abstract serialize?(): any;
  46850. /**
  46851. * Initializes the effect layer with the required options.
  46852. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46853. */
  46854. protected _init(options: Partial<IEffectLayerOptions>): void;
  46855. /**
  46856. * Generates the index buffer of the full screen quad blending to the main canvas.
  46857. */
  46858. private _generateIndexBuffer;
  46859. /**
  46860. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46861. */
  46862. private _generateVertexBuffer;
  46863. /**
  46864. * Sets the main texture desired size which is the closest power of two
  46865. * of the engine canvas size.
  46866. */
  46867. private _setMainTextureSize;
  46868. /**
  46869. * Creates the main texture for the effect layer.
  46870. */
  46871. protected _createMainTexture(): void;
  46872. /**
  46873. * Adds specific effects defines.
  46874. * @param defines The defines to add specifics to.
  46875. */
  46876. protected _addCustomEffectDefines(defines: string[]): void;
  46877. /**
  46878. * Checks for the readiness of the element composing the layer.
  46879. * @param subMesh the mesh to check for
  46880. * @param useInstances specify wether or not to use instances to render the mesh
  46881. * @param emissiveTexture the associated emissive texture used to generate the glow
  46882. * @return true if ready otherwise, false
  46883. */
  46884. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46885. /**
  46886. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46887. */
  46888. render(): void;
  46889. /**
  46890. * Determine if a given mesh will be used in the current effect.
  46891. * @param mesh mesh to test
  46892. * @returns true if the mesh will be used
  46893. */
  46894. hasMesh(mesh: AbstractMesh): boolean;
  46895. /**
  46896. * Returns true if the layer contains information to display, otherwise false.
  46897. * @returns true if the glow layer should be rendered
  46898. */
  46899. shouldRender(): boolean;
  46900. /**
  46901. * Returns true if the mesh should render, otherwise false.
  46902. * @param mesh The mesh to render
  46903. * @returns true if it should render otherwise false
  46904. */
  46905. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46906. /**
  46907. * Returns true if the mesh can be rendered, otherwise false.
  46908. * @param mesh The mesh to render
  46909. * @param material The material used on the mesh
  46910. * @returns true if it can be rendered otherwise false
  46911. */
  46912. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46913. /**
  46914. * Returns true if the mesh should render, otherwise false.
  46915. * @param mesh The mesh to render
  46916. * @returns true if it should render otherwise false
  46917. */
  46918. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46919. /**
  46920. * Renders the submesh passed in parameter to the generation map.
  46921. */
  46922. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46923. /**
  46924. * Rebuild the required buffers.
  46925. * @hidden Internal use only.
  46926. */ private _rebuild(): void;
  46927. /**
  46928. * Dispose only the render target textures and post process.
  46929. */
  46930. private _disposeTextureAndPostProcesses;
  46931. /**
  46932. * Dispose the highlight layer and free resources.
  46933. */
  46934. dispose(): void;
  46935. /**
  46936. * Gets the class name of the effect layer
  46937. * @returns the string with the class name of the effect layer
  46938. */
  46939. getClassName(): string;
  46940. /**
  46941. * Creates an effect layer from parsed effect layer data
  46942. * @param parsedEffectLayer defines effect layer data
  46943. * @param scene defines the current scene
  46944. * @param rootUrl defines the root URL containing the effect layer information
  46945. * @returns a parsed effect Layer
  46946. */
  46947. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46948. }
  46949. }
  46950. declare module BABYLON {
  46951. interface AbstractScene {
  46952. /**
  46953. * The list of effect layers (highlights/glow) added to the scene
  46954. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46955. * @see http://doc.babylonjs.com/how_to/glow_layer
  46956. */
  46957. effectLayers: Array<EffectLayer>;
  46958. /**
  46959. * Removes the given effect layer from this scene.
  46960. * @param toRemove defines the effect layer to remove
  46961. * @returns the index of the removed effect layer
  46962. */
  46963. removeEffectLayer(toRemove: EffectLayer): number;
  46964. /**
  46965. * Adds the given effect layer to this scene
  46966. * @param newEffectLayer defines the effect layer to add
  46967. */
  46968. addEffectLayer(newEffectLayer: EffectLayer): void;
  46969. }
  46970. /**
  46971. * Defines the layer scene component responsible to manage any effect layers
  46972. * in a given scene.
  46973. */
  46974. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46975. /**
  46976. * The component name helpfull to identify the component in the list of scene components.
  46977. */
  46978. readonly name: string;
  46979. /**
  46980. * The scene the component belongs to.
  46981. */
  46982. scene: Scene;
  46983. private _engine;
  46984. private _renderEffects;
  46985. private _needStencil;
  46986. private _previousStencilState;
  46987. /**
  46988. * Creates a new instance of the component for the given scene
  46989. * @param scene Defines the scene to register the component in
  46990. */
  46991. constructor(scene: Scene);
  46992. /**
  46993. * Registers the component in a given scene
  46994. */
  46995. register(): void;
  46996. /**
  46997. * Rebuilds the elements related to this component in case of
  46998. * context lost for instance.
  46999. */
  47000. rebuild(): void;
  47001. /**
  47002. * Serializes the component data to the specified json object
  47003. * @param serializationObject The object to serialize to
  47004. */
  47005. serialize(serializationObject: any): void;
  47006. /**
  47007. * Adds all the elements from the container to the scene
  47008. * @param container the container holding the elements
  47009. */
  47010. addFromContainer(container: AbstractScene): void;
  47011. /**
  47012. * Removes all the elements in the container from the scene
  47013. * @param container contains the elements to remove
  47014. * @param dispose if the removed element should be disposed (default: false)
  47015. */
  47016. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47017. /**
  47018. * Disposes the component and the associated ressources.
  47019. */
  47020. dispose(): void;
  47021. private _isReadyForMesh;
  47022. private _renderMainTexture;
  47023. private _setStencil;
  47024. private _setStencilBack;
  47025. private _draw;
  47026. private _drawCamera;
  47027. private _drawRenderingGroup;
  47028. }
  47029. }
  47030. declare module BABYLON {
  47031. /** @hidden */
  47032. export var glowMapMergePixelShader: {
  47033. name: string;
  47034. shader: string;
  47035. };
  47036. }
  47037. declare module BABYLON {
  47038. /** @hidden */
  47039. export var glowMapMergeVertexShader: {
  47040. name: string;
  47041. shader: string;
  47042. };
  47043. }
  47044. declare module BABYLON {
  47045. interface AbstractScene {
  47046. /**
  47047. * Return a the first highlight layer of the scene with a given name.
  47048. * @param name The name of the highlight layer to look for.
  47049. * @return The highlight layer if found otherwise null.
  47050. */
  47051. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47052. }
  47053. /**
  47054. * Glow layer options. This helps customizing the behaviour
  47055. * of the glow layer.
  47056. */
  47057. export interface IGlowLayerOptions {
  47058. /**
  47059. * Multiplication factor apply to the canvas size to compute the render target size
  47060. * used to generated the glowing objects (the smaller the faster).
  47061. */
  47062. mainTextureRatio: number;
  47063. /**
  47064. * Enforces a fixed size texture to ensure resize independant blur.
  47065. */
  47066. mainTextureFixedSize?: number;
  47067. /**
  47068. * How big is the kernel of the blur texture.
  47069. */
  47070. blurKernelSize: number;
  47071. /**
  47072. * The camera attached to the layer.
  47073. */
  47074. camera: Nullable<Camera>;
  47075. /**
  47076. * Enable MSAA by chosing the number of samples.
  47077. */
  47078. mainTextureSamples?: number;
  47079. /**
  47080. * The rendering group to draw the layer in.
  47081. */
  47082. renderingGroupId: number;
  47083. }
  47084. /**
  47085. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47086. *
  47087. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47088. * glowy meshes to your scene.
  47089. *
  47090. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47091. */
  47092. export class GlowLayer extends EffectLayer {
  47093. /**
  47094. * Effect Name of the layer.
  47095. */
  47096. static readonly EffectName: string;
  47097. /**
  47098. * The default blur kernel size used for the glow.
  47099. */
  47100. static DefaultBlurKernelSize: number;
  47101. /**
  47102. * The default texture size ratio used for the glow.
  47103. */
  47104. static DefaultTextureRatio: number;
  47105. /**
  47106. * Sets the kernel size of the blur.
  47107. */
  47108. /**
  47109. * Gets the kernel size of the blur.
  47110. */
  47111. blurKernelSize: number;
  47112. /**
  47113. * Sets the glow intensity.
  47114. */
  47115. /**
  47116. * Gets the glow intensity.
  47117. */
  47118. intensity: number;
  47119. private _options;
  47120. private _intensity;
  47121. private _horizontalBlurPostprocess1;
  47122. private _verticalBlurPostprocess1;
  47123. private _horizontalBlurPostprocess2;
  47124. private _verticalBlurPostprocess2;
  47125. private _blurTexture1;
  47126. private _blurTexture2;
  47127. private _postProcesses1;
  47128. private _postProcesses2;
  47129. private _includedOnlyMeshes;
  47130. private _excludedMeshes;
  47131. /**
  47132. * Callback used to let the user override the color selection on a per mesh basis
  47133. */
  47134. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47135. /**
  47136. * Callback used to let the user override the texture selection on a per mesh basis
  47137. */
  47138. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47139. /**
  47140. * Instantiates a new glow Layer and references it to the scene.
  47141. * @param name The name of the layer
  47142. * @param scene The scene to use the layer in
  47143. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47144. */
  47145. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47146. /**
  47147. * Get the effect name of the layer.
  47148. * @return The effect name
  47149. */
  47150. getEffectName(): string;
  47151. /**
  47152. * Create the merge effect. This is the shader use to blit the information back
  47153. * to the main canvas at the end of the scene rendering.
  47154. */
  47155. protected _createMergeEffect(): Effect;
  47156. /**
  47157. * Creates the render target textures and post processes used in the glow layer.
  47158. */
  47159. protected _createTextureAndPostProcesses(): void;
  47160. /**
  47161. * Checks for the readiness of the element composing the layer.
  47162. * @param subMesh the mesh to check for
  47163. * @param useInstances specify wether or not to use instances to render the mesh
  47164. * @param emissiveTexture the associated emissive texture used to generate the glow
  47165. * @return true if ready otherwise, false
  47166. */
  47167. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47168. /**
  47169. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47170. */
  47171. needStencil(): boolean;
  47172. /**
  47173. * Returns true if the mesh can be rendered, otherwise false.
  47174. * @param mesh The mesh to render
  47175. * @param material The material used on the mesh
  47176. * @returns true if it can be rendered otherwise false
  47177. */
  47178. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47179. /**
  47180. * Implementation specific of rendering the generating effect on the main canvas.
  47181. * @param effect The effect used to render through
  47182. */
  47183. protected _internalRender(effect: Effect): void;
  47184. /**
  47185. * Sets the required values for both the emissive texture and and the main color.
  47186. */
  47187. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47188. /**
  47189. * Returns true if the mesh should render, otherwise false.
  47190. * @param mesh The mesh to render
  47191. * @returns true if it should render otherwise false
  47192. */
  47193. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47194. /**
  47195. * Adds specific effects defines.
  47196. * @param defines The defines to add specifics to.
  47197. */
  47198. protected _addCustomEffectDefines(defines: string[]): void;
  47199. /**
  47200. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47201. * @param mesh The mesh to exclude from the glow layer
  47202. */
  47203. addExcludedMesh(mesh: Mesh): void;
  47204. /**
  47205. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47206. * @param mesh The mesh to remove
  47207. */
  47208. removeExcludedMesh(mesh: Mesh): void;
  47209. /**
  47210. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47211. * @param mesh The mesh to include in the glow layer
  47212. */
  47213. addIncludedOnlyMesh(mesh: Mesh): void;
  47214. /**
  47215. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47216. * @param mesh The mesh to remove
  47217. */
  47218. removeIncludedOnlyMesh(mesh: Mesh): void;
  47219. /**
  47220. * Determine if a given mesh will be used in the glow layer
  47221. * @param mesh The mesh to test
  47222. * @returns true if the mesh will be highlighted by the current glow layer
  47223. */
  47224. hasMesh(mesh: AbstractMesh): boolean;
  47225. /**
  47226. * Free any resources and references associated to a mesh.
  47227. * Internal use
  47228. * @param mesh The mesh to free.
  47229. * @hidden
  47230. */ private _disposeMesh(mesh: Mesh): void;
  47231. /**
  47232. * Gets the class name of the effect layer
  47233. * @returns the string with the class name of the effect layer
  47234. */
  47235. getClassName(): string;
  47236. /**
  47237. * Serializes this glow layer
  47238. * @returns a serialized glow layer object
  47239. */
  47240. serialize(): any;
  47241. /**
  47242. * Creates a Glow Layer from parsed glow layer data
  47243. * @param parsedGlowLayer defines glow layer data
  47244. * @param scene defines the current scene
  47245. * @param rootUrl defines the root URL containing the glow layer information
  47246. * @returns a parsed Glow Layer
  47247. */
  47248. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47249. }
  47250. }
  47251. declare module BABYLON {
  47252. /** @hidden */
  47253. export var glowBlurPostProcessPixelShader: {
  47254. name: string;
  47255. shader: string;
  47256. };
  47257. }
  47258. declare module BABYLON {
  47259. interface AbstractScene {
  47260. /**
  47261. * Return a the first highlight layer of the scene with a given name.
  47262. * @param name The name of the highlight layer to look for.
  47263. * @return The highlight layer if found otherwise null.
  47264. */
  47265. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47266. }
  47267. /**
  47268. * Highlight layer options. This helps customizing the behaviour
  47269. * of the highlight layer.
  47270. */
  47271. export interface IHighlightLayerOptions {
  47272. /**
  47273. * Multiplication factor apply to the canvas size to compute the render target size
  47274. * used to generated the glowing objects (the smaller the faster).
  47275. */
  47276. mainTextureRatio: number;
  47277. /**
  47278. * Enforces a fixed size texture to ensure resize independant blur.
  47279. */
  47280. mainTextureFixedSize?: number;
  47281. /**
  47282. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47283. * of the picture to blur (the smaller the faster).
  47284. */
  47285. blurTextureSizeRatio: number;
  47286. /**
  47287. * How big in texel of the blur texture is the vertical blur.
  47288. */
  47289. blurVerticalSize: number;
  47290. /**
  47291. * How big in texel of the blur texture is the horizontal blur.
  47292. */
  47293. blurHorizontalSize: number;
  47294. /**
  47295. * Alpha blending mode used to apply the blur. Default is combine.
  47296. */
  47297. alphaBlendingMode: number;
  47298. /**
  47299. * The camera attached to the layer.
  47300. */
  47301. camera: Nullable<Camera>;
  47302. /**
  47303. * Should we display highlight as a solid stroke?
  47304. */
  47305. isStroke?: boolean;
  47306. /**
  47307. * The rendering group to draw the layer in.
  47308. */
  47309. renderingGroupId: number;
  47310. }
  47311. /**
  47312. * The highlight layer Helps adding a glow effect around a mesh.
  47313. *
  47314. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47315. * glowy meshes to your scene.
  47316. *
  47317. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47318. */
  47319. export class HighlightLayer extends EffectLayer {
  47320. name: string;
  47321. /**
  47322. * Effect Name of the highlight layer.
  47323. */
  47324. static readonly EffectName: string;
  47325. /**
  47326. * The neutral color used during the preparation of the glow effect.
  47327. * This is black by default as the blend operation is a blend operation.
  47328. */
  47329. static NeutralColor: Color4;
  47330. /**
  47331. * Stencil value used for glowing meshes.
  47332. */
  47333. static GlowingMeshStencilReference: number;
  47334. /**
  47335. * Stencil value used for the other meshes in the scene.
  47336. */
  47337. static NormalMeshStencilReference: number;
  47338. /**
  47339. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47340. */
  47341. innerGlow: boolean;
  47342. /**
  47343. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47344. */
  47345. outerGlow: boolean;
  47346. /**
  47347. * Specifies the horizontal size of the blur.
  47348. */
  47349. /**
  47350. * Gets the horizontal size of the blur.
  47351. */
  47352. blurHorizontalSize: number;
  47353. /**
  47354. * Specifies the vertical size of the blur.
  47355. */
  47356. /**
  47357. * Gets the vertical size of the blur.
  47358. */
  47359. blurVerticalSize: number;
  47360. /**
  47361. * An event triggered when the highlight layer is being blurred.
  47362. */
  47363. onBeforeBlurObservable: Observable<HighlightLayer>;
  47364. /**
  47365. * An event triggered when the highlight layer has been blurred.
  47366. */
  47367. onAfterBlurObservable: Observable<HighlightLayer>;
  47368. private _instanceGlowingMeshStencilReference;
  47369. private _options;
  47370. private _downSamplePostprocess;
  47371. private _horizontalBlurPostprocess;
  47372. private _verticalBlurPostprocess;
  47373. private _blurTexture;
  47374. private _meshes;
  47375. private _excludedMeshes;
  47376. /**
  47377. * Instantiates a new highlight Layer and references it to the scene..
  47378. * @param name The name of the layer
  47379. * @param scene The scene to use the layer in
  47380. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47381. */
  47382. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47383. /**
  47384. * Get the effect name of the layer.
  47385. * @return The effect name
  47386. */
  47387. getEffectName(): string;
  47388. /**
  47389. * Create the merge effect. This is the shader use to blit the information back
  47390. * to the main canvas at the end of the scene rendering.
  47391. */
  47392. protected _createMergeEffect(): Effect;
  47393. /**
  47394. * Creates the render target textures and post processes used in the highlight layer.
  47395. */
  47396. protected _createTextureAndPostProcesses(): void;
  47397. /**
  47398. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47399. */
  47400. needStencil(): boolean;
  47401. /**
  47402. * Checks for the readiness of the element composing the layer.
  47403. * @param subMesh the mesh to check for
  47404. * @param useInstances specify wether or not to use instances to render the mesh
  47405. * @param emissiveTexture the associated emissive texture used to generate the glow
  47406. * @return true if ready otherwise, false
  47407. */
  47408. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47409. /**
  47410. * Implementation specific of rendering the generating effect on the main canvas.
  47411. * @param effect The effect used to render through
  47412. */
  47413. protected _internalRender(effect: Effect): void;
  47414. /**
  47415. * Returns true if the layer contains information to display, otherwise false.
  47416. */
  47417. shouldRender(): boolean;
  47418. /**
  47419. * Returns true if the mesh should render, otherwise false.
  47420. * @param mesh The mesh to render
  47421. * @returns true if it should render otherwise false
  47422. */
  47423. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47424. /**
  47425. * Sets the required values for both the emissive texture and and the main color.
  47426. */
  47427. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47428. /**
  47429. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47430. * @param mesh The mesh to exclude from the highlight layer
  47431. */
  47432. addExcludedMesh(mesh: Mesh): void;
  47433. /**
  47434. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47435. * @param mesh The mesh to highlight
  47436. */
  47437. removeExcludedMesh(mesh: Mesh): void;
  47438. /**
  47439. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47440. * @param mesh mesh to test
  47441. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47442. */
  47443. hasMesh(mesh: AbstractMesh): boolean;
  47444. /**
  47445. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47446. * @param mesh The mesh to highlight
  47447. * @param color The color of the highlight
  47448. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47449. */
  47450. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47451. /**
  47452. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47453. * @param mesh The mesh to highlight
  47454. */
  47455. removeMesh(mesh: Mesh): void;
  47456. /**
  47457. * Force the stencil to the normal expected value for none glowing parts
  47458. */
  47459. private _defaultStencilReference;
  47460. /**
  47461. * Free any resources and references associated to a mesh.
  47462. * Internal use
  47463. * @param mesh The mesh to free.
  47464. * @hidden
  47465. */ private _disposeMesh(mesh: Mesh): void;
  47466. /**
  47467. * Dispose the highlight layer and free resources.
  47468. */
  47469. dispose(): void;
  47470. /**
  47471. * Gets the class name of the effect layer
  47472. * @returns the string with the class name of the effect layer
  47473. */
  47474. getClassName(): string;
  47475. /**
  47476. * Serializes this Highlight layer
  47477. * @returns a serialized Highlight layer object
  47478. */
  47479. serialize(): any;
  47480. /**
  47481. * Creates a Highlight layer from parsed Highlight layer data
  47482. * @param parsedHightlightLayer defines the Highlight layer data
  47483. * @param scene defines the current scene
  47484. * @param rootUrl defines the root URL containing the Highlight layer information
  47485. * @returns a parsed Highlight layer
  47486. */
  47487. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47488. }
  47489. }
  47490. declare module BABYLON {
  47491. interface AbstractScene {
  47492. /**
  47493. * The list of layers (background and foreground) of the scene
  47494. */
  47495. layers: Array<Layer>;
  47496. }
  47497. /**
  47498. * Defines the layer scene component responsible to manage any layers
  47499. * in a given scene.
  47500. */
  47501. export class LayerSceneComponent implements ISceneComponent {
  47502. /**
  47503. * The component name helpfull to identify the component in the list of scene components.
  47504. */
  47505. readonly name: string;
  47506. /**
  47507. * The scene the component belongs to.
  47508. */
  47509. scene: Scene;
  47510. private _engine;
  47511. /**
  47512. * Creates a new instance of the component for the given scene
  47513. * @param scene Defines the scene to register the component in
  47514. */
  47515. constructor(scene: Scene);
  47516. /**
  47517. * Registers the component in a given scene
  47518. */
  47519. register(): void;
  47520. /**
  47521. * Rebuilds the elements related to this component in case of
  47522. * context lost for instance.
  47523. */
  47524. rebuild(): void;
  47525. /**
  47526. * Disposes the component and the associated ressources.
  47527. */
  47528. dispose(): void;
  47529. private _draw;
  47530. private _drawCameraPredicate;
  47531. private _drawCameraBackground;
  47532. private _drawCameraForeground;
  47533. private _drawRenderTargetPredicate;
  47534. private _drawRenderTargetBackground;
  47535. private _drawRenderTargetForeground;
  47536. /**
  47537. * Adds all the elements from the container to the scene
  47538. * @param container the container holding the elements
  47539. */
  47540. addFromContainer(container: AbstractScene): void;
  47541. /**
  47542. * Removes all the elements in the container from the scene
  47543. * @param container contains the elements to remove
  47544. * @param dispose if the removed element should be disposed (default: false)
  47545. */
  47546. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47547. }
  47548. }
  47549. declare module BABYLON {
  47550. /** @hidden */
  47551. export var layerPixelShader: {
  47552. name: string;
  47553. shader: string;
  47554. };
  47555. }
  47556. declare module BABYLON {
  47557. /** @hidden */
  47558. export var layerVertexShader: {
  47559. name: string;
  47560. shader: string;
  47561. };
  47562. }
  47563. declare module BABYLON {
  47564. /**
  47565. * This represents a full screen 2d layer.
  47566. * This can be useful to display a picture in the background of your scene for instance.
  47567. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47568. */
  47569. export class Layer {
  47570. /**
  47571. * Define the name of the layer.
  47572. */
  47573. name: string;
  47574. /**
  47575. * Define the texture the layer should display.
  47576. */
  47577. texture: Nullable<Texture>;
  47578. /**
  47579. * Is the layer in background or foreground.
  47580. */
  47581. isBackground: boolean;
  47582. /**
  47583. * Define the color of the layer (instead of texture).
  47584. */
  47585. color: Color4;
  47586. /**
  47587. * Define the scale of the layer in order to zoom in out of the texture.
  47588. */
  47589. scale: Vector2;
  47590. /**
  47591. * Define an offset for the layer in order to shift the texture.
  47592. */
  47593. offset: Vector2;
  47594. /**
  47595. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47596. */
  47597. alphaBlendingMode: number;
  47598. /**
  47599. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47600. * Alpha test will not mix with the background color in case of transparency.
  47601. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47602. */
  47603. alphaTest: boolean;
  47604. /**
  47605. * Define a mask to restrict the layer to only some of the scene cameras.
  47606. */
  47607. layerMask: number;
  47608. /**
  47609. * Define the list of render target the layer is visible into.
  47610. */
  47611. renderTargetTextures: RenderTargetTexture[];
  47612. /**
  47613. * Define if the layer is only used in renderTarget or if it also
  47614. * renders in the main frame buffer of the canvas.
  47615. */
  47616. renderOnlyInRenderTargetTextures: boolean;
  47617. private _scene;
  47618. private _vertexBuffers;
  47619. private _indexBuffer;
  47620. private _effect;
  47621. private _alphaTestEffect;
  47622. /**
  47623. * An event triggered when the layer is disposed.
  47624. */
  47625. onDisposeObservable: Observable<Layer>;
  47626. private _onDisposeObserver;
  47627. /**
  47628. * Back compatibility with callback before the onDisposeObservable existed.
  47629. * The set callback will be triggered when the layer has been disposed.
  47630. */
  47631. onDispose: () => void;
  47632. /**
  47633. * An event triggered before rendering the scene
  47634. */
  47635. onBeforeRenderObservable: Observable<Layer>;
  47636. private _onBeforeRenderObserver;
  47637. /**
  47638. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47639. * The set callback will be triggered just before rendering the layer.
  47640. */
  47641. onBeforeRender: () => void;
  47642. /**
  47643. * An event triggered after rendering the scene
  47644. */
  47645. onAfterRenderObservable: Observable<Layer>;
  47646. private _onAfterRenderObserver;
  47647. /**
  47648. * Back compatibility with callback before the onAfterRenderObservable existed.
  47649. * The set callback will be triggered just after rendering the layer.
  47650. */
  47651. onAfterRender: () => void;
  47652. /**
  47653. * Instantiates a new layer.
  47654. * This represents a full screen 2d layer.
  47655. * This can be useful to display a picture in the background of your scene for instance.
  47656. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47657. * @param name Define the name of the layer in the scene
  47658. * @param imgUrl Define the url of the texture to display in the layer
  47659. * @param scene Define the scene the layer belongs to
  47660. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47661. * @param color Defines a color for the layer
  47662. */
  47663. constructor(
  47664. /**
  47665. * Define the name of the layer.
  47666. */
  47667. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47668. private _createIndexBuffer;
  47669. /** @hidden */ private _rebuild(): void;
  47670. /**
  47671. * Renders the layer in the scene.
  47672. */
  47673. render(): void;
  47674. /**
  47675. * Disposes and releases the associated ressources.
  47676. */
  47677. dispose(): void;
  47678. }
  47679. }
  47680. declare module BABYLON {
  47681. /** @hidden */
  47682. export var lensFlarePixelShader: {
  47683. name: string;
  47684. shader: string;
  47685. };
  47686. }
  47687. declare module BABYLON {
  47688. /** @hidden */
  47689. export var lensFlareVertexShader: {
  47690. name: string;
  47691. shader: string;
  47692. };
  47693. }
  47694. declare module BABYLON {
  47695. /**
  47696. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47697. * It is usually composed of several `lensFlare`.
  47698. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47699. */
  47700. export class LensFlareSystem {
  47701. /**
  47702. * Define the name of the lens flare system
  47703. */
  47704. name: string;
  47705. /**
  47706. * List of lens flares used in this system.
  47707. */
  47708. lensFlares: LensFlare[];
  47709. /**
  47710. * Define a limit from the border the lens flare can be visible.
  47711. */
  47712. borderLimit: number;
  47713. /**
  47714. * Define a viewport border we do not want to see the lens flare in.
  47715. */
  47716. viewportBorder: number;
  47717. /**
  47718. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47719. */
  47720. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47721. /**
  47722. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47723. */
  47724. layerMask: number;
  47725. /**
  47726. * Define the id of the lens flare system in the scene.
  47727. * (equal to name by default)
  47728. */
  47729. id: string;
  47730. private _scene;
  47731. private _emitter;
  47732. private _vertexBuffers;
  47733. private _indexBuffer;
  47734. private _effect;
  47735. private _positionX;
  47736. private _positionY;
  47737. private _isEnabled;
  47738. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47739. /**
  47740. * Instantiates a lens flare system.
  47741. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47742. * It is usually composed of several `lensFlare`.
  47743. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47744. * @param name Define the name of the lens flare system in the scene
  47745. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47746. * @param scene Define the scene the lens flare system belongs to
  47747. */
  47748. constructor(
  47749. /**
  47750. * Define the name of the lens flare system
  47751. */
  47752. name: string, emitter: any, scene: Scene);
  47753. /**
  47754. * Define if the lens flare system is enabled.
  47755. */
  47756. isEnabled: boolean;
  47757. /**
  47758. * Get the scene the effects belongs to.
  47759. * @returns the scene holding the lens flare system
  47760. */
  47761. getScene(): Scene;
  47762. /**
  47763. * Get the emitter of the lens flare system.
  47764. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47765. * @returns the emitter of the lens flare system
  47766. */
  47767. getEmitter(): any;
  47768. /**
  47769. * Set the emitter of the lens flare system.
  47770. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47771. * @param newEmitter Define the new emitter of the system
  47772. */
  47773. setEmitter(newEmitter: any): void;
  47774. /**
  47775. * Get the lens flare system emitter position.
  47776. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47777. * @returns the position
  47778. */
  47779. getEmitterPosition(): Vector3;
  47780. /**
  47781. * @hidden
  47782. */
  47783. computeEffectivePosition(globalViewport: Viewport): boolean;
  47784. /** @hidden */ private _isVisible(): boolean;
  47785. /**
  47786. * @hidden
  47787. */
  47788. render(): boolean;
  47789. /**
  47790. * Dispose and release the lens flare with its associated resources.
  47791. */
  47792. dispose(): void;
  47793. /**
  47794. * Parse a lens flare system from a JSON repressentation
  47795. * @param parsedLensFlareSystem Define the JSON to parse
  47796. * @param scene Define the scene the parsed system should be instantiated in
  47797. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47798. * @returns the parsed system
  47799. */
  47800. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47801. /**
  47802. * Serialize the current Lens Flare System into a JSON representation.
  47803. * @returns the serialized JSON
  47804. */
  47805. serialize(): any;
  47806. }
  47807. }
  47808. declare module BABYLON {
  47809. /**
  47810. * This represents one of the lens effect in a `lensFlareSystem`.
  47811. * It controls one of the indiviual texture used in the effect.
  47812. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47813. */
  47814. export class LensFlare {
  47815. /**
  47816. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47817. */
  47818. size: number;
  47819. /**
  47820. * 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.
  47821. */
  47822. position: number;
  47823. /**
  47824. * Define the lens color.
  47825. */
  47826. color: Color3;
  47827. /**
  47828. * Define the lens texture.
  47829. */
  47830. texture: Nullable<Texture>;
  47831. /**
  47832. * Define the alpha mode to render this particular lens.
  47833. */
  47834. alphaMode: number;
  47835. private _system;
  47836. /**
  47837. * Creates a new Lens Flare.
  47838. * This represents one of the lens effect in a `lensFlareSystem`.
  47839. * It controls one of the indiviual texture used in the effect.
  47840. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47841. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47842. * @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.
  47843. * @param color Define the lens color
  47844. * @param imgUrl Define the lens texture url
  47845. * @param system Define the `lensFlareSystem` this flare is part of
  47846. * @returns The newly created Lens Flare
  47847. */
  47848. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47849. /**
  47850. * Instantiates a new Lens Flare.
  47851. * This represents one of the lens effect in a `lensFlareSystem`.
  47852. * It controls one of the indiviual texture used in the effect.
  47853. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47854. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47855. * @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.
  47856. * @param color Define the lens color
  47857. * @param imgUrl Define the lens texture url
  47858. * @param system Define the `lensFlareSystem` this flare is part of
  47859. */
  47860. constructor(
  47861. /**
  47862. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47863. */
  47864. size: number,
  47865. /**
  47866. * 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.
  47867. */
  47868. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47869. /**
  47870. * Dispose and release the lens flare with its associated resources.
  47871. */
  47872. dispose(): void;
  47873. }
  47874. }
  47875. declare module BABYLON {
  47876. interface AbstractScene {
  47877. /**
  47878. * The list of lens flare system added to the scene
  47879. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47880. */
  47881. lensFlareSystems: Array<LensFlareSystem>;
  47882. /**
  47883. * Removes the given lens flare system from this scene.
  47884. * @param toRemove The lens flare system to remove
  47885. * @returns The index of the removed lens flare system
  47886. */
  47887. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47888. /**
  47889. * Adds the given lens flare system to this scene
  47890. * @param newLensFlareSystem The lens flare system to add
  47891. */
  47892. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47893. /**
  47894. * Gets a lens flare system using its name
  47895. * @param name defines the name to look for
  47896. * @returns the lens flare system or null if not found
  47897. */
  47898. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47899. /**
  47900. * Gets a lens flare system using its id
  47901. * @param id defines the id to look for
  47902. * @returns the lens flare system or null if not found
  47903. */
  47904. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47905. }
  47906. /**
  47907. * Defines the lens flare scene component responsible to manage any lens flares
  47908. * in a given scene.
  47909. */
  47910. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47911. /**
  47912. * The component name helpfull to identify the component in the list of scene components.
  47913. */
  47914. readonly name: string;
  47915. /**
  47916. * The scene the component belongs to.
  47917. */
  47918. scene: Scene;
  47919. /**
  47920. * Creates a new instance of the component for the given scene
  47921. * @param scene Defines the scene to register the component in
  47922. */
  47923. constructor(scene: Scene);
  47924. /**
  47925. * Registers the component in a given scene
  47926. */
  47927. register(): void;
  47928. /**
  47929. * Rebuilds the elements related to this component in case of
  47930. * context lost for instance.
  47931. */
  47932. rebuild(): void;
  47933. /**
  47934. * Adds all the elements from the container to the scene
  47935. * @param container the container holding the elements
  47936. */
  47937. addFromContainer(container: AbstractScene): void;
  47938. /**
  47939. * Removes all the elements in the container from the scene
  47940. * @param container contains the elements to remove
  47941. * @param dispose if the removed element should be disposed (default: false)
  47942. */
  47943. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47944. /**
  47945. * Serializes the component data to the specified json object
  47946. * @param serializationObject The object to serialize to
  47947. */
  47948. serialize(serializationObject: any): void;
  47949. /**
  47950. * Disposes the component and the associated ressources.
  47951. */
  47952. dispose(): void;
  47953. private _draw;
  47954. }
  47955. }
  47956. declare module BABYLON {
  47957. /**
  47958. * Defines the shadow generator component responsible to manage any shadow generators
  47959. * in a given scene.
  47960. */
  47961. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47962. /**
  47963. * The component name helpfull to identify the component in the list of scene components.
  47964. */
  47965. readonly name: string;
  47966. /**
  47967. * The scene the component belongs to.
  47968. */
  47969. scene: Scene;
  47970. /**
  47971. * Creates a new instance of the component for the given scene
  47972. * @param scene Defines the scene to register the component in
  47973. */
  47974. constructor(scene: Scene);
  47975. /**
  47976. * Registers the component in a given scene
  47977. */
  47978. register(): void;
  47979. /**
  47980. * Rebuilds the elements related to this component in case of
  47981. * context lost for instance.
  47982. */
  47983. rebuild(): void;
  47984. /**
  47985. * Serializes the component data to the specified json object
  47986. * @param serializationObject The object to serialize to
  47987. */
  47988. serialize(serializationObject: any): void;
  47989. /**
  47990. * Adds all the elements from the container to the scene
  47991. * @param container the container holding the elements
  47992. */
  47993. addFromContainer(container: AbstractScene): void;
  47994. /**
  47995. * Removes all the elements in the container from the scene
  47996. * @param container contains the elements to remove
  47997. * @param dispose if the removed element should be disposed (default: false)
  47998. */
  47999. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48000. /**
  48001. * Rebuilds the elements related to this component in case of
  48002. * context lost for instance.
  48003. */
  48004. dispose(): void;
  48005. private _gatherRenderTargets;
  48006. }
  48007. }
  48008. declare module BABYLON {
  48009. /**
  48010. * A point light is a light defined by an unique point in world space.
  48011. * The light is emitted in every direction from this point.
  48012. * A good example of a point light is a standard light bulb.
  48013. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48014. */
  48015. export class PointLight extends ShadowLight {
  48016. private _shadowAngle;
  48017. /**
  48018. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48019. * This specifies what angle the shadow will use to be created.
  48020. *
  48021. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48022. */
  48023. /**
  48024. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48025. * This specifies what angle the shadow will use to be created.
  48026. *
  48027. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48028. */
  48029. shadowAngle: number;
  48030. /**
  48031. * Gets the direction if it has been set.
  48032. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48033. */
  48034. /**
  48035. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48036. */
  48037. direction: Vector3;
  48038. /**
  48039. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48040. * A PointLight emits the light in every direction.
  48041. * It can cast shadows.
  48042. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48043. * ```javascript
  48044. * var pointLight = new PointLight("pl", camera.position, scene);
  48045. * ```
  48046. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48047. * @param name The light friendly name
  48048. * @param position The position of the point light in the scene
  48049. * @param scene The scene the lights belongs to
  48050. */
  48051. constructor(name: string, position: Vector3, scene: Scene);
  48052. /**
  48053. * Returns the string "PointLight"
  48054. * @returns the class name
  48055. */
  48056. getClassName(): string;
  48057. /**
  48058. * Returns the integer 0.
  48059. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48060. */
  48061. getTypeID(): number;
  48062. /**
  48063. * Specifies wether or not the shadowmap should be a cube texture.
  48064. * @returns true if the shadowmap needs to be a cube texture.
  48065. */
  48066. needCube(): boolean;
  48067. /**
  48068. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48069. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48070. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48071. */
  48072. getShadowDirection(faceIndex?: number): Vector3;
  48073. /**
  48074. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48075. * - fov = PI / 2
  48076. * - aspect ratio : 1.0
  48077. * - z-near and far equal to the active camera minZ and maxZ.
  48078. * Returns the PointLight.
  48079. */
  48080. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48081. protected _buildUniformLayout(): void;
  48082. /**
  48083. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48084. * @param effect The effect to update
  48085. * @param lightIndex The index of the light in the effect to update
  48086. * @returns The point light
  48087. */
  48088. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48089. /**
  48090. * Prepares the list of defines specific to the light type.
  48091. * @param defines the list of defines
  48092. * @param lightIndex defines the index of the light for the effect
  48093. */
  48094. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48095. }
  48096. }
  48097. declare module BABYLON {
  48098. /**
  48099. * Header information of HDR texture files.
  48100. */
  48101. export interface HDRInfo {
  48102. /**
  48103. * The height of the texture in pixels.
  48104. */
  48105. height: number;
  48106. /**
  48107. * The width of the texture in pixels.
  48108. */
  48109. width: number;
  48110. /**
  48111. * The index of the beginning of the data in the binary file.
  48112. */
  48113. dataPosition: number;
  48114. }
  48115. /**
  48116. * This groups tools to convert HDR texture to native colors array.
  48117. */
  48118. export class HDRTools {
  48119. private static Ldexp;
  48120. private static Rgbe2float;
  48121. private static readStringLine;
  48122. /**
  48123. * Reads header information from an RGBE texture stored in a native array.
  48124. * More information on this format are available here:
  48125. * https://en.wikipedia.org/wiki/RGBE_image_format
  48126. *
  48127. * @param uint8array The binary file stored in native array.
  48128. * @return The header information.
  48129. */
  48130. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48131. /**
  48132. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48133. * This RGBE texture needs to store the information as a panorama.
  48134. *
  48135. * More information on this format are available here:
  48136. * https://en.wikipedia.org/wiki/RGBE_image_format
  48137. *
  48138. * @param buffer The binary file stored in an array buffer.
  48139. * @param size The expected size of the extracted cubemap.
  48140. * @return The Cube Map information.
  48141. */
  48142. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48143. /**
  48144. * Returns the pixels data extracted from an RGBE texture.
  48145. * This pixels will be stored left to right up to down in the R G B order in one array.
  48146. *
  48147. * More information on this format are available here:
  48148. * https://en.wikipedia.org/wiki/RGBE_image_format
  48149. *
  48150. * @param uint8array The binary file stored in an array buffer.
  48151. * @param hdrInfo The header information of the file.
  48152. * @return The pixels data in RGB right to left up to down order.
  48153. */
  48154. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48155. private static RGBE_ReadPixels_RLE;
  48156. }
  48157. }
  48158. declare module BABYLON {
  48159. /**
  48160. * This represents a texture coming from an HDR input.
  48161. *
  48162. * The only supported format is currently panorama picture stored in RGBE format.
  48163. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48164. */
  48165. export class HDRCubeTexture extends BaseTexture {
  48166. private static _facesMapping;
  48167. private _generateHarmonics;
  48168. private _noMipmap;
  48169. private _textureMatrix;
  48170. private _size;
  48171. private _onLoad;
  48172. private _onError;
  48173. /**
  48174. * The texture URL.
  48175. */
  48176. url: string;
  48177. /**
  48178. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48179. */
  48180. coordinatesMode: number;
  48181. protected _isBlocking: boolean;
  48182. /**
  48183. * Sets wether or not the texture is blocking during loading.
  48184. */
  48185. /**
  48186. * Gets wether or not the texture is blocking during loading.
  48187. */
  48188. isBlocking: boolean;
  48189. protected _rotationY: number;
  48190. /**
  48191. * Sets texture matrix rotation angle around Y axis in radians.
  48192. */
  48193. /**
  48194. * Gets texture matrix rotation angle around Y axis radians.
  48195. */
  48196. rotationY: number;
  48197. /**
  48198. * Gets or sets the center of the bounding box associated with the cube texture
  48199. * It must define where the camera used to render the texture was set
  48200. */
  48201. boundingBoxPosition: Vector3;
  48202. private _boundingBoxSize;
  48203. /**
  48204. * Gets or sets the size of the bounding box associated with the cube texture
  48205. * When defined, the cubemap will switch to local mode
  48206. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48207. * @example https://www.babylonjs-playground.com/#RNASML
  48208. */
  48209. boundingBoxSize: Vector3;
  48210. /**
  48211. * Instantiates an HDRTexture from the following parameters.
  48212. *
  48213. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48214. * @param scene The scene the texture will be used in
  48215. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48216. * @param noMipmap Forces to not generate the mipmap if true
  48217. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48218. * @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)
  48219. * @param reserved Reserved flag for internal use.
  48220. */
  48221. 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>);
  48222. /**
  48223. * Get the current class name of the texture useful for serialization or dynamic coding.
  48224. * @returns "HDRCubeTexture"
  48225. */
  48226. getClassName(): string;
  48227. /**
  48228. * Occurs when the file is raw .hdr file.
  48229. */
  48230. private loadTexture;
  48231. clone(): HDRCubeTexture;
  48232. delayLoad(): void;
  48233. /**
  48234. * Get the texture reflection matrix used to rotate/transform the reflection.
  48235. * @returns the reflection matrix
  48236. */
  48237. getReflectionTextureMatrix(): Matrix;
  48238. /**
  48239. * Set the texture reflection matrix used to rotate/transform the reflection.
  48240. * @param value Define the reflection matrix to set
  48241. */
  48242. setReflectionTextureMatrix(value: Matrix): void;
  48243. /**
  48244. * Parses a JSON representation of an HDR Texture in order to create the texture
  48245. * @param parsedTexture Define the JSON representation
  48246. * @param scene Define the scene the texture should be created in
  48247. * @param rootUrl Define the root url in case we need to load relative dependencies
  48248. * @returns the newly created texture after parsing
  48249. */
  48250. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48251. serialize(): any;
  48252. }
  48253. }
  48254. declare module BABYLON {
  48255. /**
  48256. * Class used to control physics engine
  48257. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48258. */
  48259. export class PhysicsEngine implements IPhysicsEngine {
  48260. private _physicsPlugin;
  48261. /**
  48262. * Global value used to control the smallest number supported by the simulation
  48263. */
  48264. static Epsilon: number;
  48265. private _impostors;
  48266. private _joints;
  48267. /**
  48268. * Gets the gravity vector used by the simulation
  48269. */
  48270. gravity: Vector3;
  48271. /**
  48272. * Factory used to create the default physics plugin.
  48273. * @returns The default physics plugin
  48274. */
  48275. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48276. /**
  48277. * Creates a new Physics Engine
  48278. * @param gravity defines the gravity vector used by the simulation
  48279. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48280. */
  48281. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48282. /**
  48283. * Sets the gravity vector used by the simulation
  48284. * @param gravity defines the gravity vector to use
  48285. */
  48286. setGravity(gravity: Vector3): void;
  48287. /**
  48288. * Set the time step of the physics engine.
  48289. * Default is 1/60.
  48290. * To slow it down, enter 1/600 for example.
  48291. * To speed it up, 1/30
  48292. * @param newTimeStep defines the new timestep to apply to this world.
  48293. */
  48294. setTimeStep(newTimeStep?: number): void;
  48295. /**
  48296. * Get the time step of the physics engine.
  48297. * @returns the current time step
  48298. */
  48299. getTimeStep(): number;
  48300. /**
  48301. * Release all resources
  48302. */
  48303. dispose(): void;
  48304. /**
  48305. * Gets the name of the current physics plugin
  48306. * @returns the name of the plugin
  48307. */
  48308. getPhysicsPluginName(): string;
  48309. /**
  48310. * Adding a new impostor for the impostor tracking.
  48311. * This will be done by the impostor itself.
  48312. * @param impostor the impostor to add
  48313. */
  48314. addImpostor(impostor: PhysicsImpostor): void;
  48315. /**
  48316. * Remove an impostor from the engine.
  48317. * This impostor and its mesh will not longer be updated by the physics engine.
  48318. * @param impostor the impostor to remove
  48319. */
  48320. removeImpostor(impostor: PhysicsImpostor): void;
  48321. /**
  48322. * Add a joint to the physics engine
  48323. * @param mainImpostor defines the main impostor to which the joint is added.
  48324. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48325. * @param joint defines the joint that will connect both impostors.
  48326. */
  48327. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48328. /**
  48329. * Removes a joint from the simulation
  48330. * @param mainImpostor defines the impostor used with the joint
  48331. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48332. * @param joint defines the joint to remove
  48333. */
  48334. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48335. /**
  48336. * Called by the scene. No need to call it.
  48337. * @param delta defines the timespam between frames
  48338. */ private _step(delta: number): void;
  48339. /**
  48340. * Gets the current plugin used to run the simulation
  48341. * @returns current plugin
  48342. */
  48343. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48344. /**
  48345. * Gets the list of physic impostors
  48346. * @returns an array of PhysicsImpostor
  48347. */
  48348. getImpostors(): Array<PhysicsImpostor>;
  48349. /**
  48350. * Gets the impostor for a physics enabled object
  48351. * @param object defines the object impersonated by the impostor
  48352. * @returns the PhysicsImpostor or null if not found
  48353. */
  48354. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48355. /**
  48356. * Gets the impostor for a physics body object
  48357. * @param body defines physics body used by the impostor
  48358. * @returns the PhysicsImpostor or null if not found
  48359. */
  48360. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48361. /**
  48362. * Does a raycast in the physics world
  48363. * @param from when should the ray start?
  48364. * @param to when should the ray end?
  48365. * @returns PhysicsRaycastResult
  48366. */
  48367. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48368. }
  48369. }
  48370. declare module BABYLON {
  48371. /** @hidden */
  48372. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48373. private _useDeltaForWorldStep;
  48374. world: any;
  48375. name: string;
  48376. private _physicsMaterials;
  48377. private _fixedTimeStep;
  48378. private _cannonRaycastResult;
  48379. private _raycastResult;
  48380. private _physicsBodysToRemoveAfterStep;
  48381. BJSCANNON: any;
  48382. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48383. setGravity(gravity: Vector3): void;
  48384. setTimeStep(timeStep: number): void;
  48385. getTimeStep(): number;
  48386. executeStep(delta: number): void;
  48387. private _removeMarkedPhysicsBodiesFromWorld;
  48388. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48389. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48390. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48391. private _processChildMeshes;
  48392. removePhysicsBody(impostor: PhysicsImpostor): void;
  48393. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48394. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48395. private _addMaterial;
  48396. private _checkWithEpsilon;
  48397. private _createShape;
  48398. private _createHeightmap;
  48399. private _minus90X;
  48400. private _plus90X;
  48401. private _tmpPosition;
  48402. private _tmpDeltaPosition;
  48403. private _tmpUnityRotation;
  48404. private _updatePhysicsBodyTransformation;
  48405. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48406. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48407. isSupported(): boolean;
  48408. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48409. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48411. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48412. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48413. getBodyMass(impostor: PhysicsImpostor): number;
  48414. getBodyFriction(impostor: PhysicsImpostor): number;
  48415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48416. getBodyRestitution(impostor: PhysicsImpostor): number;
  48417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48418. sleepBody(impostor: PhysicsImpostor): void;
  48419. wakeUpBody(impostor: PhysicsImpostor): void;
  48420. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48421. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48422. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48424. getRadius(impostor: PhysicsImpostor): number;
  48425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48426. dispose(): void;
  48427. private _extendNamespace;
  48428. /**
  48429. * Does a raycast in the physics world
  48430. * @param from when should the ray start?
  48431. * @param to when should the ray end?
  48432. * @returns PhysicsRaycastResult
  48433. */
  48434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48435. }
  48436. }
  48437. declare module BABYLON {
  48438. /** @hidden */
  48439. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48440. world: any;
  48441. name: string;
  48442. BJSOIMO: any;
  48443. private _raycastResult;
  48444. constructor(iterations?: number, oimoInjection?: any);
  48445. setGravity(gravity: Vector3): void;
  48446. setTimeStep(timeStep: number): void;
  48447. getTimeStep(): number;
  48448. private _tmpImpostorsArray;
  48449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48451. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48452. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48453. private _tmpPositionVector;
  48454. removePhysicsBody(impostor: PhysicsImpostor): void;
  48455. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48456. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48457. isSupported(): boolean;
  48458. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48459. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48460. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48461. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48462. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48463. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48464. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48465. getBodyMass(impostor: PhysicsImpostor): number;
  48466. getBodyFriction(impostor: PhysicsImpostor): number;
  48467. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48468. getBodyRestitution(impostor: PhysicsImpostor): number;
  48469. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48470. sleepBody(impostor: PhysicsImpostor): void;
  48471. wakeUpBody(impostor: PhysicsImpostor): void;
  48472. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48473. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48474. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48475. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48476. getRadius(impostor: PhysicsImpostor): number;
  48477. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48478. dispose(): void;
  48479. /**
  48480. * Does a raycast in the physics world
  48481. * @param from when should the ray start?
  48482. * @param to when should the ray end?
  48483. * @returns PhysicsRaycastResult
  48484. */
  48485. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48486. }
  48487. }
  48488. declare module BABYLON {
  48489. /**
  48490. * Class containing static functions to help procedurally build meshes
  48491. */
  48492. export class RibbonBuilder {
  48493. /**
  48494. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48495. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48496. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48497. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48498. * * 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
  48499. * * 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
  48500. * * 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
  48501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48504. * * 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
  48505. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48506. * * 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
  48507. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48509. * @param name defines the name of the mesh
  48510. * @param options defines the options used to create the mesh
  48511. * @param scene defines the hosting scene
  48512. * @returns the ribbon mesh
  48513. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48515. */
  48516. static CreateRibbon(name: string, options: {
  48517. pathArray: Vector3[][];
  48518. closeArray?: boolean;
  48519. closePath?: boolean;
  48520. offset?: number;
  48521. updatable?: boolean;
  48522. sideOrientation?: number;
  48523. frontUVs?: Vector4;
  48524. backUVs?: Vector4;
  48525. instance?: Mesh;
  48526. invertUV?: boolean;
  48527. uvs?: Vector2[];
  48528. colors?: Color4[];
  48529. }, scene?: Nullable<Scene>): Mesh;
  48530. }
  48531. }
  48532. declare module BABYLON {
  48533. /**
  48534. * Class containing static functions to help procedurally build meshes
  48535. */
  48536. export class ShapeBuilder {
  48537. /**
  48538. * 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.
  48539. * * 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.
  48540. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48541. * * 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.
  48542. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48543. * * 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
  48544. * * 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
  48545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48550. * @param name defines the name of the mesh
  48551. * @param options defines the options used to create the mesh
  48552. * @param scene defines the hosting scene
  48553. * @returns the extruded shape mesh
  48554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48556. */
  48557. static ExtrudeShape(name: string, options: {
  48558. shape: Vector3[];
  48559. path: Vector3[];
  48560. scale?: number;
  48561. rotation?: number;
  48562. cap?: number;
  48563. updatable?: boolean;
  48564. sideOrientation?: number;
  48565. frontUVs?: Vector4;
  48566. backUVs?: Vector4;
  48567. instance?: Mesh;
  48568. invertUV?: boolean;
  48569. }, scene?: Nullable<Scene>): Mesh;
  48570. /**
  48571. * Creates an custom extruded shape mesh.
  48572. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48573. * * 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.
  48574. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48575. * * 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
  48576. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48577. * * 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
  48578. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48579. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48580. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48581. * * 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
  48582. * * 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
  48583. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48588. * @param name defines the name of the mesh
  48589. * @param options defines the options used to create the mesh
  48590. * @param scene defines the hosting scene
  48591. * @returns the custom extruded shape mesh
  48592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48595. */
  48596. static ExtrudeShapeCustom(name: string, options: {
  48597. shape: Vector3[];
  48598. path: Vector3[];
  48599. scaleFunction?: any;
  48600. rotationFunction?: any;
  48601. ribbonCloseArray?: boolean;
  48602. ribbonClosePath?: boolean;
  48603. cap?: number;
  48604. updatable?: boolean;
  48605. sideOrientation?: number;
  48606. frontUVs?: Vector4;
  48607. backUVs?: Vector4;
  48608. instance?: Mesh;
  48609. invertUV?: boolean;
  48610. }, scene?: Nullable<Scene>): Mesh;
  48611. private static _ExtrudeShapeGeneric;
  48612. }
  48613. }
  48614. declare module BABYLON {
  48615. /**
  48616. * AmmoJS Physics plugin
  48617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48618. * @see https://github.com/kripken/ammo.js/
  48619. */
  48620. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48621. private _useDeltaForWorldStep;
  48622. /**
  48623. * Reference to the Ammo library
  48624. */
  48625. bjsAMMO: any;
  48626. /**
  48627. * Created ammoJS world which physics bodies are added to
  48628. */
  48629. world: any;
  48630. /**
  48631. * Name of the plugin
  48632. */
  48633. name: string;
  48634. private _timeStep;
  48635. private _fixedTimeStep;
  48636. private _maxSteps;
  48637. private _tmpQuaternion;
  48638. private _tmpAmmoTransform;
  48639. private _tmpAmmoQuaternion;
  48640. private _tmpAmmoConcreteContactResultCallback;
  48641. private _collisionConfiguration;
  48642. private _dispatcher;
  48643. private _overlappingPairCache;
  48644. private _solver;
  48645. private _softBodySolver;
  48646. private _tmpAmmoVectorA;
  48647. private _tmpAmmoVectorB;
  48648. private _tmpAmmoVectorC;
  48649. private _tmpAmmoVectorD;
  48650. private _tmpContactCallbackResult;
  48651. private _tmpAmmoVectorRCA;
  48652. private _tmpAmmoVectorRCB;
  48653. private _raycastResult;
  48654. private static readonly DISABLE_COLLISION_FLAG;
  48655. private static readonly KINEMATIC_FLAG;
  48656. private static readonly DISABLE_DEACTIVATION_FLAG;
  48657. /**
  48658. * Initializes the ammoJS plugin
  48659. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48660. * @param ammoInjection can be used to inject your own ammo reference
  48661. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  48662. */
  48663. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  48664. /**
  48665. * Sets the gravity of the physics world (m/(s^2))
  48666. * @param gravity Gravity to set
  48667. */
  48668. setGravity(gravity: Vector3): void;
  48669. /**
  48670. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48671. * @param timeStep timestep to use in seconds
  48672. */
  48673. setTimeStep(timeStep: number): void;
  48674. /**
  48675. * 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)
  48676. * @param fixedTimeStep fixedTimeStep to use in seconds
  48677. */
  48678. setFixedTimeStep(fixedTimeStep: number): void;
  48679. /**
  48680. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48681. * @param maxSteps the maximum number of steps by the physics engine per frame
  48682. */
  48683. setMaxSteps(maxSteps: number): void;
  48684. /**
  48685. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48686. * @returns the current timestep in seconds
  48687. */
  48688. getTimeStep(): number;
  48689. private _isImpostorInContact;
  48690. private _isImpostorPairInContact;
  48691. private _stepSimulation;
  48692. /**
  48693. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48694. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48695. * After the step the babylon meshes are set to the position of the physics imposters
  48696. * @param delta amount of time to step forward
  48697. * @param impostors array of imposters to update before/after the step
  48698. */
  48699. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48700. /**
  48701. * Update babylon mesh to match physics world object
  48702. * @param impostor imposter to match
  48703. */
  48704. private _afterSoftStep;
  48705. /**
  48706. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48707. * @param impostor imposter to match
  48708. */
  48709. private _ropeStep;
  48710. /**
  48711. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48712. * @param impostor imposter to match
  48713. */
  48714. private _softbodyOrClothStep;
  48715. private _tmpVector;
  48716. private _tmpMatrix;
  48717. /**
  48718. * Applies an impulse on the imposter
  48719. * @param impostor imposter to apply impulse to
  48720. * @param force amount of force to be applied to the imposter
  48721. * @param contactPoint the location to apply the impulse on the imposter
  48722. */
  48723. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48724. /**
  48725. * Applies a force on the imposter
  48726. * @param impostor imposter to apply force
  48727. * @param force amount of force to be applied to the imposter
  48728. * @param contactPoint the location to apply the force on the imposter
  48729. */
  48730. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48731. /**
  48732. * Creates a physics body using the plugin
  48733. * @param impostor the imposter to create the physics body on
  48734. */
  48735. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48736. /**
  48737. * Removes the physics body from the imposter and disposes of the body's memory
  48738. * @param impostor imposter to remove the physics body from
  48739. */
  48740. removePhysicsBody(impostor: PhysicsImpostor): void;
  48741. /**
  48742. * Generates a joint
  48743. * @param impostorJoint the imposter joint to create the joint with
  48744. */
  48745. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48746. /**
  48747. * Removes a joint
  48748. * @param impostorJoint the imposter joint to remove the joint from
  48749. */
  48750. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48751. private _addMeshVerts;
  48752. /**
  48753. * Initialise the soft body vertices to match its object's (mesh) vertices
  48754. * Softbody vertices (nodes) are in world space and to match this
  48755. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48756. * @param impostor to create the softbody for
  48757. */
  48758. private _softVertexData;
  48759. /**
  48760. * Create an impostor's soft body
  48761. * @param impostor to create the softbody for
  48762. */
  48763. private _createSoftbody;
  48764. /**
  48765. * Create cloth for an impostor
  48766. * @param impostor to create the softbody for
  48767. */
  48768. private _createCloth;
  48769. /**
  48770. * Create rope for an impostor
  48771. * @param impostor to create the softbody for
  48772. */
  48773. private _createRope;
  48774. private _addHullVerts;
  48775. private _createShape;
  48776. /**
  48777. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48778. * @param impostor imposter containing the physics body and babylon object
  48779. */
  48780. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48781. /**
  48782. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48783. * @param impostor imposter containing the physics body and babylon object
  48784. * @param newPosition new position
  48785. * @param newRotation new rotation
  48786. */
  48787. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48788. /**
  48789. * If this plugin is supported
  48790. * @returns true if its supported
  48791. */
  48792. isSupported(): boolean;
  48793. /**
  48794. * Sets the linear velocity of the physics body
  48795. * @param impostor imposter to set the velocity on
  48796. * @param velocity velocity to set
  48797. */
  48798. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48799. /**
  48800. * Sets the angular velocity of the physics body
  48801. * @param impostor imposter to set the velocity on
  48802. * @param velocity velocity to set
  48803. */
  48804. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48805. /**
  48806. * gets the linear velocity
  48807. * @param impostor imposter to get linear velocity from
  48808. * @returns linear velocity
  48809. */
  48810. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48811. /**
  48812. * gets the angular velocity
  48813. * @param impostor imposter to get angular velocity from
  48814. * @returns angular velocity
  48815. */
  48816. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48817. /**
  48818. * Sets the mass of physics body
  48819. * @param impostor imposter to set the mass on
  48820. * @param mass mass to set
  48821. */
  48822. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48823. /**
  48824. * Gets the mass of the physics body
  48825. * @param impostor imposter to get the mass from
  48826. * @returns mass
  48827. */
  48828. getBodyMass(impostor: PhysicsImpostor): number;
  48829. /**
  48830. * Gets friction of the impostor
  48831. * @param impostor impostor to get friction from
  48832. * @returns friction value
  48833. */
  48834. getBodyFriction(impostor: PhysicsImpostor): number;
  48835. /**
  48836. * Sets friction of the impostor
  48837. * @param impostor impostor to set friction on
  48838. * @param friction friction value
  48839. */
  48840. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48841. /**
  48842. * Gets restitution of the impostor
  48843. * @param impostor impostor to get restitution from
  48844. * @returns restitution value
  48845. */
  48846. getBodyRestitution(impostor: PhysicsImpostor): number;
  48847. /**
  48848. * Sets resitution of the impostor
  48849. * @param impostor impostor to set resitution on
  48850. * @param restitution resitution value
  48851. */
  48852. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48853. /**
  48854. * Gets pressure inside the impostor
  48855. * @param impostor impostor to get pressure from
  48856. * @returns pressure value
  48857. */
  48858. getBodyPressure(impostor: PhysicsImpostor): number;
  48859. /**
  48860. * Sets pressure inside a soft body impostor
  48861. * Cloth and rope must remain 0 pressure
  48862. * @param impostor impostor to set pressure on
  48863. * @param pressure pressure value
  48864. */
  48865. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48866. /**
  48867. * Gets stiffness of the impostor
  48868. * @param impostor impostor to get stiffness from
  48869. * @returns pressure value
  48870. */
  48871. getBodyStiffness(impostor: PhysicsImpostor): number;
  48872. /**
  48873. * Sets stiffness of the impostor
  48874. * @param impostor impostor to set stiffness on
  48875. * @param stiffness stiffness value from 0 to 1
  48876. */
  48877. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48878. /**
  48879. * Gets velocityIterations of the impostor
  48880. * @param impostor impostor to get velocity iterations from
  48881. * @returns velocityIterations value
  48882. */
  48883. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48884. /**
  48885. * Sets velocityIterations of the impostor
  48886. * @param impostor impostor to set velocity iterations on
  48887. * @param velocityIterations velocityIterations value
  48888. */
  48889. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48890. /**
  48891. * Gets positionIterations of the impostor
  48892. * @param impostor impostor to get position iterations from
  48893. * @returns positionIterations value
  48894. */
  48895. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48896. /**
  48897. * Sets positionIterations of the impostor
  48898. * @param impostor impostor to set position on
  48899. * @param positionIterations positionIterations value
  48900. */
  48901. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48902. /**
  48903. * Append an anchor to a cloth object
  48904. * @param impostor is the cloth impostor to add anchor to
  48905. * @param otherImpostor is the rigid impostor to anchor to
  48906. * @param width ratio across width from 0 to 1
  48907. * @param height ratio up height from 0 to 1
  48908. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48909. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48910. */
  48911. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48912. /**
  48913. * Append an hook to a rope object
  48914. * @param impostor is the rope impostor to add hook to
  48915. * @param otherImpostor is the rigid impostor to hook to
  48916. * @param length ratio along the rope from 0 to 1
  48917. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48918. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48919. */
  48920. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48921. /**
  48922. * Sleeps the physics body and stops it from being active
  48923. * @param impostor impostor to sleep
  48924. */
  48925. sleepBody(impostor: PhysicsImpostor): void;
  48926. /**
  48927. * Activates the physics body
  48928. * @param impostor impostor to activate
  48929. */
  48930. wakeUpBody(impostor: PhysicsImpostor): void;
  48931. /**
  48932. * Updates the distance parameters of the joint
  48933. * @param joint joint to update
  48934. * @param maxDistance maximum distance of the joint
  48935. * @param minDistance minimum distance of the joint
  48936. */
  48937. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48938. /**
  48939. * Sets a motor on the joint
  48940. * @param joint joint to set motor on
  48941. * @param speed speed of the motor
  48942. * @param maxForce maximum force of the motor
  48943. * @param motorIndex index of the motor
  48944. */
  48945. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48946. /**
  48947. * Sets the motors limit
  48948. * @param joint joint to set limit on
  48949. * @param upperLimit upper limit
  48950. * @param lowerLimit lower limit
  48951. */
  48952. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48953. /**
  48954. * Syncs the position and rotation of a mesh with the impostor
  48955. * @param mesh mesh to sync
  48956. * @param impostor impostor to update the mesh with
  48957. */
  48958. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48959. /**
  48960. * Gets the radius of the impostor
  48961. * @param impostor impostor to get radius from
  48962. * @returns the radius
  48963. */
  48964. getRadius(impostor: PhysicsImpostor): number;
  48965. /**
  48966. * Gets the box size of the impostor
  48967. * @param impostor impostor to get box size from
  48968. * @param result the resulting box size
  48969. */
  48970. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48971. /**
  48972. * Disposes of the impostor
  48973. */
  48974. dispose(): void;
  48975. /**
  48976. * Does a raycast in the physics world
  48977. * @param from when should the ray start?
  48978. * @param to when should the ray end?
  48979. * @returns PhysicsRaycastResult
  48980. */
  48981. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48982. }
  48983. }
  48984. declare module BABYLON {
  48985. interface AbstractScene {
  48986. /**
  48987. * The list of reflection probes added to the scene
  48988. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48989. */
  48990. reflectionProbes: Array<ReflectionProbe>;
  48991. /**
  48992. * Removes the given reflection probe from this scene.
  48993. * @param toRemove The reflection probe to remove
  48994. * @returns The index of the removed reflection probe
  48995. */
  48996. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48997. /**
  48998. * Adds the given reflection probe to this scene.
  48999. * @param newReflectionProbe The reflection probe to add
  49000. */
  49001. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49002. }
  49003. /**
  49004. * Class used to generate realtime reflection / refraction cube textures
  49005. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49006. */
  49007. export class ReflectionProbe {
  49008. /** defines the name of the probe */
  49009. name: string;
  49010. private _scene;
  49011. private _renderTargetTexture;
  49012. private _projectionMatrix;
  49013. private _viewMatrix;
  49014. private _target;
  49015. private _add;
  49016. private _attachedMesh;
  49017. private _invertYAxis;
  49018. /** Gets or sets probe position (center of the cube map) */
  49019. position: Vector3;
  49020. /**
  49021. * Creates a new reflection probe
  49022. * @param name defines the name of the probe
  49023. * @param size defines the texture resolution (for each face)
  49024. * @param scene defines the hosting scene
  49025. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49026. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49027. */
  49028. constructor(
  49029. /** defines the name of the probe */
  49030. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49031. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49032. samples: number;
  49033. /** Gets or sets the refresh rate to use (on every frame by default) */
  49034. refreshRate: number;
  49035. /**
  49036. * Gets the hosting scene
  49037. * @returns a Scene
  49038. */
  49039. getScene(): Scene;
  49040. /** Gets the internal CubeTexture used to render to */
  49041. readonly cubeTexture: RenderTargetTexture;
  49042. /** Gets the list of meshes to render */
  49043. readonly renderList: Nullable<AbstractMesh[]>;
  49044. /**
  49045. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49046. * @param mesh defines the mesh to attach to
  49047. */
  49048. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49049. /**
  49050. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49051. * @param renderingGroupId The rendering group id corresponding to its index
  49052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49053. */
  49054. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49055. /**
  49056. * Clean all associated resources
  49057. */
  49058. dispose(): void;
  49059. /**
  49060. * Converts the reflection probe information to a readable string for debug purpose.
  49061. * @param fullDetails Supports for multiple levels of logging within scene loading
  49062. * @returns the human readable reflection probe info
  49063. */
  49064. toString(fullDetails?: boolean): string;
  49065. /**
  49066. * Get the class name of the relfection probe.
  49067. * @returns "ReflectionProbe"
  49068. */
  49069. getClassName(): string;
  49070. /**
  49071. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49072. * @returns The JSON representation of the texture
  49073. */
  49074. serialize(): any;
  49075. /**
  49076. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49077. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49078. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49079. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49080. * @returns The parsed reflection probe if successful
  49081. */
  49082. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49083. }
  49084. }
  49085. declare module BABYLON {
  49086. /** @hidden */
  49087. export var _BabylonLoaderRegistered: boolean;
  49088. }
  49089. declare module BABYLON {
  49090. /**
  49091. * The Physically based simple base material of BJS.
  49092. *
  49093. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49094. * It is used as the base class for both the specGloss and metalRough conventions.
  49095. */
  49096. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49097. /**
  49098. * Number of Simultaneous lights allowed on the material.
  49099. */
  49100. maxSimultaneousLights: number;
  49101. /**
  49102. * If sets to true, disables all the lights affecting the material.
  49103. */
  49104. disableLighting: boolean;
  49105. /**
  49106. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49107. */
  49108. environmentTexture: BaseTexture;
  49109. /**
  49110. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49111. */
  49112. invertNormalMapX: boolean;
  49113. /**
  49114. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49115. */
  49116. invertNormalMapY: boolean;
  49117. /**
  49118. * Normal map used in the model.
  49119. */
  49120. normalTexture: BaseTexture;
  49121. /**
  49122. * Emissivie color used to self-illuminate the model.
  49123. */
  49124. emissiveColor: Color3;
  49125. /**
  49126. * Emissivie texture used to self-illuminate the model.
  49127. */
  49128. emissiveTexture: BaseTexture;
  49129. /**
  49130. * Occlusion Channel Strenght.
  49131. */
  49132. occlusionStrength: number;
  49133. /**
  49134. * Occlusion Texture of the material (adding extra occlusion effects).
  49135. */
  49136. occlusionTexture: BaseTexture;
  49137. /**
  49138. * Defines the alpha limits in alpha test mode.
  49139. */
  49140. alphaCutOff: number;
  49141. /**
  49142. * Gets the current double sided mode.
  49143. */
  49144. /**
  49145. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49146. */
  49147. doubleSided: boolean;
  49148. /**
  49149. * Stores the pre-calculated light information of a mesh in a texture.
  49150. */
  49151. lightmapTexture: BaseTexture;
  49152. /**
  49153. * If true, the light map contains occlusion information instead of lighting info.
  49154. */
  49155. useLightmapAsShadowmap: boolean;
  49156. /**
  49157. * Instantiates a new PBRMaterial instance.
  49158. *
  49159. * @param name The material name
  49160. * @param scene The scene the material will be use in.
  49161. */
  49162. constructor(name: string, scene: Scene);
  49163. getClassName(): string;
  49164. }
  49165. }
  49166. declare module BABYLON {
  49167. /**
  49168. * The PBR material of BJS following the metal roughness convention.
  49169. *
  49170. * This fits to the PBR convention in the GLTF definition:
  49171. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49172. */
  49173. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49174. /**
  49175. * The base color has two different interpretations depending on the value of metalness.
  49176. * When the material is a metal, the base color is the specific measured reflectance value
  49177. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49178. * of the material.
  49179. */
  49180. baseColor: Color3;
  49181. /**
  49182. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49183. * well as opacity information in the alpha channel.
  49184. */
  49185. baseTexture: BaseTexture;
  49186. /**
  49187. * Specifies the metallic scalar value of the material.
  49188. * Can also be used to scale the metalness values of the metallic texture.
  49189. */
  49190. metallic: number;
  49191. /**
  49192. * Specifies the roughness scalar value of the material.
  49193. * Can also be used to scale the roughness values of the metallic texture.
  49194. */
  49195. roughness: number;
  49196. /**
  49197. * Texture containing both the metallic value in the B channel and the
  49198. * roughness value in the G channel to keep better precision.
  49199. */
  49200. metallicRoughnessTexture: BaseTexture;
  49201. /**
  49202. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49203. *
  49204. * @param name The material name
  49205. * @param scene The scene the material will be use in.
  49206. */
  49207. constructor(name: string, scene: Scene);
  49208. /**
  49209. * Return the currrent class name of the material.
  49210. */
  49211. getClassName(): string;
  49212. /**
  49213. * Makes a duplicate of the current material.
  49214. * @param name - name to use for the new material.
  49215. */
  49216. clone(name: string): PBRMetallicRoughnessMaterial;
  49217. /**
  49218. * Serialize the material to a parsable JSON object.
  49219. */
  49220. serialize(): any;
  49221. /**
  49222. * Parses a JSON object correponding to the serialize function.
  49223. */
  49224. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49225. }
  49226. }
  49227. declare module BABYLON {
  49228. /**
  49229. * The PBR material of BJS following the specular glossiness convention.
  49230. *
  49231. * This fits to the PBR convention in the GLTF definition:
  49232. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49233. */
  49234. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49235. /**
  49236. * Specifies the diffuse color of the material.
  49237. */
  49238. diffuseColor: Color3;
  49239. /**
  49240. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49241. * channel.
  49242. */
  49243. diffuseTexture: BaseTexture;
  49244. /**
  49245. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49246. */
  49247. specularColor: Color3;
  49248. /**
  49249. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49250. */
  49251. glossiness: number;
  49252. /**
  49253. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49254. */
  49255. specularGlossinessTexture: BaseTexture;
  49256. /**
  49257. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49258. *
  49259. * @param name The material name
  49260. * @param scene The scene the material will be use in.
  49261. */
  49262. constructor(name: string, scene: Scene);
  49263. /**
  49264. * Return the currrent class name of the material.
  49265. */
  49266. getClassName(): string;
  49267. /**
  49268. * Makes a duplicate of the current material.
  49269. * @param name - name to use for the new material.
  49270. */
  49271. clone(name: string): PBRSpecularGlossinessMaterial;
  49272. /**
  49273. * Serialize the material to a parsable JSON object.
  49274. */
  49275. serialize(): any;
  49276. /**
  49277. * Parses a JSON object correponding to the serialize function.
  49278. */
  49279. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49280. }
  49281. }
  49282. declare module BABYLON {
  49283. /**
  49284. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49285. * It can help converting any input color in a desired output one. This can then be used to create effects
  49286. * from sepia, black and white to sixties or futuristic rendering...
  49287. *
  49288. * The only supported format is currently 3dl.
  49289. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49290. */
  49291. export class ColorGradingTexture extends BaseTexture {
  49292. /**
  49293. * The current texture matrix. (will always be identity in color grading texture)
  49294. */
  49295. private _textureMatrix;
  49296. /**
  49297. * The texture URL.
  49298. */
  49299. url: string;
  49300. /**
  49301. * Empty line regex stored for GC.
  49302. */
  49303. private static _noneEmptyLineRegex;
  49304. private _engine;
  49305. /**
  49306. * Instantiates a ColorGradingTexture from the following parameters.
  49307. *
  49308. * @param url The location of the color gradind data (currently only supporting 3dl)
  49309. * @param scene The scene the texture will be used in
  49310. */
  49311. constructor(url: string, scene: Scene);
  49312. /**
  49313. * Returns the texture matrix used in most of the material.
  49314. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49315. */
  49316. getTextureMatrix(): Matrix;
  49317. /**
  49318. * Occurs when the file being loaded is a .3dl LUT file.
  49319. */
  49320. private load3dlTexture;
  49321. /**
  49322. * Starts the loading process of the texture.
  49323. */
  49324. private loadTexture;
  49325. /**
  49326. * Clones the color gradind texture.
  49327. */
  49328. clone(): ColorGradingTexture;
  49329. /**
  49330. * Called during delayed load for textures.
  49331. */
  49332. delayLoad(): void;
  49333. /**
  49334. * Parses a color grading texture serialized by Babylon.
  49335. * @param parsedTexture The texture information being parsedTexture
  49336. * @param scene The scene to load the texture in
  49337. * @param rootUrl The root url of the data assets to load
  49338. * @return A color gradind texture
  49339. */
  49340. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49341. /**
  49342. * Serializes the LUT texture to json format.
  49343. */
  49344. serialize(): any;
  49345. }
  49346. }
  49347. declare module BABYLON {
  49348. /**
  49349. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49350. */
  49351. export class EquiRectangularCubeTexture extends BaseTexture {
  49352. /** The six faces of the cube. */
  49353. private static _FacesMapping;
  49354. private _noMipmap;
  49355. private _onLoad;
  49356. private _onError;
  49357. /** The size of the cubemap. */
  49358. private _size;
  49359. /** The buffer of the image. */
  49360. private _buffer;
  49361. /** The width of the input image. */
  49362. private _width;
  49363. /** The height of the input image. */
  49364. private _height;
  49365. /** The URL to the image. */
  49366. url: string;
  49367. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49368. coordinatesMode: number;
  49369. /**
  49370. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49371. * @param url The location of the image
  49372. * @param scene The scene the texture will be used in
  49373. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49374. * @param noMipmap Forces to not generate the mipmap if true
  49375. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49376. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49377. * @param onLoad — defines a callback called when texture is loaded
  49378. * @param onError — defines a callback called if there is an error
  49379. */
  49380. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49381. /**
  49382. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49383. */
  49384. private loadImage;
  49385. /**
  49386. * Convert the image buffer into a cubemap and create a CubeTexture.
  49387. */
  49388. private loadTexture;
  49389. /**
  49390. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49391. * @param buffer The ArrayBuffer that should be converted.
  49392. * @returns The buffer as Float32Array.
  49393. */
  49394. private getFloat32ArrayFromArrayBuffer;
  49395. /**
  49396. * Get the current class name of the texture useful for serialization or dynamic coding.
  49397. * @returns "EquiRectangularCubeTexture"
  49398. */
  49399. getClassName(): string;
  49400. /**
  49401. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49402. * @returns A clone of the current EquiRectangularCubeTexture.
  49403. */
  49404. clone(): EquiRectangularCubeTexture;
  49405. }
  49406. }
  49407. declare module BABYLON {
  49408. /**
  49409. * Based on jsTGALoader - Javascript loader for TGA file
  49410. * By Vincent Thibault
  49411. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49412. */
  49413. export class TGATools {
  49414. private static _TYPE_INDEXED;
  49415. private static _TYPE_RGB;
  49416. private static _TYPE_GREY;
  49417. private static _TYPE_RLE_INDEXED;
  49418. private static _TYPE_RLE_RGB;
  49419. private static _TYPE_RLE_GREY;
  49420. private static _ORIGIN_MASK;
  49421. private static _ORIGIN_SHIFT;
  49422. private static _ORIGIN_BL;
  49423. private static _ORIGIN_BR;
  49424. private static _ORIGIN_UL;
  49425. private static _ORIGIN_UR;
  49426. /**
  49427. * Gets the header of a TGA file
  49428. * @param data defines the TGA data
  49429. * @returns the header
  49430. */
  49431. static GetTGAHeader(data: Uint8Array): any;
  49432. /**
  49433. * Uploads TGA content to a Babylon Texture
  49434. * @hidden
  49435. */
  49436. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49437. /** @hidden */ private 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;
  49438. /** @hidden */ private 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;
  49439. /** @hidden */ private 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;
  49440. /** @hidden */ private 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;
  49441. /** @hidden */ private 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;
  49442. /** @hidden */ private 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;
  49443. }
  49444. }
  49445. declare module BABYLON {
  49446. /**
  49447. * Implementation of the TGA Texture Loader.
  49448. * @hidden
  49449. */
  49450. export class _TGATextureLoader implements IInternalTextureLoader {
  49451. /**
  49452. * Defines wether the loader supports cascade loading the different faces.
  49453. */
  49454. readonly supportCascades: boolean;
  49455. /**
  49456. * This returns if the loader support the current file information.
  49457. * @param extension defines the file extension of the file being loaded
  49458. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49459. * @param fallback defines the fallback internal texture if any
  49460. * @param isBase64 defines whether the texture is encoded as a base64
  49461. * @param isBuffer defines whether the texture data are stored as a buffer
  49462. * @returns true if the loader can load the specified file
  49463. */
  49464. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49465. /**
  49466. * Transform the url before loading if required.
  49467. * @param rootUrl the url of the texture
  49468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49469. * @returns the transformed texture
  49470. */
  49471. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49472. /**
  49473. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49474. * @param rootUrl the url of the texture
  49475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49476. * @returns the fallback texture
  49477. */
  49478. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49479. /**
  49480. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49481. * @param data contains the texture data
  49482. * @param texture defines the BabylonJS internal texture
  49483. * @param createPolynomials will be true if polynomials have been requested
  49484. * @param onLoad defines the callback to trigger once the texture is ready
  49485. * @param onError defines the callback to trigger in case of error
  49486. */
  49487. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49488. /**
  49489. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49490. * @param data contains the texture data
  49491. * @param texture defines the BabylonJS internal texture
  49492. * @param callback defines the method to call once ready to upload
  49493. */
  49494. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49495. }
  49496. }
  49497. declare module BABYLON {
  49498. /**
  49499. * Info about the .basis files
  49500. */
  49501. class BasisFileInfo {
  49502. /**
  49503. * If the file has alpha
  49504. */
  49505. hasAlpha: boolean;
  49506. /**
  49507. * Info about each image of the basis file
  49508. */
  49509. images: Array<{
  49510. levels: Array<{
  49511. width: number;
  49512. height: number;
  49513. transcodedPixels: ArrayBufferView;
  49514. }>;
  49515. }>;
  49516. }
  49517. /**
  49518. * Result of transcoding a basis file
  49519. */
  49520. class TranscodeResult {
  49521. /**
  49522. * Info about the .basis file
  49523. */
  49524. fileInfo: BasisFileInfo;
  49525. /**
  49526. * Format to use when loading the file
  49527. */
  49528. format: number;
  49529. }
  49530. /**
  49531. * Configuration options for the Basis transcoder
  49532. */
  49533. export class BasisTranscodeConfiguration {
  49534. /**
  49535. * Supported compression formats used to determine the supported output format of the transcoder
  49536. */
  49537. supportedCompressionFormats?: {
  49538. /**
  49539. * etc1 compression format
  49540. */
  49541. etc1?: boolean;
  49542. /**
  49543. * s3tc compression format
  49544. */
  49545. s3tc?: boolean;
  49546. /**
  49547. * pvrtc compression format
  49548. */
  49549. pvrtc?: boolean;
  49550. /**
  49551. * etc2 compression format
  49552. */
  49553. etc2?: boolean;
  49554. };
  49555. /**
  49556. * If mipmap levels should be loaded for transcoded images (Default: true)
  49557. */
  49558. loadMipmapLevels?: boolean;
  49559. /**
  49560. * Index of a single image to load (Default: all images)
  49561. */
  49562. loadSingleImage?: number;
  49563. }
  49564. /**
  49565. * Used to load .Basis files
  49566. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  49567. */
  49568. export class BasisTools {
  49569. private static _IgnoreSupportedFormats;
  49570. /**
  49571. * URL to use when loading the basis transcoder
  49572. */
  49573. static JSModuleURL: string;
  49574. /**
  49575. * URL to use when loading the wasm module for the transcoder
  49576. */
  49577. static WasmModuleURL: string;
  49578. /**
  49579. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  49580. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  49581. * @returns internal format corresponding to the Basis format
  49582. */
  49583. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  49584. private static _WorkerPromise;
  49585. private static _Worker;
  49586. private static _actionId;
  49587. private static _CreateWorkerAsync;
  49588. /**
  49589. * Transcodes a loaded image file to compressed pixel data
  49590. * @param imageData image data to transcode
  49591. * @param config configuration options for the transcoding
  49592. * @returns a promise resulting in the transcoded image
  49593. */
  49594. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  49595. /**
  49596. * Loads a texture from the transcode result
  49597. * @param texture texture load to
  49598. * @param transcodeResult the result of transcoding the basis file to load from
  49599. */
  49600. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  49601. }
  49602. }
  49603. declare module BABYLON {
  49604. /**
  49605. * Loader for .basis file format
  49606. */
  49607. export class _BasisTextureLoader implements IInternalTextureLoader {
  49608. /**
  49609. * Defines whether the loader supports cascade loading the different faces.
  49610. */
  49611. readonly supportCascades: boolean;
  49612. /**
  49613. * This returns if the loader support the current file information.
  49614. * @param extension defines the file extension of the file being loaded
  49615. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49616. * @param fallback defines the fallback internal texture if any
  49617. * @param isBase64 defines whether the texture is encoded as a base64
  49618. * @param isBuffer defines whether the texture data are stored as a buffer
  49619. * @returns true if the loader can load the specified file
  49620. */
  49621. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49622. /**
  49623. * Transform the url before loading if required.
  49624. * @param rootUrl the url of the texture
  49625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49626. * @returns the transformed texture
  49627. */
  49628. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49629. /**
  49630. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49631. * @param rootUrl the url of the texture
  49632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49633. * @returns the fallback texture
  49634. */
  49635. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49636. /**
  49637. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  49638. * @param data contains the texture data
  49639. * @param texture defines the BabylonJS internal texture
  49640. * @param createPolynomials will be true if polynomials have been requested
  49641. * @param onLoad defines the callback to trigger once the texture is ready
  49642. * @param onError defines the callback to trigger in case of error
  49643. */
  49644. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49645. /**
  49646. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49647. * @param data contains the texture data
  49648. * @param texture defines the BabylonJS internal texture
  49649. * @param callback defines the method to call once ready to upload
  49650. */
  49651. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49652. }
  49653. }
  49654. declare module BABYLON {
  49655. /**
  49656. * 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.
  49657. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49658. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49659. */
  49660. export class CustomProceduralTexture extends ProceduralTexture {
  49661. private _animate;
  49662. private _time;
  49663. private _config;
  49664. private _texturePath;
  49665. /**
  49666. * Instantiates a new Custom Procedural Texture.
  49667. * 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.
  49668. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49669. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49670. * @param name Define the name of the texture
  49671. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49672. * @param size Define the size of the texture to create
  49673. * @param scene Define the scene the texture belongs to
  49674. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49675. * @param generateMipMaps Define if the texture should creates mip maps or not
  49676. */
  49677. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49678. private _loadJson;
  49679. /**
  49680. * Is the texture ready to be used ? (rendered at least once)
  49681. * @returns true if ready, otherwise, false.
  49682. */
  49683. isReady(): boolean;
  49684. /**
  49685. * Render the texture to its associated render target.
  49686. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49687. */
  49688. render(useCameraPostProcess?: boolean): void;
  49689. /**
  49690. * Update the list of dependant textures samplers in the shader.
  49691. */
  49692. updateTextures(): void;
  49693. /**
  49694. * Update the uniform values of the procedural texture in the shader.
  49695. */
  49696. updateShaderUniforms(): void;
  49697. /**
  49698. * Define if the texture animates or not.
  49699. */
  49700. animate: boolean;
  49701. }
  49702. }
  49703. declare module BABYLON {
  49704. /** @hidden */
  49705. export var noisePixelShader: {
  49706. name: string;
  49707. shader: string;
  49708. };
  49709. }
  49710. declare module BABYLON {
  49711. /**
  49712. * Class used to generate noise procedural textures
  49713. */
  49714. export class NoiseProceduralTexture extends ProceduralTexture {
  49715. private _time;
  49716. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49717. brightness: number;
  49718. /** Defines the number of octaves to process */
  49719. octaves: number;
  49720. /** Defines the level of persistence (0.8 by default) */
  49721. persistence: number;
  49722. /** Gets or sets animation speed factor (default is 1) */
  49723. animationSpeedFactor: number;
  49724. /**
  49725. * Creates a new NoiseProceduralTexture
  49726. * @param name defines the name fo the texture
  49727. * @param size defines the size of the texture (default is 256)
  49728. * @param scene defines the hosting scene
  49729. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49730. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49731. */
  49732. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49733. private _updateShaderUniforms;
  49734. protected _getDefines(): string;
  49735. /** Generate the current state of the procedural texture */
  49736. render(useCameraPostProcess?: boolean): void;
  49737. /**
  49738. * Serializes this noise procedural texture
  49739. * @returns a serialized noise procedural texture object
  49740. */
  49741. serialize(): any;
  49742. /**
  49743. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49744. * @param parsedTexture defines parsed texture data
  49745. * @param scene defines the current scene
  49746. * @param rootUrl defines the root URL containing noise procedural texture information
  49747. * @returns a parsed NoiseProceduralTexture
  49748. */
  49749. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49750. }
  49751. }
  49752. declare module BABYLON {
  49753. /**
  49754. * Raw cube texture where the raw buffers are passed in
  49755. */
  49756. export class RawCubeTexture extends CubeTexture {
  49757. /**
  49758. * Creates a cube texture where the raw buffers are passed in.
  49759. * @param scene defines the scene the texture is attached to
  49760. * @param data defines the array of data to use to create each face
  49761. * @param size defines the size of the textures
  49762. * @param format defines the format of the data
  49763. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49764. * @param generateMipMaps defines if the engine should generate the mip levels
  49765. * @param invertY defines if data must be stored with Y axis inverted
  49766. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49767. * @param compression defines the compression used (null by default)
  49768. */
  49769. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49770. /**
  49771. * Updates the raw cube texture.
  49772. * @param data defines the data to store
  49773. * @param format defines the data format
  49774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49775. * @param invertY defines if data must be stored with Y axis inverted
  49776. * @param compression defines the compression used (null by default)
  49777. * @param level defines which level of the texture to update
  49778. */
  49779. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49780. /**
  49781. * Updates a raw cube texture with RGBD encoded data.
  49782. * @param data defines the array of data [mipmap][face] to use to create each face
  49783. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49784. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49785. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49786. * @returns a promsie that resolves when the operation is complete
  49787. */
  49788. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49789. /**
  49790. * Clones the raw cube texture.
  49791. * @return a new cube texture
  49792. */
  49793. clone(): CubeTexture;
  49794. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49795. }
  49796. }
  49797. declare module BABYLON {
  49798. /**
  49799. * Class used to store 3D textures containing user data
  49800. */
  49801. export class RawTexture3D extends Texture {
  49802. /** Gets or sets the texture format to use */
  49803. format: number;
  49804. private _engine;
  49805. /**
  49806. * Create a new RawTexture3D
  49807. * @param data defines the data of the texture
  49808. * @param width defines the width of the texture
  49809. * @param height defines the height of the texture
  49810. * @param depth defines the depth of the texture
  49811. * @param format defines the texture format to use
  49812. * @param scene defines the hosting scene
  49813. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49814. * @param invertY defines if texture must be stored with Y axis inverted
  49815. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49816. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49817. */
  49818. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49819. /** Gets or sets the texture format to use */
  49820. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49821. /**
  49822. * Update the texture with new data
  49823. * @param data defines the data to store in the texture
  49824. */
  49825. update(data: ArrayBufferView): void;
  49826. }
  49827. }
  49828. declare module BABYLON {
  49829. /**
  49830. * Creates a refraction texture used by refraction channel of the standard material.
  49831. * It is like a mirror but to see through a material.
  49832. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49833. */
  49834. export class RefractionTexture extends RenderTargetTexture {
  49835. /**
  49836. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49837. * 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.
  49838. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49839. */
  49840. refractionPlane: Plane;
  49841. /**
  49842. * Define how deep under the surface we should see.
  49843. */
  49844. depth: number;
  49845. /**
  49846. * Creates a refraction texture used by refraction channel of the standard material.
  49847. * It is like a mirror but to see through a material.
  49848. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49849. * @param name Define the texture name
  49850. * @param size Define the size of the underlying texture
  49851. * @param scene Define the scene the refraction belongs to
  49852. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49853. */
  49854. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49855. /**
  49856. * Clone the refraction texture.
  49857. * @returns the cloned texture
  49858. */
  49859. clone(): RefractionTexture;
  49860. /**
  49861. * Serialize the texture to a JSON representation you could use in Parse later on
  49862. * @returns the serialized JSON representation
  49863. */
  49864. serialize(): any;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * Defines the options related to the creation of an HtmlElementTexture
  49870. */
  49871. export interface IHtmlElementTextureOptions {
  49872. /**
  49873. * Defines wether mip maps should be created or not.
  49874. */
  49875. generateMipMaps?: boolean;
  49876. /**
  49877. * Defines the sampling mode of the texture.
  49878. */
  49879. samplingMode?: number;
  49880. /**
  49881. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49882. */
  49883. engine: Nullable<Engine>;
  49884. /**
  49885. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49886. */
  49887. scene: Nullable<Scene>;
  49888. }
  49889. /**
  49890. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49891. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49892. * is automatically managed.
  49893. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49894. * in your application.
  49895. *
  49896. * As the update is not automatic, you need to call them manually.
  49897. */
  49898. export class HtmlElementTexture extends BaseTexture {
  49899. /**
  49900. * The texture URL.
  49901. */
  49902. element: HTMLVideoElement | HTMLCanvasElement;
  49903. private static readonly DefaultOptions;
  49904. private _textureMatrix;
  49905. private _engine;
  49906. private _isVideo;
  49907. private _generateMipMaps;
  49908. private _samplingMode;
  49909. /**
  49910. * Instantiates a HtmlElementTexture from the following parameters.
  49911. *
  49912. * @param name Defines the name of the texture
  49913. * @param element Defines the video or canvas the texture is filled with
  49914. * @param options Defines the other none mandatory texture creation options
  49915. */
  49916. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49917. private _createInternalTexture;
  49918. /**
  49919. * Returns the texture matrix used in most of the material.
  49920. */
  49921. getTextureMatrix(): Matrix;
  49922. /**
  49923. * Updates the content of the texture.
  49924. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49925. */
  49926. update(invertY?: Nullable<boolean>): void;
  49927. }
  49928. }
  49929. declare module BABYLON {
  49930. /**
  49931. * Enum used to define the target of a block
  49932. */
  49933. export enum NodeMaterialBlockTargets {
  49934. /** Vertex shader */
  49935. Vertex = 1,
  49936. /** Fragment shader */
  49937. Fragment = 2,
  49938. /** Vertex and Fragment */
  49939. VertexAndFragment = 3
  49940. }
  49941. }
  49942. declare module BABYLON {
  49943. /**
  49944. * Defines the kind of connection point for node based material
  49945. */
  49946. export enum NodeMaterialBlockConnectionPointTypes {
  49947. /** Float */
  49948. Float = 1,
  49949. /** Int */
  49950. Int = 2,
  49951. /** Vector2 */
  49952. Vector2 = 4,
  49953. /** Vector3 */
  49954. Vector3 = 8,
  49955. /** Vector4 */
  49956. Vector4 = 16,
  49957. /** Color3 */
  49958. Color3 = 32,
  49959. /** Color4 */
  49960. Color4 = 64,
  49961. /** Matrix */
  49962. Matrix = 128,
  49963. /** Texture */
  49964. Texture = 256,
  49965. /** Texture3D */
  49966. Texture3D = 512,
  49967. /** Vector3 or Color3 */
  49968. Vector3OrColor3 = 40,
  49969. /** Vector3 or Vector4 */
  49970. Vector3OrVector4 = 24,
  49971. /** Vector4 or Color4 */
  49972. Vector4OrColor4 = 80,
  49973. /** Color3 or Color4 */
  49974. Color3OrColor4 = 96,
  49975. /** Vector3 or Color3 */
  49976. Vector3OrColor3OrVector4OrColor4 = 120,
  49977. /** Detect type based on connection */
  49978. AutoDetect = 1024,
  49979. /** Output type that will be defined by input type */
  49980. BasedOnInput = 2048,
  49981. /** Light */
  49982. Light = 4096
  49983. }
  49984. }
  49985. declare module BABYLON {
  49986. /**
  49987. * Enum used to define well known values e.g. values automatically provided by the system
  49988. */
  49989. export enum NodeMaterialWellKnownValues {
  49990. /** World */
  49991. World = 1,
  49992. /** View */
  49993. View = 2,
  49994. /** Projection */
  49995. Projection = 3,
  49996. /** ViewProjection */
  49997. ViewProjection = 4,
  49998. /** WorldView */
  49999. WorldView = 5,
  50000. /** WorldViewProjection */
  50001. WorldViewProjection = 6,
  50002. /** CameraPosition */
  50003. CameraPosition = 7,
  50004. /** Will be filled by the block itself */
  50005. Automatic = 8
  50006. }
  50007. }
  50008. declare module BABYLON {
  50009. /**
  50010. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50011. */
  50012. export enum NodeMaterialBlockConnectionPointMode {
  50013. /** Value is an uniform */
  50014. Uniform = 0,
  50015. /** Value is a mesh attribute */
  50016. Attribute = 1,
  50017. /** Value is a varying between vertex and fragment shaders */
  50018. Varying = 2,
  50019. /** Mode is undefined */
  50020. Undefined = 3
  50021. }
  50022. }
  50023. declare module BABYLON {
  50024. /**
  50025. * Class used to store shared data between 2 NodeMaterialBuildState
  50026. */
  50027. export class NodeMaterialBuildStateSharedData {
  50028. /**
  50029. * Gets the list of emitted varyings
  50030. */
  50031. varyings: string[];
  50032. /**
  50033. * Gets the varying declaration string
  50034. */
  50035. varyingDeclaration: string;
  50036. /**
  50037. * Uniform connection points
  50038. */
  50039. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50040. /**
  50041. * Bindable blocks (Blocks that need to set data to the effect)
  50042. */
  50043. bindableBlocks: NodeMaterialBlock[];
  50044. /**
  50045. * List of blocks that can provide a compilation fallback
  50046. */
  50047. blocksWithFallbacks: NodeMaterialBlock[];
  50048. /**
  50049. * List of blocks that can provide a define update
  50050. */
  50051. blocksWithDefines: NodeMaterialBlock[];
  50052. /**
  50053. * List of blocks that can provide a repeatable content
  50054. */
  50055. repeatableContentBlocks: NodeMaterialBlock[];
  50056. /**
  50057. * List of blocks that can provide a dynamic list of uniforms
  50058. */
  50059. dynamicUniformBlocks: NodeMaterialBlock[];
  50060. /**
  50061. * List of blocks that can block the isReady function for the material
  50062. */
  50063. blockingBlocks: NodeMaterialBlock[];
  50064. /**
  50065. * Build Id used to avoid multiple recompilations
  50066. */
  50067. buildId: number;
  50068. /** List of emitted variables */
  50069. variableNames: {
  50070. [key: string]: number;
  50071. };
  50072. /** List of emitted defines */
  50073. defineNames: {
  50074. [key: string]: number;
  50075. };
  50076. /** Should emit comments? */
  50077. emitComments: boolean;
  50078. /** Emit build activity */
  50079. verbose: boolean;
  50080. /**
  50081. * Gets the compilation hints emitted at compilation time
  50082. */
  50083. hints: {
  50084. needWorldViewMatrix: boolean;
  50085. needWorldViewProjectionMatrix: boolean;
  50086. needAlphaBlending: boolean;
  50087. needAlphaTesting: boolean;
  50088. };
  50089. /**
  50090. * List of compilation checks
  50091. */
  50092. checks: {
  50093. emitVertex: boolean;
  50094. emitFragment: boolean;
  50095. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50096. };
  50097. /** Creates a new shared data */
  50098. constructor();
  50099. /**
  50100. * Emits console errors and exceptions if there is a failing check
  50101. */
  50102. emitErrors(): void;
  50103. }
  50104. }
  50105. declare module BABYLON {
  50106. /**
  50107. * Class used to store node based material build state
  50108. */
  50109. export class NodeMaterialBuildState {
  50110. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50111. supportUniformBuffers: boolean;
  50112. /**
  50113. * Gets the list of emitted attributes
  50114. */
  50115. attributes: string[];
  50116. /**
  50117. * Gets the list of emitted uniforms
  50118. */
  50119. uniforms: string[];
  50120. /**
  50121. * Gets the list of emitted uniform buffers
  50122. */
  50123. uniformBuffers: string[];
  50124. /**
  50125. * Gets the list of emitted samplers
  50126. */
  50127. samplers: string[];
  50128. /**
  50129. * Gets the list of emitted functions
  50130. */
  50131. functions: {
  50132. [key: string]: string;
  50133. };
  50134. /**
  50135. * Gets the target of the compilation state
  50136. */
  50137. target: NodeMaterialBlockTargets;
  50138. /**
  50139. * Gets the list of emitted counters
  50140. */
  50141. counters: {
  50142. [key: string]: number;
  50143. };
  50144. /**
  50145. * Shared data between multiple NodeMaterialBuildState instances
  50146. */
  50147. sharedData: NodeMaterialBuildStateSharedData;
  50148. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  50149. private _attributeDeclaration;
  50150. private _uniformDeclaration;
  50151. private _samplerDeclaration;
  50152. private _varyingTransfer;
  50153. private _repeatableContentAnchorIndex;
  50154. /** @hidden */ private _builtCompilationString: string;
  50155. /**
  50156. * Gets the emitted compilation strings
  50157. */
  50158. compilationString: string;
  50159. /**
  50160. * Finalize the compilation strings
  50161. * @param state defines the current compilation state
  50162. */
  50163. finalize(state: NodeMaterialBuildState): void;
  50164. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  50165. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  50166. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  50167. /** @hidden */ private _excludeVariableName(name: string): void;
  50168. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50169. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  50170. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50171. replaceStrings?: {
  50172. search: RegExp;
  50173. replace: string;
  50174. }[];
  50175. repeatKey?: string;
  50176. }): string;
  50177. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50178. repeatKey?: string;
  50179. removeAttributes?: boolean;
  50180. removeUniforms?: boolean;
  50181. removeVaryings?: boolean;
  50182. removeIfDef?: boolean;
  50183. replaceStrings?: {
  50184. search: RegExp;
  50185. replace: string;
  50186. }[];
  50187. }, storeKey?: string): void;
  50188. /** @hidden */ private _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50189. private _emitDefine;
  50190. /** @hidden */ private _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50191. }
  50192. }
  50193. declare module BABYLON {
  50194. /**
  50195. * Root class for all node material optimizers
  50196. */
  50197. export class NodeMaterialOptimizer {
  50198. /**
  50199. * Function used to optimize a NodeMaterial graph
  50200. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50201. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50202. */
  50203. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50204. }
  50205. }
  50206. declare module BABYLON {
  50207. /**
  50208. * Block used to transform a vector4 with a matrix
  50209. */
  50210. export class Vector4TransformBlock extends NodeMaterialBlock {
  50211. /**
  50212. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50213. */
  50214. complementW: number;
  50215. /**
  50216. * Creates a new Vector4TransformBlock
  50217. * @param name defines the block name
  50218. */
  50219. constructor(name: string);
  50220. /**
  50221. * Gets the current class name
  50222. * @returns the class name
  50223. */
  50224. getClassName(): string;
  50225. /**
  50226. * Gets the vector input
  50227. */
  50228. readonly vector: NodeMaterialConnectionPoint;
  50229. /**
  50230. * Gets the output component
  50231. */
  50232. readonly output: NodeMaterialConnectionPoint;
  50233. /**
  50234. * Gets the matrix transform input
  50235. */
  50236. readonly transform: NodeMaterialConnectionPoint;
  50237. protected _buildBlock(state: NodeMaterialBuildState): this;
  50238. }
  50239. }
  50240. declare module BABYLON {
  50241. /**
  50242. * Block used to output the vertex position
  50243. */
  50244. export class VertexOutputBlock extends NodeMaterialBlock {
  50245. /**
  50246. * Creates a new VertexOutputBlock
  50247. * @param name defines the block name
  50248. */
  50249. constructor(name: string);
  50250. /**
  50251. * Gets the current class name
  50252. * @returns the class name
  50253. */
  50254. getClassName(): string;
  50255. /**
  50256. * Gets the vector input component
  50257. */
  50258. readonly vector: NodeMaterialConnectionPoint;
  50259. protected _buildBlock(state: NodeMaterialBuildState): this;
  50260. }
  50261. }
  50262. declare module BABYLON {
  50263. /**
  50264. * Block used to output the final color
  50265. */
  50266. export class FragmentOutputBlock extends NodeMaterialBlock {
  50267. /**
  50268. * Gets or sets a boolean indicating if this block will output an alpha value
  50269. */
  50270. alphaBlendingEnabled: boolean;
  50271. /**
  50272. * Create a new FragmentOutputBlock
  50273. * @param name defines the block name
  50274. */
  50275. constructor(name: string);
  50276. /**
  50277. * Gets the current class name
  50278. * @returns the class name
  50279. */
  50280. getClassName(): string;
  50281. /**
  50282. * Gets the color input component
  50283. */
  50284. readonly color: NodeMaterialConnectionPoint;
  50285. protected _buildBlock(state: NodeMaterialBuildState): this;
  50286. }
  50287. }
  50288. declare module BABYLON {
  50289. /**
  50290. * Interface used to configure the node material editor
  50291. */
  50292. export interface INodeMaterialEditorOptions {
  50293. /** Define the URl to load node editor script */
  50294. editorURL?: string;
  50295. }
  50296. /** @hidden */
  50297. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50298. /** BONES */
  50299. NUM_BONE_INFLUENCERS: number;
  50300. BonesPerMesh: number;
  50301. BONETEXTURE: boolean;
  50302. /** MORPH TARGETS */
  50303. MORPHTARGETS: boolean;
  50304. MORPHTARGETS_NORMAL: boolean;
  50305. MORPHTARGETS_TANGENT: boolean;
  50306. MORPHTARGETS_UV: boolean;
  50307. NUM_MORPH_INFLUENCERS: number;
  50308. /** IMAGE PROCESSING */
  50309. IMAGEPROCESSING: boolean;
  50310. VIGNETTE: boolean;
  50311. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50312. VIGNETTEBLENDMODEOPAQUE: boolean;
  50313. TONEMAPPING: boolean;
  50314. TONEMAPPING_ACES: boolean;
  50315. CONTRAST: boolean;
  50316. EXPOSURE: boolean;
  50317. COLORCURVES: boolean;
  50318. COLORGRADING: boolean;
  50319. COLORGRADING3D: boolean;
  50320. SAMPLER3DGREENDEPTH: boolean;
  50321. SAMPLER3DBGRMAP: boolean;
  50322. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50323. constructor();
  50324. setValue(name: string, value: boolean): void;
  50325. }
  50326. /**
  50327. * Class used to configure NodeMaterial
  50328. */
  50329. export interface INodeMaterialOptions {
  50330. /**
  50331. * Defines if blocks should emit comments
  50332. */
  50333. emitComments: boolean;
  50334. }
  50335. /**
  50336. * Class used to create a node based material built by assembling shader blocks
  50337. */
  50338. export class NodeMaterial extends PushMaterial {
  50339. private _options;
  50340. private _vertexCompilationState;
  50341. private _fragmentCompilationState;
  50342. private _sharedData;
  50343. private _buildId;
  50344. private _buildWasSuccessful;
  50345. private _cachedWorldViewMatrix;
  50346. private _cachedWorldViewProjectionMatrix;
  50347. private _textureConnectionPoints;
  50348. private _optimizers;
  50349. /** Define the URl to load node editor script */
  50350. static EditorURL: string;
  50351. private BJSNODEMATERIALEDITOR;
  50352. /** Get the inspector from bundle or global */
  50353. private _getGlobalNodeMaterialEditor;
  50354. /**
  50355. * Defines the maximum number of lights that can be used in the material
  50356. */
  50357. maxSimultaneousLights: number;
  50358. /**
  50359. * Observable raised when the material is built
  50360. */
  50361. onBuildObservable: Observable<NodeMaterial>;
  50362. /**
  50363. * Gets or sets the root nodes of the material vertex shader
  50364. */ private _vertexOutputNodes: NodeMaterialBlock[];
  50365. /**
  50366. * Gets or sets the root nodes of the material fragment (pixel) shader
  50367. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  50368. /** Gets or sets options to control the node material overall behavior */
  50369. options: INodeMaterialOptions;
  50370. /**
  50371. * Default configuration related to image processing available in the standard Material.
  50372. */
  50373. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50374. /**
  50375. * Gets the image processing configuration used either in this material.
  50376. */
  50377. /**
  50378. * Sets the Default image processing configuration used either in the this material.
  50379. *
  50380. * If sets to null, the scene one is in use.
  50381. */
  50382. imageProcessingConfiguration: ImageProcessingConfiguration;
  50383. /**
  50384. * Create a new node based material
  50385. * @param name defines the material name
  50386. * @param scene defines the hosting scene
  50387. * @param options defines creation option
  50388. */
  50389. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50390. /**
  50391. * Gets the current class name of the material e.g. "NodeMaterial"
  50392. * @returns the class name
  50393. */
  50394. getClassName(): string;
  50395. /**
  50396. * Keep track of the image processing observer to allow dispose and replace.
  50397. */
  50398. private _imageProcessingObserver;
  50399. /**
  50400. * Attaches a new image processing configuration to the Standard Material.
  50401. * @param configuration
  50402. */
  50403. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50404. /**
  50405. * Adds a new optimizer to the list of optimizers
  50406. * @param optimizer defines the optimizers to add
  50407. * @returns the current material
  50408. */
  50409. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50410. /**
  50411. * Remove an optimizer from the list of optimizers
  50412. * @param optimizer defines the optimizers to remove
  50413. * @returns the current material
  50414. */
  50415. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50416. /**
  50417. * Add a new block to the list of output nodes
  50418. * @param node defines the node to add
  50419. * @returns the current material
  50420. */
  50421. addOutputNode(node: NodeMaterialBlock): this;
  50422. /**
  50423. * Remove a block from the list of root nodes
  50424. * @param node defines the node to remove
  50425. * @returns the current material
  50426. */
  50427. removeOutputNode(node: NodeMaterialBlock): this;
  50428. private _addVertexOutputNode;
  50429. private _removeVertexOutputNode;
  50430. private _addFragmentOutputNode;
  50431. private _removeFragmentOutputNode;
  50432. /**
  50433. * Specifies if the material will require alpha blending
  50434. * @returns a boolean specifying if alpha blending is needed
  50435. */
  50436. needAlphaBlending(): boolean;
  50437. /**
  50438. * Specifies if this material should be rendered in alpha test mode
  50439. * @returns a boolean specifying if an alpha test is needed.
  50440. */
  50441. needAlphaTesting(): boolean;
  50442. private _initializeBlock;
  50443. private _resetDualBlocks;
  50444. /**
  50445. * Build the material and generates the inner effect
  50446. * @param verbose defines if the build should log activity
  50447. */
  50448. build(verbose?: boolean): void;
  50449. /**
  50450. * Runs an otpimization phase to try to improve the shader code
  50451. */
  50452. optimize(): void;
  50453. private _prepareDefinesForAttributes;
  50454. /**
  50455. * Get if the submesh is ready to be used and all its information available.
  50456. * Child classes can use it to update shaders
  50457. * @param mesh defines the mesh to check
  50458. * @param subMesh defines which submesh to check
  50459. * @param useInstances specifies that instances should be used
  50460. * @returns a boolean indicating that the submesh is ready or not
  50461. */
  50462. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50463. /**
  50464. * Binds the world matrix to the material
  50465. * @param world defines the world transformation matrix
  50466. */
  50467. bindOnlyWorldMatrix(world: Matrix): void;
  50468. /**
  50469. * Binds the submesh to this material by preparing the effect and shader to draw
  50470. * @param world defines the world transformation matrix
  50471. * @param mesh defines the mesh containing the submesh
  50472. * @param subMesh defines the submesh to bind the material to
  50473. */
  50474. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50475. /**
  50476. * Gets the active textures from the material
  50477. * @returns an array of textures
  50478. */
  50479. getActiveTextures(): BaseTexture[];
  50480. /**
  50481. * Specifies if the material uses a texture
  50482. * @param texture defines the texture to check against the material
  50483. * @returns a boolean specifying if the material uses the texture
  50484. */
  50485. hasTexture(texture: BaseTexture): boolean;
  50486. /**
  50487. * Disposes the material
  50488. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50489. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50490. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50491. */
  50492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50493. /** Creates the node editor window. */
  50494. private _createNodeEditor;
  50495. /**
  50496. * Launch the node material editor
  50497. * @param config Define the configuration of the editor
  50498. * @return a promise fulfilled when the node editor is visible
  50499. */
  50500. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50501. /**
  50502. * Clear the current material
  50503. */
  50504. clear(): void;
  50505. /**
  50506. * Clear the current material and set it to a default state
  50507. */
  50508. setToDefault(): void;
  50509. }
  50510. }
  50511. declare module BABYLON {
  50512. /**
  50513. * Defines a block that can be used inside a node based material
  50514. */
  50515. export class NodeMaterialBlock {
  50516. private _buildId;
  50517. private _target;
  50518. private _isFinalMerger;
  50519. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  50520. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  50521. /**
  50522. * Gets or sets the name of the block
  50523. */
  50524. name: string;
  50525. /**
  50526. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  50527. */
  50528. readonly isFinalMerger: boolean;
  50529. /**
  50530. * Gets or sets the build Id
  50531. */
  50532. buildId: number;
  50533. /**
  50534. * Gets or sets the target of the block
  50535. */
  50536. target: NodeMaterialBlockTargets;
  50537. /**
  50538. * Gets the list of input points
  50539. */
  50540. readonly inputs: NodeMaterialConnectionPoint[];
  50541. /** Gets the list of output points */
  50542. readonly outputs: NodeMaterialConnectionPoint[];
  50543. /**
  50544. * Find an input by its name
  50545. * @param name defines the name of the input to look for
  50546. * @returns the input or null if not found
  50547. */
  50548. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50549. /**
  50550. * Find an output by its name
  50551. * @param name defines the name of the outputto look for
  50552. * @returns the output or null if not found
  50553. */
  50554. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50555. /**
  50556. * Creates a new NodeMaterialBlock
  50557. * @param name defines the block name
  50558. * @param target defines the target of that block (Vertex by default)
  50559. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  50560. */
  50561. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  50562. /**
  50563. * Initialize the block and prepare the context for build
  50564. * @param state defines the state that will be used for the build
  50565. */
  50566. initialize(state: NodeMaterialBuildState): void;
  50567. /**
  50568. * Bind data to effect. Will only be called for blocks with isBindable === true
  50569. * @param effect defines the effect to bind data to
  50570. * @param nodeMaterial defines the hosting NodeMaterial
  50571. * @param mesh defines the mesh that will be rendered
  50572. */
  50573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50574. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  50575. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  50576. protected _writeFloat(value: number): string;
  50577. /**
  50578. * Gets the current class name e.g. "NodeMaterialBlock"
  50579. * @returns the class name
  50580. */
  50581. getClassName(): string;
  50582. /**
  50583. * Register a new input. Must be called inside a block constructor
  50584. * @param name defines the connection point name
  50585. * @param type defines the connection point type
  50586. * @param isOptional defines a boolean indicating that this input can be omitted
  50587. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50588. * @returns the current block
  50589. */
  50590. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  50591. /**
  50592. * Register a new output. Must be called inside a block constructor
  50593. * @param name defines the connection point name
  50594. * @param type defines the connection point type
  50595. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50596. * @returns the current block
  50597. */
  50598. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  50599. /**
  50600. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  50601. * @param forOutput defines an optional connection point to check compatibility with
  50602. * @returns the first available input or null
  50603. */
  50604. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  50605. /**
  50606. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  50607. * @param forBlock defines an optional block to check compatibility with
  50608. * @returns the first available input or null
  50609. */
  50610. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  50611. /**
  50612. * Connect current block with another block
  50613. * @param other defines the block to connect with
  50614. * @param options define the various options to help pick the right connections
  50615. * @returns the current block
  50616. */
  50617. connectTo(other: NodeMaterialBlock, options?: {
  50618. input?: string;
  50619. output?: string;
  50620. outputSwizzle?: string;
  50621. }): this | undefined;
  50622. protected _buildBlock(state: NodeMaterialBuildState): void;
  50623. /**
  50624. * Add uniforms, samplers and uniform buffers at compilation time
  50625. * @param state defines the state to update
  50626. * @param nodeMaterial defines the node material requesting the update
  50627. * @param defines defines the material defines to update
  50628. */
  50629. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50630. /**
  50631. * Add potential fallbacks if shader compilation fails
  50632. * @param mesh defines the mesh to be rendered
  50633. * @param fallbacks defines the current prioritized list of fallbacks
  50634. */
  50635. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50636. /**
  50637. * Update defines for shader compilation
  50638. * @param mesh defines the mesh to be rendered
  50639. * @param nodeMaterial defines the node material requesting the update
  50640. * @param defines defines the material defines to update
  50641. * @param useInstances specifies that instances should be used
  50642. */
  50643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50644. /**
  50645. * Lets the block try to connect some inputs automatically
  50646. */
  50647. autoConfigure(): void;
  50648. /**
  50649. * Function called when a block is declared as repeatable content generator
  50650. * @param vertexShaderState defines the current compilation state for the vertex shader
  50651. * @param fragmentShaderState defines the current compilation state for the fragment shader
  50652. * @param mesh defines the mesh to be rendered
  50653. * @param defines defines the material defines to update
  50654. */
  50655. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50656. /**
  50657. * Checks if the block is ready
  50658. * @param mesh defines the mesh to be rendered
  50659. * @param nodeMaterial defines the node material requesting the update
  50660. * @param defines defines the material defines to update
  50661. * @param useInstances specifies that instances should be used
  50662. * @returns true if the block is ready
  50663. */
  50664. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  50665. /**
  50666. * Compile the current node and generate the shader code
  50667. * @param state defines the current compilation state (uniforms, samplers, current string)
  50668. * @returns the current block
  50669. */
  50670. build(state: NodeMaterialBuildState): this | undefined;
  50671. }
  50672. }
  50673. declare module BABYLON {
  50674. /**
  50675. * Defines a connection point for a block
  50676. */
  50677. export class NodeMaterialConnectionPoint {
  50678. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  50679. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50680. private _associatedVariableName;
  50681. private _endpoints;
  50682. private _storedValue;
  50683. private _valueCallback;
  50684. private _mode;
  50685. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50686. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  50687. /** @hidden */ private _needToEmitVarying: boolean;
  50688. /** @hidden */ private _forceUniformInVertexShaderOnly: boolean;
  50689. private _type;
  50690. /**
  50691. * Gets or sets the connection point type (default is float)
  50692. */
  50693. type: NodeMaterialBlockConnectionPointTypes;
  50694. /**
  50695. * Gets or sets the connection point name
  50696. */
  50697. name: string;
  50698. /**
  50699. * Gets or sets the swizzle to apply to this connection point when reading or writing
  50700. */
  50701. swizzle: string;
  50702. /**
  50703. * Gets or sets a boolean indicating that this connection point can be omitted
  50704. */
  50705. isOptional: boolean;
  50706. /**
  50707. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  50708. */
  50709. define: string;
  50710. /** Gets or sets the target of that connection point */
  50711. target: NodeMaterialBlockTargets;
  50712. /**
  50713. * Gets or sets the value of that point.
  50714. * Please note that this value will be ignored if valueCallback is defined
  50715. */
  50716. value: any;
  50717. /**
  50718. * Gets or sets a callback used to get the value of that point.
  50719. * Please note that setting this value will force the connection point to ignore the value property
  50720. */
  50721. valueCallback: () => any;
  50722. /**
  50723. * Gets or sets the associated variable name in the shader
  50724. */
  50725. associatedVariableName: string;
  50726. /**
  50727. * Gets a boolean indicating that this connection point not defined yet
  50728. */
  50729. readonly isUndefined: boolean;
  50730. /**
  50731. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  50732. * In this case the connection point name must be the name of the uniform to use.
  50733. * Can only be set on inputs
  50734. */
  50735. isUniform: boolean;
  50736. /**
  50737. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  50738. * In this case the connection point name must be the name of the attribute to use
  50739. * Can only be set on inputs
  50740. */
  50741. isAttribute: boolean;
  50742. /**
  50743. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  50744. * Can only be set on exit points
  50745. */
  50746. isVarying: boolean;
  50747. /** Get the other side of the connection (if any) */
  50748. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50749. /** Get the block that owns this connection point */
  50750. readonly ownerBlock: NodeMaterialBlock;
  50751. /** Get the block connected on the other side of this connection (if any) */
  50752. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  50753. /** Get the block connected on the endpoints of this connection (if any) */
  50754. readonly connectedBlocks: Array<NodeMaterialBlock>;
  50755. /**
  50756. * Creates a new connection point
  50757. * @param name defines the connection point name
  50758. * @param ownerBlock defines the block hosting this connection point
  50759. */
  50760. constructor(name: string, ownerBlock: NodeMaterialBlock);
  50761. /**
  50762. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  50763. * @returns the class name
  50764. */
  50765. getClassName(): string;
  50766. /**
  50767. * Set the source of this connection point to a vertex attribute
  50768. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  50769. * @returns the current connection point
  50770. */
  50771. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  50772. /**
  50773. * Set the source of this connection point to a well known value
  50774. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  50775. * @returns the current connection point
  50776. */
  50777. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  50778. /**
  50779. * Gets a boolean indicating that the current connection point is a well known value
  50780. */
  50781. readonly isWellKnownValue: boolean;
  50782. /**
  50783. * Gets or sets the current well known value or null if not defined as well know value
  50784. */
  50785. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50786. private _getTypeLength;
  50787. /**
  50788. * Gets an boolean indicating if the current point can be connected to another point
  50789. * @param connectionPoint defines the other connection point
  50790. * @returns true if the connection is possible
  50791. */
  50792. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  50793. /**
  50794. * Connect this point to another connection point
  50795. * @param connectionPoint defines the other connection point
  50796. * @returns the current connection point
  50797. */
  50798. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50799. /**
  50800. * Disconnect this point from one of his endpoint
  50801. * @param endpoint defines the other connection point
  50802. * @returns the current connection point
  50803. */
  50804. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50805. /**
  50806. * When connection point is an uniform, this function will send its value to the effect
  50807. * @param effect defines the effect to transmit value to
  50808. * @param world defines the world matrix
  50809. * @param worldView defines the worldxview matrix
  50810. * @param worldViewProjection defines the worldxviewxprojection matrix
  50811. */
  50812. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  50813. /**
  50814. * When connection point is an uniform, this function will send its value to the effect
  50815. * @param effect defines the effect to transmit value to
  50816. * @param scene defines the hosting scene
  50817. */
  50818. transmit(effect: Effect, scene: Scene): void;
  50819. }
  50820. }
  50821. declare module BABYLON {
  50822. /**
  50823. * Block used to add support for vertex skinning (bones)
  50824. */
  50825. export class BonesBlock extends NodeMaterialBlock {
  50826. /**
  50827. * Creates a new BonesBlock
  50828. * @param name defines the block name
  50829. */
  50830. constructor(name: string);
  50831. /**
  50832. * Initialize the block and prepare the context for build
  50833. * @param state defines the state that will be used for the build
  50834. */
  50835. initialize(state: NodeMaterialBuildState): void;
  50836. /**
  50837. * Gets the current class name
  50838. * @returns the class name
  50839. */
  50840. getClassName(): string;
  50841. /**
  50842. * Gets the matrix indices input component
  50843. */
  50844. readonly matricesIndices: NodeMaterialConnectionPoint;
  50845. /**
  50846. * Gets the matrix weights input component
  50847. */
  50848. readonly matricesWeights: NodeMaterialConnectionPoint;
  50849. /**
  50850. * Gets the extra matrix indices input component
  50851. */
  50852. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  50853. /**
  50854. * Gets the extra matrix weights input component
  50855. */
  50856. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  50857. /**
  50858. * Gets the world input component
  50859. */
  50860. readonly world: NodeMaterialConnectionPoint;
  50861. /**
  50862. * Gets the output component
  50863. */
  50864. readonly output: NodeMaterialConnectionPoint;
  50865. autoConfigure(): void;
  50866. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50867. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50868. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50869. protected _buildBlock(state: NodeMaterialBuildState): this;
  50870. }
  50871. }
  50872. declare module BABYLON {
  50873. /**
  50874. * Block used to add support for instances
  50875. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  50876. */
  50877. export class InstancesBlock extends NodeMaterialBlock {
  50878. /**
  50879. * Creates a new InstancesBlock
  50880. * @param name defines the block name
  50881. */
  50882. constructor(name: string);
  50883. /**
  50884. * Gets the current class name
  50885. * @returns the class name
  50886. */
  50887. getClassName(): string;
  50888. /**
  50889. * Gets the first world row input component
  50890. */
  50891. readonly world0: NodeMaterialConnectionPoint;
  50892. /**
  50893. * Gets the second world row input component
  50894. */
  50895. readonly world1: NodeMaterialConnectionPoint;
  50896. /**
  50897. * Gets the third world row input component
  50898. */
  50899. readonly world2: NodeMaterialConnectionPoint;
  50900. /**
  50901. * Gets the forth world row input component
  50902. */
  50903. readonly world3: NodeMaterialConnectionPoint;
  50904. /**
  50905. * Gets the world input component
  50906. */
  50907. readonly world: NodeMaterialConnectionPoint;
  50908. /**
  50909. * Gets the output component
  50910. */
  50911. readonly output: NodeMaterialConnectionPoint;
  50912. autoConfigure(): void;
  50913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50914. protected _buildBlock(state: NodeMaterialBuildState): this;
  50915. }
  50916. }
  50917. declare module BABYLON {
  50918. /**
  50919. * Block used to add morph targets support to vertex shader
  50920. */
  50921. export class MorphTargetsBlock extends NodeMaterialBlock {
  50922. private _repeatableContentAnchor;
  50923. private _repeatebleContentGenerated;
  50924. /**
  50925. * Create a new MorphTargetsBlock
  50926. * @param name defines the block name
  50927. */
  50928. constructor(name: string);
  50929. /**
  50930. * Gets the current class name
  50931. * @returns the class name
  50932. */
  50933. getClassName(): string;
  50934. /**
  50935. * Gets the position input component
  50936. */
  50937. readonly position: NodeMaterialConnectionPoint;
  50938. /**
  50939. * Gets the normal input component
  50940. */
  50941. readonly normal: NodeMaterialConnectionPoint;
  50942. /**
  50943. * Gets the tangent input component
  50944. */
  50945. readonly tangent: NodeMaterialConnectionPoint;
  50946. /**
  50947. * Gets the tangent input component
  50948. */
  50949. readonly uv: NodeMaterialConnectionPoint;
  50950. /**
  50951. * Gets the position output component
  50952. */
  50953. readonly positionOutput: NodeMaterialConnectionPoint;
  50954. /**
  50955. * Gets the normal output component
  50956. */
  50957. readonly normalOutput: NodeMaterialConnectionPoint;
  50958. /**
  50959. * Gets the tangent output component
  50960. */
  50961. readonly tangentOutput: NodeMaterialConnectionPoint;
  50962. /**
  50963. * Gets the tangent output component
  50964. */
  50965. readonly uvOutput: NodeMaterialConnectionPoint;
  50966. initialize(state: NodeMaterialBuildState): void;
  50967. autoConfigure(): void;
  50968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50969. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50970. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50971. protected _buildBlock(state: NodeMaterialBuildState): this;
  50972. }
  50973. }
  50974. declare module BABYLON {
  50975. /**
  50976. * Block used to add an alpha test in the fragment shader
  50977. */
  50978. export class AlphaTestBlock extends NodeMaterialBlock {
  50979. /**
  50980. * Gets or sets the alpha value where alpha testing happens
  50981. */
  50982. alphaCutOff: number;
  50983. /**
  50984. * Create a new AlphaTestBlock
  50985. * @param name defines the block name
  50986. */
  50987. constructor(name: string);
  50988. /**
  50989. * Gets the current class name
  50990. * @returns the class name
  50991. */
  50992. getClassName(): string;
  50993. /**
  50994. * Gets the color input component
  50995. */
  50996. readonly color: NodeMaterialConnectionPoint;
  50997. protected _buildBlock(state: NodeMaterialBuildState): this;
  50998. }
  50999. }
  51000. declare module BABYLON {
  51001. /**
  51002. * Block used to create a Color4 out of 4 inputs (one for each component)
  51003. */
  51004. export class RGBAMergerBlock extends NodeMaterialBlock {
  51005. /**
  51006. * Create a new RGBAMergerBlock
  51007. * @param name defines the block name
  51008. */
  51009. constructor(name: string);
  51010. /**
  51011. * Gets the current class name
  51012. * @returns the class name
  51013. */
  51014. getClassName(): string;
  51015. /**
  51016. * Gets the R input component
  51017. */
  51018. readonly r: NodeMaterialConnectionPoint;
  51019. /**
  51020. * Gets the G input component
  51021. */
  51022. readonly g: NodeMaterialConnectionPoint;
  51023. /**
  51024. * Gets the B input component
  51025. */
  51026. readonly b: NodeMaterialConnectionPoint;
  51027. /**
  51028. * Gets the RGB input component
  51029. */
  51030. readonly rgb: NodeMaterialConnectionPoint;
  51031. /**
  51032. * Gets the R input component
  51033. */
  51034. readonly a: NodeMaterialConnectionPoint;
  51035. /**
  51036. * Gets the output component
  51037. */
  51038. readonly output: NodeMaterialConnectionPoint;
  51039. protected _buildBlock(state: NodeMaterialBuildState): this;
  51040. }
  51041. }
  51042. declare module BABYLON {
  51043. /**
  51044. * Block used to create a Color3 out of 3 inputs (one for each component)
  51045. */
  51046. export class RGBMergerBlock extends NodeMaterialBlock {
  51047. /**
  51048. * Create a new RGBMergerBlock
  51049. * @param name defines the block name
  51050. */
  51051. constructor(name: string);
  51052. /**
  51053. * Gets the current class name
  51054. * @returns the class name
  51055. */
  51056. getClassName(): string;
  51057. /**
  51058. * Gets the R component input
  51059. */
  51060. readonly r: NodeMaterialConnectionPoint;
  51061. /**
  51062. * Gets the G component input
  51063. */
  51064. readonly g: NodeMaterialConnectionPoint;
  51065. /**
  51066. * Gets the B component input
  51067. */
  51068. readonly b: NodeMaterialConnectionPoint;
  51069. /**
  51070. * Gets the output component
  51071. */
  51072. readonly output: NodeMaterialConnectionPoint;
  51073. protected _buildBlock(state: NodeMaterialBuildState): this;
  51074. }
  51075. }
  51076. declare module BABYLON {
  51077. /**
  51078. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51079. */
  51080. export class RGBASplitterBlock extends NodeMaterialBlock {
  51081. /**
  51082. * Create a new RGBASplitterBlock
  51083. * @param name defines the block name
  51084. */
  51085. constructor(name: string);
  51086. /**
  51087. * Gets the current class name
  51088. * @returns the class name
  51089. */
  51090. getClassName(): string;
  51091. /**
  51092. * Gets the input component
  51093. */
  51094. readonly input: NodeMaterialConnectionPoint;
  51095. protected _buildBlock(state: NodeMaterialBuildState): this;
  51096. }
  51097. }
  51098. declare module BABYLON {
  51099. /**
  51100. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51101. */
  51102. export class RGBSplitterBlock extends NodeMaterialBlock {
  51103. /**
  51104. * Create a new RGBSplitterBlock
  51105. * @param name defines the block name
  51106. */
  51107. constructor(name: string);
  51108. /**
  51109. * Gets the current class name
  51110. * @returns the class name
  51111. */
  51112. getClassName(): string;
  51113. /**
  51114. * Gets the input component
  51115. */
  51116. readonly input: NodeMaterialConnectionPoint;
  51117. protected _buildBlock(state: NodeMaterialBuildState): this;
  51118. }
  51119. }
  51120. declare module BABYLON {
  51121. /**
  51122. * Block used to read a texture from a sampler
  51123. */
  51124. export class TextureBlock extends NodeMaterialBlock {
  51125. private _defineName;
  51126. /**
  51127. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51128. */
  51129. autoConnectTextureMatrix: boolean;
  51130. /**
  51131. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51132. */
  51133. autoSelectUV: boolean;
  51134. /**
  51135. * Create a new TextureBlock
  51136. * @param name defines the block name
  51137. */
  51138. constructor(name: string);
  51139. /**
  51140. * Gets the current class name
  51141. * @returns the class name
  51142. */
  51143. getClassName(): string;
  51144. /**
  51145. * Gets the uv input component
  51146. */
  51147. readonly uv: NodeMaterialConnectionPoint;
  51148. /**
  51149. * Gets the texture information input component
  51150. */
  51151. readonly textureInfo: NodeMaterialConnectionPoint;
  51152. /**
  51153. * Gets the transformed uv input component
  51154. */
  51155. readonly transformedUV: NodeMaterialConnectionPoint;
  51156. /**
  51157. * Gets the texture input component
  51158. */
  51159. readonly texture: NodeMaterialConnectionPoint;
  51160. /**
  51161. * Gets the texture transform input component
  51162. */
  51163. readonly textureTransform: NodeMaterialConnectionPoint;
  51164. /**
  51165. * Gets the output component
  51166. */
  51167. readonly output: NodeMaterialConnectionPoint;
  51168. autoConfigure(): void;
  51169. initialize(state: NodeMaterialBuildState): void;
  51170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51171. isReady(): boolean;
  51172. private _injectVertexCode;
  51173. protected _buildBlock(state: NodeMaterialBuildState): this;
  51174. }
  51175. }
  51176. declare module BABYLON {
  51177. /**
  51178. * Block used to add image processing support to fragment shader
  51179. */
  51180. export class ImageProcessingBlock extends NodeMaterialBlock {
  51181. /**
  51182. * Create a new ImageProcessingBlock
  51183. * @param name defines the block name
  51184. */
  51185. constructor(name: string);
  51186. /**
  51187. * Gets the current class name
  51188. * @returns the class name
  51189. */
  51190. getClassName(): string;
  51191. /**
  51192. * Gets the color input component
  51193. */
  51194. readonly color: NodeMaterialConnectionPoint;
  51195. /**
  51196. * Gets the output component
  51197. */
  51198. readonly output: NodeMaterialConnectionPoint;
  51199. /**
  51200. * Initialize the block and prepare the context for build
  51201. * @param state defines the state that will be used for the build
  51202. */
  51203. initialize(state: NodeMaterialBuildState): void;
  51204. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51205. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51207. protected _buildBlock(state: NodeMaterialBuildState): this;
  51208. }
  51209. }
  51210. declare module BABYLON {
  51211. /**
  51212. * Block used to add support for scene fog
  51213. */
  51214. export class FogBlock extends NodeMaterialBlock {
  51215. /**
  51216. * Create a new FogBlock
  51217. * @param name defines the block name
  51218. */
  51219. constructor(name: string);
  51220. /**
  51221. * Gets the current class name
  51222. * @returns the class name
  51223. */
  51224. getClassName(): string;
  51225. /**
  51226. * Gets the world position input component
  51227. */
  51228. readonly worldPosition: NodeMaterialConnectionPoint;
  51229. /**
  51230. * Gets the view input component
  51231. */
  51232. readonly view: NodeMaterialConnectionPoint;
  51233. /**
  51234. * Gets the color input component
  51235. */
  51236. readonly color: NodeMaterialConnectionPoint;
  51237. /**
  51238. * Gets the fog color input component
  51239. */
  51240. readonly fogColor: NodeMaterialConnectionPoint;
  51241. /**
  51242. * Gets the for parameter input component
  51243. */
  51244. readonly fogParameters: NodeMaterialConnectionPoint;
  51245. /**
  51246. * Gets the output component
  51247. */
  51248. readonly output: NodeMaterialConnectionPoint;
  51249. autoConfigure(): void;
  51250. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51251. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51252. protected _buildBlock(state: NodeMaterialBuildState): this;
  51253. }
  51254. }
  51255. declare module BABYLON {
  51256. /**
  51257. * Block used to add light in the fragment shader
  51258. */
  51259. export class LightBlock extends NodeMaterialBlock {
  51260. private _lightId;
  51261. /**
  51262. * Create a new LightBlock
  51263. * @param name defines the block name
  51264. */
  51265. constructor(name: string);
  51266. /**
  51267. * Gets the current class name
  51268. * @returns the class name
  51269. */
  51270. getClassName(): string;
  51271. /**
  51272. * Gets the world position input component
  51273. */
  51274. readonly worldPosition: NodeMaterialConnectionPoint;
  51275. /**
  51276. * Gets the world normal input component
  51277. */
  51278. readonly worldNormal: NodeMaterialConnectionPoint;
  51279. /**
  51280. * Gets the light input component.
  51281. * If not defined, all lights will be considered
  51282. */
  51283. readonly light: NodeMaterialConnectionPoint;
  51284. /**
  51285. * Gets the camera (or eye) position component
  51286. */
  51287. readonly cameraPosition: NodeMaterialConnectionPoint;
  51288. /**
  51289. * Gets the diffuse output component
  51290. */
  51291. readonly diffuseOutput: NodeMaterialConnectionPoint;
  51292. /**
  51293. * Gets the specular output component
  51294. */
  51295. readonly specularOutput: NodeMaterialConnectionPoint;
  51296. autoConfigure(): void;
  51297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51298. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51299. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51300. private _injectVertexCode;
  51301. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51302. }
  51303. }
  51304. declare module BABYLON {
  51305. /**
  51306. * Block used to multiply 2 values
  51307. */
  51308. export class MultiplyBlock extends NodeMaterialBlock {
  51309. /**
  51310. * Creates a new MultiplyBlock
  51311. * @param name defines the block name
  51312. */
  51313. constructor(name: string);
  51314. /**
  51315. * Gets the current class name
  51316. * @returns the class name
  51317. */
  51318. getClassName(): string;
  51319. /**
  51320. * Gets the left operand input component
  51321. */
  51322. readonly left: NodeMaterialConnectionPoint;
  51323. /**
  51324. * Gets the right operand input component
  51325. */
  51326. readonly right: NodeMaterialConnectionPoint;
  51327. /**
  51328. * Gets the output component
  51329. */
  51330. readonly output: NodeMaterialConnectionPoint;
  51331. protected _buildBlock(state: NodeMaterialBuildState): this;
  51332. }
  51333. }
  51334. declare module BABYLON {
  51335. /**
  51336. * Block used to add 2 vector4
  51337. */
  51338. export class AddBlock extends NodeMaterialBlock {
  51339. /**
  51340. * Creates a new AddBlock
  51341. * @param name defines the block name
  51342. */
  51343. constructor(name: string);
  51344. /**
  51345. * Gets the current class name
  51346. * @returns the class name
  51347. */
  51348. getClassName(): string;
  51349. /**
  51350. * Gets the left operand input component
  51351. */
  51352. readonly left: NodeMaterialConnectionPoint;
  51353. /**
  51354. * Gets the right operand input component
  51355. */
  51356. readonly right: NodeMaterialConnectionPoint;
  51357. /**
  51358. * Gets the output component
  51359. */
  51360. readonly output: NodeMaterialConnectionPoint;
  51361. protected _buildBlock(state: NodeMaterialBuildState): this;
  51362. }
  51363. }
  51364. declare module BABYLON {
  51365. /**
  51366. * Block used to clamp a float
  51367. */
  51368. export class ClampBlock extends NodeMaterialBlock {
  51369. /** Gets or sets the minimum range */
  51370. minimum: number;
  51371. /** Gets or sets the maximum range */
  51372. maximum: number;
  51373. /**
  51374. * Creates a new ClampBlock
  51375. * @param name defines the block name
  51376. */
  51377. constructor(name: string);
  51378. /**
  51379. * Gets the current class name
  51380. * @returns the class name
  51381. */
  51382. getClassName(): string;
  51383. /**
  51384. * Gets the value input component
  51385. */
  51386. readonly value: NodeMaterialConnectionPoint;
  51387. /**
  51388. * Gets the output component
  51389. */
  51390. readonly output: NodeMaterialConnectionPoint;
  51391. protected _buildBlock(state: NodeMaterialBuildState): this;
  51392. }
  51393. }
  51394. declare module BABYLON {
  51395. /**
  51396. * Block used to transform a vector2 with a matrix
  51397. */
  51398. export class Vector2TransformBlock extends NodeMaterialBlock {
  51399. /**
  51400. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51401. */
  51402. complementZ: number;
  51403. /**
  51404. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51405. */
  51406. complementW: number;
  51407. /**
  51408. * Creates a new Vector2TransformBlock
  51409. * @param name defines the block name
  51410. */
  51411. constructor(name: string);
  51412. /**
  51413. * Gets the vector input
  51414. */
  51415. readonly vector: NodeMaterialConnectionPoint;
  51416. /**
  51417. * Gets the matrix transform input
  51418. */
  51419. readonly transform: NodeMaterialConnectionPoint;
  51420. /**
  51421. * Gets the output component
  51422. */
  51423. readonly output: NodeMaterialConnectionPoint;
  51424. /**
  51425. * Gets the current class name
  51426. * @returns the class name
  51427. */
  51428. getClassName(): string;
  51429. protected _buildBlock(state: NodeMaterialBuildState): this;
  51430. }
  51431. }
  51432. declare module BABYLON {
  51433. /**
  51434. * Block used to transform a vector3 with a matrix
  51435. */
  51436. export class Vector3TransformBlock extends NodeMaterialBlock {
  51437. /**
  51438. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51439. */
  51440. complement: number;
  51441. /**
  51442. * Creates a new Vector3TransformBlock
  51443. * @param name defines the block name
  51444. */
  51445. constructor(name: string);
  51446. /**
  51447. * Gets the vector input
  51448. */
  51449. readonly vector: NodeMaterialConnectionPoint;
  51450. /**
  51451. * Gets the matrix transform input
  51452. */
  51453. readonly transform: NodeMaterialConnectionPoint;
  51454. /**
  51455. * Gets the output component
  51456. */
  51457. readonly output: NodeMaterialConnectionPoint;
  51458. /**
  51459. * Gets the current class name
  51460. * @returns the class name
  51461. */
  51462. getClassName(): string;
  51463. protected _buildBlock(state: NodeMaterialBuildState): this;
  51464. }
  51465. }
  51466. declare module BABYLON {
  51467. /**
  51468. * Helper class to render one or more effects
  51469. */
  51470. export class EffectRenderer {
  51471. private engine;
  51472. private static _Vertices;
  51473. private static _Indices;
  51474. private _vertexBuffers;
  51475. private _indexBuffer;
  51476. private _ringBufferIndex;
  51477. private _ringScreenBuffer;
  51478. private _getNextFrameBuffer;
  51479. /**
  51480. * Creates an effect renderer
  51481. * @param engine the engine to use for rendering
  51482. */
  51483. constructor(engine: Engine);
  51484. /**
  51485. * renders one or more effects to a specified texture
  51486. * @param effectWrappers list of effects to renderer
  51487. * @param outputTexture texture to draw to, if null it will render to the screen
  51488. */
  51489. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  51490. /**
  51491. * Disposes of the effect renderer
  51492. */
  51493. dispose(): void;
  51494. }
  51495. /**
  51496. * Options to create an EffectWrapper
  51497. */
  51498. interface EffectWrapperCreationOptions {
  51499. /**
  51500. * Engine to use to create the effect
  51501. */
  51502. engine: Engine;
  51503. /**
  51504. * Fragment shader for the effect
  51505. */
  51506. fragmentShader: string;
  51507. /**
  51508. * Attributes to use in the shader
  51509. */
  51510. attributeNames: Array<string>;
  51511. /**
  51512. * Uniforms to use in the shader
  51513. */
  51514. uniformNames: Array<string>;
  51515. /**
  51516. * Texture sampler names to use in the shader
  51517. */
  51518. samplerNames: Array<string>;
  51519. }
  51520. /**
  51521. * Wraps an effect to be used for rendering
  51522. */
  51523. export class EffectWrapper {
  51524. /**
  51525. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  51526. */
  51527. onApplyObservable: Observable<{}>;
  51528. /**
  51529. * The underlying effect
  51530. */
  51531. effect: Effect;
  51532. /**
  51533. * Creates an effect to be renderer
  51534. * @param creationOptions options to create the effect
  51535. */
  51536. constructor(creationOptions: EffectWrapperCreationOptions);
  51537. /**
  51538. * Disposes of the effect wrapper
  51539. */
  51540. dispose(): void;
  51541. }
  51542. }
  51543. declare module BABYLON {
  51544. /**
  51545. * Helper class to push actions to a pool of workers.
  51546. */
  51547. export class WorkerPool implements IDisposable {
  51548. private _workerInfos;
  51549. private _pendingActions;
  51550. /**
  51551. * Constructor
  51552. * @param workers Array of workers to use for actions
  51553. */
  51554. constructor(workers: Array<Worker>);
  51555. /**
  51556. * Terminates all workers and clears any pending actions.
  51557. */
  51558. dispose(): void;
  51559. /**
  51560. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51561. * pended until a worker has completed its action.
  51562. * @param action The action to perform. Call onComplete when the action is complete.
  51563. */
  51564. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51565. private _execute;
  51566. }
  51567. }
  51568. declare module BABYLON {
  51569. /**
  51570. * Configuration for Draco compression
  51571. */
  51572. export interface IDracoCompressionConfiguration {
  51573. /**
  51574. * Configuration for the decoder.
  51575. */
  51576. decoder: {
  51577. /**
  51578. * The url to the WebAssembly module.
  51579. */
  51580. wasmUrl?: string;
  51581. /**
  51582. * The url to the WebAssembly binary.
  51583. */
  51584. wasmBinaryUrl?: string;
  51585. /**
  51586. * The url to the fallback JavaScript module.
  51587. */
  51588. fallbackUrl?: string;
  51589. };
  51590. }
  51591. /**
  51592. * Draco compression (https://google.github.io/draco/)
  51593. *
  51594. * This class wraps the Draco module.
  51595. *
  51596. * **Encoder**
  51597. *
  51598. * The encoder is not currently implemented.
  51599. *
  51600. * **Decoder**
  51601. *
  51602. * 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.
  51603. *
  51604. * To update the configuration, use the following code:
  51605. * ```javascript
  51606. * DracoCompression.Configuration = {
  51607. * decoder: {
  51608. * wasmUrl: "<url to the WebAssembly library>",
  51609. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51610. * fallbackUrl: "<url to the fallback JavaScript library>",
  51611. * }
  51612. * };
  51613. * ```
  51614. *
  51615. * 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.
  51616. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51617. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51618. *
  51619. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51620. * ```javascript
  51621. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51622. * ```
  51623. *
  51624. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51625. */
  51626. export class DracoCompression implements IDisposable {
  51627. private _workerPoolPromise?;
  51628. private _decoderModulePromise?;
  51629. /**
  51630. * The configuration. Defaults to the following urls:
  51631. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51632. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51633. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51634. */
  51635. static Configuration: IDracoCompressionConfiguration;
  51636. /**
  51637. * Returns true if the decoder configuration is available.
  51638. */
  51639. static readonly DecoderAvailable: boolean;
  51640. /**
  51641. * Default number of workers to create when creating the draco compression object.
  51642. */
  51643. static DefaultNumWorkers: number;
  51644. private static GetDefaultNumWorkers;
  51645. private static _Default;
  51646. /**
  51647. * Default instance for the draco compression object.
  51648. */
  51649. static readonly Default: DracoCompression;
  51650. /**
  51651. * Constructor
  51652. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  51653. */
  51654. constructor(numWorkers?: number);
  51655. /**
  51656. * Stop all async operations and release resources.
  51657. */
  51658. dispose(): void;
  51659. /**
  51660. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51661. * @returns a promise that resolves when ready
  51662. */
  51663. whenReadyAsync(): Promise<void>;
  51664. /**
  51665. * Decode Draco compressed mesh data to vertex data.
  51666. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51667. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51668. * @returns A promise that resolves with the decoded vertex data
  51669. */
  51670. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51671. [kind: string]: number;
  51672. }): Promise<VertexData>;
  51673. }
  51674. }
  51675. declare module BABYLON {
  51676. /**
  51677. * Class for building Constructive Solid Geometry
  51678. */
  51679. export class CSG {
  51680. private polygons;
  51681. /**
  51682. * The world matrix
  51683. */
  51684. matrix: Matrix;
  51685. /**
  51686. * Stores the position
  51687. */
  51688. position: Vector3;
  51689. /**
  51690. * Stores the rotation
  51691. */
  51692. rotation: Vector3;
  51693. /**
  51694. * Stores the rotation quaternion
  51695. */
  51696. rotationQuaternion: Nullable<Quaternion>;
  51697. /**
  51698. * Stores the scaling vector
  51699. */
  51700. scaling: Vector3;
  51701. /**
  51702. * Convert the Mesh to CSG
  51703. * @param mesh The Mesh to convert to CSG
  51704. * @returns A new CSG from the Mesh
  51705. */
  51706. static FromMesh(mesh: Mesh): CSG;
  51707. /**
  51708. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51709. * @param polygons Polygons used to construct a CSG solid
  51710. */
  51711. private static FromPolygons;
  51712. /**
  51713. * Clones, or makes a deep copy, of the CSG
  51714. * @returns A new CSG
  51715. */
  51716. clone(): CSG;
  51717. /**
  51718. * Unions this CSG with another CSG
  51719. * @param csg The CSG to union against this CSG
  51720. * @returns The unioned CSG
  51721. */
  51722. union(csg: CSG): CSG;
  51723. /**
  51724. * Unions this CSG with another CSG in place
  51725. * @param csg The CSG to union against this CSG
  51726. */
  51727. unionInPlace(csg: CSG): void;
  51728. /**
  51729. * Subtracts this CSG with another CSG
  51730. * @param csg The CSG to subtract against this CSG
  51731. * @returns A new CSG
  51732. */
  51733. subtract(csg: CSG): CSG;
  51734. /**
  51735. * Subtracts this CSG with another CSG in place
  51736. * @param csg The CSG to subtact against this CSG
  51737. */
  51738. subtractInPlace(csg: CSG): void;
  51739. /**
  51740. * Intersect this CSG with another CSG
  51741. * @param csg The CSG to intersect against this CSG
  51742. * @returns A new CSG
  51743. */
  51744. intersect(csg: CSG): CSG;
  51745. /**
  51746. * Intersects this CSG with another CSG in place
  51747. * @param csg The CSG to intersect against this CSG
  51748. */
  51749. intersectInPlace(csg: CSG): void;
  51750. /**
  51751. * Return a new CSG solid with solid and empty space switched. This solid is
  51752. * not modified.
  51753. * @returns A new CSG solid with solid and empty space switched
  51754. */
  51755. inverse(): CSG;
  51756. /**
  51757. * Inverses the CSG in place
  51758. */
  51759. inverseInPlace(): void;
  51760. /**
  51761. * This is used to keep meshes transformations so they can be restored
  51762. * when we build back a Babylon Mesh
  51763. * NB : All CSG operations are performed in world coordinates
  51764. * @param csg The CSG to copy the transform attributes from
  51765. * @returns This CSG
  51766. */
  51767. copyTransformAttributes(csg: CSG): CSG;
  51768. /**
  51769. * Build Raw mesh from CSG
  51770. * Coordinates here are in world space
  51771. * @param name The name of the mesh geometry
  51772. * @param scene The Scene
  51773. * @param keepSubMeshes Specifies if the submeshes should be kept
  51774. * @returns A new Mesh
  51775. */
  51776. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51777. /**
  51778. * Build Mesh from CSG taking material and transforms into account
  51779. * @param name The name of the Mesh
  51780. * @param material The material of the Mesh
  51781. * @param scene The Scene
  51782. * @param keepSubMeshes Specifies if submeshes should be kept
  51783. * @returns The new Mesh
  51784. */
  51785. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51786. }
  51787. }
  51788. declare module BABYLON {
  51789. /**
  51790. * Class used to create a trail following a mesh
  51791. */
  51792. export class TrailMesh extends Mesh {
  51793. private _generator;
  51794. private _autoStart;
  51795. private _running;
  51796. private _diameter;
  51797. private _length;
  51798. private _sectionPolygonPointsCount;
  51799. private _sectionVectors;
  51800. private _sectionNormalVectors;
  51801. private _beforeRenderObserver;
  51802. /**
  51803. * @constructor
  51804. * @param name The value used by scene.getMeshByName() to do a lookup.
  51805. * @param generator The mesh to generate a trail.
  51806. * @param scene The scene to add this mesh to.
  51807. * @param diameter Diameter of trailing mesh. Default is 1.
  51808. * @param length Length of trailing mesh. Default is 60.
  51809. * @param autoStart Automatically start trailing mesh. Default true.
  51810. */
  51811. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51812. /**
  51813. * "TrailMesh"
  51814. * @returns "TrailMesh"
  51815. */
  51816. getClassName(): string;
  51817. private _createMesh;
  51818. /**
  51819. * Start trailing mesh.
  51820. */
  51821. start(): void;
  51822. /**
  51823. * Stop trailing mesh.
  51824. */
  51825. stop(): void;
  51826. /**
  51827. * Update trailing mesh geometry.
  51828. */
  51829. update(): void;
  51830. /**
  51831. * Returns a new TrailMesh object.
  51832. * @param name is a string, the name given to the new mesh
  51833. * @param newGenerator use new generator object for cloned trail mesh
  51834. * @returns a new mesh
  51835. */
  51836. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51837. /**
  51838. * Serializes this trail mesh
  51839. * @param serializationObject object to write serialization to
  51840. */
  51841. serialize(serializationObject: any): void;
  51842. /**
  51843. * Parses a serialized trail mesh
  51844. * @param parsedMesh the serialized mesh
  51845. * @param scene the scene to create the trail mesh in
  51846. * @returns the created trail mesh
  51847. */
  51848. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51849. }
  51850. }
  51851. declare module BABYLON {
  51852. /**
  51853. * Class containing static functions to help procedurally build meshes
  51854. */
  51855. export class TiledBoxBuilder {
  51856. /**
  51857. * Creates a box mesh
  51858. * 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)
  51859. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51863. * @param name defines the name of the mesh
  51864. * @param options defines the options used to create the mesh
  51865. * @param scene defines the hosting scene
  51866. * @returns the box mesh
  51867. */
  51868. static CreateTiledBox(name: string, options: {
  51869. pattern?: number;
  51870. width?: number;
  51871. height?: number;
  51872. depth?: number;
  51873. tileSize?: number;
  51874. tileWidth?: number;
  51875. tileHeight?: number;
  51876. alignHorizontal?: number;
  51877. alignVertical?: number;
  51878. faceUV?: Vector4[];
  51879. faceColors?: Color4[];
  51880. sideOrientation?: number;
  51881. updatable?: boolean;
  51882. }, scene?: Nullable<Scene>): Mesh;
  51883. }
  51884. }
  51885. declare module BABYLON {
  51886. /**
  51887. * Class containing static functions to help procedurally build meshes
  51888. */
  51889. export class TorusKnotBuilder {
  51890. /**
  51891. * Creates a torus knot mesh
  51892. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51893. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51894. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51895. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51899. * @param name defines the name of the mesh
  51900. * @param options defines the options used to create the mesh
  51901. * @param scene defines the hosting scene
  51902. * @returns the torus knot mesh
  51903. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51904. */
  51905. static CreateTorusKnot(name: string, options: {
  51906. radius?: number;
  51907. tube?: number;
  51908. radialSegments?: number;
  51909. tubularSegments?: number;
  51910. p?: number;
  51911. q?: number;
  51912. updatable?: boolean;
  51913. sideOrientation?: number;
  51914. frontUVs?: Vector4;
  51915. backUVs?: Vector4;
  51916. }, scene: any): Mesh;
  51917. }
  51918. }
  51919. declare module BABYLON {
  51920. /**
  51921. * Polygon
  51922. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51923. */
  51924. export class Polygon {
  51925. /**
  51926. * Creates a rectangle
  51927. * @param xmin bottom X coord
  51928. * @param ymin bottom Y coord
  51929. * @param xmax top X coord
  51930. * @param ymax top Y coord
  51931. * @returns points that make the resulting rectation
  51932. */
  51933. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51934. /**
  51935. * Creates a circle
  51936. * @param radius radius of circle
  51937. * @param cx scale in x
  51938. * @param cy scale in y
  51939. * @param numberOfSides number of sides that make up the circle
  51940. * @returns points that make the resulting circle
  51941. */
  51942. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51943. /**
  51944. * Creates a polygon from input string
  51945. * @param input Input polygon data
  51946. * @returns the parsed points
  51947. */
  51948. static Parse(input: string): Vector2[];
  51949. /**
  51950. * Starts building a polygon from x and y coordinates
  51951. * @param x x coordinate
  51952. * @param y y coordinate
  51953. * @returns the started path2
  51954. */
  51955. static StartingAt(x: number, y: number): Path2;
  51956. }
  51957. /**
  51958. * Builds a polygon
  51959. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51960. */
  51961. export class PolygonMeshBuilder {
  51962. private _points;
  51963. private _outlinepoints;
  51964. private _holes;
  51965. private _name;
  51966. private _scene;
  51967. private _epoints;
  51968. private _eholes;
  51969. private _addToepoint;
  51970. /**
  51971. * Babylon reference to the earcut plugin.
  51972. */
  51973. bjsEarcut: any;
  51974. /**
  51975. * Creates a PolygonMeshBuilder
  51976. * @param name name of the builder
  51977. * @param contours Path of the polygon
  51978. * @param scene scene to add to when creating the mesh
  51979. * @param earcutInjection can be used to inject your own earcut reference
  51980. */
  51981. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51982. /**
  51983. * Adds a whole within the polygon
  51984. * @param hole Array of points defining the hole
  51985. * @returns this
  51986. */
  51987. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51988. /**
  51989. * Creates the polygon
  51990. * @param updatable If the mesh should be updatable
  51991. * @param depth The depth of the mesh created
  51992. * @returns the created mesh
  51993. */
  51994. build(updatable?: boolean, depth?: number): Mesh;
  51995. /**
  51996. * Creates the polygon
  51997. * @param depth The depth of the mesh created
  51998. * @returns the created VertexData
  51999. */
  52000. buildVertexData(depth?: number): VertexData;
  52001. /**
  52002. * Adds a side to the polygon
  52003. * @param positions points that make the polygon
  52004. * @param normals normals of the polygon
  52005. * @param uvs uvs of the polygon
  52006. * @param indices indices of the polygon
  52007. * @param bounds bounds of the polygon
  52008. * @param points points of the polygon
  52009. * @param depth depth of the polygon
  52010. * @param flip flip of the polygon
  52011. */
  52012. private addSide;
  52013. }
  52014. }
  52015. declare module BABYLON {
  52016. /**
  52017. * Class containing static functions to help procedurally build meshes
  52018. */
  52019. export class PolygonBuilder {
  52020. /**
  52021. * Creates a polygon mesh
  52022. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52023. * * 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
  52024. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52027. * * Remember you can only change the shape positions, not their number when updating a polygon
  52028. * @param name defines the name of the mesh
  52029. * @param options defines the options used to create the mesh
  52030. * @param scene defines the hosting scene
  52031. * @param earcutInjection can be used to inject your own earcut reference
  52032. * @returns the polygon mesh
  52033. */
  52034. static CreatePolygon(name: string, options: {
  52035. shape: Vector3[];
  52036. holes?: Vector3[][];
  52037. depth?: number;
  52038. faceUV?: Vector4[];
  52039. faceColors?: Color4[];
  52040. updatable?: boolean;
  52041. sideOrientation?: number;
  52042. frontUVs?: Vector4;
  52043. backUVs?: Vector4;
  52044. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52045. /**
  52046. * Creates an extruded polygon mesh, with depth in the Y direction.
  52047. * * 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)
  52048. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52049. * @param name defines the name of the mesh
  52050. * @param options defines the options used to create the mesh
  52051. * @param scene defines the hosting scene
  52052. * @param earcutInjection can be used to inject your own earcut reference
  52053. * @returns the polygon mesh
  52054. */
  52055. static ExtrudePolygon(name: string, options: {
  52056. shape: Vector3[];
  52057. holes?: Vector3[][];
  52058. depth?: number;
  52059. faceUV?: Vector4[];
  52060. faceColors?: Color4[];
  52061. updatable?: boolean;
  52062. sideOrientation?: number;
  52063. frontUVs?: Vector4;
  52064. backUVs?: Vector4;
  52065. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52066. }
  52067. }
  52068. declare module BABYLON {
  52069. /**
  52070. * Class containing static functions to help procedurally build meshes
  52071. */
  52072. export class LatheBuilder {
  52073. /**
  52074. * Creates lathe mesh.
  52075. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52076. * * 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
  52077. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52078. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52079. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52080. * * 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
  52081. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52082. * * 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
  52083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52087. * @param name defines the name of the mesh
  52088. * @param options defines the options used to create the mesh
  52089. * @param scene defines the hosting scene
  52090. * @returns the lathe mesh
  52091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52092. */
  52093. static CreateLathe(name: string, options: {
  52094. shape: Vector3[];
  52095. radius?: number;
  52096. tessellation?: number;
  52097. clip?: number;
  52098. arc?: number;
  52099. closed?: boolean;
  52100. updatable?: boolean;
  52101. sideOrientation?: number;
  52102. frontUVs?: Vector4;
  52103. backUVs?: Vector4;
  52104. cap?: number;
  52105. invertUV?: boolean;
  52106. }, scene?: Nullable<Scene>): Mesh;
  52107. }
  52108. }
  52109. declare module BABYLON {
  52110. /**
  52111. * Class containing static functions to help procedurally build meshes
  52112. */
  52113. export class TiledPlaneBuilder {
  52114. /**
  52115. * Creates a tiled plane mesh
  52116. * * The parameter `pattern` will, depending on value, do nothing or
  52117. * * * flip (reflect about central vertical) alternate tiles across and up
  52118. * * * flip every tile on alternate rows
  52119. * * * rotate (180 degs) alternate tiles across and up
  52120. * * * rotate every tile on alternate rows
  52121. * * * flip and rotate alternate tiles across and up
  52122. * * * flip and rotate every tile on alternate rows
  52123. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52124. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52127. * * 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)
  52128. * * 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)
  52129. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52130. * @param name defines the name of the mesh
  52131. * @param options defines the options used to create the mesh
  52132. * @param scene defines the hosting scene
  52133. * @returns the box mesh
  52134. */
  52135. static CreateTiledPlane(name: string, options: {
  52136. pattern?: number;
  52137. tileSize?: number;
  52138. tileWidth?: number;
  52139. tileHeight?: number;
  52140. size?: number;
  52141. width?: number;
  52142. height?: number;
  52143. alignHorizontal?: number;
  52144. alignVertical?: number;
  52145. sideOrientation?: number;
  52146. frontUVs?: Vector4;
  52147. backUVs?: Vector4;
  52148. updatable?: boolean;
  52149. }, scene?: Nullable<Scene>): Mesh;
  52150. }
  52151. }
  52152. declare module BABYLON {
  52153. /**
  52154. * Class containing static functions to help procedurally build meshes
  52155. */
  52156. export class TubeBuilder {
  52157. /**
  52158. * Creates a tube mesh.
  52159. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52160. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52161. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52162. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52163. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52164. * * 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)
  52165. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52166. * * 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
  52167. * * 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
  52168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52172. * @param name defines the name of the mesh
  52173. * @param options defines the options used to create the mesh
  52174. * @param scene defines the hosting scene
  52175. * @returns the tube mesh
  52176. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52177. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52178. */
  52179. static CreateTube(name: string, options: {
  52180. path: Vector3[];
  52181. radius?: number;
  52182. tessellation?: number;
  52183. radiusFunction?: {
  52184. (i: number, distance: number): number;
  52185. };
  52186. cap?: number;
  52187. arc?: number;
  52188. updatable?: boolean;
  52189. sideOrientation?: number;
  52190. frontUVs?: Vector4;
  52191. backUVs?: Vector4;
  52192. instance?: Mesh;
  52193. invertUV?: boolean;
  52194. }, scene?: Nullable<Scene>): Mesh;
  52195. }
  52196. }
  52197. declare module BABYLON {
  52198. /**
  52199. * Class containing static functions to help procedurally build meshes
  52200. */
  52201. export class IcoSphereBuilder {
  52202. /**
  52203. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52204. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52205. * * 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`)
  52206. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52207. * * 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
  52208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52211. * @param name defines the name of the mesh
  52212. * @param options defines the options used to create the mesh
  52213. * @param scene defines the hosting scene
  52214. * @returns the icosahedron mesh
  52215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52216. */
  52217. static CreateIcoSphere(name: string, options: {
  52218. radius?: number;
  52219. radiusX?: number;
  52220. radiusY?: number;
  52221. radiusZ?: number;
  52222. flat?: boolean;
  52223. subdivisions?: number;
  52224. sideOrientation?: number;
  52225. frontUVs?: Vector4;
  52226. backUVs?: Vector4;
  52227. updatable?: boolean;
  52228. }, scene?: Nullable<Scene>): Mesh;
  52229. }
  52230. }
  52231. declare module BABYLON {
  52232. /**
  52233. * Class containing static functions to help procedurally build meshes
  52234. */
  52235. export class DecalBuilder {
  52236. /**
  52237. * Creates a decal mesh.
  52238. * 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
  52239. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52240. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52241. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52242. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52243. * @param name defines the name of the mesh
  52244. * @param sourceMesh defines the mesh where the decal must be applied
  52245. * @param options defines the options used to create the mesh
  52246. * @param scene defines the hosting scene
  52247. * @returns the decal mesh
  52248. * @see https://doc.babylonjs.com/how_to/decals
  52249. */
  52250. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52251. position?: Vector3;
  52252. normal?: Vector3;
  52253. size?: Vector3;
  52254. angle?: number;
  52255. }): Mesh;
  52256. }
  52257. }
  52258. declare module BABYLON {
  52259. /**
  52260. * Class containing static functions to help procedurally build meshes
  52261. */
  52262. export class MeshBuilder {
  52263. /**
  52264. * Creates a box mesh
  52265. * * The parameter `size` sets the size (float) of each box side (default 1)
  52266. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52267. * * 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)
  52268. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52272. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52273. * @param name defines the name of the mesh
  52274. * @param options defines the options used to create the mesh
  52275. * @param scene defines the hosting scene
  52276. * @returns the box mesh
  52277. */
  52278. static CreateBox(name: string, options: {
  52279. size?: number;
  52280. width?: number;
  52281. height?: number;
  52282. depth?: number;
  52283. faceUV?: Vector4[];
  52284. faceColors?: Color4[];
  52285. sideOrientation?: number;
  52286. frontUVs?: Vector4;
  52287. backUVs?: Vector4;
  52288. updatable?: boolean;
  52289. }, scene?: Nullable<Scene>): Mesh;
  52290. /**
  52291. * Creates a tiled box mesh
  52292. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52294. * @param name defines the name of the mesh
  52295. * @param options defines the options used to create the mesh
  52296. * @param scene defines the hosting scene
  52297. * @returns the tiled box mesh
  52298. */
  52299. static CreateTiledBox(name: string, options: {
  52300. pattern?: number;
  52301. size?: number;
  52302. width?: number;
  52303. height?: number;
  52304. depth: number;
  52305. tileSize?: number;
  52306. tileWidth?: number;
  52307. tileHeight?: number;
  52308. faceUV?: Vector4[];
  52309. faceColors?: Color4[];
  52310. alignHorizontal?: number;
  52311. alignVertical?: number;
  52312. sideOrientation?: number;
  52313. updatable?: boolean;
  52314. }, scene?: Nullable<Scene>): Mesh;
  52315. /**
  52316. * Creates a sphere mesh
  52317. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52318. * * 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`)
  52319. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52320. * * 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
  52321. * * 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)
  52322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52325. * @param name defines the name of the mesh
  52326. * @param options defines the options used to create the mesh
  52327. * @param scene defines the hosting scene
  52328. * @returns the sphere mesh
  52329. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52330. */
  52331. static CreateSphere(name: string, options: {
  52332. segments?: number;
  52333. diameter?: number;
  52334. diameterX?: number;
  52335. diameterY?: number;
  52336. diameterZ?: number;
  52337. arc?: number;
  52338. slice?: number;
  52339. sideOrientation?: number;
  52340. frontUVs?: Vector4;
  52341. backUVs?: Vector4;
  52342. updatable?: boolean;
  52343. }, scene?: Nullable<Scene>): Mesh;
  52344. /**
  52345. * Creates a plane polygonal mesh. By default, this is a disc
  52346. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52347. * * 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
  52348. * * 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
  52349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52352. * @param name defines the name of the mesh
  52353. * @param options defines the options used to create the mesh
  52354. * @param scene defines the hosting scene
  52355. * @returns the plane polygonal mesh
  52356. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52357. */
  52358. static CreateDisc(name: string, options: {
  52359. radius?: number;
  52360. tessellation?: number;
  52361. arc?: number;
  52362. updatable?: boolean;
  52363. sideOrientation?: number;
  52364. frontUVs?: Vector4;
  52365. backUVs?: Vector4;
  52366. }, scene?: Nullable<Scene>): Mesh;
  52367. /**
  52368. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52369. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52370. * * 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`)
  52371. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52372. * * 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
  52373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52376. * @param name defines the name of the mesh
  52377. * @param options defines the options used to create the mesh
  52378. * @param scene defines the hosting scene
  52379. * @returns the icosahedron mesh
  52380. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52381. */
  52382. static CreateIcoSphere(name: string, options: {
  52383. radius?: number;
  52384. radiusX?: number;
  52385. radiusY?: number;
  52386. radiusZ?: number;
  52387. flat?: boolean;
  52388. subdivisions?: number;
  52389. sideOrientation?: number;
  52390. frontUVs?: Vector4;
  52391. backUVs?: Vector4;
  52392. updatable?: boolean;
  52393. }, scene?: Nullable<Scene>): Mesh;
  52394. /**
  52395. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52396. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52397. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52398. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52399. * * 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
  52400. * * 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
  52401. * * 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
  52402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52405. * * 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
  52406. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52407. * * 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
  52408. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52410. * @param name defines the name of the mesh
  52411. * @param options defines the options used to create the mesh
  52412. * @param scene defines the hosting scene
  52413. * @returns the ribbon mesh
  52414. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52416. */
  52417. static CreateRibbon(name: string, options: {
  52418. pathArray: Vector3[][];
  52419. closeArray?: boolean;
  52420. closePath?: boolean;
  52421. offset?: number;
  52422. updatable?: boolean;
  52423. sideOrientation?: number;
  52424. frontUVs?: Vector4;
  52425. backUVs?: Vector4;
  52426. instance?: Mesh;
  52427. invertUV?: boolean;
  52428. uvs?: Vector2[];
  52429. colors?: Color4[];
  52430. }, scene?: Nullable<Scene>): Mesh;
  52431. /**
  52432. * Creates a cylinder or a cone mesh
  52433. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52434. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52435. * * 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.
  52436. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52437. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52438. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52439. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52440. * * 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).
  52441. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52442. * * 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).
  52443. * * 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
  52444. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52445. * * 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
  52446. * * 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.
  52447. * * If `enclose` is false, a ring surface is one element.
  52448. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52449. * * 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
  52450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52453. * @param name defines the name of the mesh
  52454. * @param options defines the options used to create the mesh
  52455. * @param scene defines the hosting scene
  52456. * @returns the cylinder mesh
  52457. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52458. */
  52459. static CreateCylinder(name: string, options: {
  52460. height?: number;
  52461. diameterTop?: number;
  52462. diameterBottom?: number;
  52463. diameter?: number;
  52464. tessellation?: number;
  52465. subdivisions?: number;
  52466. arc?: number;
  52467. faceColors?: Color4[];
  52468. faceUV?: Vector4[];
  52469. updatable?: boolean;
  52470. hasRings?: boolean;
  52471. enclose?: boolean;
  52472. cap?: number;
  52473. sideOrientation?: number;
  52474. frontUVs?: Vector4;
  52475. backUVs?: Vector4;
  52476. }, scene?: Nullable<Scene>): Mesh;
  52477. /**
  52478. * Creates a torus mesh
  52479. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52480. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52481. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52485. * @param name defines the name of the mesh
  52486. * @param options defines the options used to create the mesh
  52487. * @param scene defines the hosting scene
  52488. * @returns the torus mesh
  52489. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52490. */
  52491. static CreateTorus(name: string, options: {
  52492. diameter?: number;
  52493. thickness?: number;
  52494. tessellation?: number;
  52495. updatable?: boolean;
  52496. sideOrientation?: number;
  52497. frontUVs?: Vector4;
  52498. backUVs?: Vector4;
  52499. }, scene?: Nullable<Scene>): Mesh;
  52500. /**
  52501. * Creates a torus knot mesh
  52502. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52503. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52504. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52505. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52509. * @param name defines the name of the mesh
  52510. * @param options defines the options used to create the mesh
  52511. * @param scene defines the hosting scene
  52512. * @returns the torus knot mesh
  52513. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52514. */
  52515. static CreateTorusKnot(name: string, options: {
  52516. radius?: number;
  52517. tube?: number;
  52518. radialSegments?: number;
  52519. tubularSegments?: number;
  52520. p?: number;
  52521. q?: number;
  52522. updatable?: boolean;
  52523. sideOrientation?: number;
  52524. frontUVs?: Vector4;
  52525. backUVs?: Vector4;
  52526. }, scene?: Nullable<Scene>): Mesh;
  52527. /**
  52528. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52529. * * 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
  52530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52531. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52532. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52533. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52535. * * 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
  52536. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52539. * @param name defines the name of the new line system
  52540. * @param options defines the options used to create the line system
  52541. * @param scene defines the hosting scene
  52542. * @returns a new line system mesh
  52543. */
  52544. static CreateLineSystem(name: string, options: {
  52545. lines: Vector3[][];
  52546. updatable?: boolean;
  52547. instance?: Nullable<LinesMesh>;
  52548. colors?: Nullable<Color4[][]>;
  52549. useVertexAlpha?: boolean;
  52550. }, scene: Nullable<Scene>): LinesMesh;
  52551. /**
  52552. * Creates a line mesh
  52553. * 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
  52554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52555. * * The parameter `points` is an array successive Vector3
  52556. * * 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
  52557. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52558. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52559. * * When updating an instance, remember that only point positions can change, not the number of points
  52560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52562. * @param name defines the name of the new line system
  52563. * @param options defines the options used to create the line system
  52564. * @param scene defines the hosting scene
  52565. * @returns a new line mesh
  52566. */
  52567. static CreateLines(name: string, options: {
  52568. points: Vector3[];
  52569. updatable?: boolean;
  52570. instance?: Nullable<LinesMesh>;
  52571. colors?: Color4[];
  52572. useVertexAlpha?: boolean;
  52573. }, scene?: Nullable<Scene>): LinesMesh;
  52574. /**
  52575. * Creates a dashed line mesh
  52576. * * 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
  52577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52578. * * The parameter `points` is an array successive Vector3
  52579. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52580. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52581. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52582. * * 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
  52583. * * When updating an instance, remember that only point positions can change, not the number of points
  52584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52585. * @param name defines the name of the mesh
  52586. * @param options defines the options used to create the mesh
  52587. * @param scene defines the hosting scene
  52588. * @returns the dashed line mesh
  52589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52590. */
  52591. static CreateDashedLines(name: string, options: {
  52592. points: Vector3[];
  52593. dashSize?: number;
  52594. gapSize?: number;
  52595. dashNb?: number;
  52596. updatable?: boolean;
  52597. instance?: LinesMesh;
  52598. }, scene?: Nullable<Scene>): LinesMesh;
  52599. /**
  52600. * 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.
  52601. * * 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.
  52602. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52603. * * 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.
  52604. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52605. * * 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
  52606. * * 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
  52607. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52612. * @param name defines the name of the mesh
  52613. * @param options defines the options used to create the mesh
  52614. * @param scene defines the hosting scene
  52615. * @returns the extruded shape mesh
  52616. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52618. */
  52619. static ExtrudeShape(name: string, options: {
  52620. shape: Vector3[];
  52621. path: Vector3[];
  52622. scale?: number;
  52623. rotation?: number;
  52624. cap?: number;
  52625. updatable?: boolean;
  52626. sideOrientation?: number;
  52627. frontUVs?: Vector4;
  52628. backUVs?: Vector4;
  52629. instance?: Mesh;
  52630. invertUV?: boolean;
  52631. }, scene?: Nullable<Scene>): Mesh;
  52632. /**
  52633. * Creates an custom extruded shape mesh.
  52634. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52635. * * 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.
  52636. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52637. * * 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
  52638. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52639. * * 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
  52640. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52641. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52642. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52643. * * 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
  52644. * * 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
  52645. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52650. * @param name defines the name of the mesh
  52651. * @param options defines the options used to create the mesh
  52652. * @param scene defines the hosting scene
  52653. * @returns the custom extruded shape mesh
  52654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52655. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52657. */
  52658. static ExtrudeShapeCustom(name: string, options: {
  52659. shape: Vector3[];
  52660. path: Vector3[];
  52661. scaleFunction?: any;
  52662. rotationFunction?: any;
  52663. ribbonCloseArray?: boolean;
  52664. ribbonClosePath?: boolean;
  52665. cap?: number;
  52666. updatable?: boolean;
  52667. sideOrientation?: number;
  52668. frontUVs?: Vector4;
  52669. backUVs?: Vector4;
  52670. instance?: Mesh;
  52671. invertUV?: boolean;
  52672. }, scene?: Nullable<Scene>): Mesh;
  52673. /**
  52674. * Creates lathe mesh.
  52675. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52676. * * 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
  52677. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52678. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52679. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52680. * * 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
  52681. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52682. * * 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
  52683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52687. * @param name defines the name of the mesh
  52688. * @param options defines the options used to create the mesh
  52689. * @param scene defines the hosting scene
  52690. * @returns the lathe mesh
  52691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52692. */
  52693. static CreateLathe(name: string, options: {
  52694. shape: Vector3[];
  52695. radius?: number;
  52696. tessellation?: number;
  52697. clip?: number;
  52698. arc?: number;
  52699. closed?: boolean;
  52700. updatable?: boolean;
  52701. sideOrientation?: number;
  52702. frontUVs?: Vector4;
  52703. backUVs?: Vector4;
  52704. cap?: number;
  52705. invertUV?: boolean;
  52706. }, scene?: Nullable<Scene>): Mesh;
  52707. /**
  52708. * Creates a tiled plane mesh
  52709. * * You can set a limited pattern arrangement with the tiles
  52710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52713. * @param name defines the name of the mesh
  52714. * @param options defines the options used to create the mesh
  52715. * @param scene defines the hosting scene
  52716. * @returns the plane mesh
  52717. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52718. */
  52719. static CreateTiledPlane(name: string, options: {
  52720. pattern?: number;
  52721. tileSize?: number;
  52722. tileWidth?: number;
  52723. tileHeight?: number;
  52724. size?: number;
  52725. width?: number;
  52726. height?: number;
  52727. alignHorizontal?: number;
  52728. alignVertical?: number;
  52729. sideOrientation?: number;
  52730. frontUVs?: Vector4;
  52731. backUVs?: Vector4;
  52732. updatable?: boolean;
  52733. }, scene?: Nullable<Scene>): Mesh;
  52734. /**
  52735. * Creates a plane mesh
  52736. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52737. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52738. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52742. * @param name defines the name of the mesh
  52743. * @param options defines the options used to create the mesh
  52744. * @param scene defines the hosting scene
  52745. * @returns the plane mesh
  52746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52747. */
  52748. static CreatePlane(name: string, options: {
  52749. size?: number;
  52750. width?: number;
  52751. height?: number;
  52752. sideOrientation?: number;
  52753. frontUVs?: Vector4;
  52754. backUVs?: Vector4;
  52755. updatable?: boolean;
  52756. sourcePlane?: Plane;
  52757. }, scene?: Nullable<Scene>): Mesh;
  52758. /**
  52759. * Creates a ground mesh
  52760. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52761. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52763. * @param name defines the name of the mesh
  52764. * @param options defines the options used to create the mesh
  52765. * @param scene defines the hosting scene
  52766. * @returns the ground mesh
  52767. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52768. */
  52769. static CreateGround(name: string, options: {
  52770. width?: number;
  52771. height?: number;
  52772. subdivisions?: number;
  52773. subdivisionsX?: number;
  52774. subdivisionsY?: number;
  52775. updatable?: boolean;
  52776. }, scene?: Nullable<Scene>): Mesh;
  52777. /**
  52778. * Creates a tiled ground mesh
  52779. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52780. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52781. * * 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
  52782. * * 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
  52783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52784. * @param name defines the name of the mesh
  52785. * @param options defines the options used to create the mesh
  52786. * @param scene defines the hosting scene
  52787. * @returns the tiled ground mesh
  52788. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52789. */
  52790. static CreateTiledGround(name: string, options: {
  52791. xmin: number;
  52792. zmin: number;
  52793. xmax: number;
  52794. zmax: number;
  52795. subdivisions?: {
  52796. w: number;
  52797. h: number;
  52798. };
  52799. precision?: {
  52800. w: number;
  52801. h: number;
  52802. };
  52803. updatable?: boolean;
  52804. }, scene?: Nullable<Scene>): Mesh;
  52805. /**
  52806. * Creates a ground mesh from a height map
  52807. * * The parameter `url` sets the URL of the height map image resource.
  52808. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52809. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52810. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52811. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52812. * * 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.
  52813. * * 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).
  52814. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52816. * @param name defines the name of the mesh
  52817. * @param url defines the url to the height map
  52818. * @param options defines the options used to create the mesh
  52819. * @param scene defines the hosting scene
  52820. * @returns the ground mesh
  52821. * @see https://doc.babylonjs.com/babylon101/height_map
  52822. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52823. */
  52824. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52825. width?: number;
  52826. height?: number;
  52827. subdivisions?: number;
  52828. minHeight?: number;
  52829. maxHeight?: number;
  52830. colorFilter?: Color3;
  52831. alphaFilter?: number;
  52832. updatable?: boolean;
  52833. onReady?: (mesh: GroundMesh) => void;
  52834. }, scene?: Nullable<Scene>): GroundMesh;
  52835. /**
  52836. * Creates a polygon mesh
  52837. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52838. * * 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
  52839. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52842. * * Remember you can only change the shape positions, not their number when updating a polygon
  52843. * @param name defines the name of the mesh
  52844. * @param options defines the options used to create the mesh
  52845. * @param scene defines the hosting scene
  52846. * @param earcutInjection can be used to inject your own earcut reference
  52847. * @returns the polygon mesh
  52848. */
  52849. static CreatePolygon(name: string, options: {
  52850. shape: Vector3[];
  52851. holes?: Vector3[][];
  52852. depth?: number;
  52853. faceUV?: Vector4[];
  52854. faceColors?: Color4[];
  52855. updatable?: boolean;
  52856. sideOrientation?: number;
  52857. frontUVs?: Vector4;
  52858. backUVs?: Vector4;
  52859. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52860. /**
  52861. * Creates an extruded polygon mesh, with depth in the Y direction.
  52862. * * 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)
  52863. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52864. * @param name defines the name of the mesh
  52865. * @param options defines the options used to create the mesh
  52866. * @param scene defines the hosting scene
  52867. * @param earcutInjection can be used to inject your own earcut reference
  52868. * @returns the polygon mesh
  52869. */
  52870. static ExtrudePolygon(name: string, options: {
  52871. shape: Vector3[];
  52872. holes?: Vector3[][];
  52873. depth?: number;
  52874. faceUV?: Vector4[];
  52875. faceColors?: Color4[];
  52876. updatable?: boolean;
  52877. sideOrientation?: number;
  52878. frontUVs?: Vector4;
  52879. backUVs?: Vector4;
  52880. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52881. /**
  52882. * Creates a tube mesh.
  52883. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52884. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52885. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52886. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52887. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52888. * * 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)
  52889. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52890. * * 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
  52891. * * 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
  52892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52896. * @param name defines the name of the mesh
  52897. * @param options defines the options used to create the mesh
  52898. * @param scene defines the hosting scene
  52899. * @returns the tube mesh
  52900. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52901. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52902. */
  52903. static CreateTube(name: string, options: {
  52904. path: Vector3[];
  52905. radius?: number;
  52906. tessellation?: number;
  52907. radiusFunction?: {
  52908. (i: number, distance: number): number;
  52909. };
  52910. cap?: number;
  52911. arc?: number;
  52912. updatable?: boolean;
  52913. sideOrientation?: number;
  52914. frontUVs?: Vector4;
  52915. backUVs?: Vector4;
  52916. instance?: Mesh;
  52917. invertUV?: boolean;
  52918. }, scene?: Nullable<Scene>): Mesh;
  52919. /**
  52920. * Creates a polyhedron mesh
  52921. * * 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
  52922. * * The parameter `size` (positive float, default 1) sets the polygon size
  52923. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52924. * * 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`
  52925. * * 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
  52926. * * 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)`)
  52927. * * 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
  52928. * * 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
  52929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52932. * @param name defines the name of the mesh
  52933. * @param options defines the options used to create the mesh
  52934. * @param scene defines the hosting scene
  52935. * @returns the polyhedron mesh
  52936. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52937. */
  52938. static CreatePolyhedron(name: string, options: {
  52939. type?: number;
  52940. size?: number;
  52941. sizeX?: number;
  52942. sizeY?: number;
  52943. sizeZ?: number;
  52944. custom?: any;
  52945. faceUV?: Vector4[];
  52946. faceColors?: Color4[];
  52947. flat?: boolean;
  52948. updatable?: boolean;
  52949. sideOrientation?: number;
  52950. frontUVs?: Vector4;
  52951. backUVs?: Vector4;
  52952. }, scene?: Nullable<Scene>): Mesh;
  52953. /**
  52954. * Creates a decal mesh.
  52955. * 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
  52956. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52957. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52958. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52959. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52960. * @param name defines the name of the mesh
  52961. * @param sourceMesh defines the mesh where the decal must be applied
  52962. * @param options defines the options used to create the mesh
  52963. * @param scene defines the hosting scene
  52964. * @returns the decal mesh
  52965. * @see https://doc.babylonjs.com/how_to/decals
  52966. */
  52967. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52968. position?: Vector3;
  52969. normal?: Vector3;
  52970. size?: Vector3;
  52971. angle?: number;
  52972. }): Mesh;
  52973. }
  52974. }
  52975. declare module BABYLON {
  52976. /**
  52977. * A simplifier interface for future simplification implementations
  52978. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52979. */
  52980. export interface ISimplifier {
  52981. /**
  52982. * Simplification of a given mesh according to the given settings.
  52983. * Since this requires computation, it is assumed that the function runs async.
  52984. * @param settings The settings of the simplification, including quality and distance
  52985. * @param successCallback A callback that will be called after the mesh was simplified.
  52986. * @param errorCallback in case of an error, this callback will be called. optional.
  52987. */
  52988. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52989. }
  52990. /**
  52991. * Expected simplification settings.
  52992. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52993. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52994. */
  52995. export interface ISimplificationSettings {
  52996. /**
  52997. * Gets or sets the expected quality
  52998. */
  52999. quality: number;
  53000. /**
  53001. * Gets or sets the distance when this optimized version should be used
  53002. */
  53003. distance: number;
  53004. /**
  53005. * Gets an already optimized mesh
  53006. */
  53007. optimizeMesh?: boolean;
  53008. }
  53009. /**
  53010. * Class used to specify simplification options
  53011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53012. */
  53013. export class SimplificationSettings implements ISimplificationSettings {
  53014. /** expected quality */
  53015. quality: number;
  53016. /** distance when this optimized version should be used */
  53017. distance: number;
  53018. /** already optimized mesh */
  53019. optimizeMesh?: boolean | undefined;
  53020. /**
  53021. * Creates a SimplificationSettings
  53022. * @param quality expected quality
  53023. * @param distance distance when this optimized version should be used
  53024. * @param optimizeMesh already optimized mesh
  53025. */
  53026. constructor(
  53027. /** expected quality */
  53028. quality: number,
  53029. /** distance when this optimized version should be used */
  53030. distance: number,
  53031. /** already optimized mesh */
  53032. optimizeMesh?: boolean | undefined);
  53033. }
  53034. /**
  53035. * Interface used to define a simplification task
  53036. */
  53037. export interface ISimplificationTask {
  53038. /**
  53039. * Array of settings
  53040. */
  53041. settings: Array<ISimplificationSettings>;
  53042. /**
  53043. * Simplification type
  53044. */
  53045. simplificationType: SimplificationType;
  53046. /**
  53047. * Mesh to simplify
  53048. */
  53049. mesh: Mesh;
  53050. /**
  53051. * Callback called on success
  53052. */
  53053. successCallback?: () => void;
  53054. /**
  53055. * Defines if parallel processing can be used
  53056. */
  53057. parallelProcessing: boolean;
  53058. }
  53059. /**
  53060. * Queue used to order the simplification tasks
  53061. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53062. */
  53063. export class SimplificationQueue {
  53064. private _simplificationArray;
  53065. /**
  53066. * Gets a boolean indicating that the process is still running
  53067. */
  53068. running: boolean;
  53069. /**
  53070. * Creates a new queue
  53071. */
  53072. constructor();
  53073. /**
  53074. * Adds a new simplification task
  53075. * @param task defines a task to add
  53076. */
  53077. addTask(task: ISimplificationTask): void;
  53078. /**
  53079. * Execute next task
  53080. */
  53081. executeNext(): void;
  53082. /**
  53083. * Execute a simplification task
  53084. * @param task defines the task to run
  53085. */
  53086. runSimplification(task: ISimplificationTask): void;
  53087. private getSimplifier;
  53088. }
  53089. /**
  53090. * The implemented types of simplification
  53091. * At the moment only Quadratic Error Decimation is implemented
  53092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53093. */
  53094. export enum SimplificationType {
  53095. /** Quadratic error decimation */
  53096. QUADRATIC = 0
  53097. }
  53098. }
  53099. declare module BABYLON {
  53100. interface Scene {
  53101. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  53102. /**
  53103. * Gets or sets the simplification queue attached to the scene
  53104. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53105. */
  53106. simplificationQueue: SimplificationQueue;
  53107. }
  53108. interface Mesh {
  53109. /**
  53110. * Simplify the mesh according to the given array of settings.
  53111. * Function will return immediately and will simplify async
  53112. * @param settings a collection of simplification settings
  53113. * @param parallelProcessing should all levels calculate parallel or one after the other
  53114. * @param simplificationType the type of simplification to run
  53115. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53116. * @returns the current mesh
  53117. */
  53118. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53119. }
  53120. /**
  53121. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53122. * created in a scene
  53123. */
  53124. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53125. /**
  53126. * The component name helpfull to identify the component in the list of scene components.
  53127. */
  53128. readonly name: string;
  53129. /**
  53130. * The scene the component belongs to.
  53131. */
  53132. scene: Scene;
  53133. /**
  53134. * Creates a new instance of the component for the given scene
  53135. * @param scene Defines the scene to register the component in
  53136. */
  53137. constructor(scene: Scene);
  53138. /**
  53139. * Registers the component in a given scene
  53140. */
  53141. register(): void;
  53142. /**
  53143. * Rebuilds the elements related to this component in case of
  53144. * context lost for instance.
  53145. */
  53146. rebuild(): void;
  53147. /**
  53148. * Disposes the component and the associated ressources
  53149. */
  53150. dispose(): void;
  53151. private _beforeCameraUpdate;
  53152. }
  53153. }
  53154. declare module BABYLON {
  53155. /**
  53156. * Class used to enable access to IndexedDB
  53157. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53158. */
  53159. export class Database implements IOfflineProvider {
  53160. private _callbackManifestChecked;
  53161. private _currentSceneUrl;
  53162. private _db;
  53163. private _enableSceneOffline;
  53164. private _enableTexturesOffline;
  53165. private _manifestVersionFound;
  53166. private _mustUpdateRessources;
  53167. private _hasReachedQuota;
  53168. private _isSupported;
  53169. private _idbFactory;
  53170. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53171. private static IsUASupportingBlobStorage;
  53172. /**
  53173. * Gets a boolean indicating if Database storate is enabled (off by default)
  53174. */
  53175. static IDBStorageEnabled: boolean;
  53176. /**
  53177. * Gets a boolean indicating if scene must be saved in the database
  53178. */
  53179. readonly enableSceneOffline: boolean;
  53180. /**
  53181. * Gets a boolean indicating if textures must be saved in the database
  53182. */
  53183. readonly enableTexturesOffline: boolean;
  53184. /**
  53185. * Creates a new Database
  53186. * @param urlToScene defines the url to load the scene
  53187. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53188. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53189. */
  53190. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53191. private static _ParseURL;
  53192. private static _ReturnFullUrlLocation;
  53193. private _checkManifestFile;
  53194. /**
  53195. * Open the database and make it available
  53196. * @param successCallback defines the callback to call on success
  53197. * @param errorCallback defines the callback to call on error
  53198. */
  53199. open(successCallback: () => void, errorCallback: () => void): void;
  53200. /**
  53201. * Loads an image from the database
  53202. * @param url defines the url to load from
  53203. * @param image defines the target DOM image
  53204. */
  53205. loadImage(url: string, image: HTMLImageElement): void;
  53206. private _loadImageFromDBAsync;
  53207. private _saveImageIntoDBAsync;
  53208. private _checkVersionFromDB;
  53209. private _loadVersionFromDBAsync;
  53210. private _saveVersionIntoDBAsync;
  53211. /**
  53212. * Loads a file from database
  53213. * @param url defines the URL to load from
  53214. * @param sceneLoaded defines a callback to call on success
  53215. * @param progressCallBack defines a callback to call when progress changed
  53216. * @param errorCallback defines a callback to call on error
  53217. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53218. */
  53219. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53220. private _loadFileAsync;
  53221. private _saveFileAsync;
  53222. /**
  53223. * Validates if xhr data is correct
  53224. * @param xhr defines the request to validate
  53225. * @param dataType defines the expected data type
  53226. * @returns true if data is correct
  53227. */
  53228. private static _ValidateXHRData;
  53229. }
  53230. }
  53231. declare module BABYLON {
  53232. /** @hidden */
  53233. export var gpuUpdateParticlesPixelShader: {
  53234. name: string;
  53235. shader: string;
  53236. };
  53237. }
  53238. declare module BABYLON {
  53239. /** @hidden */
  53240. export var gpuUpdateParticlesVertexShader: {
  53241. name: string;
  53242. shader: string;
  53243. };
  53244. }
  53245. declare module BABYLON {
  53246. /** @hidden */
  53247. export var clipPlaneFragmentDeclaration2: {
  53248. name: string;
  53249. shader: string;
  53250. };
  53251. }
  53252. declare module BABYLON {
  53253. /** @hidden */
  53254. export var gpuRenderParticlesPixelShader: {
  53255. name: string;
  53256. shader: string;
  53257. };
  53258. }
  53259. declare module BABYLON {
  53260. /** @hidden */
  53261. export var clipPlaneVertexDeclaration2: {
  53262. name: string;
  53263. shader: string;
  53264. };
  53265. }
  53266. declare module BABYLON {
  53267. /** @hidden */
  53268. export var gpuRenderParticlesVertexShader: {
  53269. name: string;
  53270. shader: string;
  53271. };
  53272. }
  53273. declare module BABYLON {
  53274. /**
  53275. * This represents a GPU particle system in Babylon
  53276. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53277. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53278. */
  53279. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53280. /**
  53281. * The layer mask we are rendering the particles through.
  53282. */
  53283. layerMask: number;
  53284. private _capacity;
  53285. private _activeCount;
  53286. private _currentActiveCount;
  53287. private _accumulatedCount;
  53288. private _renderEffect;
  53289. private _updateEffect;
  53290. private _buffer0;
  53291. private _buffer1;
  53292. private _spriteBuffer;
  53293. private _updateVAO;
  53294. private _renderVAO;
  53295. private _targetIndex;
  53296. private _sourceBuffer;
  53297. private _targetBuffer;
  53298. private _engine;
  53299. private _currentRenderId;
  53300. private _started;
  53301. private _stopped;
  53302. private _timeDelta;
  53303. private _randomTexture;
  53304. private _randomTexture2;
  53305. private _attributesStrideSize;
  53306. private _updateEffectOptions;
  53307. private _randomTextureSize;
  53308. private _actualFrame;
  53309. private readonly _rawTextureWidth;
  53310. /**
  53311. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53312. */
  53313. static readonly IsSupported: boolean;
  53314. /**
  53315. * An event triggered when the system is disposed.
  53316. */
  53317. onDisposeObservable: Observable<GPUParticleSystem>;
  53318. /**
  53319. * Gets the maximum number of particles active at the same time.
  53320. * @returns The max number of active particles.
  53321. */
  53322. getCapacity(): number;
  53323. /**
  53324. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53325. * to override the particles.
  53326. */
  53327. forceDepthWrite: boolean;
  53328. /**
  53329. * Gets or set the number of active particles
  53330. */
  53331. activeParticleCount: number;
  53332. private _preWarmDone;
  53333. /**
  53334. * Is this system ready to be used/rendered
  53335. * @return true if the system is ready
  53336. */
  53337. isReady(): boolean;
  53338. /**
  53339. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53340. * @returns True if it has been started, otherwise false.
  53341. */
  53342. isStarted(): boolean;
  53343. /**
  53344. * Starts the particle system and begins to emit
  53345. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53346. */
  53347. start(delay?: number): void;
  53348. /**
  53349. * Stops the particle system.
  53350. */
  53351. stop(): void;
  53352. /**
  53353. * Remove all active particles
  53354. */
  53355. reset(): void;
  53356. /**
  53357. * Returns the string "GPUParticleSystem"
  53358. * @returns a string containing the class name
  53359. */
  53360. getClassName(): string;
  53361. private _colorGradientsTexture;
  53362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53363. /**
  53364. * Adds a new color gradient
  53365. * @param gradient defines the gradient to use (between 0 and 1)
  53366. * @param color1 defines the color to affect to the specified gradient
  53367. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53368. * @returns the current particle system
  53369. */
  53370. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53371. /**
  53372. * Remove a specific color gradient
  53373. * @param gradient defines the gradient to remove
  53374. * @returns the current particle system
  53375. */
  53376. removeColorGradient(gradient: number): GPUParticleSystem;
  53377. private _angularSpeedGradientsTexture;
  53378. private _sizeGradientsTexture;
  53379. private _velocityGradientsTexture;
  53380. private _limitVelocityGradientsTexture;
  53381. private _dragGradientsTexture;
  53382. private _addFactorGradient;
  53383. /**
  53384. * Adds a new size gradient
  53385. * @param gradient defines the gradient to use (between 0 and 1)
  53386. * @param factor defines the size factor to affect to the specified gradient
  53387. * @returns the current particle system
  53388. */
  53389. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53390. /**
  53391. * Remove a specific size gradient
  53392. * @param gradient defines the gradient to remove
  53393. * @returns the current particle system
  53394. */
  53395. removeSizeGradient(gradient: number): GPUParticleSystem;
  53396. /**
  53397. * Adds a new angular speed gradient
  53398. * @param gradient defines the gradient to use (between 0 and 1)
  53399. * @param factor defines the angular speed to affect to the specified gradient
  53400. * @returns the current particle system
  53401. */
  53402. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53403. /**
  53404. * Remove a specific angular speed gradient
  53405. * @param gradient defines the gradient to remove
  53406. * @returns the current particle system
  53407. */
  53408. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53409. /**
  53410. * Adds a new velocity gradient
  53411. * @param gradient defines the gradient to use (between 0 and 1)
  53412. * @param factor defines the velocity to affect to the specified gradient
  53413. * @returns the current particle system
  53414. */
  53415. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53416. /**
  53417. * Remove a specific velocity gradient
  53418. * @param gradient defines the gradient to remove
  53419. * @returns the current particle system
  53420. */
  53421. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53422. /**
  53423. * Adds a new limit velocity gradient
  53424. * @param gradient defines the gradient to use (between 0 and 1)
  53425. * @param factor defines the limit velocity value to affect to the specified gradient
  53426. * @returns the current particle system
  53427. */
  53428. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53429. /**
  53430. * Remove a specific limit velocity gradient
  53431. * @param gradient defines the gradient to remove
  53432. * @returns the current particle system
  53433. */
  53434. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53435. /**
  53436. * Adds a new drag gradient
  53437. * @param gradient defines the gradient to use (between 0 and 1)
  53438. * @param factor defines the drag value to affect to the specified gradient
  53439. * @returns the current particle system
  53440. */
  53441. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53442. /**
  53443. * Remove a specific drag gradient
  53444. * @param gradient defines the gradient to remove
  53445. * @returns the current particle system
  53446. */
  53447. removeDragGradient(gradient: number): GPUParticleSystem;
  53448. /**
  53449. * Not supported by GPUParticleSystem
  53450. * @param gradient defines the gradient to use (between 0 and 1)
  53451. * @param factor defines the emit rate value to affect to the specified gradient
  53452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53453. * @returns the current particle system
  53454. */
  53455. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53456. /**
  53457. * Not supported by GPUParticleSystem
  53458. * @param gradient defines the gradient to remove
  53459. * @returns the current particle system
  53460. */
  53461. removeEmitRateGradient(gradient: number): IParticleSystem;
  53462. /**
  53463. * Not supported by GPUParticleSystem
  53464. * @param gradient defines the gradient to use (between 0 and 1)
  53465. * @param factor defines the start size value to affect to the specified gradient
  53466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53467. * @returns the current particle system
  53468. */
  53469. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53470. /**
  53471. * Not supported by GPUParticleSystem
  53472. * @param gradient defines the gradient to remove
  53473. * @returns the current particle system
  53474. */
  53475. removeStartSizeGradient(gradient: number): IParticleSystem;
  53476. /**
  53477. * Not supported by GPUParticleSystem
  53478. * @param gradient defines the gradient to use (between 0 and 1)
  53479. * @param min defines the color remap minimal range
  53480. * @param max defines the color remap maximal range
  53481. * @returns the current particle system
  53482. */
  53483. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53484. /**
  53485. * Not supported by GPUParticleSystem
  53486. * @param gradient defines the gradient to remove
  53487. * @returns the current particle system
  53488. */
  53489. removeColorRemapGradient(): IParticleSystem;
  53490. /**
  53491. * Not supported by GPUParticleSystem
  53492. * @param gradient defines the gradient to use (between 0 and 1)
  53493. * @param min defines the alpha remap minimal range
  53494. * @param max defines the alpha remap maximal range
  53495. * @returns the current particle system
  53496. */
  53497. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53498. /**
  53499. * Not supported by GPUParticleSystem
  53500. * @param gradient defines the gradient to remove
  53501. * @returns the current particle system
  53502. */
  53503. removeAlphaRemapGradient(): IParticleSystem;
  53504. /**
  53505. * Not supported by GPUParticleSystem
  53506. * @param gradient defines the gradient to use (between 0 and 1)
  53507. * @param color defines the color to affect to the specified gradient
  53508. * @returns the current particle system
  53509. */
  53510. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53511. /**
  53512. * Not supported by GPUParticleSystem
  53513. * @param gradient defines the gradient to remove
  53514. * @returns the current particle system
  53515. */
  53516. removeRampGradient(): IParticleSystem;
  53517. /**
  53518. * Not supported by GPUParticleSystem
  53519. * @returns the list of ramp gradients
  53520. */
  53521. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53522. /**
  53523. * Not supported by GPUParticleSystem
  53524. * Gets or sets a boolean indicating that ramp gradients must be used
  53525. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53526. */
  53527. useRampGradients: boolean;
  53528. /**
  53529. * Not supported by GPUParticleSystem
  53530. * @param gradient defines the gradient to use (between 0 and 1)
  53531. * @param factor defines the life time factor to affect to the specified gradient
  53532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53533. * @returns the current particle system
  53534. */
  53535. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53536. /**
  53537. * Not supported by GPUParticleSystem
  53538. * @param gradient defines the gradient to remove
  53539. * @returns the current particle system
  53540. */
  53541. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53542. /**
  53543. * Instantiates a GPU particle system.
  53544. * 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.
  53545. * @param name The name of the particle system
  53546. * @param options The options used to create the system
  53547. * @param scene The scene the particle system belongs to
  53548. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53549. */
  53550. constructor(name: string, options: Partial<{
  53551. capacity: number;
  53552. randomTextureSize: number;
  53553. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53554. protected _reset(): void;
  53555. private _createUpdateVAO;
  53556. private _createRenderVAO;
  53557. private _initialize;
  53558. /** @hidden */ private _recreateUpdateEffect(): void;
  53559. /** @hidden */ private _recreateRenderEffect(): void;
  53560. /**
  53561. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53562. * @param preWarm defines if we are in the pre-warmimg phase
  53563. */
  53564. animate(preWarm?: boolean): void;
  53565. private _createFactorGradientTexture;
  53566. private _createSizeGradientTexture;
  53567. private _createAngularSpeedGradientTexture;
  53568. private _createVelocityGradientTexture;
  53569. private _createLimitVelocityGradientTexture;
  53570. private _createDragGradientTexture;
  53571. private _createColorGradientTexture;
  53572. /**
  53573. * Renders the particle system in its current state
  53574. * @param preWarm defines if the system should only update the particles but not render them
  53575. * @returns the current number of particles
  53576. */
  53577. render(preWarm?: boolean): number;
  53578. /**
  53579. * Rebuilds the particle system
  53580. */
  53581. rebuild(): void;
  53582. private _releaseBuffers;
  53583. private _releaseVAOs;
  53584. /**
  53585. * Disposes the particle system and free the associated resources
  53586. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53587. */
  53588. dispose(disposeTexture?: boolean): void;
  53589. /**
  53590. * Clones the particle system.
  53591. * @param name The name of the cloned object
  53592. * @param newEmitter The new emitter to use
  53593. * @returns the cloned particle system
  53594. */
  53595. clone(name: string, newEmitter: any): GPUParticleSystem;
  53596. /**
  53597. * Serializes the particle system to a JSON object.
  53598. * @returns the JSON object
  53599. */
  53600. serialize(): any;
  53601. /**
  53602. * Parses a JSON object to create a GPU particle system.
  53603. * @param parsedParticleSystem The JSON object to parse
  53604. * @param scene The scene to create the particle system in
  53605. * @param rootUrl The root url to use to load external dependencies like texture
  53606. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53607. * @returns the parsed GPU particle system
  53608. */
  53609. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53610. }
  53611. }
  53612. declare module BABYLON {
  53613. /**
  53614. * Represents a set of particle systems working together to create a specific effect
  53615. */
  53616. export class ParticleSystemSet implements IDisposable {
  53617. private _emitterCreationOptions;
  53618. private _emitterNode;
  53619. /**
  53620. * Gets the particle system list
  53621. */
  53622. systems: IParticleSystem[];
  53623. /**
  53624. * Gets the emitter node used with this set
  53625. */
  53626. readonly emitterNode: Nullable<TransformNode>;
  53627. /**
  53628. * Creates a new emitter mesh as a sphere
  53629. * @param options defines the options used to create the sphere
  53630. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53631. * @param scene defines the hosting scene
  53632. */
  53633. setEmitterAsSphere(options: {
  53634. diameter: number;
  53635. segments: number;
  53636. color: Color3;
  53637. }, renderingGroupId: number, scene: Scene): void;
  53638. /**
  53639. * Starts all particle systems of the set
  53640. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53641. */
  53642. start(emitter?: AbstractMesh): void;
  53643. /**
  53644. * Release all associated resources
  53645. */
  53646. dispose(): void;
  53647. /**
  53648. * Serialize the set into a JSON compatible object
  53649. * @returns a JSON compatible representation of the set
  53650. */
  53651. serialize(): any;
  53652. /**
  53653. * Parse a new ParticleSystemSet from a serialized source
  53654. * @param data defines a JSON compatible representation of the set
  53655. * @param scene defines the hosting scene
  53656. * @param gpu defines if we want GPU particles or CPU particles
  53657. * @returns a new ParticleSystemSet
  53658. */
  53659. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53660. }
  53661. }
  53662. declare module BABYLON {
  53663. /**
  53664. * This class is made for on one-liner static method to help creating particle system set.
  53665. */
  53666. export class ParticleHelper {
  53667. /**
  53668. * Gets or sets base Assets URL
  53669. */
  53670. static BaseAssetsUrl: string;
  53671. /**
  53672. * Create a default particle system that you can tweak
  53673. * @param emitter defines the emitter to use
  53674. * @param capacity defines the system capacity (default is 500 particles)
  53675. * @param scene defines the hosting scene
  53676. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53677. * @returns the new Particle system
  53678. */
  53679. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53680. /**
  53681. * This is the main static method (one-liner) of this helper to create different particle systems
  53682. * @param type This string represents the type to the particle system to create
  53683. * @param scene The scene where the particle system should live
  53684. * @param gpu If the system will use gpu
  53685. * @returns the ParticleSystemSet created
  53686. */
  53687. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53688. /**
  53689. * Static function used to export a particle system to a ParticleSystemSet variable.
  53690. * Please note that the emitter shape is not exported
  53691. * @param systems defines the particle systems to export
  53692. * @returns the created particle system set
  53693. */
  53694. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53695. }
  53696. }
  53697. declare module BABYLON {
  53698. interface Engine {
  53699. /**
  53700. * Create an effect to use with particle systems.
  53701. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53702. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53703. * @param uniformsNames defines a list of attribute names
  53704. * @param samplers defines an array of string used to represent textures
  53705. * @param defines defines the string containing the defines to use to compile the shaders
  53706. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53707. * @param onCompiled defines a function to call when the effect creation is successful
  53708. * @param onError defines a function to call when the effect creation has failed
  53709. * @returns the new Effect
  53710. */
  53711. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53712. }
  53713. interface Mesh {
  53714. /**
  53715. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53716. * @returns an array of IParticleSystem
  53717. */
  53718. getEmittedParticleSystems(): IParticleSystem[];
  53719. /**
  53720. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53721. * @returns an array of IParticleSystem
  53722. */
  53723. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53724. }
  53725. /**
  53726. * @hidden
  53727. */
  53728. export var _IDoNeedToBeInTheBuild: number;
  53729. }
  53730. declare module BABYLON {
  53731. interface Scene {
  53732. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  53733. /**
  53734. * Gets the current physics engine
  53735. * @returns a IPhysicsEngine or null if none attached
  53736. */
  53737. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53738. /**
  53739. * Enables physics to the current scene
  53740. * @param gravity defines the scene's gravity for the physics engine
  53741. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53742. * @return a boolean indicating if the physics engine was initialized
  53743. */
  53744. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53745. /**
  53746. * Disables and disposes the physics engine associated with the scene
  53747. */
  53748. disablePhysicsEngine(): void;
  53749. /**
  53750. * Gets a boolean indicating if there is an active physics engine
  53751. * @returns a boolean indicating if there is an active physics engine
  53752. */
  53753. isPhysicsEnabled(): boolean;
  53754. /**
  53755. * Deletes a physics compound impostor
  53756. * @param compound defines the compound to delete
  53757. */
  53758. deleteCompoundImpostor(compound: any): void;
  53759. /**
  53760. * An event triggered when physic simulation is about to be run
  53761. */
  53762. onBeforePhysicsObservable: Observable<Scene>;
  53763. /**
  53764. * An event triggered when physic simulation has been done
  53765. */
  53766. onAfterPhysicsObservable: Observable<Scene>;
  53767. }
  53768. interface AbstractMesh {
  53769. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  53770. /**
  53771. * Gets or sets impostor used for physic simulation
  53772. * @see http://doc.babylonjs.com/features/physics_engine
  53773. */
  53774. physicsImpostor: Nullable<PhysicsImpostor>;
  53775. /**
  53776. * Gets the current physics impostor
  53777. * @see http://doc.babylonjs.com/features/physics_engine
  53778. * @returns a physics impostor or null
  53779. */
  53780. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53781. /** Apply a physic impulse to the mesh
  53782. * @param force defines the force to apply
  53783. * @param contactPoint defines where to apply the force
  53784. * @returns the current mesh
  53785. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53786. */
  53787. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53788. /**
  53789. * Creates a physic joint between two meshes
  53790. * @param otherMesh defines the other mesh to use
  53791. * @param pivot1 defines the pivot to use on this mesh
  53792. * @param pivot2 defines the pivot to use on the other mesh
  53793. * @param options defines additional options (can be plugin dependent)
  53794. * @returns the current mesh
  53795. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53796. */
  53797. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53798. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  53799. }
  53800. /**
  53801. * Defines the physics engine scene component responsible to manage a physics engine
  53802. */
  53803. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53804. /**
  53805. * The component name helpful to identify the component in the list of scene components.
  53806. */
  53807. readonly name: string;
  53808. /**
  53809. * The scene the component belongs to.
  53810. */
  53811. scene: Scene;
  53812. /**
  53813. * Creates a new instance of the component for the given scene
  53814. * @param scene Defines the scene to register the component in
  53815. */
  53816. constructor(scene: Scene);
  53817. /**
  53818. * Registers the component in a given scene
  53819. */
  53820. register(): void;
  53821. /**
  53822. * Rebuilds the elements related to this component in case of
  53823. * context lost for instance.
  53824. */
  53825. rebuild(): void;
  53826. /**
  53827. * Disposes the component and the associated ressources
  53828. */
  53829. dispose(): void;
  53830. }
  53831. }
  53832. declare module BABYLON {
  53833. /**
  53834. * A helper for physics simulations
  53835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53836. */
  53837. export class PhysicsHelper {
  53838. private _scene;
  53839. private _physicsEngine;
  53840. /**
  53841. * Initializes the Physics helper
  53842. * @param scene Babylon.js scene
  53843. */
  53844. constructor(scene: Scene);
  53845. /**
  53846. * Applies a radial explosion impulse
  53847. * @param origin the origin of the explosion
  53848. * @param radiusOrEventOptions the radius or the options of radial explosion
  53849. * @param strength the explosion strength
  53850. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53851. * @returns A physics radial explosion event, or null
  53852. */
  53853. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53854. /**
  53855. * Applies a radial explosion force
  53856. * @param origin the origin of the explosion
  53857. * @param radiusOrEventOptions the radius or the options of radial explosion
  53858. * @param strength the explosion strength
  53859. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53860. * @returns A physics radial explosion event, or null
  53861. */
  53862. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53863. /**
  53864. * Creates a gravitational field
  53865. * @param origin the origin of the explosion
  53866. * @param radiusOrEventOptions the radius or the options of radial explosion
  53867. * @param strength the explosion strength
  53868. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53869. * @returns A physics gravitational field event, or null
  53870. */
  53871. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53872. /**
  53873. * Creates a physics updraft event
  53874. * @param origin the origin of the updraft
  53875. * @param radiusOrEventOptions the radius or the options of the updraft
  53876. * @param strength the strength of the updraft
  53877. * @param height the height of the updraft
  53878. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53879. * @returns A physics updraft event, or null
  53880. */
  53881. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53882. /**
  53883. * Creates a physics vortex event
  53884. * @param origin the of the vortex
  53885. * @param radiusOrEventOptions the radius or the options of the vortex
  53886. * @param strength the strength of the vortex
  53887. * @param height the height of the vortex
  53888. * @returns a Physics vortex event, or null
  53889. * A physics vortex event or null
  53890. */
  53891. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53892. }
  53893. /**
  53894. * Represents a physics radial explosion event
  53895. */
  53896. class PhysicsRadialExplosionEvent {
  53897. private _scene;
  53898. private _options;
  53899. private _sphere;
  53900. private _dataFetched;
  53901. /**
  53902. * Initializes a radial explosioin event
  53903. * @param _scene BabylonJS scene
  53904. * @param _options The options for the vortex event
  53905. */
  53906. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53907. /**
  53908. * Returns the data related to the radial explosion event (sphere).
  53909. * @returns The radial explosion event data
  53910. */
  53911. getData(): PhysicsRadialExplosionEventData;
  53912. /**
  53913. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53914. * @param impostor A physics imposter
  53915. * @param origin the origin of the explosion
  53916. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53917. */
  53918. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53919. /**
  53920. * Triggers affecterd impostors callbacks
  53921. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53922. */
  53923. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53924. /**
  53925. * Disposes the sphere.
  53926. * @param force Specifies if the sphere should be disposed by force
  53927. */
  53928. dispose(force?: boolean): void;
  53929. /*** Helpers ***/
  53930. private _prepareSphere;
  53931. private _intersectsWithSphere;
  53932. }
  53933. /**
  53934. * Represents a gravitational field event
  53935. */
  53936. class PhysicsGravitationalFieldEvent {
  53937. private _physicsHelper;
  53938. private _scene;
  53939. private _origin;
  53940. private _options;
  53941. private _tickCallback;
  53942. private _sphere;
  53943. private _dataFetched;
  53944. /**
  53945. * Initializes the physics gravitational field event
  53946. * @param _physicsHelper A physics helper
  53947. * @param _scene BabylonJS scene
  53948. * @param _origin The origin position of the gravitational field event
  53949. * @param _options The options for the vortex event
  53950. */
  53951. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53952. /**
  53953. * Returns the data related to the gravitational field event (sphere).
  53954. * @returns A gravitational field event
  53955. */
  53956. getData(): PhysicsGravitationalFieldEventData;
  53957. /**
  53958. * Enables the gravitational field.
  53959. */
  53960. enable(): void;
  53961. /**
  53962. * Disables the gravitational field.
  53963. */
  53964. disable(): void;
  53965. /**
  53966. * Disposes the sphere.
  53967. * @param force The force to dispose from the gravitational field event
  53968. */
  53969. dispose(force?: boolean): void;
  53970. private _tick;
  53971. }
  53972. /**
  53973. * Represents a physics updraft event
  53974. */
  53975. class PhysicsUpdraftEvent {
  53976. private _scene;
  53977. private _origin;
  53978. private _options;
  53979. private _physicsEngine;
  53980. private _originTop;
  53981. private _originDirection;
  53982. private _tickCallback;
  53983. private _cylinder;
  53984. private _cylinderPosition;
  53985. private _dataFetched;
  53986. /**
  53987. * Initializes the physics updraft event
  53988. * @param _scene BabylonJS scene
  53989. * @param _origin The origin position of the updraft
  53990. * @param _options The options for the updraft event
  53991. */
  53992. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53993. /**
  53994. * Returns the data related to the updraft event (cylinder).
  53995. * @returns A physics updraft event
  53996. */
  53997. getData(): PhysicsUpdraftEventData;
  53998. /**
  53999. * Enables the updraft.
  54000. */
  54001. enable(): void;
  54002. /**
  54003. * Disables the updraft.
  54004. */
  54005. disable(): void;
  54006. /**
  54007. * Disposes the cylinder.
  54008. * @param force Specifies if the updraft should be disposed by force
  54009. */
  54010. dispose(force?: boolean): void;
  54011. private getImpostorHitData;
  54012. private _tick;
  54013. /*** Helpers ***/
  54014. private _prepareCylinder;
  54015. private _intersectsWithCylinder;
  54016. }
  54017. /**
  54018. * Represents a physics vortex event
  54019. */
  54020. class PhysicsVortexEvent {
  54021. private _scene;
  54022. private _origin;
  54023. private _options;
  54024. private _physicsEngine;
  54025. private _originTop;
  54026. private _tickCallback;
  54027. private _cylinder;
  54028. private _cylinderPosition;
  54029. private _dataFetched;
  54030. /**
  54031. * Initializes the physics vortex event
  54032. * @param _scene The BabylonJS scene
  54033. * @param _origin The origin position of the vortex
  54034. * @param _options The options for the vortex event
  54035. */
  54036. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54037. /**
  54038. * Returns the data related to the vortex event (cylinder).
  54039. * @returns The physics vortex event data
  54040. */
  54041. getData(): PhysicsVortexEventData;
  54042. /**
  54043. * Enables the vortex.
  54044. */
  54045. enable(): void;
  54046. /**
  54047. * Disables the cortex.
  54048. */
  54049. disable(): void;
  54050. /**
  54051. * Disposes the sphere.
  54052. * @param force
  54053. */
  54054. dispose(force?: boolean): void;
  54055. private getImpostorHitData;
  54056. private _tick;
  54057. /*** Helpers ***/
  54058. private _prepareCylinder;
  54059. private _intersectsWithCylinder;
  54060. }
  54061. /**
  54062. * Options fot the radial explosion event
  54063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54064. */
  54065. export class PhysicsRadialExplosionEventOptions {
  54066. /**
  54067. * The radius of the sphere for the radial explosion.
  54068. */
  54069. radius: number;
  54070. /**
  54071. * The strenth of the explosion.
  54072. */
  54073. strength: number;
  54074. /**
  54075. * The strenght of the force in correspondence to the distance of the affected object
  54076. */
  54077. falloff: PhysicsRadialImpulseFalloff;
  54078. /**
  54079. * Sphere options for the radial explosion.
  54080. */
  54081. sphere: {
  54082. segments: number;
  54083. diameter: number;
  54084. };
  54085. /**
  54086. * Sphere options for the radial explosion.
  54087. */
  54088. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54089. }
  54090. /**
  54091. * Options fot the updraft event
  54092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54093. */
  54094. export class PhysicsUpdraftEventOptions {
  54095. /**
  54096. * The radius of the cylinder for the vortex
  54097. */
  54098. radius: number;
  54099. /**
  54100. * The strenth of the updraft.
  54101. */
  54102. strength: number;
  54103. /**
  54104. * The height of the cylinder for the updraft.
  54105. */
  54106. height: number;
  54107. /**
  54108. * The mode for the the updraft.
  54109. */
  54110. updraftMode: PhysicsUpdraftMode;
  54111. }
  54112. /**
  54113. * Options fot the vortex event
  54114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54115. */
  54116. export class PhysicsVortexEventOptions {
  54117. /**
  54118. * The radius of the cylinder for the vortex
  54119. */
  54120. radius: number;
  54121. /**
  54122. * The strenth of the vortex.
  54123. */
  54124. strength: number;
  54125. /**
  54126. * The height of the cylinder for the vortex.
  54127. */
  54128. height: number;
  54129. /**
  54130. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54131. */
  54132. centripetalForceThreshold: number;
  54133. /**
  54134. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54135. */
  54136. centripetalForceMultiplier: number;
  54137. /**
  54138. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54139. */
  54140. centrifugalForceMultiplier: number;
  54141. /**
  54142. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54143. */
  54144. updraftForceMultiplier: number;
  54145. }
  54146. /**
  54147. * The strenght of the force in correspondence to the distance of the affected object
  54148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54149. */
  54150. export enum PhysicsRadialImpulseFalloff {
  54151. /** Defines that impulse is constant in strength across it's whole radius */
  54152. Constant = 0,
  54153. /** Defines that impulse gets weaker if it's further from the origin */
  54154. Linear = 1
  54155. }
  54156. /**
  54157. * The strength of the force in correspondence to the distance of the affected object
  54158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54159. */
  54160. export enum PhysicsUpdraftMode {
  54161. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54162. Center = 0,
  54163. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54164. Perpendicular = 1
  54165. }
  54166. /**
  54167. * Interface for a physics hit data
  54168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54169. */
  54170. export interface PhysicsHitData {
  54171. /**
  54172. * The force applied at the contact point
  54173. */
  54174. force: Vector3;
  54175. /**
  54176. * The contact point
  54177. */
  54178. contactPoint: Vector3;
  54179. /**
  54180. * The distance from the origin to the contact point
  54181. */
  54182. distanceFromOrigin: number;
  54183. }
  54184. /**
  54185. * Interface for radial explosion event data
  54186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54187. */
  54188. export interface PhysicsRadialExplosionEventData {
  54189. /**
  54190. * A sphere used for the radial explosion event
  54191. */
  54192. sphere: Mesh;
  54193. }
  54194. /**
  54195. * Interface for gravitational field event data
  54196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54197. */
  54198. export interface PhysicsGravitationalFieldEventData {
  54199. /**
  54200. * A sphere mesh used for the gravitational field event
  54201. */
  54202. sphere: Mesh;
  54203. }
  54204. /**
  54205. * Interface for updraft event data
  54206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54207. */
  54208. export interface PhysicsUpdraftEventData {
  54209. /**
  54210. * A cylinder used for the updraft event
  54211. */
  54212. cylinder: Mesh;
  54213. }
  54214. /**
  54215. * Interface for vortex event data
  54216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54217. */
  54218. export interface PhysicsVortexEventData {
  54219. /**
  54220. * A cylinder used for the vortex event
  54221. */
  54222. cylinder: Mesh;
  54223. }
  54224. /**
  54225. * Interface for an affected physics impostor
  54226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54227. */
  54228. export interface PhysicsAffectedImpostorWithData {
  54229. /**
  54230. * The impostor affected by the effect
  54231. */
  54232. impostor: PhysicsImpostor;
  54233. /**
  54234. * The data about the hit/horce from the explosion
  54235. */
  54236. hitData: PhysicsHitData;
  54237. }
  54238. }
  54239. declare module BABYLON {
  54240. /** @hidden */
  54241. export var blackAndWhitePixelShader: {
  54242. name: string;
  54243. shader: string;
  54244. };
  54245. }
  54246. declare module BABYLON {
  54247. /**
  54248. * Post process used to render in black and white
  54249. */
  54250. export class BlackAndWhitePostProcess extends PostProcess {
  54251. /**
  54252. * Linear about to convert he result to black and white (default: 1)
  54253. */
  54254. degree: number;
  54255. /**
  54256. * Creates a black and white post process
  54257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54258. * @param name The name of the effect.
  54259. * @param options The required width/height ratio to downsize to before computing the render pass.
  54260. * @param camera The camera to apply the render pass to.
  54261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54262. * @param engine The engine which the post process will be applied. (default: current engine)
  54263. * @param reusable If the post process can be reused on the same frame. (default: false)
  54264. */
  54265. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54266. }
  54267. }
  54268. declare module BABYLON {
  54269. /**
  54270. * This represents a set of one or more post processes in Babylon.
  54271. * A post process can be used to apply a shader to a texture after it is rendered.
  54272. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54273. */
  54274. export class PostProcessRenderEffect {
  54275. private _postProcesses;
  54276. private _getPostProcesses;
  54277. private _singleInstance;
  54278. private _cameras;
  54279. private _indicesForCamera;
  54280. /**
  54281. * Name of the effect
  54282. * @hidden
  54283. */ private _name: string;
  54284. /**
  54285. * Instantiates a post process render effect.
  54286. * A post process can be used to apply a shader to a texture after it is rendered.
  54287. * @param engine The engine the effect is tied to
  54288. * @param name The name of the effect
  54289. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54290. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54291. */
  54292. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54293. /**
  54294. * Checks if all the post processes in the effect are supported.
  54295. */
  54296. readonly isSupported: boolean;
  54297. /**
  54298. * Updates the current state of the effect
  54299. * @hidden
  54300. */ private _update(): void;
  54301. /**
  54302. * Attaches the effect on cameras
  54303. * @param cameras The camera to attach to.
  54304. * @hidden
  54305. */ private _attachCameras(cameras: Camera): void;
  54306. /**
  54307. * Attaches the effect on cameras
  54308. * @param cameras The camera to attach to.
  54309. * @hidden
  54310. */ private _attachCameras(cameras: Camera[]): void;
  54311. /**
  54312. * Detaches the effect on cameras
  54313. * @param cameras The camera to detatch from.
  54314. * @hidden
  54315. */ private _detachCameras(cameras: Camera): void;
  54316. /**
  54317. * Detatches the effect on cameras
  54318. * @param cameras The camera to detatch from.
  54319. * @hidden
  54320. */ private _detachCameras(cameras: Camera[]): void;
  54321. /**
  54322. * Enables the effect on given cameras
  54323. * @param cameras The camera to enable.
  54324. * @hidden
  54325. */ private _enable(cameras: Camera): void;
  54326. /**
  54327. * Enables the effect on given cameras
  54328. * @param cameras The camera to enable.
  54329. * @hidden
  54330. */ private _enable(cameras: Nullable<Camera[]>): void;
  54331. /**
  54332. * Disables the effect on the given cameras
  54333. * @param cameras The camera to disable.
  54334. * @hidden
  54335. */ private _disable(cameras: Camera): void;
  54336. /**
  54337. * Disables the effect on the given cameras
  54338. * @param cameras The camera to disable.
  54339. * @hidden
  54340. */ private _disable(cameras: Nullable<Camera[]>): void;
  54341. /**
  54342. * Gets a list of the post processes contained in the effect.
  54343. * @param camera The camera to get the post processes on.
  54344. * @returns The list of the post processes in the effect.
  54345. */
  54346. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54347. }
  54348. }
  54349. declare module BABYLON {
  54350. /** @hidden */
  54351. export var extractHighlightsPixelShader: {
  54352. name: string;
  54353. shader: string;
  54354. };
  54355. }
  54356. declare module BABYLON {
  54357. /**
  54358. * 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.
  54359. */
  54360. export class ExtractHighlightsPostProcess extends PostProcess {
  54361. /**
  54362. * The luminance threshold, pixels below this value will be set to black.
  54363. */
  54364. threshold: number;
  54365. /** @hidden */ private _exposure: number;
  54366. /**
  54367. * Post process which has the input texture to be used when performing highlight extraction
  54368. * @hidden
  54369. */ private _inputPostProcess: Nullable<PostProcess>;
  54370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54371. }
  54372. }
  54373. declare module BABYLON {
  54374. /** @hidden */
  54375. export var bloomMergePixelShader: {
  54376. name: string;
  54377. shader: string;
  54378. };
  54379. }
  54380. declare module BABYLON {
  54381. /**
  54382. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54383. */
  54384. export class BloomMergePostProcess extends PostProcess {
  54385. /** Weight of the bloom to be added to the original input. */
  54386. weight: number;
  54387. /**
  54388. * Creates a new instance of @see BloomMergePostProcess
  54389. * @param name The name of the effect.
  54390. * @param originalFromInput Post process which's input will be used for the merge.
  54391. * @param blurred Blurred highlights post process which's output will be used.
  54392. * @param weight Weight of the bloom to be added to the original input.
  54393. * @param options The required width/height ratio to downsize to before computing the render pass.
  54394. * @param camera The camera to apply the render pass to.
  54395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54396. * @param engine The engine which the post process will be applied. (default: current engine)
  54397. * @param reusable If the post process can be reused on the same frame. (default: false)
  54398. * @param textureType Type of textures used when performing the post process. (default: 0)
  54399. * @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)
  54400. */
  54401. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54402. /** Weight of the bloom to be added to the original input. */
  54403. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54404. }
  54405. }
  54406. declare module BABYLON {
  54407. /**
  54408. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54409. */
  54410. export class BloomEffect extends PostProcessRenderEffect {
  54411. private bloomScale;
  54412. /**
  54413. * @hidden Internal
  54414. */ private _effects: Array<PostProcess>;
  54415. /**
  54416. * @hidden Internal
  54417. */ private _downscale: ExtractHighlightsPostProcess;
  54418. private _blurX;
  54419. private _blurY;
  54420. private _merge;
  54421. /**
  54422. * The luminance threshold to find bright areas of the image to bloom.
  54423. */
  54424. threshold: number;
  54425. /**
  54426. * The strength of the bloom.
  54427. */
  54428. weight: number;
  54429. /**
  54430. * Specifies the size of the bloom blur kernel, relative to the final output size
  54431. */
  54432. kernel: number;
  54433. /**
  54434. * Creates a new instance of @see BloomEffect
  54435. * @param scene The scene the effect belongs to.
  54436. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54437. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54438. * @param bloomWeight The the strength of bloom.
  54439. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54440. * @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)
  54441. */
  54442. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54443. /**
  54444. * Disposes each of the internal effects for a given camera.
  54445. * @param camera The camera to dispose the effect on.
  54446. */
  54447. disposeEffects(camera: Camera): void;
  54448. /**
  54449. * @hidden Internal
  54450. */ private _updateEffects(): void;
  54451. /**
  54452. * Internal
  54453. * @returns if all the contained post processes are ready.
  54454. * @hidden
  54455. */ private _isReady(): boolean;
  54456. }
  54457. }
  54458. declare module BABYLON {
  54459. /** @hidden */
  54460. export var chromaticAberrationPixelShader: {
  54461. name: string;
  54462. shader: string;
  54463. };
  54464. }
  54465. declare module BABYLON {
  54466. /**
  54467. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54468. */
  54469. export class ChromaticAberrationPostProcess extends PostProcess {
  54470. /**
  54471. * The amount of seperation of rgb channels (default: 30)
  54472. */
  54473. aberrationAmount: number;
  54474. /**
  54475. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54476. */
  54477. radialIntensity: number;
  54478. /**
  54479. * 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))
  54480. */
  54481. direction: Vector2;
  54482. /**
  54483. * 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))
  54484. */
  54485. centerPosition: Vector2;
  54486. /**
  54487. * Creates a new instance ChromaticAberrationPostProcess
  54488. * @param name The name of the effect.
  54489. * @param screenWidth The width of the screen to apply the effect on.
  54490. * @param screenHeight The height of the screen to apply the effect on.
  54491. * @param options The required width/height ratio to downsize to before computing the render pass.
  54492. * @param camera The camera to apply the render pass to.
  54493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54494. * @param engine The engine which the post process will be applied. (default: current engine)
  54495. * @param reusable If the post process can be reused on the same frame. (default: false)
  54496. * @param textureType Type of textures used when performing the post process. (default: 0)
  54497. * @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)
  54498. */
  54499. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54500. }
  54501. }
  54502. declare module BABYLON {
  54503. /** @hidden */
  54504. export var circleOfConfusionPixelShader: {
  54505. name: string;
  54506. shader: string;
  54507. };
  54508. }
  54509. declare module BABYLON {
  54510. /**
  54511. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54512. */
  54513. export class CircleOfConfusionPostProcess extends PostProcess {
  54514. /**
  54515. * 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.
  54516. */
  54517. lensSize: number;
  54518. /**
  54519. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54520. */
  54521. fStop: number;
  54522. /**
  54523. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54524. */
  54525. focusDistance: number;
  54526. /**
  54527. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54528. */
  54529. focalLength: number;
  54530. private _depthTexture;
  54531. /**
  54532. * Creates a new instance CircleOfConfusionPostProcess
  54533. * @param name The name of the effect.
  54534. * @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.
  54535. * @param options The required width/height ratio to downsize to before computing the render pass.
  54536. * @param camera The camera to apply the render pass to.
  54537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54538. * @param engine The engine which the post process will be applied. (default: current engine)
  54539. * @param reusable If the post process can be reused on the same frame. (default: false)
  54540. * @param textureType Type of textures used when performing the post process. (default: 0)
  54541. * @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)
  54542. */
  54543. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54544. /**
  54545. * 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.
  54546. */
  54547. depthTexture: RenderTargetTexture;
  54548. }
  54549. }
  54550. declare module BABYLON {
  54551. /** @hidden */
  54552. export var colorCorrectionPixelShader: {
  54553. name: string;
  54554. shader: string;
  54555. };
  54556. }
  54557. declare module BABYLON {
  54558. /**
  54559. *
  54560. * This post-process allows the modification of rendered colors by using
  54561. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54562. *
  54563. * The object needs to be provided an url to a texture containing the color
  54564. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54565. * Use an image editing software to tweak the LUT to match your needs.
  54566. *
  54567. * For an example of a color LUT, see here:
  54568. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54569. * For explanations on color grading, see here:
  54570. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54571. *
  54572. */
  54573. export class ColorCorrectionPostProcess extends PostProcess {
  54574. private _colorTableTexture;
  54575. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54576. }
  54577. }
  54578. declare module BABYLON {
  54579. /** @hidden */
  54580. export var convolutionPixelShader: {
  54581. name: string;
  54582. shader: string;
  54583. };
  54584. }
  54585. declare module BABYLON {
  54586. /**
  54587. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54588. * input texture to perform effects such as edge detection or sharpening
  54589. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54590. */
  54591. export class ConvolutionPostProcess extends PostProcess {
  54592. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54593. kernel: number[];
  54594. /**
  54595. * Creates a new instance ConvolutionPostProcess
  54596. * @param name The name of the effect.
  54597. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  54598. * @param options The required width/height ratio to downsize to before computing the render pass.
  54599. * @param camera The camera to apply the render pass to.
  54600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54601. * @param engine The engine which the post process will be applied. (default: current engine)
  54602. * @param reusable If the post process can be reused on the same frame. (default: false)
  54603. * @param textureType Type of textures used when performing the post process. (default: 0)
  54604. */
  54605. constructor(name: string,
  54606. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  54607. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54608. /**
  54609. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54610. */
  54611. static EdgeDetect0Kernel: number[];
  54612. /**
  54613. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54614. */
  54615. static EdgeDetect1Kernel: number[];
  54616. /**
  54617. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54618. */
  54619. static EdgeDetect2Kernel: number[];
  54620. /**
  54621. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54622. */
  54623. static SharpenKernel: number[];
  54624. /**
  54625. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54626. */
  54627. static EmbossKernel: number[];
  54628. /**
  54629. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54630. */
  54631. static GaussianKernel: number[];
  54632. }
  54633. }
  54634. declare module BABYLON {
  54635. /**
  54636. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54637. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54638. * based on samples that have a large difference in distance than the center pixel.
  54639. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54640. */
  54641. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54642. direction: Vector2;
  54643. /**
  54644. * Creates a new instance CircleOfConfusionPostProcess
  54645. * @param name The name of the effect.
  54646. * @param scene The scene the effect belongs to.
  54647. * @param direction The direction the blur should be applied.
  54648. * @param kernel The size of the kernel used to blur.
  54649. * @param options The required width/height ratio to downsize to before computing the render pass.
  54650. * @param camera The camera to apply the render pass to.
  54651. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54652. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54654. * @param engine The engine which the post process will be applied. (default: current engine)
  54655. * @param reusable If the post process can be reused on the same frame. (default: false)
  54656. * @param textureType Type of textures used when performing the post process. (default: 0)
  54657. * @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)
  54658. */
  54659. 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);
  54660. }
  54661. }
  54662. declare module BABYLON {
  54663. /** @hidden */
  54664. export var depthOfFieldMergePixelShader: {
  54665. name: string;
  54666. shader: string;
  54667. };
  54668. }
  54669. declare module BABYLON {
  54670. /**
  54671. * Options to be set when merging outputs from the default pipeline.
  54672. */
  54673. export class DepthOfFieldMergePostProcessOptions {
  54674. /**
  54675. * The original image to merge on top of
  54676. */
  54677. originalFromInput: PostProcess;
  54678. /**
  54679. * Parameters to perform the merge of the depth of field effect
  54680. */
  54681. depthOfField?: {
  54682. circleOfConfusion: PostProcess;
  54683. blurSteps: Array<PostProcess>;
  54684. };
  54685. /**
  54686. * Parameters to perform the merge of bloom effect
  54687. */
  54688. bloom?: {
  54689. blurred: PostProcess;
  54690. weight: number;
  54691. };
  54692. }
  54693. /**
  54694. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54695. */
  54696. export class DepthOfFieldMergePostProcess extends PostProcess {
  54697. private blurSteps;
  54698. /**
  54699. * Creates a new instance of DepthOfFieldMergePostProcess
  54700. * @param name The name of the effect.
  54701. * @param originalFromInput Post process which's input will be used for the merge.
  54702. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54703. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54704. * @param options The required width/height ratio to downsize to before computing the render pass.
  54705. * @param camera The camera to apply the render pass to.
  54706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54707. * @param engine The engine which the post process will be applied. (default: current engine)
  54708. * @param reusable If the post process can be reused on the same frame. (default: false)
  54709. * @param textureType Type of textures used when performing the post process. (default: 0)
  54710. * @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)
  54711. */
  54712. 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);
  54713. /**
  54714. * Updates the effect with the current post process compile time values and recompiles the shader.
  54715. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54716. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54717. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54718. * @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
  54719. * @param onCompiled Called when the shader has been compiled.
  54720. * @param onError Called if there is an error when compiling a shader.
  54721. */
  54722. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54723. }
  54724. }
  54725. declare module BABYLON {
  54726. /**
  54727. * Specifies the level of max blur that should be applied when using the depth of field effect
  54728. */
  54729. export enum DepthOfFieldEffectBlurLevel {
  54730. /**
  54731. * Subtle blur
  54732. */
  54733. Low = 0,
  54734. /**
  54735. * Medium blur
  54736. */
  54737. Medium = 1,
  54738. /**
  54739. * Large blur
  54740. */
  54741. High = 2
  54742. }
  54743. /**
  54744. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54745. */
  54746. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54747. private _circleOfConfusion;
  54748. /**
  54749. * @hidden Internal, blurs from high to low
  54750. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54751. private _depthOfFieldBlurY;
  54752. private _dofMerge;
  54753. /**
  54754. * @hidden Internal post processes in depth of field effect
  54755. */ private _effects: Array<PostProcess>;
  54756. /**
  54757. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54758. */
  54759. focalLength: number;
  54760. /**
  54761. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54762. */
  54763. fStop: number;
  54764. /**
  54765. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54766. */
  54767. focusDistance: number;
  54768. /**
  54769. * 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.
  54770. */
  54771. lensSize: number;
  54772. /**
  54773. * Creates a new instance DepthOfFieldEffect
  54774. * @param scene The scene the effect belongs to.
  54775. * @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.
  54776. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54777. * @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)
  54778. */
  54779. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54780. /**
  54781. * Get the current class name of the current effet
  54782. * @returns "DepthOfFieldEffect"
  54783. */
  54784. getClassName(): string;
  54785. /**
  54786. * 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.
  54787. */
  54788. depthTexture: RenderTargetTexture;
  54789. /**
  54790. * Disposes each of the internal effects for a given camera.
  54791. * @param camera The camera to dispose the effect on.
  54792. */
  54793. disposeEffects(camera: Camera): void;
  54794. /**
  54795. * @hidden Internal
  54796. */ private _updateEffects(): void;
  54797. /**
  54798. * Internal
  54799. * @returns if all the contained post processes are ready.
  54800. * @hidden
  54801. */ private _isReady(): boolean;
  54802. }
  54803. }
  54804. declare module BABYLON {
  54805. /** @hidden */
  54806. export var displayPassPixelShader: {
  54807. name: string;
  54808. shader: string;
  54809. };
  54810. }
  54811. declare module BABYLON {
  54812. /**
  54813. * DisplayPassPostProcess which produces an output the same as it's input
  54814. */
  54815. export class DisplayPassPostProcess extends PostProcess {
  54816. /**
  54817. * Creates the DisplayPassPostProcess
  54818. * @param name The name of the effect.
  54819. * @param options The required width/height ratio to downsize to before computing the render pass.
  54820. * @param camera The camera to apply the render pass to.
  54821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54822. * @param engine The engine which the post process will be applied. (default: current engine)
  54823. * @param reusable If the post process can be reused on the same frame. (default: false)
  54824. */
  54825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54826. }
  54827. }
  54828. declare module BABYLON {
  54829. /** @hidden */
  54830. export var filterPixelShader: {
  54831. name: string;
  54832. shader: string;
  54833. };
  54834. }
  54835. declare module BABYLON {
  54836. /**
  54837. * Applies a kernel filter to the image
  54838. */
  54839. export class FilterPostProcess extends PostProcess {
  54840. /** The matrix to be applied to the image */
  54841. kernelMatrix: Matrix;
  54842. /**
  54843. *
  54844. * @param name The name of the effect.
  54845. * @param kernelMatrix The matrix to be applied to the image
  54846. * @param options The required width/height ratio to downsize to before computing the render pass.
  54847. * @param camera The camera to apply the render pass to.
  54848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54849. * @param engine The engine which the post process will be applied. (default: current engine)
  54850. * @param reusable If the post process can be reused on the same frame. (default: false)
  54851. */
  54852. constructor(name: string,
  54853. /** The matrix to be applied to the image */
  54854. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54855. }
  54856. }
  54857. declare module BABYLON {
  54858. /** @hidden */
  54859. export var fxaaPixelShader: {
  54860. name: string;
  54861. shader: string;
  54862. };
  54863. }
  54864. declare module BABYLON {
  54865. /** @hidden */
  54866. export var fxaaVertexShader: {
  54867. name: string;
  54868. shader: string;
  54869. };
  54870. }
  54871. declare module BABYLON {
  54872. /**
  54873. * Fxaa post process
  54874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54875. */
  54876. export class FxaaPostProcess extends PostProcess {
  54877. /** @hidden */
  54878. texelWidth: number;
  54879. /** @hidden */
  54880. texelHeight: number;
  54881. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54882. private _getDefines;
  54883. }
  54884. }
  54885. declare module BABYLON {
  54886. /** @hidden */
  54887. export var grainPixelShader: {
  54888. name: string;
  54889. shader: string;
  54890. };
  54891. }
  54892. declare module BABYLON {
  54893. /**
  54894. * The GrainPostProcess adds noise to the image at mid luminance levels
  54895. */
  54896. export class GrainPostProcess extends PostProcess {
  54897. /**
  54898. * The intensity of the grain added (default: 30)
  54899. */
  54900. intensity: number;
  54901. /**
  54902. * If the grain should be randomized on every frame
  54903. */
  54904. animated: boolean;
  54905. /**
  54906. * Creates a new instance of @see GrainPostProcess
  54907. * @param name The name of the effect.
  54908. * @param options The required width/height ratio to downsize to before computing the render pass.
  54909. * @param camera The camera to apply the render pass to.
  54910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54911. * @param engine The engine which the post process will be applied. (default: current engine)
  54912. * @param reusable If the post process can be reused on the same frame. (default: false)
  54913. * @param textureType Type of textures used when performing the post process. (default: 0)
  54914. * @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)
  54915. */
  54916. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54917. }
  54918. }
  54919. declare module BABYLON {
  54920. /** @hidden */
  54921. export var highlightsPixelShader: {
  54922. name: string;
  54923. shader: string;
  54924. };
  54925. }
  54926. declare module BABYLON {
  54927. /**
  54928. * Extracts highlights from the image
  54929. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54930. */
  54931. export class HighlightsPostProcess extends PostProcess {
  54932. /**
  54933. * Extracts highlights from the image
  54934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54935. * @param name The name of the effect.
  54936. * @param options The required width/height ratio to downsize to before computing the render pass.
  54937. * @param camera The camera to apply the render pass to.
  54938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54939. * @param engine The engine which the post process will be applied. (default: current engine)
  54940. * @param reusable If the post process can be reused on the same frame. (default: false)
  54941. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54942. */
  54943. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54944. }
  54945. }
  54946. declare module BABYLON {
  54947. /** @hidden */
  54948. export var mrtFragmentDeclaration: {
  54949. name: string;
  54950. shader: string;
  54951. };
  54952. }
  54953. declare module BABYLON {
  54954. /** @hidden */
  54955. export var geometryPixelShader: {
  54956. name: string;
  54957. shader: string;
  54958. };
  54959. }
  54960. declare module BABYLON {
  54961. /** @hidden */
  54962. export var geometryVertexShader: {
  54963. name: string;
  54964. shader: string;
  54965. };
  54966. }
  54967. declare module BABYLON {
  54968. /** @hidden */
  54969. interface ISavedTransformationMatrix {
  54970. world: Matrix;
  54971. viewProjection: Matrix;
  54972. }
  54973. /**
  54974. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54975. */
  54976. export class GeometryBufferRenderer {
  54977. /**
  54978. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54979. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54980. */
  54981. static readonly POSITION_TEXTURE_TYPE: number;
  54982. /**
  54983. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54984. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54985. */
  54986. static readonly VELOCITY_TEXTURE_TYPE: number;
  54987. /**
  54988. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54989. * in order to compute objects velocities when enableVelocity is set to "true"
  54990. * @hidden
  54991. */ private _previousTransformationMatrices: {
  54992. [index: number]: ISavedTransformationMatrix;
  54993. };
  54994. /**
  54995. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  54996. * in order to compute objects velocities when enableVelocity is set to "true"
  54997. * @hidden
  54998. */ private _previousBonesTransformationMatrices: {
  54999. [index: number]: Float32Array;
  55000. };
  55001. /**
  55002. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55003. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55004. */
  55005. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55006. private _scene;
  55007. private _multiRenderTarget;
  55008. private _ratio;
  55009. private _enablePosition;
  55010. private _enableVelocity;
  55011. private _positionIndex;
  55012. private _velocityIndex;
  55013. protected _effect: Effect;
  55014. protected _cachedDefines: string;
  55015. /**
  55016. * Set the render list (meshes to be rendered) used in the G buffer.
  55017. */
  55018. renderList: Mesh[];
  55019. /**
  55020. * Gets wether or not G buffer are supported by the running hardware.
  55021. * This requires draw buffer supports
  55022. */
  55023. readonly isSupported: boolean;
  55024. /**
  55025. * Returns the index of the given texture type in the G-Buffer textures array
  55026. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55027. * @returns the index of the given texture type in the G-Buffer textures array
  55028. */
  55029. getTextureIndex(textureType: number): number;
  55030. /**
  55031. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55032. */
  55033. /**
  55034. * Sets whether or not objects positions are enabled for the G buffer.
  55035. */
  55036. enablePosition: boolean;
  55037. /**
  55038. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55039. */
  55040. /**
  55041. * Sets wether or not objects velocities are enabled for the G buffer.
  55042. */
  55043. enableVelocity: boolean;
  55044. /**
  55045. * Gets the scene associated with the buffer.
  55046. */
  55047. readonly scene: Scene;
  55048. /**
  55049. * Gets the ratio used by the buffer during its creation.
  55050. * How big is the buffer related to the main canvas.
  55051. */
  55052. readonly ratio: number;
  55053. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  55054. /**
  55055. * Creates a new G Buffer for the scene
  55056. * @param scene The scene the buffer belongs to
  55057. * @param ratio How big is the buffer related to the main canvas.
  55058. */
  55059. constructor(scene: Scene, ratio?: number);
  55060. /**
  55061. * Checks wether everything is ready to render a submesh to the G buffer.
  55062. * @param subMesh the submesh to check readiness for
  55063. * @param useInstances is the mesh drawn using instance or not
  55064. * @returns true if ready otherwise false
  55065. */
  55066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55067. /**
  55068. * Gets the current underlying G Buffer.
  55069. * @returns the buffer
  55070. */
  55071. getGBuffer(): MultiRenderTarget;
  55072. /**
  55073. * Gets the number of samples used to render the buffer (anti aliasing).
  55074. */
  55075. /**
  55076. * Sets the number of samples used to render the buffer (anti aliasing).
  55077. */
  55078. samples: number;
  55079. /**
  55080. * Disposes the renderer and frees up associated resources.
  55081. */
  55082. dispose(): void;
  55083. protected _createRenderTargets(): void;
  55084. private _copyBonesTransformationMatrices;
  55085. }
  55086. }
  55087. declare module BABYLON {
  55088. interface Scene {
  55089. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55090. /**
  55091. * Gets or Sets the current geometry buffer associated to the scene.
  55092. */
  55093. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55094. /**
  55095. * Enables a GeometryBufferRender and associates it with the scene
  55096. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55097. * @returns the GeometryBufferRenderer
  55098. */
  55099. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55100. /**
  55101. * Disables the GeometryBufferRender associated with the scene
  55102. */
  55103. disableGeometryBufferRenderer(): void;
  55104. }
  55105. /**
  55106. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55107. * in several rendering techniques.
  55108. */
  55109. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55110. /**
  55111. * The component name helpful to identify the component in the list of scene components.
  55112. */
  55113. readonly name: string;
  55114. /**
  55115. * The scene the component belongs to.
  55116. */
  55117. scene: Scene;
  55118. /**
  55119. * Creates a new instance of the component for the given scene
  55120. * @param scene Defines the scene to register the component in
  55121. */
  55122. constructor(scene: Scene);
  55123. /**
  55124. * Registers the component in a given scene
  55125. */
  55126. register(): void;
  55127. /**
  55128. * Rebuilds the elements related to this component in case of
  55129. * context lost for instance.
  55130. */
  55131. rebuild(): void;
  55132. /**
  55133. * Disposes the component and the associated ressources
  55134. */
  55135. dispose(): void;
  55136. private _gatherRenderTargets;
  55137. }
  55138. }
  55139. declare module BABYLON {
  55140. /** @hidden */
  55141. export var motionBlurPixelShader: {
  55142. name: string;
  55143. shader: string;
  55144. };
  55145. }
  55146. declare module BABYLON {
  55147. /**
  55148. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55149. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55150. * As an example, all you have to do is to create the post-process:
  55151. * var mb = new BABYLON.MotionBlurPostProcess(
  55152. * 'mb', // The name of the effect.
  55153. * scene, // The scene containing the objects to blur according to their velocity.
  55154. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55155. * camera // The camera to apply the render pass to.
  55156. * );
  55157. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55158. */
  55159. export class MotionBlurPostProcess extends PostProcess {
  55160. /**
  55161. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55162. */
  55163. motionStrength: number;
  55164. /**
  55165. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55166. */
  55167. /**
  55168. * Sets the number of iterations to be used for motion blur quality
  55169. */
  55170. motionBlurSamples: number;
  55171. private _motionBlurSamples;
  55172. private _geometryBufferRenderer;
  55173. /**
  55174. * Creates a new instance MotionBlurPostProcess
  55175. * @param name The name of the effect.
  55176. * @param scene The scene containing the objects to blur according to their velocity.
  55177. * @param options The required width/height ratio to downsize to before computing the render pass.
  55178. * @param camera The camera to apply the render pass to.
  55179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55180. * @param engine The engine which the post process will be applied. (default: current engine)
  55181. * @param reusable If the post process can be reused on the same frame. (default: false)
  55182. * @param textureType Type of textures used when performing the post process. (default: 0)
  55183. * @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)
  55184. */
  55185. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55186. /**
  55187. * Excludes the given skinned mesh from computing bones velocities.
  55188. * 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.
  55189. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55190. */
  55191. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55192. /**
  55193. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55194. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55195. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55196. */
  55197. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55198. /**
  55199. * Disposes the post process.
  55200. * @param camera The camera to dispose the post process on.
  55201. */
  55202. dispose(camera?: Camera): void;
  55203. }
  55204. }
  55205. declare module BABYLON {
  55206. /** @hidden */
  55207. export var refractionPixelShader: {
  55208. name: string;
  55209. shader: string;
  55210. };
  55211. }
  55212. declare module BABYLON {
  55213. /**
  55214. * Post process which applies a refractin texture
  55215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55216. */
  55217. export class RefractionPostProcess extends PostProcess {
  55218. /** the base color of the refraction (used to taint the rendering) */
  55219. color: Color3;
  55220. /** simulated refraction depth */
  55221. depth: number;
  55222. /** the coefficient of the base color (0 to remove base color tainting) */
  55223. colorLevel: number;
  55224. private _refTexture;
  55225. private _ownRefractionTexture;
  55226. /**
  55227. * Gets or sets the refraction texture
  55228. * Please note that you are responsible for disposing the texture if you set it manually
  55229. */
  55230. refractionTexture: Texture;
  55231. /**
  55232. * Initializes the RefractionPostProcess
  55233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55234. * @param name The name of the effect.
  55235. * @param refractionTextureUrl Url of the refraction texture to use
  55236. * @param color the base color of the refraction (used to taint the rendering)
  55237. * @param depth simulated refraction depth
  55238. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55239. * @param camera The camera to apply the render pass to.
  55240. * @param options The required width/height ratio to downsize to before computing the render pass.
  55241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55242. * @param engine The engine which the post process will be applied. (default: current engine)
  55243. * @param reusable If the post process can be reused on the same frame. (default: false)
  55244. */
  55245. constructor(name: string, refractionTextureUrl: string,
  55246. /** the base color of the refraction (used to taint the rendering) */
  55247. color: Color3,
  55248. /** simulated refraction depth */
  55249. depth: number,
  55250. /** the coefficient of the base color (0 to remove base color tainting) */
  55251. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55252. /**
  55253. * Disposes of the post process
  55254. * @param camera Camera to dispose post process on
  55255. */
  55256. dispose(camera: Camera): void;
  55257. }
  55258. }
  55259. declare module BABYLON {
  55260. /** @hidden */
  55261. export var sharpenPixelShader: {
  55262. name: string;
  55263. shader: string;
  55264. };
  55265. }
  55266. declare module BABYLON {
  55267. /**
  55268. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55269. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55270. */
  55271. export class SharpenPostProcess extends PostProcess {
  55272. /**
  55273. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55274. */
  55275. colorAmount: number;
  55276. /**
  55277. * How much sharpness should be applied (default: 0.3)
  55278. */
  55279. edgeAmount: number;
  55280. /**
  55281. * Creates a new instance ConvolutionPostProcess
  55282. * @param name The name of the effect.
  55283. * @param options The required width/height ratio to downsize to before computing the render pass.
  55284. * @param camera The camera to apply the render pass to.
  55285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55286. * @param engine The engine which the post process will be applied. (default: current engine)
  55287. * @param reusable If the post process can be reused on the same frame. (default: false)
  55288. * @param textureType Type of textures used when performing the post process. (default: 0)
  55289. * @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)
  55290. */
  55291. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55292. }
  55293. }
  55294. declare module BABYLON {
  55295. /**
  55296. * PostProcessRenderPipeline
  55297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55298. */
  55299. export class PostProcessRenderPipeline {
  55300. private engine;
  55301. private _renderEffects;
  55302. private _renderEffectsForIsolatedPass;
  55303. /**
  55304. * List of inspectable custom properties (used by the Inspector)
  55305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55306. */
  55307. inspectableCustomProperties: IInspectable[];
  55308. /**
  55309. * @hidden
  55310. */
  55311. protected _cameras: Camera[];
  55312. /** @hidden */ private _name: string;
  55313. /**
  55314. * Gets pipeline name
  55315. */
  55316. readonly name: string;
  55317. /**
  55318. * Initializes a PostProcessRenderPipeline
  55319. * @param engine engine to add the pipeline to
  55320. * @param name name of the pipeline
  55321. */
  55322. constructor(engine: Engine, name: string);
  55323. /**
  55324. * Gets the class name
  55325. * @returns "PostProcessRenderPipeline"
  55326. */
  55327. getClassName(): string;
  55328. /**
  55329. * If all the render effects in the pipeline are supported
  55330. */
  55331. readonly isSupported: boolean;
  55332. /**
  55333. * Adds an effect to the pipeline
  55334. * @param renderEffect the effect to add
  55335. */
  55336. addEffect(renderEffect: PostProcessRenderEffect): void;
  55337. /** @hidden */ private _rebuild(): void;
  55338. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  55339. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55340. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55341. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55342. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  55343. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  55344. /** @hidden */ private _detachCameras(cameras: Camera): void;
  55345. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  55346. /** @hidden */ private _update(): void;
  55347. /** @hidden */ private _reset(): void;
  55348. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55349. /**
  55350. * Disposes of the pipeline
  55351. */
  55352. dispose(): void;
  55353. }
  55354. }
  55355. declare module BABYLON {
  55356. /**
  55357. * PostProcessRenderPipelineManager class
  55358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55359. */
  55360. export class PostProcessRenderPipelineManager {
  55361. private _renderPipelines;
  55362. /**
  55363. * Initializes a PostProcessRenderPipelineManager
  55364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55365. */
  55366. constructor();
  55367. /**
  55368. * Gets the list of supported render pipelines
  55369. */
  55370. readonly supportedPipelines: PostProcessRenderPipeline[];
  55371. /**
  55372. * Adds a pipeline to the manager
  55373. * @param renderPipeline The pipeline to add
  55374. */
  55375. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55376. /**
  55377. * Attaches a camera to the pipeline
  55378. * @param renderPipelineName The name of the pipeline to attach to
  55379. * @param cameras the camera to attach
  55380. * @param unique if the camera can be attached multiple times to the pipeline
  55381. */
  55382. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55383. /**
  55384. * Detaches a camera from the pipeline
  55385. * @param renderPipelineName The name of the pipeline to detach from
  55386. * @param cameras the camera to detach
  55387. */
  55388. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55389. /**
  55390. * Enables an effect by name on a pipeline
  55391. * @param renderPipelineName the name of the pipeline to enable the effect in
  55392. * @param renderEffectName the name of the effect to enable
  55393. * @param cameras the cameras that the effect should be enabled on
  55394. */
  55395. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55396. /**
  55397. * Disables an effect by name on a pipeline
  55398. * @param renderPipelineName the name of the pipeline to disable the effect in
  55399. * @param renderEffectName the name of the effect to disable
  55400. * @param cameras the cameras that the effect should be disabled on
  55401. */
  55402. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55403. /**
  55404. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55405. */
  55406. update(): void;
  55407. /** @hidden */ private _rebuild(): void;
  55408. /**
  55409. * Disposes of the manager and pipelines
  55410. */
  55411. dispose(): void;
  55412. }
  55413. }
  55414. declare module BABYLON {
  55415. interface Scene {
  55416. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55417. /**
  55418. * Gets the postprocess render pipeline manager
  55419. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55420. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55421. */
  55422. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55423. }
  55424. /**
  55425. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55426. */
  55427. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55428. /**
  55429. * The component name helpfull to identify the component in the list of scene components.
  55430. */
  55431. readonly name: string;
  55432. /**
  55433. * The scene the component belongs to.
  55434. */
  55435. scene: Scene;
  55436. /**
  55437. * Creates a new instance of the component for the given scene
  55438. * @param scene Defines the scene to register the component in
  55439. */
  55440. constructor(scene: Scene);
  55441. /**
  55442. * Registers the component in a given scene
  55443. */
  55444. register(): void;
  55445. /**
  55446. * Rebuilds the elements related to this component in case of
  55447. * context lost for instance.
  55448. */
  55449. rebuild(): void;
  55450. /**
  55451. * Disposes the component and the associated ressources
  55452. */
  55453. dispose(): void;
  55454. private _gatherRenderTargets;
  55455. }
  55456. }
  55457. declare module BABYLON {
  55458. /**
  55459. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55460. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55461. */
  55462. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55463. private _scene;
  55464. private _camerasToBeAttached;
  55465. /**
  55466. * ID of the sharpen post process,
  55467. */
  55468. private readonly SharpenPostProcessId;
  55469. /**
  55470. * @ignore
  55471. * ID of the image processing post process;
  55472. */
  55473. readonly ImageProcessingPostProcessId: string;
  55474. /**
  55475. * @ignore
  55476. * ID of the Fast Approximate Anti-Aliasing post process;
  55477. */
  55478. readonly FxaaPostProcessId: string;
  55479. /**
  55480. * ID of the chromatic aberration post process,
  55481. */
  55482. private readonly ChromaticAberrationPostProcessId;
  55483. /**
  55484. * ID of the grain post process
  55485. */
  55486. private readonly GrainPostProcessId;
  55487. /**
  55488. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55489. */
  55490. sharpen: SharpenPostProcess;
  55491. private _sharpenEffect;
  55492. private bloom;
  55493. /**
  55494. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55495. */
  55496. depthOfField: DepthOfFieldEffect;
  55497. /**
  55498. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55499. */
  55500. fxaa: FxaaPostProcess;
  55501. /**
  55502. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55503. */
  55504. imageProcessing: ImageProcessingPostProcess;
  55505. /**
  55506. * Chromatic aberration post process which will shift rgb colors in the image
  55507. */
  55508. chromaticAberration: ChromaticAberrationPostProcess;
  55509. private _chromaticAberrationEffect;
  55510. /**
  55511. * Grain post process which add noise to the image
  55512. */
  55513. grain: GrainPostProcess;
  55514. private _grainEffect;
  55515. /**
  55516. * Glow post process which adds a glow to emissive areas of the image
  55517. */
  55518. private _glowLayer;
  55519. /**
  55520. * Animations which can be used to tweak settings over a period of time
  55521. */
  55522. animations: Animation[];
  55523. private _imageProcessingConfigurationObserver;
  55524. private _sharpenEnabled;
  55525. private _bloomEnabled;
  55526. private _depthOfFieldEnabled;
  55527. private _depthOfFieldBlurLevel;
  55528. private _fxaaEnabled;
  55529. private _imageProcessingEnabled;
  55530. private _defaultPipelineTextureType;
  55531. private _bloomScale;
  55532. private _chromaticAberrationEnabled;
  55533. private _grainEnabled;
  55534. private _buildAllowed;
  55535. /**
  55536. * Gets active scene
  55537. */
  55538. readonly scene: Scene;
  55539. /**
  55540. * Enable or disable the sharpen process from the pipeline
  55541. */
  55542. sharpenEnabled: boolean;
  55543. private _resizeObserver;
  55544. private _hardwareScaleLevel;
  55545. private _bloomKernel;
  55546. /**
  55547. * Specifies the size of the bloom blur kernel, relative to the final output size
  55548. */
  55549. bloomKernel: number;
  55550. /**
  55551. * Specifies the weight of the bloom in the final rendering
  55552. */
  55553. private _bloomWeight;
  55554. /**
  55555. * Specifies the luma threshold for the area that will be blurred by the bloom
  55556. */
  55557. private _bloomThreshold;
  55558. private _hdr;
  55559. /**
  55560. * The strength of the bloom.
  55561. */
  55562. bloomWeight: number;
  55563. /**
  55564. * The strength of the bloom.
  55565. */
  55566. bloomThreshold: number;
  55567. /**
  55568. * The scale of the bloom, lower value will provide better performance.
  55569. */
  55570. bloomScale: number;
  55571. /**
  55572. * Enable or disable the bloom from the pipeline
  55573. */
  55574. bloomEnabled: boolean;
  55575. private _rebuildBloom;
  55576. /**
  55577. * If the depth of field is enabled.
  55578. */
  55579. depthOfFieldEnabled: boolean;
  55580. /**
  55581. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55582. */
  55583. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55584. /**
  55585. * If the anti aliasing is enabled.
  55586. */
  55587. fxaaEnabled: boolean;
  55588. private _samples;
  55589. /**
  55590. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55591. */
  55592. samples: number;
  55593. /**
  55594. * If image processing is enabled.
  55595. */
  55596. imageProcessingEnabled: boolean;
  55597. /**
  55598. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55599. */
  55600. glowLayerEnabled: boolean;
  55601. /**
  55602. * Gets the glow layer (or null if not defined)
  55603. */
  55604. readonly glowLayer: Nullable<GlowLayer>;
  55605. /**
  55606. * Enable or disable the chromaticAberration process from the pipeline
  55607. */
  55608. chromaticAberrationEnabled: boolean;
  55609. /**
  55610. * Enable or disable the grain process from the pipeline
  55611. */
  55612. grainEnabled: boolean;
  55613. /**
  55614. * @constructor
  55615. * @param name - The rendering pipeline name (default: "")
  55616. * @param hdr - If high dynamic range textures should be used (default: true)
  55617. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55618. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55619. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55620. */
  55621. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55622. /**
  55623. * Get the class name
  55624. * @returns "DefaultRenderingPipeline"
  55625. */
  55626. getClassName(): string;
  55627. /**
  55628. * Force the compilation of the entire pipeline.
  55629. */
  55630. prepare(): void;
  55631. private _hasCleared;
  55632. private _prevPostProcess;
  55633. private _prevPrevPostProcess;
  55634. private _setAutoClearAndTextureSharing;
  55635. private _depthOfFieldSceneObserver;
  55636. private _buildPipeline;
  55637. private _disposePostProcesses;
  55638. /**
  55639. * Adds a camera to the pipeline
  55640. * @param camera the camera to be added
  55641. */
  55642. addCamera(camera: Camera): void;
  55643. /**
  55644. * Removes a camera from the pipeline
  55645. * @param camera the camera to remove
  55646. */
  55647. removeCamera(camera: Camera): void;
  55648. /**
  55649. * Dispose of the pipeline and stop all post processes
  55650. */
  55651. dispose(): void;
  55652. /**
  55653. * Serialize the rendering pipeline (Used when exporting)
  55654. * @returns the serialized object
  55655. */
  55656. serialize(): any;
  55657. /**
  55658. * Parse the serialized pipeline
  55659. * @param source Source pipeline.
  55660. * @param scene The scene to load the pipeline to.
  55661. * @param rootUrl The URL of the serialized pipeline.
  55662. * @returns An instantiated pipeline from the serialized object.
  55663. */
  55664. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55665. }
  55666. }
  55667. declare module BABYLON {
  55668. /** @hidden */
  55669. export var lensHighlightsPixelShader: {
  55670. name: string;
  55671. shader: string;
  55672. };
  55673. }
  55674. declare module BABYLON {
  55675. /** @hidden */
  55676. export var depthOfFieldPixelShader: {
  55677. name: string;
  55678. shader: string;
  55679. };
  55680. }
  55681. declare module BABYLON {
  55682. /**
  55683. * BABYLON.JS Chromatic Aberration GLSL Shader
  55684. * Author: Olivier Guyot
  55685. * Separates very slightly R, G and B colors on the edges of the screen
  55686. * Inspired by Francois Tarlier & Martins Upitis
  55687. */
  55688. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55689. /**
  55690. * @ignore
  55691. * The chromatic aberration PostProcess id in the pipeline
  55692. */
  55693. LensChromaticAberrationEffect: string;
  55694. /**
  55695. * @ignore
  55696. * The highlights enhancing PostProcess id in the pipeline
  55697. */
  55698. HighlightsEnhancingEffect: string;
  55699. /**
  55700. * @ignore
  55701. * The depth-of-field PostProcess id in the pipeline
  55702. */
  55703. LensDepthOfFieldEffect: string;
  55704. private _scene;
  55705. private _depthTexture;
  55706. private _grainTexture;
  55707. private _chromaticAberrationPostProcess;
  55708. private _highlightsPostProcess;
  55709. private _depthOfFieldPostProcess;
  55710. private _edgeBlur;
  55711. private _grainAmount;
  55712. private _chromaticAberration;
  55713. private _distortion;
  55714. private _highlightsGain;
  55715. private _highlightsThreshold;
  55716. private _dofDistance;
  55717. private _dofAperture;
  55718. private _dofDarken;
  55719. private _dofPentagon;
  55720. private _blurNoise;
  55721. /**
  55722. * @constructor
  55723. *
  55724. * Effect parameters are as follow:
  55725. * {
  55726. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55727. * edge_blur: number; // from 0 to x (1 for realism)
  55728. * distortion: number; // from 0 to x (1 for realism)
  55729. * grain_amount: number; // from 0 to 1
  55730. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55731. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55732. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55733. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55734. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55735. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55736. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55737. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55738. * }
  55739. * Note: if an effect parameter is unset, effect is disabled
  55740. *
  55741. * @param name The rendering pipeline name
  55742. * @param parameters - An object containing all parameters (see above)
  55743. * @param scene The scene linked to this pipeline
  55744. * @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)
  55745. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55746. */
  55747. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55748. /**
  55749. * Get the class name
  55750. * @returns "LensRenderingPipeline"
  55751. */
  55752. getClassName(): string;
  55753. /**
  55754. * Gets associated scene
  55755. */
  55756. readonly scene: Scene;
  55757. /**
  55758. * Gets or sets the edge blur
  55759. */
  55760. edgeBlur: number;
  55761. /**
  55762. * Gets or sets the grain amount
  55763. */
  55764. grainAmount: number;
  55765. /**
  55766. * Gets or sets the chromatic aberration amount
  55767. */
  55768. chromaticAberration: number;
  55769. /**
  55770. * Gets or sets the depth of field aperture
  55771. */
  55772. dofAperture: number;
  55773. /**
  55774. * Gets or sets the edge distortion
  55775. */
  55776. edgeDistortion: number;
  55777. /**
  55778. * Gets or sets the depth of field distortion
  55779. */
  55780. dofDistortion: number;
  55781. /**
  55782. * Gets or sets the darken out of focus amount
  55783. */
  55784. darkenOutOfFocus: number;
  55785. /**
  55786. * Gets or sets a boolean indicating if blur noise is enabled
  55787. */
  55788. blurNoise: boolean;
  55789. /**
  55790. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55791. */
  55792. pentagonBokeh: boolean;
  55793. /**
  55794. * Gets or sets the highlight grain amount
  55795. */
  55796. highlightsGain: number;
  55797. /**
  55798. * Gets or sets the highlight threshold
  55799. */
  55800. highlightsThreshold: number;
  55801. /**
  55802. * Sets the amount of blur at the edges
  55803. * @param amount blur amount
  55804. */
  55805. setEdgeBlur(amount: number): void;
  55806. /**
  55807. * Sets edge blur to 0
  55808. */
  55809. disableEdgeBlur(): void;
  55810. /**
  55811. * Sets the amout of grain
  55812. * @param amount Amount of grain
  55813. */
  55814. setGrainAmount(amount: number): void;
  55815. /**
  55816. * Set grain amount to 0
  55817. */
  55818. disableGrain(): void;
  55819. /**
  55820. * Sets the chromatic aberration amount
  55821. * @param amount amount of chromatic aberration
  55822. */
  55823. setChromaticAberration(amount: number): void;
  55824. /**
  55825. * Sets chromatic aberration amount to 0
  55826. */
  55827. disableChromaticAberration(): void;
  55828. /**
  55829. * Sets the EdgeDistortion amount
  55830. * @param amount amount of EdgeDistortion
  55831. */
  55832. setEdgeDistortion(amount: number): void;
  55833. /**
  55834. * Sets edge distortion to 0
  55835. */
  55836. disableEdgeDistortion(): void;
  55837. /**
  55838. * Sets the FocusDistance amount
  55839. * @param amount amount of FocusDistance
  55840. */
  55841. setFocusDistance(amount: number): void;
  55842. /**
  55843. * Disables depth of field
  55844. */
  55845. disableDepthOfField(): void;
  55846. /**
  55847. * Sets the Aperture amount
  55848. * @param amount amount of Aperture
  55849. */
  55850. setAperture(amount: number): void;
  55851. /**
  55852. * Sets the DarkenOutOfFocus amount
  55853. * @param amount amount of DarkenOutOfFocus
  55854. */
  55855. setDarkenOutOfFocus(amount: number): void;
  55856. private _pentagonBokehIsEnabled;
  55857. /**
  55858. * Creates a pentagon bokeh effect
  55859. */
  55860. enablePentagonBokeh(): void;
  55861. /**
  55862. * Disables the pentagon bokeh effect
  55863. */
  55864. disablePentagonBokeh(): void;
  55865. /**
  55866. * Enables noise blur
  55867. */
  55868. enableNoiseBlur(): void;
  55869. /**
  55870. * Disables noise blur
  55871. */
  55872. disableNoiseBlur(): void;
  55873. /**
  55874. * Sets the HighlightsGain amount
  55875. * @param amount amount of HighlightsGain
  55876. */
  55877. setHighlightsGain(amount: number): void;
  55878. /**
  55879. * Sets the HighlightsThreshold amount
  55880. * @param amount amount of HighlightsThreshold
  55881. */
  55882. setHighlightsThreshold(amount: number): void;
  55883. /**
  55884. * Disables highlights
  55885. */
  55886. disableHighlights(): void;
  55887. /**
  55888. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55889. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55890. */
  55891. dispose(disableDepthRender?: boolean): void;
  55892. private _createChromaticAberrationPostProcess;
  55893. private _createHighlightsPostProcess;
  55894. private _createDepthOfFieldPostProcess;
  55895. private _createGrainTexture;
  55896. }
  55897. }
  55898. declare module BABYLON {
  55899. /** @hidden */
  55900. export var ssao2PixelShader: {
  55901. name: string;
  55902. shader: string;
  55903. };
  55904. }
  55905. declare module BABYLON {
  55906. /** @hidden */
  55907. export var ssaoCombinePixelShader: {
  55908. name: string;
  55909. shader: string;
  55910. };
  55911. }
  55912. declare module BABYLON {
  55913. /**
  55914. * Render pipeline to produce ssao effect
  55915. */
  55916. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55917. /**
  55918. * @ignore
  55919. * The PassPostProcess id in the pipeline that contains the original scene color
  55920. */
  55921. SSAOOriginalSceneColorEffect: string;
  55922. /**
  55923. * @ignore
  55924. * The SSAO PostProcess id in the pipeline
  55925. */
  55926. SSAORenderEffect: string;
  55927. /**
  55928. * @ignore
  55929. * The horizontal blur PostProcess id in the pipeline
  55930. */
  55931. SSAOBlurHRenderEffect: string;
  55932. /**
  55933. * @ignore
  55934. * The vertical blur PostProcess id in the pipeline
  55935. */
  55936. SSAOBlurVRenderEffect: string;
  55937. /**
  55938. * @ignore
  55939. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55940. */
  55941. SSAOCombineRenderEffect: string;
  55942. /**
  55943. * The output strength of the SSAO post-process. Default value is 1.0.
  55944. */
  55945. totalStrength: number;
  55946. /**
  55947. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55948. */
  55949. maxZ: number;
  55950. /**
  55951. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55952. */
  55953. minZAspect: number;
  55954. private _samples;
  55955. /**
  55956. * Number of samples used for the SSAO calculations. Default value is 8
  55957. */
  55958. samples: number;
  55959. private _textureSamples;
  55960. /**
  55961. * Number of samples to use for antialiasing
  55962. */
  55963. textureSamples: number;
  55964. /**
  55965. * Ratio object used for SSAO ratio and blur ratio
  55966. */
  55967. private _ratio;
  55968. /**
  55969. * Dynamically generated sphere sampler.
  55970. */
  55971. private _sampleSphere;
  55972. /**
  55973. * Blur filter offsets
  55974. */
  55975. private _samplerOffsets;
  55976. private _expensiveBlur;
  55977. /**
  55978. * If bilateral blur should be used
  55979. */
  55980. expensiveBlur: boolean;
  55981. /**
  55982. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55983. */
  55984. radius: number;
  55985. /**
  55986. * The base color of the SSAO post-process
  55987. * The final result is "base + ssao" between [0, 1]
  55988. */
  55989. base: number;
  55990. /**
  55991. * Support test.
  55992. */
  55993. static readonly IsSupported: boolean;
  55994. private _scene;
  55995. private _depthTexture;
  55996. private _normalTexture;
  55997. private _randomTexture;
  55998. private _originalColorPostProcess;
  55999. private _ssaoPostProcess;
  56000. private _blurHPostProcess;
  56001. private _blurVPostProcess;
  56002. private _ssaoCombinePostProcess;
  56003. private _firstUpdate;
  56004. /**
  56005. * Gets active scene
  56006. */
  56007. readonly scene: Scene;
  56008. /**
  56009. * @constructor
  56010. * @param name The rendering pipeline name
  56011. * @param scene The scene linked to this pipeline
  56012. * @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 }
  56013. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56014. */
  56015. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56016. /**
  56017. * Get the class name
  56018. * @returns "SSAO2RenderingPipeline"
  56019. */
  56020. getClassName(): string;
  56021. /**
  56022. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56023. */
  56024. dispose(disableGeometryBufferRenderer?: boolean): void;
  56025. private _createBlurPostProcess;
  56026. /** @hidden */ private _rebuild(): void;
  56027. private _bits;
  56028. private _radicalInverse_VdC;
  56029. private _hammersley;
  56030. private _hemisphereSample_uniform;
  56031. private _generateHemisphere;
  56032. private _createSSAOPostProcess;
  56033. private _createSSAOCombinePostProcess;
  56034. private _createRandomTexture;
  56035. /**
  56036. * Serialize the rendering pipeline (Used when exporting)
  56037. * @returns the serialized object
  56038. */
  56039. serialize(): any;
  56040. /**
  56041. * Parse the serialized pipeline
  56042. * @param source Source pipeline.
  56043. * @param scene The scene to load the pipeline to.
  56044. * @param rootUrl The URL of the serialized pipeline.
  56045. * @returns An instantiated pipeline from the serialized object.
  56046. */
  56047. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56048. }
  56049. }
  56050. declare module BABYLON {
  56051. /** @hidden */
  56052. export var ssaoPixelShader: {
  56053. name: string;
  56054. shader: string;
  56055. };
  56056. }
  56057. declare module BABYLON {
  56058. /**
  56059. * Render pipeline to produce ssao effect
  56060. */
  56061. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56062. /**
  56063. * @ignore
  56064. * The PassPostProcess id in the pipeline that contains the original scene color
  56065. */
  56066. SSAOOriginalSceneColorEffect: string;
  56067. /**
  56068. * @ignore
  56069. * The SSAO PostProcess id in the pipeline
  56070. */
  56071. SSAORenderEffect: string;
  56072. /**
  56073. * @ignore
  56074. * The horizontal blur PostProcess id in the pipeline
  56075. */
  56076. SSAOBlurHRenderEffect: string;
  56077. /**
  56078. * @ignore
  56079. * The vertical blur PostProcess id in the pipeline
  56080. */
  56081. SSAOBlurVRenderEffect: string;
  56082. /**
  56083. * @ignore
  56084. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56085. */
  56086. SSAOCombineRenderEffect: string;
  56087. /**
  56088. * The output strength of the SSAO post-process. Default value is 1.0.
  56089. */
  56090. totalStrength: number;
  56091. /**
  56092. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56093. */
  56094. radius: number;
  56095. /**
  56096. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56097. * Must not be equal to fallOff and superior to fallOff.
  56098. * Default value is 0.0075
  56099. */
  56100. area: number;
  56101. /**
  56102. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56103. * Must not be equal to area and inferior to area.
  56104. * Default value is 0.000001
  56105. */
  56106. fallOff: number;
  56107. /**
  56108. * The base color of the SSAO post-process
  56109. * The final result is "base + ssao" between [0, 1]
  56110. */
  56111. base: number;
  56112. private _scene;
  56113. private _depthTexture;
  56114. private _randomTexture;
  56115. private _originalColorPostProcess;
  56116. private _ssaoPostProcess;
  56117. private _blurHPostProcess;
  56118. private _blurVPostProcess;
  56119. private _ssaoCombinePostProcess;
  56120. private _firstUpdate;
  56121. /**
  56122. * Gets active scene
  56123. */
  56124. readonly scene: Scene;
  56125. /**
  56126. * @constructor
  56127. * @param name - The rendering pipeline name
  56128. * @param scene - The scene linked to this pipeline
  56129. * @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 }
  56130. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56131. */
  56132. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56133. /**
  56134. * Get the class name
  56135. * @returns "SSAORenderingPipeline"
  56136. */
  56137. getClassName(): string;
  56138. /**
  56139. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56140. */
  56141. dispose(disableDepthRender?: boolean): void;
  56142. private _createBlurPostProcess;
  56143. /** @hidden */ private _rebuild(): void;
  56144. private _createSSAOPostProcess;
  56145. private _createSSAOCombinePostProcess;
  56146. private _createRandomTexture;
  56147. }
  56148. }
  56149. declare module BABYLON {
  56150. /** @hidden */
  56151. export var standardPixelShader: {
  56152. name: string;
  56153. shader: string;
  56154. };
  56155. }
  56156. declare module BABYLON {
  56157. /**
  56158. * Standard rendering pipeline
  56159. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56160. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56161. */
  56162. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56163. /**
  56164. * Public members
  56165. */
  56166. /**
  56167. * Post-process which contains the original scene color before the pipeline applies all the effects
  56168. */
  56169. originalPostProcess: Nullable<PostProcess>;
  56170. /**
  56171. * Post-process used to down scale an image x4
  56172. */
  56173. downSampleX4PostProcess: Nullable<PostProcess>;
  56174. /**
  56175. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56176. */
  56177. brightPassPostProcess: Nullable<PostProcess>;
  56178. /**
  56179. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56180. */
  56181. blurHPostProcesses: PostProcess[];
  56182. /**
  56183. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56184. */
  56185. blurVPostProcesses: PostProcess[];
  56186. /**
  56187. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56188. */
  56189. textureAdderPostProcess: Nullable<PostProcess>;
  56190. /**
  56191. * Post-process used to create volumetric lighting effect
  56192. */
  56193. volumetricLightPostProcess: Nullable<PostProcess>;
  56194. /**
  56195. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56196. */
  56197. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56198. /**
  56199. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56200. */
  56201. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56202. /**
  56203. * Post-process used to merge the volumetric light effect and the real scene color
  56204. */
  56205. volumetricLightMergePostProces: Nullable<PostProcess>;
  56206. /**
  56207. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56208. */
  56209. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56210. /**
  56211. * Base post-process used to calculate the average luminance of the final image for HDR
  56212. */
  56213. luminancePostProcess: Nullable<PostProcess>;
  56214. /**
  56215. * Post-processes used to create down sample post-processes in order to get
  56216. * the average luminance of the final image for HDR
  56217. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56218. */
  56219. luminanceDownSamplePostProcesses: PostProcess[];
  56220. /**
  56221. * Post-process used to create a HDR effect (light adaptation)
  56222. */
  56223. hdrPostProcess: Nullable<PostProcess>;
  56224. /**
  56225. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56226. */
  56227. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56228. /**
  56229. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56230. */
  56231. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56232. /**
  56233. * Post-process used to merge the final HDR post-process and the real scene color
  56234. */
  56235. hdrFinalPostProcess: Nullable<PostProcess>;
  56236. /**
  56237. * Post-process used to create a lens flare effect
  56238. */
  56239. lensFlarePostProcess: Nullable<PostProcess>;
  56240. /**
  56241. * Post-process that merges the result of the lens flare post-process and the real scene color
  56242. */
  56243. lensFlareComposePostProcess: Nullable<PostProcess>;
  56244. /**
  56245. * Post-process used to create a motion blur effect
  56246. */
  56247. motionBlurPostProcess: Nullable<PostProcess>;
  56248. /**
  56249. * Post-process used to create a depth of field effect
  56250. */
  56251. depthOfFieldPostProcess: Nullable<PostProcess>;
  56252. /**
  56253. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56254. */
  56255. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56256. /**
  56257. * Represents the brightness threshold in order to configure the illuminated surfaces
  56258. */
  56259. brightThreshold: number;
  56260. /**
  56261. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56262. */
  56263. blurWidth: number;
  56264. /**
  56265. * Sets if the blur for highlighted surfaces must be only horizontal
  56266. */
  56267. horizontalBlur: boolean;
  56268. /**
  56269. * Gets the overall exposure used by the pipeline
  56270. */
  56271. /**
  56272. * Sets the overall exposure used by the pipeline
  56273. */
  56274. exposure: number;
  56275. /**
  56276. * Texture used typically to simulate "dirty" on camera lens
  56277. */
  56278. lensTexture: Nullable<Texture>;
  56279. /**
  56280. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56281. */
  56282. volumetricLightCoefficient: number;
  56283. /**
  56284. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56285. */
  56286. volumetricLightPower: number;
  56287. /**
  56288. * Used the set the blur intensity to smooth the volumetric lights
  56289. */
  56290. volumetricLightBlurScale: number;
  56291. /**
  56292. * Light (spot or directional) used to generate the volumetric lights rays
  56293. * The source light must have a shadow generate so the pipeline can get its
  56294. * depth map
  56295. */
  56296. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56297. /**
  56298. * For eye adaptation, represents the minimum luminance the eye can see
  56299. */
  56300. hdrMinimumLuminance: number;
  56301. /**
  56302. * For eye adaptation, represents the decrease luminance speed
  56303. */
  56304. hdrDecreaseRate: number;
  56305. /**
  56306. * For eye adaptation, represents the increase luminance speed
  56307. */
  56308. hdrIncreaseRate: number;
  56309. /**
  56310. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56311. */
  56312. /**
  56313. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56314. */
  56315. hdrAutoExposure: boolean;
  56316. /**
  56317. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56318. */
  56319. lensColorTexture: Nullable<Texture>;
  56320. /**
  56321. * The overall strengh for the lens flare effect
  56322. */
  56323. lensFlareStrength: number;
  56324. /**
  56325. * Dispersion coefficient for lens flare ghosts
  56326. */
  56327. lensFlareGhostDispersal: number;
  56328. /**
  56329. * Main lens flare halo width
  56330. */
  56331. lensFlareHaloWidth: number;
  56332. /**
  56333. * Based on the lens distortion effect, defines how much the lens flare result
  56334. * is distorted
  56335. */
  56336. lensFlareDistortionStrength: number;
  56337. /**
  56338. * Lens star texture must be used to simulate rays on the flares and is available
  56339. * in the documentation
  56340. */
  56341. lensStarTexture: Nullable<Texture>;
  56342. /**
  56343. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56344. * flare effect by taking account of the dirt texture
  56345. */
  56346. lensFlareDirtTexture: Nullable<Texture>;
  56347. /**
  56348. * Represents the focal length for the depth of field effect
  56349. */
  56350. depthOfFieldDistance: number;
  56351. /**
  56352. * Represents the blur intensity for the blurred part of the depth of field effect
  56353. */
  56354. depthOfFieldBlurWidth: number;
  56355. /**
  56356. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56357. */
  56358. /**
  56359. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56360. */
  56361. motionStrength: number;
  56362. /**
  56363. * Gets wether or not the motion blur post-process is object based or screen based.
  56364. */
  56365. /**
  56366. * Sets wether or not the motion blur post-process should be object based or screen based
  56367. */
  56368. objectBasedMotionBlur: boolean;
  56369. /**
  56370. * List of animations for the pipeline (IAnimatable implementation)
  56371. */
  56372. animations: Animation[];
  56373. /**
  56374. * Private members
  56375. */
  56376. private _scene;
  56377. private _currentDepthOfFieldSource;
  56378. private _basePostProcess;
  56379. private _fixedExposure;
  56380. private _currentExposure;
  56381. private _hdrAutoExposure;
  56382. private _hdrCurrentLuminance;
  56383. private _motionStrength;
  56384. private _isObjectBasedMotionBlur;
  56385. private _floatTextureType;
  56386. private _ratio;
  56387. private _bloomEnabled;
  56388. private _depthOfFieldEnabled;
  56389. private _vlsEnabled;
  56390. private _lensFlareEnabled;
  56391. private _hdrEnabled;
  56392. private _motionBlurEnabled;
  56393. private _fxaaEnabled;
  56394. private _motionBlurSamples;
  56395. private _volumetricLightStepsCount;
  56396. private _samples;
  56397. /**
  56398. * @ignore
  56399. * Specifies if the bloom pipeline is enabled
  56400. */
  56401. BloomEnabled: boolean;
  56402. /**
  56403. * @ignore
  56404. * Specifies if the depth of field pipeline is enabed
  56405. */
  56406. DepthOfFieldEnabled: boolean;
  56407. /**
  56408. * @ignore
  56409. * Specifies if the lens flare pipeline is enabed
  56410. */
  56411. LensFlareEnabled: boolean;
  56412. /**
  56413. * @ignore
  56414. * Specifies if the HDR pipeline is enabled
  56415. */
  56416. HDREnabled: boolean;
  56417. /**
  56418. * @ignore
  56419. * Specifies if the volumetric lights scattering effect is enabled
  56420. */
  56421. VLSEnabled: boolean;
  56422. /**
  56423. * @ignore
  56424. * Specifies if the motion blur effect is enabled
  56425. */
  56426. MotionBlurEnabled: boolean;
  56427. /**
  56428. * Specifies if anti-aliasing is enabled
  56429. */
  56430. fxaaEnabled: boolean;
  56431. /**
  56432. * Specifies the number of steps used to calculate the volumetric lights
  56433. * Typically in interval [50, 200]
  56434. */
  56435. volumetricLightStepsCount: number;
  56436. /**
  56437. * Specifies the number of samples used for the motion blur effect
  56438. * Typically in interval [16, 64]
  56439. */
  56440. motionBlurSamples: number;
  56441. /**
  56442. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56443. */
  56444. samples: number;
  56445. /**
  56446. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56447. * @constructor
  56448. * @param name The rendering pipeline name
  56449. * @param scene The scene linked to this pipeline
  56450. * @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)
  56451. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56452. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56453. */
  56454. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56455. private _buildPipeline;
  56456. private _createDownSampleX4PostProcess;
  56457. private _createBrightPassPostProcess;
  56458. private _createBlurPostProcesses;
  56459. private _createTextureAdderPostProcess;
  56460. private _createVolumetricLightPostProcess;
  56461. private _createLuminancePostProcesses;
  56462. private _createHdrPostProcess;
  56463. private _createLensFlarePostProcess;
  56464. private _createDepthOfFieldPostProcess;
  56465. private _createMotionBlurPostProcess;
  56466. private _getDepthTexture;
  56467. private _disposePostProcesses;
  56468. /**
  56469. * Dispose of the pipeline and stop all post processes
  56470. */
  56471. dispose(): void;
  56472. /**
  56473. * Serialize the rendering pipeline (Used when exporting)
  56474. * @returns the serialized object
  56475. */
  56476. serialize(): any;
  56477. /**
  56478. * Parse the serialized pipeline
  56479. * @param source Source pipeline.
  56480. * @param scene The scene to load the pipeline to.
  56481. * @param rootUrl The URL of the serialized pipeline.
  56482. * @returns An instantiated pipeline from the serialized object.
  56483. */
  56484. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56485. /**
  56486. * Luminance steps
  56487. */
  56488. static LuminanceSteps: number;
  56489. }
  56490. }
  56491. declare module BABYLON {
  56492. /** @hidden */
  56493. export var tonemapPixelShader: {
  56494. name: string;
  56495. shader: string;
  56496. };
  56497. }
  56498. declare module BABYLON {
  56499. /** Defines operator used for tonemapping */
  56500. export enum TonemappingOperator {
  56501. /** Hable */
  56502. Hable = 0,
  56503. /** Reinhard */
  56504. Reinhard = 1,
  56505. /** HejiDawson */
  56506. HejiDawson = 2,
  56507. /** Photographic */
  56508. Photographic = 3
  56509. }
  56510. /**
  56511. * Defines a post process to apply tone mapping
  56512. */
  56513. export class TonemapPostProcess extends PostProcess {
  56514. private _operator;
  56515. /** Defines the required exposure adjustement */
  56516. exposureAdjustment: number;
  56517. /**
  56518. * Creates a new TonemapPostProcess
  56519. * @param name defines the name of the postprocess
  56520. * @param _operator defines the operator to use
  56521. * @param exposureAdjustment defines the required exposure adjustement
  56522. * @param camera defines the camera to use (can be null)
  56523. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56524. * @param engine defines the hosting engine (can be ignore if camera is set)
  56525. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56526. */
  56527. constructor(name: string, _operator: TonemappingOperator,
  56528. /** Defines the required exposure adjustement */
  56529. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56530. }
  56531. }
  56532. declare module BABYLON {
  56533. /** @hidden */
  56534. export var depthVertexShader: {
  56535. name: string;
  56536. shader: string;
  56537. };
  56538. }
  56539. declare module BABYLON {
  56540. /** @hidden */
  56541. export var volumetricLightScatteringPixelShader: {
  56542. name: string;
  56543. shader: string;
  56544. };
  56545. }
  56546. declare module BABYLON {
  56547. /** @hidden */
  56548. export var volumetricLightScatteringPassPixelShader: {
  56549. name: string;
  56550. shader: string;
  56551. };
  56552. }
  56553. declare module BABYLON {
  56554. /**
  56555. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56556. */
  56557. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56558. private _volumetricLightScatteringPass;
  56559. private _volumetricLightScatteringRTT;
  56560. private _viewPort;
  56561. private _screenCoordinates;
  56562. private _cachedDefines;
  56563. /**
  56564. * If not undefined, the mesh position is computed from the attached node position
  56565. */
  56566. attachedNode: {
  56567. position: Vector3;
  56568. };
  56569. /**
  56570. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56571. */
  56572. customMeshPosition: Vector3;
  56573. /**
  56574. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56575. */
  56576. useCustomMeshPosition: boolean;
  56577. /**
  56578. * If the post-process should inverse the light scattering direction
  56579. */
  56580. invert: boolean;
  56581. /**
  56582. * The internal mesh used by the post-process
  56583. */
  56584. mesh: Mesh;
  56585. /**
  56586. * @hidden
  56587. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56588. */
  56589. useDiffuseColor: boolean;
  56590. /**
  56591. * Array containing the excluded meshes not rendered in the internal pass
  56592. */
  56593. excludedMeshes: AbstractMesh[];
  56594. /**
  56595. * Controls the overall intensity of the post-process
  56596. */
  56597. exposure: number;
  56598. /**
  56599. * Dissipates each sample's contribution in range [0, 1]
  56600. */
  56601. decay: number;
  56602. /**
  56603. * Controls the overall intensity of each sample
  56604. */
  56605. weight: number;
  56606. /**
  56607. * Controls the density of each sample
  56608. */
  56609. density: number;
  56610. /**
  56611. * @constructor
  56612. * @param name The post-process name
  56613. * @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)
  56614. * @param camera The camera that the post-process will be attached to
  56615. * @param mesh The mesh used to create the light scattering
  56616. * @param samples The post-process quality, default 100
  56617. * @param samplingModeThe post-process filtering mode
  56618. * @param engine The babylon engine
  56619. * @param reusable If the post-process is reusable
  56620. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56621. */
  56622. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56623. /**
  56624. * Returns the string "VolumetricLightScatteringPostProcess"
  56625. * @returns "VolumetricLightScatteringPostProcess"
  56626. */
  56627. getClassName(): string;
  56628. private _isReady;
  56629. /**
  56630. * Sets the new light position for light scattering effect
  56631. * @param position The new custom light position
  56632. */
  56633. setCustomMeshPosition(position: Vector3): void;
  56634. /**
  56635. * Returns the light position for light scattering effect
  56636. * @return Vector3 The custom light position
  56637. */
  56638. getCustomMeshPosition(): Vector3;
  56639. /**
  56640. * Disposes the internal assets and detaches the post-process from the camera
  56641. */
  56642. dispose(camera: Camera): void;
  56643. /**
  56644. * Returns the render target texture used by the post-process
  56645. * @return the render target texture used by the post-process
  56646. */
  56647. getPass(): RenderTargetTexture;
  56648. private _meshExcluded;
  56649. private _createPass;
  56650. private _updateMeshScreenCoordinates;
  56651. /**
  56652. * Creates a default mesh for the Volumeric Light Scattering post-process
  56653. * @param name The mesh name
  56654. * @param scene The scene where to create the mesh
  56655. * @return the default mesh
  56656. */
  56657. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56658. }
  56659. }
  56660. declare module BABYLON {
  56661. interface Scene {
  56662. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  56663. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  56664. /**
  56665. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56666. */
  56667. forceShowBoundingBoxes: boolean;
  56668. /**
  56669. * Gets the bounding box renderer associated with the scene
  56670. * @returns a BoundingBoxRenderer
  56671. */
  56672. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56673. }
  56674. interface AbstractMesh {
  56675. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  56676. /**
  56677. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56678. */
  56679. showBoundingBox: boolean;
  56680. }
  56681. /**
  56682. * Component responsible of rendering the bounding box of the meshes in a scene.
  56683. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56684. */
  56685. export class BoundingBoxRenderer implements ISceneComponent {
  56686. /**
  56687. * The component name helpfull to identify the component in the list of scene components.
  56688. */
  56689. readonly name: string;
  56690. /**
  56691. * The scene the component belongs to.
  56692. */
  56693. scene: Scene;
  56694. /**
  56695. * Color of the bounding box lines placed in front of an object
  56696. */
  56697. frontColor: Color3;
  56698. /**
  56699. * Color of the bounding box lines placed behind an object
  56700. */
  56701. backColor: Color3;
  56702. /**
  56703. * Defines if the renderer should show the back lines or not
  56704. */
  56705. showBackLines: boolean;
  56706. /**
  56707. * @hidden
  56708. */
  56709. renderList: SmartArray<BoundingBox>;
  56710. private _colorShader;
  56711. private _vertexBuffers;
  56712. private _indexBuffer;
  56713. private _fillIndexBuffer;
  56714. private _fillIndexData;
  56715. /**
  56716. * Instantiates a new bounding box renderer in a scene.
  56717. * @param scene the scene the renderer renders in
  56718. */
  56719. constructor(scene: Scene);
  56720. /**
  56721. * Registers the component in a given scene
  56722. */
  56723. register(): void;
  56724. private _evaluateSubMesh;
  56725. private _activeMesh;
  56726. private _prepareRessources;
  56727. private _createIndexBuffer;
  56728. /**
  56729. * Rebuilds the elements related to this component in case of
  56730. * context lost for instance.
  56731. */
  56732. rebuild(): void;
  56733. /**
  56734. * @hidden
  56735. */
  56736. reset(): void;
  56737. /**
  56738. * Render the bounding boxes of a specific rendering group
  56739. * @param renderingGroupId defines the rendering group to render
  56740. */
  56741. render(renderingGroupId: number): void;
  56742. /**
  56743. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56744. * @param mesh Define the mesh to render the occlusion bounding box for
  56745. */
  56746. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56747. /**
  56748. * Dispose and release the resources attached to this renderer.
  56749. */
  56750. dispose(): void;
  56751. }
  56752. }
  56753. declare module BABYLON {
  56754. /** @hidden */
  56755. export var depthPixelShader: {
  56756. name: string;
  56757. shader: string;
  56758. };
  56759. }
  56760. declare module BABYLON {
  56761. /**
  56762. * This represents a depth renderer in Babylon.
  56763. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56764. */
  56765. export class DepthRenderer {
  56766. private _scene;
  56767. private _depthMap;
  56768. private _effect;
  56769. private _cachedDefines;
  56770. private _camera;
  56771. /**
  56772. * Specifiess that the depth renderer will only be used within
  56773. * the camera it is created for.
  56774. * This can help forcing its rendering during the camera processing.
  56775. */
  56776. useOnlyInActiveCamera: boolean;
  56777. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  56778. /**
  56779. * Instantiates a depth renderer
  56780. * @param scene The scene the renderer belongs to
  56781. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56782. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56783. */
  56784. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56785. /**
  56786. * Creates the depth rendering effect and checks if the effect is ready.
  56787. * @param subMesh The submesh to be used to render the depth map of
  56788. * @param useInstances If multiple world instances should be used
  56789. * @returns if the depth renderer is ready to render the depth map
  56790. */
  56791. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56792. /**
  56793. * Gets the texture which the depth map will be written to.
  56794. * @returns The depth map texture
  56795. */
  56796. getDepthMap(): RenderTargetTexture;
  56797. /**
  56798. * Disposes of the depth renderer.
  56799. */
  56800. dispose(): void;
  56801. }
  56802. }
  56803. declare module BABYLON {
  56804. interface Scene {
  56805. /** @hidden (Backing field) */ private _depthRenderer: {
  56806. [id: string]: DepthRenderer;
  56807. };
  56808. /**
  56809. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56810. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56811. * @returns the created depth renderer
  56812. */
  56813. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56814. /**
  56815. * Disables a depth renderer for a given camera
  56816. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56817. */
  56818. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56819. }
  56820. /**
  56821. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56822. * in several rendering techniques.
  56823. */
  56824. export class DepthRendererSceneComponent implements ISceneComponent {
  56825. /**
  56826. * The component name helpfull to identify the component in the list of scene components.
  56827. */
  56828. readonly name: string;
  56829. /**
  56830. * The scene the component belongs to.
  56831. */
  56832. scene: Scene;
  56833. /**
  56834. * Creates a new instance of the component for the given scene
  56835. * @param scene Defines the scene to register the component in
  56836. */
  56837. constructor(scene: Scene);
  56838. /**
  56839. * Registers the component in a given scene
  56840. */
  56841. register(): void;
  56842. /**
  56843. * Rebuilds the elements related to this component in case of
  56844. * context lost for instance.
  56845. */
  56846. rebuild(): void;
  56847. /**
  56848. * Disposes the component and the associated ressources
  56849. */
  56850. dispose(): void;
  56851. private _gatherRenderTargets;
  56852. private _gatherActiveCameraRenderTargets;
  56853. }
  56854. }
  56855. declare module BABYLON {
  56856. /** @hidden */
  56857. export var outlinePixelShader: {
  56858. name: string;
  56859. shader: string;
  56860. };
  56861. }
  56862. declare module BABYLON {
  56863. /** @hidden */
  56864. export var outlineVertexShader: {
  56865. name: string;
  56866. shader: string;
  56867. };
  56868. }
  56869. declare module BABYLON {
  56870. interface Scene {
  56871. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  56872. /**
  56873. * Gets the outline renderer associated with the scene
  56874. * @returns a OutlineRenderer
  56875. */
  56876. getOutlineRenderer(): OutlineRenderer;
  56877. }
  56878. interface AbstractMesh {
  56879. /** @hidden (Backing field) */ private _renderOutline: boolean;
  56880. /**
  56881. * Gets or sets a boolean indicating if the outline must be rendered as well
  56882. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56883. */
  56884. renderOutline: boolean;
  56885. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  56886. /**
  56887. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56888. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56889. */
  56890. renderOverlay: boolean;
  56891. }
  56892. /**
  56893. * This class is responsible to draw bothe outline/overlay of meshes.
  56894. * It should not be used directly but through the available method on mesh.
  56895. */
  56896. export class OutlineRenderer implements ISceneComponent {
  56897. /**
  56898. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56899. */
  56900. private static _StencilReference;
  56901. /**
  56902. * The name of the component. Each component must have a unique name.
  56903. */
  56904. name: string;
  56905. /**
  56906. * The scene the component belongs to.
  56907. */
  56908. scene: Scene;
  56909. /**
  56910. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56911. */
  56912. zOffset: number;
  56913. private _engine;
  56914. private _effect;
  56915. private _cachedDefines;
  56916. private _savedDepthWrite;
  56917. /**
  56918. * Instantiates a new outline renderer. (There could be only one per scene).
  56919. * @param scene Defines the scene it belongs to
  56920. */
  56921. constructor(scene: Scene);
  56922. /**
  56923. * Register the component to one instance of a scene.
  56924. */
  56925. register(): void;
  56926. /**
  56927. * Rebuilds the elements related to this component in case of
  56928. * context lost for instance.
  56929. */
  56930. rebuild(): void;
  56931. /**
  56932. * Disposes the component and the associated ressources.
  56933. */
  56934. dispose(): void;
  56935. /**
  56936. * Renders the outline in the canvas.
  56937. * @param subMesh Defines the sumesh to render
  56938. * @param batch Defines the batch of meshes in case of instances
  56939. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56940. */
  56941. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56942. /**
  56943. * Returns whether or not the outline renderer is ready for a given submesh.
  56944. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56945. * @param subMesh Defines the submesh to check readyness for
  56946. * @param useInstances Defines wheter wee are trying to render instances or not
  56947. * @returns true if ready otherwise false
  56948. */
  56949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56950. private _beforeRenderingMesh;
  56951. private _afterRenderingMesh;
  56952. }
  56953. }
  56954. declare module BABYLON {
  56955. /**
  56956. * Defines the list of states available for a task inside a AssetsManager
  56957. */
  56958. export enum AssetTaskState {
  56959. /**
  56960. * Initialization
  56961. */
  56962. INIT = 0,
  56963. /**
  56964. * Running
  56965. */
  56966. RUNNING = 1,
  56967. /**
  56968. * Done
  56969. */
  56970. DONE = 2,
  56971. /**
  56972. * Error
  56973. */
  56974. ERROR = 3
  56975. }
  56976. /**
  56977. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56978. */
  56979. export abstract class AbstractAssetTask {
  56980. /**
  56981. * Task name
  56982. */ name: string;
  56983. /**
  56984. * Callback called when the task is successful
  56985. */
  56986. onSuccess: (task: any) => void;
  56987. /**
  56988. * Callback called when the task is not successful
  56989. */
  56990. onError: (task: any, message?: string, exception?: any) => void;
  56991. /**
  56992. * Creates a new AssetsManager
  56993. * @param name defines the name of the task
  56994. */
  56995. constructor(
  56996. /**
  56997. * Task name
  56998. */ name: string);
  56999. private _isCompleted;
  57000. private _taskState;
  57001. private _errorObject;
  57002. /**
  57003. * Get if the task is completed
  57004. */
  57005. readonly isCompleted: boolean;
  57006. /**
  57007. * Gets the current state of the task
  57008. */
  57009. readonly taskState: AssetTaskState;
  57010. /**
  57011. * Gets the current error object (if task is in error)
  57012. */
  57013. readonly errorObject: {
  57014. message?: string;
  57015. exception?: any;
  57016. };
  57017. /**
  57018. * Internal only
  57019. * @hidden
  57020. */ private _setErrorObject(message?: string, exception?: any): void;
  57021. /**
  57022. * Execute the current task
  57023. * @param scene defines the scene where you want your assets to be loaded
  57024. * @param onSuccess is a callback called when the task is successfully executed
  57025. * @param onError is a callback called if an error occurs
  57026. */
  57027. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57028. /**
  57029. * Execute the current task
  57030. * @param scene defines the scene where you want your assets to be loaded
  57031. * @param onSuccess is a callback called when the task is successfully executed
  57032. * @param onError is a callback called if an error occurs
  57033. */
  57034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57035. /**
  57036. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57037. * This can be used with failed tasks that have the reason for failure fixed.
  57038. */
  57039. reset(): void;
  57040. private onErrorCallback;
  57041. private onDoneCallback;
  57042. }
  57043. /**
  57044. * Define the interface used by progress events raised during assets loading
  57045. */
  57046. export interface IAssetsProgressEvent {
  57047. /**
  57048. * Defines the number of remaining tasks to process
  57049. */
  57050. remainingCount: number;
  57051. /**
  57052. * Defines the total number of tasks
  57053. */
  57054. totalCount: number;
  57055. /**
  57056. * Defines the task that was just processed
  57057. */
  57058. task: AbstractAssetTask;
  57059. }
  57060. /**
  57061. * Class used to share progress information about assets loading
  57062. */
  57063. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57064. /**
  57065. * Defines the number of remaining tasks to process
  57066. */
  57067. remainingCount: number;
  57068. /**
  57069. * Defines the total number of tasks
  57070. */
  57071. totalCount: number;
  57072. /**
  57073. * Defines the task that was just processed
  57074. */
  57075. task: AbstractAssetTask;
  57076. /**
  57077. * Creates a AssetsProgressEvent
  57078. * @param remainingCount defines the number of remaining tasks to process
  57079. * @param totalCount defines the total number of tasks
  57080. * @param task defines the task that was just processed
  57081. */
  57082. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57083. }
  57084. /**
  57085. * Define a task used by AssetsManager to load meshes
  57086. */
  57087. export class MeshAssetTask extends AbstractAssetTask {
  57088. /**
  57089. * Defines the name of the task
  57090. */
  57091. name: string;
  57092. /**
  57093. * Defines the list of mesh's names you want to load
  57094. */
  57095. meshesNames: any;
  57096. /**
  57097. * Defines the root url to use as a base to load your meshes and associated resources
  57098. */
  57099. rootUrl: string;
  57100. /**
  57101. * Defines the filename of the scene to load from
  57102. */
  57103. sceneFilename: string;
  57104. /**
  57105. * Gets the list of loaded meshes
  57106. */
  57107. loadedMeshes: Array<AbstractMesh>;
  57108. /**
  57109. * Gets the list of loaded particle systems
  57110. */
  57111. loadedParticleSystems: Array<IParticleSystem>;
  57112. /**
  57113. * Gets the list of loaded skeletons
  57114. */
  57115. loadedSkeletons: Array<Skeleton>;
  57116. /**
  57117. * Gets the list of loaded animation groups
  57118. */
  57119. loadedAnimationGroups: Array<AnimationGroup>;
  57120. /**
  57121. * Callback called when the task is successful
  57122. */
  57123. onSuccess: (task: MeshAssetTask) => void;
  57124. /**
  57125. * Callback called when the task is successful
  57126. */
  57127. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57128. /**
  57129. * Creates a new MeshAssetTask
  57130. * @param name defines the name of the task
  57131. * @param meshesNames defines the list of mesh's names you want to load
  57132. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57133. * @param sceneFilename defines the filename of the scene to load from
  57134. */
  57135. constructor(
  57136. /**
  57137. * Defines the name of the task
  57138. */
  57139. name: string,
  57140. /**
  57141. * Defines the list of mesh's names you want to load
  57142. */
  57143. meshesNames: any,
  57144. /**
  57145. * Defines the root url to use as a base to load your meshes and associated resources
  57146. */
  57147. rootUrl: string,
  57148. /**
  57149. * Defines the filename of the scene to load from
  57150. */
  57151. sceneFilename: string);
  57152. /**
  57153. * Execute the current task
  57154. * @param scene defines the scene where you want your assets to be loaded
  57155. * @param onSuccess is a callback called when the task is successfully executed
  57156. * @param onError is a callback called if an error occurs
  57157. */
  57158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57159. }
  57160. /**
  57161. * Define a task used by AssetsManager to load text content
  57162. */
  57163. export class TextFileAssetTask extends AbstractAssetTask {
  57164. /**
  57165. * Defines the name of the task
  57166. */
  57167. name: string;
  57168. /**
  57169. * Defines the location of the file to load
  57170. */
  57171. url: string;
  57172. /**
  57173. * Gets the loaded text string
  57174. */
  57175. text: string;
  57176. /**
  57177. * Callback called when the task is successful
  57178. */
  57179. onSuccess: (task: TextFileAssetTask) => void;
  57180. /**
  57181. * Callback called when the task is successful
  57182. */
  57183. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57184. /**
  57185. * Creates a new TextFileAssetTask object
  57186. * @param name defines the name of the task
  57187. * @param url defines the location of the file to load
  57188. */
  57189. constructor(
  57190. /**
  57191. * Defines the name of the task
  57192. */
  57193. name: string,
  57194. /**
  57195. * Defines the location of the file to load
  57196. */
  57197. url: string);
  57198. /**
  57199. * Execute the current task
  57200. * @param scene defines the scene where you want your assets to be loaded
  57201. * @param onSuccess is a callback called when the task is successfully executed
  57202. * @param onError is a callback called if an error occurs
  57203. */
  57204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57205. }
  57206. /**
  57207. * Define a task used by AssetsManager to load binary data
  57208. */
  57209. export class BinaryFileAssetTask extends AbstractAssetTask {
  57210. /**
  57211. * Defines the name of the task
  57212. */
  57213. name: string;
  57214. /**
  57215. * Defines the location of the file to load
  57216. */
  57217. url: string;
  57218. /**
  57219. * Gets the lodaded data (as an array buffer)
  57220. */
  57221. data: ArrayBuffer;
  57222. /**
  57223. * Callback called when the task is successful
  57224. */
  57225. onSuccess: (task: BinaryFileAssetTask) => void;
  57226. /**
  57227. * Callback called when the task is successful
  57228. */
  57229. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57230. /**
  57231. * Creates a new BinaryFileAssetTask object
  57232. * @param name defines the name of the new task
  57233. * @param url defines the location of the file to load
  57234. */
  57235. constructor(
  57236. /**
  57237. * Defines the name of the task
  57238. */
  57239. name: string,
  57240. /**
  57241. * Defines the location of the file to load
  57242. */
  57243. url: string);
  57244. /**
  57245. * Execute the current task
  57246. * @param scene defines the scene where you want your assets to be loaded
  57247. * @param onSuccess is a callback called when the task is successfully executed
  57248. * @param onError is a callback called if an error occurs
  57249. */
  57250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57251. }
  57252. /**
  57253. * Define a task used by AssetsManager to load images
  57254. */
  57255. export class ImageAssetTask extends AbstractAssetTask {
  57256. /**
  57257. * Defines the name of the task
  57258. */
  57259. name: string;
  57260. /**
  57261. * Defines the location of the image to load
  57262. */
  57263. url: string;
  57264. /**
  57265. * Gets the loaded images
  57266. */
  57267. image: HTMLImageElement;
  57268. /**
  57269. * Callback called when the task is successful
  57270. */
  57271. onSuccess: (task: ImageAssetTask) => void;
  57272. /**
  57273. * Callback called when the task is successful
  57274. */
  57275. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57276. /**
  57277. * Creates a new ImageAssetTask
  57278. * @param name defines the name of the task
  57279. * @param url defines the location of the image to load
  57280. */
  57281. constructor(
  57282. /**
  57283. * Defines the name of the task
  57284. */
  57285. name: string,
  57286. /**
  57287. * Defines the location of the image to load
  57288. */
  57289. url: string);
  57290. /**
  57291. * Execute the current task
  57292. * @param scene defines the scene where you want your assets to be loaded
  57293. * @param onSuccess is a callback called when the task is successfully executed
  57294. * @param onError is a callback called if an error occurs
  57295. */
  57296. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57297. }
  57298. /**
  57299. * Defines the interface used by texture loading tasks
  57300. */
  57301. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57302. /**
  57303. * Gets the loaded texture
  57304. */
  57305. texture: TEX;
  57306. }
  57307. /**
  57308. * Define a task used by AssetsManager to load 2D textures
  57309. */
  57310. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57311. /**
  57312. * Defines the name of the task
  57313. */
  57314. name: string;
  57315. /**
  57316. * Defines the location of the file to load
  57317. */
  57318. url: string;
  57319. /**
  57320. * Defines if mipmap should not be generated (default is false)
  57321. */
  57322. noMipmap?: boolean | undefined;
  57323. /**
  57324. * Defines if texture must be inverted on Y axis (default is false)
  57325. */
  57326. invertY?: boolean | undefined;
  57327. /**
  57328. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57329. */
  57330. samplingMode: number;
  57331. /**
  57332. * Gets the loaded texture
  57333. */
  57334. texture: Texture;
  57335. /**
  57336. * Callback called when the task is successful
  57337. */
  57338. onSuccess: (task: TextureAssetTask) => void;
  57339. /**
  57340. * Callback called when the task is successful
  57341. */
  57342. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57343. /**
  57344. * Creates a new TextureAssetTask object
  57345. * @param name defines the name of the task
  57346. * @param url defines the location of the file to load
  57347. * @param noMipmap defines if mipmap should not be generated (default is false)
  57348. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57349. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57350. */
  57351. constructor(
  57352. /**
  57353. * Defines the name of the task
  57354. */
  57355. name: string,
  57356. /**
  57357. * Defines the location of the file to load
  57358. */
  57359. url: string,
  57360. /**
  57361. * Defines if mipmap should not be generated (default is false)
  57362. */
  57363. noMipmap?: boolean | undefined,
  57364. /**
  57365. * Defines if texture must be inverted on Y axis (default is false)
  57366. */
  57367. invertY?: boolean | undefined,
  57368. /**
  57369. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57370. */
  57371. samplingMode?: number);
  57372. /**
  57373. * Execute the current task
  57374. * @param scene defines the scene where you want your assets to be loaded
  57375. * @param onSuccess is a callback called when the task is successfully executed
  57376. * @param onError is a callback called if an error occurs
  57377. */
  57378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57379. }
  57380. /**
  57381. * Define a task used by AssetsManager to load cube textures
  57382. */
  57383. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57384. /**
  57385. * Defines the name of the task
  57386. */
  57387. name: string;
  57388. /**
  57389. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57390. */
  57391. url: string;
  57392. /**
  57393. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57394. */
  57395. extensions?: string[] | undefined;
  57396. /**
  57397. * Defines if mipmaps should not be generated (default is false)
  57398. */
  57399. noMipmap?: boolean | undefined;
  57400. /**
  57401. * Defines the explicit list of files (undefined by default)
  57402. */
  57403. files?: string[] | undefined;
  57404. /**
  57405. * Gets the loaded texture
  57406. */
  57407. texture: CubeTexture;
  57408. /**
  57409. * Callback called when the task is successful
  57410. */
  57411. onSuccess: (task: CubeTextureAssetTask) => void;
  57412. /**
  57413. * Callback called when the task is successful
  57414. */
  57415. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57416. /**
  57417. * Creates a new CubeTextureAssetTask
  57418. * @param name defines the name of the task
  57419. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57420. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57422. * @param files defines the explicit list of files (undefined by default)
  57423. */
  57424. constructor(
  57425. /**
  57426. * Defines the name of the task
  57427. */
  57428. name: string,
  57429. /**
  57430. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57431. */
  57432. url: string,
  57433. /**
  57434. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57435. */
  57436. extensions?: string[] | undefined,
  57437. /**
  57438. * Defines if mipmaps should not be generated (default is false)
  57439. */
  57440. noMipmap?: boolean | undefined,
  57441. /**
  57442. * Defines the explicit list of files (undefined by default)
  57443. */
  57444. files?: string[] | undefined);
  57445. /**
  57446. * Execute the current task
  57447. * @param scene defines the scene where you want your assets to be loaded
  57448. * @param onSuccess is a callback called when the task is successfully executed
  57449. * @param onError is a callback called if an error occurs
  57450. */
  57451. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57452. }
  57453. /**
  57454. * Define a task used by AssetsManager to load HDR cube textures
  57455. */
  57456. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57457. /**
  57458. * Defines the name of the task
  57459. */
  57460. name: string;
  57461. /**
  57462. * Defines the location of the file to load
  57463. */
  57464. url: string;
  57465. /**
  57466. * Defines the desired size (the more it increases the longer the generation will be)
  57467. */
  57468. size: number;
  57469. /**
  57470. * Defines if mipmaps should not be generated (default is false)
  57471. */
  57472. noMipmap: boolean;
  57473. /**
  57474. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57475. */
  57476. generateHarmonics: boolean;
  57477. /**
  57478. * 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)
  57479. */
  57480. gammaSpace: boolean;
  57481. /**
  57482. * Internal Use Only
  57483. */
  57484. reserved: boolean;
  57485. /**
  57486. * Gets the loaded texture
  57487. */
  57488. texture: HDRCubeTexture;
  57489. /**
  57490. * Callback called when the task is successful
  57491. */
  57492. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57493. /**
  57494. * Callback called when the task is successful
  57495. */
  57496. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57497. /**
  57498. * Creates a new HDRCubeTextureAssetTask object
  57499. * @param name defines the name of the task
  57500. * @param url defines the location of the file to load
  57501. * @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.
  57502. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57503. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57504. * @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)
  57505. * @param reserved Internal use only
  57506. */
  57507. constructor(
  57508. /**
  57509. * Defines the name of the task
  57510. */
  57511. name: string,
  57512. /**
  57513. * Defines the location of the file to load
  57514. */
  57515. url: string,
  57516. /**
  57517. * Defines the desired size (the more it increases the longer the generation will be)
  57518. */
  57519. size: number,
  57520. /**
  57521. * Defines if mipmaps should not be generated (default is false)
  57522. */
  57523. noMipmap?: boolean,
  57524. /**
  57525. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57526. */
  57527. generateHarmonics?: boolean,
  57528. /**
  57529. * 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)
  57530. */
  57531. gammaSpace?: boolean,
  57532. /**
  57533. * Internal Use Only
  57534. */
  57535. reserved?: boolean);
  57536. /**
  57537. * Execute the current task
  57538. * @param scene defines the scene where you want your assets to be loaded
  57539. * @param onSuccess is a callback called when the task is successfully executed
  57540. * @param onError is a callback called if an error occurs
  57541. */
  57542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57543. }
  57544. /**
  57545. * Define a task used by AssetsManager to load Equirectangular cube textures
  57546. */
  57547. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57548. /**
  57549. * Defines the name of the task
  57550. */
  57551. name: string;
  57552. /**
  57553. * Defines the location of the file to load
  57554. */
  57555. url: string;
  57556. /**
  57557. * Defines the desired size (the more it increases the longer the generation will be)
  57558. */
  57559. size: number;
  57560. /**
  57561. * Defines if mipmaps should not be generated (default is false)
  57562. */
  57563. noMipmap: boolean;
  57564. /**
  57565. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57566. * but the standard material would require them in Gamma space) (default is true)
  57567. */
  57568. gammaSpace: boolean;
  57569. /**
  57570. * Gets the loaded texture
  57571. */
  57572. texture: EquiRectangularCubeTexture;
  57573. /**
  57574. * Callback called when the task is successful
  57575. */
  57576. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57577. /**
  57578. * Callback called when the task is successful
  57579. */
  57580. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57581. /**
  57582. * Creates a new EquiRectangularCubeTextureAssetTask object
  57583. * @param name defines the name of the task
  57584. * @param url defines the location of the file to load
  57585. * @param size defines the desired size (the more it increases the longer the generation will be)
  57586. * If the size is omitted this implies you are using a preprocessed cubemap.
  57587. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57588. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57589. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57590. * (default is true)
  57591. */
  57592. constructor(
  57593. /**
  57594. * Defines the name of the task
  57595. */
  57596. name: string,
  57597. /**
  57598. * Defines the location of the file to load
  57599. */
  57600. url: string,
  57601. /**
  57602. * Defines the desired size (the more it increases the longer the generation will be)
  57603. */
  57604. size: number,
  57605. /**
  57606. * Defines if mipmaps should not be generated (default is false)
  57607. */
  57608. noMipmap?: boolean,
  57609. /**
  57610. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57611. * but the standard material would require them in Gamma space) (default is true)
  57612. */
  57613. gammaSpace?: boolean);
  57614. /**
  57615. * Execute the current task
  57616. * @param scene defines the scene where you want your assets to be loaded
  57617. * @param onSuccess is a callback called when the task is successfully executed
  57618. * @param onError is a callback called if an error occurs
  57619. */
  57620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57621. }
  57622. /**
  57623. * This class can be used to easily import assets into a scene
  57624. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57625. */
  57626. export class AssetsManager {
  57627. private _scene;
  57628. private _isLoading;
  57629. protected _tasks: AbstractAssetTask[];
  57630. protected _waitingTasksCount: number;
  57631. protected _totalTasksCount: number;
  57632. /**
  57633. * Callback called when all tasks are processed
  57634. */
  57635. onFinish: (tasks: AbstractAssetTask[]) => void;
  57636. /**
  57637. * Callback called when a task is successful
  57638. */
  57639. onTaskSuccess: (task: AbstractAssetTask) => void;
  57640. /**
  57641. * Callback called when a task had an error
  57642. */
  57643. onTaskError: (task: AbstractAssetTask) => void;
  57644. /**
  57645. * Callback called when a task is done (whatever the result is)
  57646. */
  57647. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57648. /**
  57649. * Observable called when all tasks are processed
  57650. */
  57651. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57652. /**
  57653. * Observable called when a task had an error
  57654. */
  57655. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57656. /**
  57657. * Observable called when all tasks were executed
  57658. */
  57659. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57660. /**
  57661. * Observable called when a task is done (whatever the result is)
  57662. */
  57663. onProgressObservable: Observable<IAssetsProgressEvent>;
  57664. /**
  57665. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57666. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57667. */
  57668. useDefaultLoadingScreen: boolean;
  57669. /**
  57670. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  57671. * when all assets have been downloaded.
  57672. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  57673. */
  57674. autoHideLoadingUI: boolean;
  57675. /**
  57676. * Creates a new AssetsManager
  57677. * @param scene defines the scene to work on
  57678. */
  57679. constructor(scene: Scene);
  57680. /**
  57681. * Add a MeshAssetTask to the list of active tasks
  57682. * @param taskName defines the name of the new task
  57683. * @param meshesNames defines the name of meshes to load
  57684. * @param rootUrl defines the root url to use to locate files
  57685. * @param sceneFilename defines the filename of the scene file
  57686. * @returns a new MeshAssetTask object
  57687. */
  57688. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57689. /**
  57690. * Add a TextFileAssetTask to the list of active tasks
  57691. * @param taskName defines the name of the new task
  57692. * @param url defines the url of the file to load
  57693. * @returns a new TextFileAssetTask object
  57694. */
  57695. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57696. /**
  57697. * Add a BinaryFileAssetTask to the list of active tasks
  57698. * @param taskName defines the name of the new task
  57699. * @param url defines the url of the file to load
  57700. * @returns a new BinaryFileAssetTask object
  57701. */
  57702. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57703. /**
  57704. * Add a ImageAssetTask to the list of active tasks
  57705. * @param taskName defines the name of the new task
  57706. * @param url defines the url of the file to load
  57707. * @returns a new ImageAssetTask object
  57708. */
  57709. addImageTask(taskName: string, url: string): ImageAssetTask;
  57710. /**
  57711. * Add a TextureAssetTask to the list of active tasks
  57712. * @param taskName defines the name of the new task
  57713. * @param url defines the url of the file to load
  57714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57715. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57716. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57717. * @returns a new TextureAssetTask object
  57718. */
  57719. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57720. /**
  57721. * Add a CubeTextureAssetTask to the list of active tasks
  57722. * @param taskName defines the name of the new task
  57723. * @param url defines the url of the file to load
  57724. * @param extensions defines the extension to use to load the cube map (can be null)
  57725. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57726. * @param files defines the list of files to load (can be null)
  57727. * @returns a new CubeTextureAssetTask object
  57728. */
  57729. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57730. /**
  57731. *
  57732. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57733. * @param taskName defines the name of the new task
  57734. * @param url defines the url of the file to load
  57735. * @param size defines the size you want for the cubemap (can be null)
  57736. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57737. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57738. * @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)
  57739. * @param reserved Internal use only
  57740. * @returns a new HDRCubeTextureAssetTask object
  57741. */
  57742. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57743. /**
  57744. *
  57745. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57746. * @param taskName defines the name of the new task
  57747. * @param url defines the url of the file to load
  57748. * @param size defines the size you want for the cubemap (can be null)
  57749. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57750. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57751. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57752. * @returns a new EquiRectangularCubeTextureAssetTask object
  57753. */
  57754. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57755. /**
  57756. * Remove a task from the assets manager.
  57757. * @param task the task to remove
  57758. */
  57759. removeTask(task: AbstractAssetTask): void;
  57760. private _decreaseWaitingTasksCount;
  57761. private _runTask;
  57762. /**
  57763. * Reset the AssetsManager and remove all tasks
  57764. * @return the current instance of the AssetsManager
  57765. */
  57766. reset(): AssetsManager;
  57767. /**
  57768. * Start the loading process
  57769. * @return the current instance of the AssetsManager
  57770. */
  57771. load(): AssetsManager;
  57772. /**
  57773. * Start the loading process as an async operation
  57774. * @return a promise returning the list of failed tasks
  57775. */
  57776. loadAsync(): Promise<void>;
  57777. }
  57778. }
  57779. declare module BABYLON {
  57780. /**
  57781. * Wrapper class for promise with external resolve and reject.
  57782. */
  57783. export class Deferred<T> {
  57784. /**
  57785. * The promise associated with this deferred object.
  57786. */
  57787. readonly promise: Promise<T>;
  57788. private _resolve;
  57789. private _reject;
  57790. /**
  57791. * The resolve method of the promise associated with this deferred object.
  57792. */
  57793. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57794. /**
  57795. * The reject method of the promise associated with this deferred object.
  57796. */
  57797. readonly reject: (reason?: any) => void;
  57798. /**
  57799. * Constructor for this deferred object.
  57800. */
  57801. constructor();
  57802. }
  57803. }
  57804. declare module BABYLON {
  57805. /**
  57806. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57807. */
  57808. export class MeshExploder {
  57809. private _centerMesh;
  57810. private _meshes;
  57811. private _meshesOrigins;
  57812. private _toCenterVectors;
  57813. private _scaledDirection;
  57814. private _newPosition;
  57815. private _centerPosition;
  57816. /**
  57817. * Explodes meshes from a center mesh.
  57818. * @param meshes The meshes to explode.
  57819. * @param centerMesh The mesh to be center of explosion.
  57820. */
  57821. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57822. private _setCenterMesh;
  57823. /**
  57824. * Get class name
  57825. * @returns "MeshExploder"
  57826. */
  57827. getClassName(): string;
  57828. /**
  57829. * "Exploded meshes"
  57830. * @returns Array of meshes with the centerMesh at index 0.
  57831. */
  57832. getMeshes(): Array<Mesh>;
  57833. /**
  57834. * Explodes meshes giving a specific direction
  57835. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57836. */
  57837. explode(direction?: number): void;
  57838. }
  57839. }
  57840. declare module BABYLON {
  57841. /**
  57842. * Class used to help managing file picking and drag'n'drop
  57843. */
  57844. export class FilesInput {
  57845. /**
  57846. * List of files ready to be loaded
  57847. */
  57848. static readonly FilesToLoad: {
  57849. [key: string]: File;
  57850. };
  57851. /**
  57852. * Callback called when a file is processed
  57853. */
  57854. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57855. private _engine;
  57856. private _currentScene;
  57857. private _sceneLoadedCallback;
  57858. private _progressCallback;
  57859. private _additionalRenderLoopLogicCallback;
  57860. private _textureLoadingCallback;
  57861. private _startingProcessingFilesCallback;
  57862. private _onReloadCallback;
  57863. private _errorCallback;
  57864. private _elementToMonitor;
  57865. private _sceneFileToLoad;
  57866. private _filesToLoad;
  57867. /**
  57868. * Creates a new FilesInput
  57869. * @param engine defines the rendering engine
  57870. * @param scene defines the hosting scene
  57871. * @param sceneLoadedCallback callback called when scene is loaded
  57872. * @param progressCallback callback called to track progress
  57873. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57874. * @param textureLoadingCallback callback called when a texture is loading
  57875. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57876. * @param onReloadCallback callback called when a reload is requested
  57877. * @param errorCallback callback call if an error occurs
  57878. */
  57879. 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);
  57880. private _dragEnterHandler;
  57881. private _dragOverHandler;
  57882. private _dropHandler;
  57883. /**
  57884. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57885. * @param elementToMonitor defines the DOM element to track
  57886. */
  57887. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57888. /**
  57889. * Release all associated resources
  57890. */
  57891. dispose(): void;
  57892. private renderFunction;
  57893. private drag;
  57894. private drop;
  57895. private _traverseFolder;
  57896. private _processFiles;
  57897. /**
  57898. * Load files from a drop event
  57899. * @param event defines the drop event to use as source
  57900. */
  57901. loadFiles(event: any): void;
  57902. private _processReload;
  57903. /**
  57904. * Reload the current scene from the loaded files
  57905. */
  57906. reload(): void;
  57907. }
  57908. }
  57909. declare module BABYLON {
  57910. /**
  57911. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57913. */
  57914. export class SceneOptimization {
  57915. /**
  57916. * Defines the priority of this optimization (0 by default which means first in the list)
  57917. */
  57918. priority: number;
  57919. /**
  57920. * Gets a string describing the action executed by the current optimization
  57921. * @returns description string
  57922. */
  57923. getDescription(): string;
  57924. /**
  57925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57926. * @param scene defines the current scene where to apply this optimization
  57927. * @param optimizer defines the current optimizer
  57928. * @returns true if everything that can be done was applied
  57929. */
  57930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57931. /**
  57932. * Creates the SceneOptimization object
  57933. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57934. * @param desc defines the description associated with the optimization
  57935. */
  57936. constructor(
  57937. /**
  57938. * Defines the priority of this optimization (0 by default which means first in the list)
  57939. */
  57940. priority?: number);
  57941. }
  57942. /**
  57943. * Defines an optimization used to reduce the size of render target textures
  57944. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57945. */
  57946. export class TextureOptimization extends SceneOptimization {
  57947. /**
  57948. * Defines the priority of this optimization (0 by default which means first in the list)
  57949. */
  57950. priority: number;
  57951. /**
  57952. * 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
  57953. */
  57954. maximumSize: number;
  57955. /**
  57956. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57957. */
  57958. step: number;
  57959. /**
  57960. * Gets a string describing the action executed by the current optimization
  57961. * @returns description string
  57962. */
  57963. getDescription(): string;
  57964. /**
  57965. * Creates the TextureOptimization object
  57966. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57967. * @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
  57968. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57969. */
  57970. constructor(
  57971. /**
  57972. * Defines the priority of this optimization (0 by default which means first in the list)
  57973. */
  57974. priority?: number,
  57975. /**
  57976. * 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
  57977. */
  57978. maximumSize?: number,
  57979. /**
  57980. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57981. */
  57982. step?: number);
  57983. /**
  57984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57985. * @param scene defines the current scene where to apply this optimization
  57986. * @param optimizer defines the current optimizer
  57987. * @returns true if everything that can be done was applied
  57988. */
  57989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57990. }
  57991. /**
  57992. * Defines an optimization used to increase or decrease the rendering resolution
  57993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57994. */
  57995. export class HardwareScalingOptimization extends SceneOptimization {
  57996. /**
  57997. * Defines the priority of this optimization (0 by default which means first in the list)
  57998. */
  57999. priority: number;
  58000. /**
  58001. * Defines the maximum scale to use (2 by default)
  58002. */
  58003. maximumScale: number;
  58004. /**
  58005. * Defines the step to use between two passes (0.5 by default)
  58006. */
  58007. step: number;
  58008. private _currentScale;
  58009. private _directionOffset;
  58010. /**
  58011. * Gets a string describing the action executed by the current optimization
  58012. * @return description string
  58013. */
  58014. getDescription(): string;
  58015. /**
  58016. * Creates the HardwareScalingOptimization object
  58017. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58018. * @param maximumScale defines the maximum scale to use (2 by default)
  58019. * @param step defines the step to use between two passes (0.5 by default)
  58020. */
  58021. constructor(
  58022. /**
  58023. * Defines the priority of this optimization (0 by default which means first in the list)
  58024. */
  58025. priority?: number,
  58026. /**
  58027. * Defines the maximum scale to use (2 by default)
  58028. */
  58029. maximumScale?: number,
  58030. /**
  58031. * Defines the step to use between two passes (0.5 by default)
  58032. */
  58033. step?: number);
  58034. /**
  58035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58036. * @param scene defines the current scene where to apply this optimization
  58037. * @param optimizer defines the current optimizer
  58038. * @returns true if everything that can be done was applied
  58039. */
  58040. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58041. }
  58042. /**
  58043. * Defines an optimization used to remove shadows
  58044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58045. */
  58046. export class ShadowsOptimization extends SceneOptimization {
  58047. /**
  58048. * Gets a string describing the action executed by the current optimization
  58049. * @return description string
  58050. */
  58051. getDescription(): string;
  58052. /**
  58053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58054. * @param scene defines the current scene where to apply this optimization
  58055. * @param optimizer defines the current optimizer
  58056. * @returns true if everything that can be done was applied
  58057. */
  58058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58059. }
  58060. /**
  58061. * Defines an optimization used to turn post-processes off
  58062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58063. */
  58064. export class PostProcessesOptimization extends SceneOptimization {
  58065. /**
  58066. * Gets a string describing the action executed by the current optimization
  58067. * @return description string
  58068. */
  58069. getDescription(): string;
  58070. /**
  58071. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58072. * @param scene defines the current scene where to apply this optimization
  58073. * @param optimizer defines the current optimizer
  58074. * @returns true if everything that can be done was applied
  58075. */
  58076. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58077. }
  58078. /**
  58079. * Defines an optimization used to turn lens flares off
  58080. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58081. */
  58082. export class LensFlaresOptimization extends SceneOptimization {
  58083. /**
  58084. * Gets a string describing the action executed by the current optimization
  58085. * @return description string
  58086. */
  58087. getDescription(): string;
  58088. /**
  58089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58090. * @param scene defines the current scene where to apply this optimization
  58091. * @param optimizer defines the current optimizer
  58092. * @returns true if everything that can be done was applied
  58093. */
  58094. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58095. }
  58096. /**
  58097. * Defines an optimization based on user defined callback.
  58098. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58099. */
  58100. export class CustomOptimization extends SceneOptimization {
  58101. /**
  58102. * Callback called to apply the custom optimization.
  58103. */
  58104. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58105. /**
  58106. * Callback called to get custom description
  58107. */
  58108. onGetDescription: () => string;
  58109. /**
  58110. * Gets a string describing the action executed by the current optimization
  58111. * @returns description string
  58112. */
  58113. getDescription(): string;
  58114. /**
  58115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58116. * @param scene defines the current scene where to apply this optimization
  58117. * @param optimizer defines the current optimizer
  58118. * @returns true if everything that can be done was applied
  58119. */
  58120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58121. }
  58122. /**
  58123. * Defines an optimization used to turn particles off
  58124. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58125. */
  58126. export class ParticlesOptimization extends SceneOptimization {
  58127. /**
  58128. * Gets a string describing the action executed by the current optimization
  58129. * @return description string
  58130. */
  58131. getDescription(): string;
  58132. /**
  58133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58134. * @param scene defines the current scene where to apply this optimization
  58135. * @param optimizer defines the current optimizer
  58136. * @returns true if everything that can be done was applied
  58137. */
  58138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58139. }
  58140. /**
  58141. * Defines an optimization used to turn render targets off
  58142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58143. */
  58144. export class RenderTargetsOptimization extends SceneOptimization {
  58145. /**
  58146. * Gets a string describing the action executed by the current optimization
  58147. * @return description string
  58148. */
  58149. getDescription(): string;
  58150. /**
  58151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58152. * @param scene defines the current scene where to apply this optimization
  58153. * @param optimizer defines the current optimizer
  58154. * @returns true if everything that can be done was applied
  58155. */
  58156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58157. }
  58158. /**
  58159. * Defines an optimization used to merge meshes with compatible materials
  58160. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58161. */
  58162. export class MergeMeshesOptimization extends SceneOptimization {
  58163. private static _UpdateSelectionTree;
  58164. /**
  58165. * Gets or sets a boolean which defines if optimization octree has to be updated
  58166. */
  58167. /**
  58168. * Gets or sets a boolean which defines if optimization octree has to be updated
  58169. */
  58170. static UpdateSelectionTree: boolean;
  58171. /**
  58172. * Gets a string describing the action executed by the current optimization
  58173. * @return description string
  58174. */
  58175. getDescription(): string;
  58176. private _canBeMerged;
  58177. /**
  58178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58179. * @param scene defines the current scene where to apply this optimization
  58180. * @param optimizer defines the current optimizer
  58181. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58182. * @returns true if everything that can be done was applied
  58183. */
  58184. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58185. }
  58186. /**
  58187. * Defines a list of options used by SceneOptimizer
  58188. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58189. */
  58190. export class SceneOptimizerOptions {
  58191. /**
  58192. * Defines the target frame rate to reach (60 by default)
  58193. */
  58194. targetFrameRate: number;
  58195. /**
  58196. * Defines the interval between two checkes (2000ms by default)
  58197. */
  58198. trackerDuration: number;
  58199. /**
  58200. * Gets the list of optimizations to apply
  58201. */
  58202. optimizations: SceneOptimization[];
  58203. /**
  58204. * Creates a new list of options used by SceneOptimizer
  58205. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58206. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58207. */
  58208. constructor(
  58209. /**
  58210. * Defines the target frame rate to reach (60 by default)
  58211. */
  58212. targetFrameRate?: number,
  58213. /**
  58214. * Defines the interval between two checkes (2000ms by default)
  58215. */
  58216. trackerDuration?: number);
  58217. /**
  58218. * Add a new optimization
  58219. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58220. * @returns the current SceneOptimizerOptions
  58221. */
  58222. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58223. /**
  58224. * Add a new custom optimization
  58225. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58226. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58227. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58228. * @returns the current SceneOptimizerOptions
  58229. */
  58230. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58231. /**
  58232. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58233. * @param targetFrameRate defines the target frame rate (60 by default)
  58234. * @returns a SceneOptimizerOptions object
  58235. */
  58236. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58237. /**
  58238. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58239. * @param targetFrameRate defines the target frame rate (60 by default)
  58240. * @returns a SceneOptimizerOptions object
  58241. */
  58242. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58243. /**
  58244. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58245. * @param targetFrameRate defines the target frame rate (60 by default)
  58246. * @returns a SceneOptimizerOptions object
  58247. */
  58248. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58249. }
  58250. /**
  58251. * Class used to run optimizations in order to reach a target frame rate
  58252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58253. */
  58254. export class SceneOptimizer implements IDisposable {
  58255. private _isRunning;
  58256. private _options;
  58257. private _scene;
  58258. private _currentPriorityLevel;
  58259. private _targetFrameRate;
  58260. private _trackerDuration;
  58261. private _currentFrameRate;
  58262. private _sceneDisposeObserver;
  58263. private _improvementMode;
  58264. /**
  58265. * Defines an observable called when the optimizer reaches the target frame rate
  58266. */
  58267. onSuccessObservable: Observable<SceneOptimizer>;
  58268. /**
  58269. * Defines an observable called when the optimizer enables an optimization
  58270. */
  58271. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58272. /**
  58273. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58274. */
  58275. onFailureObservable: Observable<SceneOptimizer>;
  58276. /**
  58277. * Gets a boolean indicating if the optimizer is in improvement mode
  58278. */
  58279. readonly isInImprovementMode: boolean;
  58280. /**
  58281. * Gets the current priority level (0 at start)
  58282. */
  58283. readonly currentPriorityLevel: number;
  58284. /**
  58285. * Gets the current frame rate checked by the SceneOptimizer
  58286. */
  58287. readonly currentFrameRate: number;
  58288. /**
  58289. * Gets or sets the current target frame rate (60 by default)
  58290. */
  58291. /**
  58292. * Gets or sets the current target frame rate (60 by default)
  58293. */
  58294. targetFrameRate: number;
  58295. /**
  58296. * Gets or sets the current interval between two checks (every 2000ms by default)
  58297. */
  58298. /**
  58299. * Gets or sets the current interval between two checks (every 2000ms by default)
  58300. */
  58301. trackerDuration: number;
  58302. /**
  58303. * Gets the list of active optimizations
  58304. */
  58305. readonly optimizations: SceneOptimization[];
  58306. /**
  58307. * Creates a new SceneOptimizer
  58308. * @param scene defines the scene to work on
  58309. * @param options defines the options to use with the SceneOptimizer
  58310. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58311. * @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)
  58312. */
  58313. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58314. /**
  58315. * Stops the current optimizer
  58316. */
  58317. stop(): void;
  58318. /**
  58319. * Reset the optimizer to initial step (current priority level = 0)
  58320. */
  58321. reset(): void;
  58322. /**
  58323. * Start the optimizer. By default it will try to reach a specific framerate
  58324. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58325. */
  58326. start(): void;
  58327. private _checkCurrentState;
  58328. /**
  58329. * Release all resources
  58330. */
  58331. dispose(): void;
  58332. /**
  58333. * Helper function to create a SceneOptimizer with one single line of code
  58334. * @param scene defines the scene to work on
  58335. * @param options defines the options to use with the SceneOptimizer
  58336. * @param onSuccess defines a callback to call on success
  58337. * @param onFailure defines a callback to call on failure
  58338. * @returns the new SceneOptimizer object
  58339. */
  58340. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58341. }
  58342. }
  58343. declare module BABYLON {
  58344. /**
  58345. * Class used to serialize a scene into a string
  58346. */
  58347. export class SceneSerializer {
  58348. /**
  58349. * Clear cache used by a previous serialization
  58350. */
  58351. static ClearCache(): void;
  58352. /**
  58353. * Serialize a scene into a JSON compatible object
  58354. * @param scene defines the scene to serialize
  58355. * @returns a JSON compatible object
  58356. */
  58357. static Serialize(scene: Scene): any;
  58358. /**
  58359. * Serialize a mesh into a JSON compatible object
  58360. * @param toSerialize defines the mesh to serialize
  58361. * @param withParents defines if parents must be serialized as well
  58362. * @param withChildren defines if children must be serialized as well
  58363. * @returns a JSON compatible object
  58364. */
  58365. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58366. }
  58367. }
  58368. declare module BABYLON {
  58369. /**
  58370. * Class used to host texture specific utilities
  58371. */
  58372. export class TextureTools {
  58373. /**
  58374. * Uses the GPU to create a copy texture rescaled at a given size
  58375. * @param texture Texture to copy from
  58376. * @param width defines the desired width
  58377. * @param height defines the desired height
  58378. * @param useBilinearMode defines if bilinear mode has to be used
  58379. * @return the generated texture
  58380. */
  58381. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58382. }
  58383. }
  58384. declare module BABYLON {
  58385. /**
  58386. * This represents the different options available for the video capture.
  58387. */
  58388. export interface VideoRecorderOptions {
  58389. /** Defines the mime type of the video. */
  58390. mimeType: string;
  58391. /** Defines the FPS the video should be recorded at. */
  58392. fps: number;
  58393. /** Defines the chunk size for the recording data. */
  58394. recordChunckSize: number;
  58395. /** The audio tracks to attach to the recording. */
  58396. audioTracks?: MediaStreamTrack[];
  58397. }
  58398. /**
  58399. * This can help with recording videos from BabylonJS.
  58400. * This is based on the available WebRTC functionalities of the browser.
  58401. *
  58402. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58403. */
  58404. export class VideoRecorder {
  58405. private static readonly _defaultOptions;
  58406. /**
  58407. * Returns whether or not the VideoRecorder is available in your browser.
  58408. * @param engine Defines the Babylon Engine.
  58409. * @returns true if supported otherwise false.
  58410. */
  58411. static IsSupported(engine: Engine): boolean;
  58412. private readonly _options;
  58413. private _canvas;
  58414. private _mediaRecorder;
  58415. private _recordedChunks;
  58416. private _fileName;
  58417. private _resolve;
  58418. private _reject;
  58419. /**
  58420. * True when a recording is already in progress.
  58421. */
  58422. readonly isRecording: boolean;
  58423. /**
  58424. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  58425. * @param engine Defines the BabylonJS Engine you wish to record.
  58426. * @param options Defines options that can be used to customize the capture.
  58427. */
  58428. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58429. /**
  58430. * Stops the current recording before the default capture timeout passed in the startRecording function.
  58431. */
  58432. stopRecording(): void;
  58433. /**
  58434. * Starts recording the canvas for a max duration specified in parameters.
  58435. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  58436. * If null no automatic download will start and you can rely on the promise to get the data back.
  58437. * @param maxDuration Defines the maximum recording time in seconds.
  58438. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58439. * @return A promise callback at the end of the recording with the video data in Blob.
  58440. */
  58441. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58442. /**
  58443. * Releases internal resources used during the recording.
  58444. */
  58445. dispose(): void;
  58446. private _handleDataAvailable;
  58447. private _handleError;
  58448. private _handleStop;
  58449. }
  58450. }
  58451. declare module BABYLON {
  58452. /**
  58453. * Class containing a set of static utilities functions for screenshots
  58454. */
  58455. export class ScreenshotTools {
  58456. /**
  58457. * Captures a screenshot of the current rendering
  58458. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58459. * @param engine defines the rendering engine
  58460. * @param camera defines the source camera
  58461. * @param size This parameter can be set to a single number or to an object with the
  58462. * following (optional) properties: precision, width, height. If a single number is passed,
  58463. * it will be used for both width and height. If an object is passed, the screenshot size
  58464. * will be derived from the parameters. The precision property is a multiplier allowing
  58465. * rendering at a higher or lower resolution
  58466. * @param successCallback defines the callback receives a single parameter which contains the
  58467. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58468. * src parameter of an <img> to display it
  58469. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58470. * Check your browser for supported MIME types
  58471. */
  58472. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58473. /**
  58474. * Generates an image screenshot from the specified camera.
  58475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58476. * @param engine The engine to use for rendering
  58477. * @param camera The camera to use for rendering
  58478. * @param size This parameter can be set to a single number or to an object with the
  58479. * following (optional) properties: precision, width, height. If a single number is passed,
  58480. * it will be used for both width and height. If an object is passed, the screenshot size
  58481. * will be derived from the parameters. The precision property is a multiplier allowing
  58482. * rendering at a higher or lower resolution
  58483. * @param successCallback The callback receives a single parameter which contains the
  58484. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58485. * src parameter of an <img> to display it
  58486. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58487. * Check your browser for supported MIME types
  58488. * @param samples Texture samples (default: 1)
  58489. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58490. * @param fileName A name for for the downloaded file.
  58491. */
  58492. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58493. }
  58494. }
  58495. declare module BABYLON {
  58496. /**
  58497. * A cursor which tracks a point on a path
  58498. */
  58499. export class PathCursor {
  58500. private path;
  58501. /**
  58502. * Stores path cursor callbacks for when an onchange event is triggered
  58503. */
  58504. private _onchange;
  58505. /**
  58506. * The value of the path cursor
  58507. */
  58508. value: number;
  58509. /**
  58510. * The animation array of the path cursor
  58511. */
  58512. animations: Animation[];
  58513. /**
  58514. * Initializes the path cursor
  58515. * @param path The path to track
  58516. */
  58517. constructor(path: Path2);
  58518. /**
  58519. * Gets the cursor point on the path
  58520. * @returns A point on the path cursor at the cursor location
  58521. */
  58522. getPoint(): Vector3;
  58523. /**
  58524. * Moves the cursor ahead by the step amount
  58525. * @param step The amount to move the cursor forward
  58526. * @returns This path cursor
  58527. */
  58528. moveAhead(step?: number): PathCursor;
  58529. /**
  58530. * Moves the cursor behind by the step amount
  58531. * @param step The amount to move the cursor back
  58532. * @returns This path cursor
  58533. */
  58534. moveBack(step?: number): PathCursor;
  58535. /**
  58536. * Moves the cursor by the step amount
  58537. * If the step amount is greater than one, an exception is thrown
  58538. * @param step The amount to move the cursor
  58539. * @returns This path cursor
  58540. */
  58541. move(step: number): PathCursor;
  58542. /**
  58543. * Ensures that the value is limited between zero and one
  58544. * @returns This path cursor
  58545. */
  58546. private ensureLimits;
  58547. /**
  58548. * Runs onchange callbacks on change (used by the animation engine)
  58549. * @returns This path cursor
  58550. */
  58551. private raiseOnChange;
  58552. /**
  58553. * Executes a function on change
  58554. * @param f A path cursor onchange callback
  58555. * @returns This path cursor
  58556. */
  58557. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58558. }
  58559. }
  58560. declare module BABYLON {
  58561. /** @hidden */
  58562. export var blurPixelShader: {
  58563. name: string;
  58564. shader: string;
  58565. };
  58566. }
  58567. declare module BABYLON {
  58568. /** @hidden */
  58569. export var pointCloudVertexDeclaration: {
  58570. name: string;
  58571. shader: string;
  58572. };
  58573. }
  58574. // Mixins
  58575. interface Window {
  58576. mozIndexedDB: IDBFactory;
  58577. webkitIndexedDB: IDBFactory;
  58578. msIndexedDB: IDBFactory;
  58579. webkitURL: typeof URL;
  58580. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58581. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58582. WebGLRenderingContext: WebGLRenderingContext;
  58583. MSGesture: MSGesture;
  58584. CANNON: any;
  58585. AudioContext: AudioContext;
  58586. webkitAudioContext: AudioContext;
  58587. PointerEvent: any;
  58588. Math: Math;
  58589. Uint8Array: Uint8ArrayConstructor;
  58590. Float32Array: Float32ArrayConstructor;
  58591. mozURL: typeof URL;
  58592. msURL: typeof URL;
  58593. VRFrameData: any; // WebVR, from specs 1.1
  58594. DracoDecoderModule: any;
  58595. setImmediate(handler: (...args: any[]) => void): number;
  58596. }
  58597. interface HTMLCanvasElement {
  58598. requestPointerLock(): void;
  58599. msRequestPointerLock?(): void;
  58600. mozRequestPointerLock?(): void;
  58601. webkitRequestPointerLock?(): void;
  58602. /** Track wether a record is in progress */
  58603. isRecording: boolean;
  58604. /** Capture Stream method defined by some browsers */
  58605. captureStream(fps?: number): MediaStream;
  58606. }
  58607. interface CanvasRenderingContext2D {
  58608. msImageSmoothingEnabled: boolean;
  58609. }
  58610. interface MouseEvent {
  58611. mozMovementX: number;
  58612. mozMovementY: number;
  58613. webkitMovementX: number;
  58614. webkitMovementY: number;
  58615. msMovementX: number;
  58616. msMovementY: number;
  58617. }
  58618. interface Navigator {
  58619. mozGetVRDevices: (any: any) => any;
  58620. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58621. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58622. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58623. webkitGetGamepads(): Gamepad[];
  58624. msGetGamepads(): Gamepad[];
  58625. webkitGamepads(): Gamepad[];
  58626. }
  58627. interface HTMLVideoElement {
  58628. mozSrcObject: any;
  58629. }
  58630. interface Math {
  58631. fround(x: number): number;
  58632. imul(a: number, b: number): number;
  58633. }
  58634. interface WebGLRenderingContext {
  58635. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58636. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58637. vertexAttribDivisor(index: number, divisor: number): void;
  58638. createVertexArray(): any;
  58639. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58640. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58641. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58642. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58643. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58644. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58645. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58646. // Queries
  58647. createQuery(): WebGLQuery;
  58648. deleteQuery(query: WebGLQuery): void;
  58649. beginQuery(target: number, query: WebGLQuery): void;
  58650. endQuery(target: number): void;
  58651. getQueryParameter(query: WebGLQuery, pname: number): any;
  58652. getQuery(target: number, pname: number): any;
  58653. MAX_SAMPLES: number;
  58654. RGBA8: number;
  58655. READ_FRAMEBUFFER: number;
  58656. DRAW_FRAMEBUFFER: number;
  58657. UNIFORM_BUFFER: number;
  58658. HALF_FLOAT_OES: number;
  58659. RGBA16F: number;
  58660. RGBA32F: number;
  58661. R32F: number;
  58662. RG32F: number;
  58663. RGB32F: number;
  58664. R16F: number;
  58665. RG16F: number;
  58666. RGB16F: number;
  58667. RED: number;
  58668. RG: number;
  58669. R8: number;
  58670. RG8: number;
  58671. UNSIGNED_INT_24_8: number;
  58672. DEPTH24_STENCIL8: number;
  58673. /* Multiple Render Targets */
  58674. drawBuffers(buffers: number[]): void;
  58675. readBuffer(src: number): void;
  58676. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58677. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58678. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58679. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58680. // Occlusion Query
  58681. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58682. ANY_SAMPLES_PASSED: number;
  58683. QUERY_RESULT_AVAILABLE: number;
  58684. QUERY_RESULT: number;
  58685. }
  58686. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58687. }
  58688. interface EXT_disjoint_timer_query {
  58689. QUERY_COUNTER_BITS_EXT: number;
  58690. TIME_ELAPSED_EXT: number;
  58691. TIMESTAMP_EXT: number;
  58692. GPU_DISJOINT_EXT: number;
  58693. QUERY_RESULT_EXT: number;
  58694. QUERY_RESULT_AVAILABLE_EXT: number;
  58695. queryCounterEXT(query: WebGLQuery, target: number): void;
  58696. createQueryEXT(): WebGLQuery;
  58697. beginQueryEXT(target: number, query: WebGLQuery): void;
  58698. endQueryEXT(target: number): void;
  58699. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58700. deleteQueryEXT(query: WebGLQuery): void;
  58701. }
  58702. interface WebGLUniformLocation { private _currentState: any;
  58703. }
  58704. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58705. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58706. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58707. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58708. interface WebGLRenderingContext {
  58709. readonly RASTERIZER_DISCARD: number;
  58710. readonly DEPTH_COMPONENT24: number;
  58711. readonly TEXTURE_3D: number;
  58712. readonly TEXTURE_2D_ARRAY: number;
  58713. readonly TEXTURE_COMPARE_FUNC: number;
  58714. readonly TEXTURE_COMPARE_MODE: number;
  58715. readonly COMPARE_REF_TO_TEXTURE: number;
  58716. readonly TEXTURE_WRAP_R: number;
  58717. readonly HALF_FLOAT: number;
  58718. readonly RGB8: number;
  58719. readonly RED_INTEGER: number;
  58720. readonly RG_INTEGER: number;
  58721. readonly RGB_INTEGER: number;
  58722. readonly RGBA_INTEGER: number;
  58723. readonly R8_SNORM: number;
  58724. readonly RG8_SNORM: number;
  58725. readonly RGB8_SNORM: number;
  58726. readonly RGBA8_SNORM: number;
  58727. readonly R8I: number;
  58728. readonly RG8I: number;
  58729. readonly RGB8I: number;
  58730. readonly RGBA8I: number;
  58731. readonly R8UI: number;
  58732. readonly RG8UI: number;
  58733. readonly RGB8UI: number;
  58734. readonly RGBA8UI: number;
  58735. readonly R16I: number;
  58736. readonly RG16I: number;
  58737. readonly RGB16I: number;
  58738. readonly RGBA16I: number;
  58739. readonly R16UI: number;
  58740. readonly RG16UI: number;
  58741. readonly RGB16UI: number;
  58742. readonly RGBA16UI: number;
  58743. readonly R32I: number;
  58744. readonly RG32I: number;
  58745. readonly RGB32I: number;
  58746. readonly RGBA32I: number;
  58747. readonly R32UI: number;
  58748. readonly RG32UI: number;
  58749. readonly RGB32UI: number;
  58750. readonly RGBA32UI: number;
  58751. readonly RGB10_A2UI: number;
  58752. readonly R11F_G11F_B10F: number;
  58753. readonly RGB9_E5: number;
  58754. readonly RGB10_A2: number;
  58755. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58756. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58757. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58758. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58759. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58760. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58761. 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;
  58762. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58763. readonly TRANSFORM_FEEDBACK: number;
  58764. readonly INTERLEAVED_ATTRIBS: number;
  58765. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58766. createTransformFeedback(): WebGLTransformFeedback;
  58767. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58768. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58769. beginTransformFeedback(primitiveMode: number): void;
  58770. endTransformFeedback(): void;
  58771. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58772. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58773. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58774. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58775. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58776. }
  58777. interface ImageBitmap {
  58778. readonly width: number;
  58779. readonly height: number;
  58780. close(): void;
  58781. }
  58782. interface WebGLQuery extends WebGLObject {
  58783. }
  58784. declare var WebGLQuery: {
  58785. prototype: WebGLQuery;
  58786. new(): WebGLQuery;
  58787. };
  58788. interface WebGLSampler extends WebGLObject {
  58789. }
  58790. declare var WebGLSampler: {
  58791. prototype: WebGLSampler;
  58792. new(): WebGLSampler;
  58793. };
  58794. interface WebGLSync extends WebGLObject {
  58795. }
  58796. declare var WebGLSync: {
  58797. prototype: WebGLSync;
  58798. new(): WebGLSync;
  58799. };
  58800. interface WebGLTransformFeedback extends WebGLObject {
  58801. }
  58802. declare var WebGLTransformFeedback: {
  58803. prototype: WebGLTransformFeedback;
  58804. new(): WebGLTransformFeedback;
  58805. };
  58806. interface WebGLVertexArrayObject extends WebGLObject {
  58807. }
  58808. declare var WebGLVertexArrayObject: {
  58809. prototype: WebGLVertexArrayObject;
  58810. new(): WebGLVertexArrayObject;
  58811. };
  58812. // Type definitions for WebVR API
  58813. // Project: https://w3c.github.io/webvr/
  58814. // Definitions by: six a <https://github.com/lostfictions>
  58815. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58816. interface VRDisplay extends EventTarget {
  58817. /**
  58818. * Dictionary of capabilities describing the VRDisplay.
  58819. */
  58820. readonly capabilities: VRDisplayCapabilities;
  58821. /**
  58822. * z-depth defining the far plane of the eye view frustum
  58823. * enables mapping of values in the render target depth
  58824. * attachment to scene coordinates. Initially set to 10000.0.
  58825. */
  58826. depthFar: number;
  58827. /**
  58828. * z-depth defining the near plane of the eye view frustum
  58829. * enables mapping of values in the render target depth
  58830. * attachment to scene coordinates. Initially set to 0.01.
  58831. */
  58832. depthNear: number;
  58833. /**
  58834. * An identifier for this distinct VRDisplay. Used as an
  58835. * association point in the Gamepad API.
  58836. */
  58837. readonly displayId: number;
  58838. /**
  58839. * A display name, a user-readable name identifying it.
  58840. */
  58841. readonly displayName: string;
  58842. readonly isConnected: boolean;
  58843. readonly isPresenting: boolean;
  58844. /**
  58845. * If this VRDisplay supports room-scale experiences, the optional
  58846. * stage attribute contains details on the room-scale parameters.
  58847. */
  58848. readonly stageParameters: VRStageParameters | null;
  58849. /**
  58850. * Passing the value returned by `requestAnimationFrame` to
  58851. * `cancelAnimationFrame` will unregister the callback.
  58852. * @param handle Define the hanle of the request to cancel
  58853. */
  58854. cancelAnimationFrame(handle: number): void;
  58855. /**
  58856. * Stops presenting to the VRDisplay.
  58857. * @returns a promise to know when it stopped
  58858. */
  58859. exitPresent(): Promise<void>;
  58860. /**
  58861. * Return the current VREyeParameters for the given eye.
  58862. * @param whichEye Define the eye we want the parameter for
  58863. * @returns the eye parameters
  58864. */
  58865. getEyeParameters(whichEye: string): VREyeParameters;
  58866. /**
  58867. * Populates the passed VRFrameData with the information required to render
  58868. * the current frame.
  58869. * @param frameData Define the data structure to populate
  58870. * @returns true if ok otherwise false
  58871. */
  58872. getFrameData(frameData: VRFrameData): boolean;
  58873. /**
  58874. * Get the layers currently being presented.
  58875. * @returns the list of VR layers
  58876. */
  58877. getLayers(): VRLayer[];
  58878. /**
  58879. * Return a VRPose containing the future predicted pose of the VRDisplay
  58880. * when the current frame will be presented. The value returned will not
  58881. * change until JavaScript has returned control to the browser.
  58882. *
  58883. * The VRPose will contain the position, orientation, velocity,
  58884. * and acceleration of each of these properties.
  58885. * @returns the pose object
  58886. */
  58887. getPose(): VRPose;
  58888. /**
  58889. * Return the current instantaneous pose of the VRDisplay, with no
  58890. * prediction applied.
  58891. * @returns the current instantaneous pose
  58892. */
  58893. getImmediatePose(): VRPose;
  58894. /**
  58895. * The callback passed to `requestAnimationFrame` will be called
  58896. * any time a new frame should be rendered. When the VRDisplay is
  58897. * presenting the callback will be called at the native refresh
  58898. * rate of the HMD. When not presenting this function acts
  58899. * identically to how window.requestAnimationFrame acts. Content should
  58900. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58901. * asynchronously from other displays and at differing refresh rates.
  58902. * @param callback Define the eaction to run next frame
  58903. * @returns the request handle it
  58904. */
  58905. requestAnimationFrame(callback: FrameRequestCallback): number;
  58906. /**
  58907. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58908. * Repeat calls while already presenting will update the VRLayers being displayed.
  58909. * @param layers Define the list of layer to present
  58910. * @returns a promise to know when the request has been fulfilled
  58911. */
  58912. requestPresent(layers: VRLayer[]): Promise<void>;
  58913. /**
  58914. * Reset the pose for this display, treating its current position and
  58915. * orientation as the "origin/zero" values. VRPose.position,
  58916. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58917. * updated when calling resetPose(). This should be called in only
  58918. * sitting-space experiences.
  58919. */
  58920. resetPose(): void;
  58921. /**
  58922. * The VRLayer provided to the VRDisplay will be captured and presented
  58923. * in the HMD. Calling this function has the same effect on the source
  58924. * canvas as any other operation that uses its source image, and canvases
  58925. * created without preserveDrawingBuffer set to true will be cleared.
  58926. * @param pose Define the pose to submit
  58927. */
  58928. submitFrame(pose?: VRPose): void;
  58929. }
  58930. declare var VRDisplay: {
  58931. prototype: VRDisplay;
  58932. new(): VRDisplay;
  58933. };
  58934. interface VRLayer {
  58935. leftBounds?: number[] | Float32Array | null;
  58936. rightBounds?: number[] | Float32Array | null;
  58937. source?: HTMLCanvasElement | null;
  58938. }
  58939. interface VRDisplayCapabilities {
  58940. readonly canPresent: boolean;
  58941. readonly hasExternalDisplay: boolean;
  58942. readonly hasOrientation: boolean;
  58943. readonly hasPosition: boolean;
  58944. readonly maxLayers: number;
  58945. }
  58946. interface VREyeParameters {
  58947. /** @deprecated */
  58948. readonly fieldOfView: VRFieldOfView;
  58949. readonly offset: Float32Array;
  58950. readonly renderHeight: number;
  58951. readonly renderWidth: number;
  58952. }
  58953. interface VRFieldOfView {
  58954. readonly downDegrees: number;
  58955. readonly leftDegrees: number;
  58956. readonly rightDegrees: number;
  58957. readonly upDegrees: number;
  58958. }
  58959. interface VRFrameData {
  58960. readonly leftProjectionMatrix: Float32Array;
  58961. readonly leftViewMatrix: Float32Array;
  58962. readonly pose: VRPose;
  58963. readonly rightProjectionMatrix: Float32Array;
  58964. readonly rightViewMatrix: Float32Array;
  58965. readonly timestamp: number;
  58966. }
  58967. interface VRPose {
  58968. readonly angularAcceleration: Float32Array | null;
  58969. readonly angularVelocity: Float32Array | null;
  58970. readonly linearAcceleration: Float32Array | null;
  58971. readonly linearVelocity: Float32Array | null;
  58972. readonly orientation: Float32Array | null;
  58973. readonly position: Float32Array | null;
  58974. readonly timestamp: number;
  58975. }
  58976. interface VRStageParameters {
  58977. sittingToStandingTransform?: Float32Array;
  58978. sizeX?: number;
  58979. sizeY?: number;
  58980. }
  58981. interface Navigator {
  58982. getVRDisplays(): Promise<VRDisplay[]>;
  58983. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58984. }
  58985. interface Window {
  58986. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58987. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58988. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58989. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58990. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58991. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58992. }
  58993. interface Gamepad {
  58994. readonly displayId: number;
  58995. }
  58996. interface XRDevice {
  58997. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58998. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58999. }
  59000. interface XRSession {
  59001. getInputSources(): Array<any>;
  59002. baseLayer: XRWebGLLayer;
  59003. requestFrameOfReference(type: string): Promise<void>;
  59004. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59005. end(): Promise<void>;
  59006. requestAnimationFrame: Function;
  59007. addEventListener: Function;
  59008. }
  59009. interface XRSessionCreationOptions {
  59010. outputContext?: WebGLRenderingContext | null;
  59011. immersive?: boolean;
  59012. environmentIntegration?: boolean;
  59013. }
  59014. interface XRLayer {
  59015. getViewport: Function;
  59016. framebufferWidth: number;
  59017. framebufferHeight: number;
  59018. }
  59019. interface XRView {
  59020. projectionMatrix: Float32Array;
  59021. }
  59022. interface XRFrame {
  59023. getDevicePose: Function;
  59024. getInputPose: Function;
  59025. views: Array<XRView>;
  59026. baseLayer: XRLayer;
  59027. }
  59028. interface XRFrameOfReference {
  59029. }
  59030. interface XRWebGLLayer extends XRLayer {
  59031. framebuffer: WebGLFramebuffer;
  59032. }
  59033. declare var XRWebGLLayer: {
  59034. prototype: XRWebGLLayer;
  59035. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59036. };
  59037. declare module BABYLON.GUI {
  59038. /**
  59039. * Class used to specific a value and its associated unit
  59040. */
  59041. export class ValueAndUnit {
  59042. /** defines the unit to store */
  59043. unit: number;
  59044. /** defines a boolean indicating if the value can be negative */
  59045. negativeValueAllowed: boolean;
  59046. private _value;
  59047. private _originalUnit;
  59048. /**
  59049. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59050. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59051. */
  59052. ignoreAdaptiveScaling: boolean;
  59053. /**
  59054. * Creates a new ValueAndUnit
  59055. * @param value defines the value to store
  59056. * @param unit defines the unit to store
  59057. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59058. */
  59059. constructor(value: number,
  59060. /** defines the unit to store */
  59061. unit?: number,
  59062. /** defines a boolean indicating if the value can be negative */
  59063. negativeValueAllowed?: boolean);
  59064. /** Gets a boolean indicating if the value is a percentage */
  59065. readonly isPercentage: boolean;
  59066. /** Gets a boolean indicating if the value is store as pixel */
  59067. readonly isPixel: boolean;
  59068. /** Gets direct internal value */
  59069. readonly internalValue: number;
  59070. /**
  59071. * Gets value as pixel
  59072. * @param host defines the root host
  59073. * @param refValue defines the reference value for percentages
  59074. * @returns the value as pixel
  59075. */
  59076. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59077. /**
  59078. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59079. * @param value defines the value to store
  59080. * @param unit defines the unit to store
  59081. * @returns the current ValueAndUnit
  59082. */
  59083. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59084. /**
  59085. * Gets the value accordingly to its unit
  59086. * @param host defines the root host
  59087. * @returns the value
  59088. */
  59089. getValue(host: AdvancedDynamicTexture): number;
  59090. /**
  59091. * Gets a string representation of the value
  59092. * @param host defines the root host
  59093. * @param decimals defines an optional number of decimals to display
  59094. * @returns a string
  59095. */
  59096. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59097. /**
  59098. * Store a value parsed from a string
  59099. * @param source defines the source string
  59100. * @returns true if the value was successfully parsed
  59101. */
  59102. fromString(source: string | number): boolean;
  59103. private static _Regex;
  59104. private static _UNITMODE_PERCENTAGE;
  59105. private static _UNITMODE_PIXEL;
  59106. /** UNITMODE_PERCENTAGE */
  59107. static readonly UNITMODE_PERCENTAGE: number;
  59108. /** UNITMODE_PIXEL */
  59109. static readonly UNITMODE_PIXEL: number;
  59110. }
  59111. }
  59112. declare module BABYLON.GUI {
  59113. /**
  59114. * Define a style used by control to automatically setup properties based on a template.
  59115. * Only support font related properties so far
  59116. */
  59117. export class Style implements BABYLON.IDisposable {
  59118. private _fontFamily;
  59119. private _fontStyle;
  59120. private _fontWeight;
  59121. /** @hidden */ private _host: AdvancedDynamicTexture;
  59122. /** @hidden */ private _fontSize: ValueAndUnit;
  59123. /**
  59124. * BABYLON.Observable raised when the style values are changed
  59125. */
  59126. onChangedObservable: BABYLON.Observable<Style>;
  59127. /**
  59128. * Creates a new style object
  59129. * @param host defines the AdvancedDynamicTexture which hosts this style
  59130. */
  59131. constructor(host: AdvancedDynamicTexture);
  59132. /**
  59133. * Gets or sets the font size
  59134. */
  59135. fontSize: string | number;
  59136. /**
  59137. * Gets or sets the font family
  59138. */
  59139. fontFamily: string;
  59140. /**
  59141. * Gets or sets the font style
  59142. */
  59143. fontStyle: string;
  59144. /** Gets or sets font weight */
  59145. fontWeight: string;
  59146. /** Dispose all associated resources */
  59147. dispose(): void;
  59148. }
  59149. }
  59150. declare module BABYLON.GUI {
  59151. /**
  59152. * Class used to transport BABYLON.Vector2 information for pointer events
  59153. */
  59154. export class Vector2WithInfo extends BABYLON.Vector2 {
  59155. /** defines the current mouse button index */
  59156. buttonIndex: number;
  59157. /**
  59158. * Creates a new Vector2WithInfo
  59159. * @param source defines the vector2 data to transport
  59160. * @param buttonIndex defines the current mouse button index
  59161. */
  59162. constructor(source: BABYLON.Vector2,
  59163. /** defines the current mouse button index */
  59164. buttonIndex?: number);
  59165. }
  59166. /** Class used to provide 2D matrix features */
  59167. export class Matrix2D {
  59168. /** Gets the internal array of 6 floats used to store matrix data */
  59169. m: Float32Array;
  59170. /**
  59171. * Creates a new matrix
  59172. * @param m00 defines value for (0, 0)
  59173. * @param m01 defines value for (0, 1)
  59174. * @param m10 defines value for (1, 0)
  59175. * @param m11 defines value for (1, 1)
  59176. * @param m20 defines value for (2, 0)
  59177. * @param m21 defines value for (2, 1)
  59178. */
  59179. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59180. /**
  59181. * Fills the matrix from direct values
  59182. * @param m00 defines value for (0, 0)
  59183. * @param m01 defines value for (0, 1)
  59184. * @param m10 defines value for (1, 0)
  59185. * @param m11 defines value for (1, 1)
  59186. * @param m20 defines value for (2, 0)
  59187. * @param m21 defines value for (2, 1)
  59188. * @returns the current modified matrix
  59189. */
  59190. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59191. /**
  59192. * Gets matrix determinant
  59193. * @returns the determinant
  59194. */
  59195. determinant(): number;
  59196. /**
  59197. * Inverses the matrix and stores it in a target matrix
  59198. * @param result defines the target matrix
  59199. * @returns the current matrix
  59200. */
  59201. invertToRef(result: Matrix2D): Matrix2D;
  59202. /**
  59203. * Multiplies the current matrix with another one
  59204. * @param other defines the second operand
  59205. * @param result defines the target matrix
  59206. * @returns the current matrix
  59207. */
  59208. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59209. /**
  59210. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59211. * @param x defines the x coordinate to transform
  59212. * @param y defines the x coordinate to transform
  59213. * @param result defines the target vector2
  59214. * @returns the current matrix
  59215. */
  59216. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59217. /**
  59218. * Creates an identity matrix
  59219. * @returns a new matrix
  59220. */
  59221. static Identity(): Matrix2D;
  59222. /**
  59223. * Creates a translation matrix and stores it in a target matrix
  59224. * @param x defines the x coordinate of the translation
  59225. * @param y defines the y coordinate of the translation
  59226. * @param result defines the target matrix
  59227. */
  59228. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59229. /**
  59230. * Creates a scaling matrix and stores it in a target matrix
  59231. * @param x defines the x coordinate of the scaling
  59232. * @param y defines the y coordinate of the scaling
  59233. * @param result defines the target matrix
  59234. */
  59235. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59236. /**
  59237. * Creates a rotation matrix and stores it in a target matrix
  59238. * @param angle defines the rotation angle
  59239. * @param result defines the target matrix
  59240. */
  59241. static RotationToRef(angle: number, result: Matrix2D): void;
  59242. private static _TempPreTranslationMatrix;
  59243. private static _TempPostTranslationMatrix;
  59244. private static _TempRotationMatrix;
  59245. private static _TempScalingMatrix;
  59246. private static _TempCompose0;
  59247. private static _TempCompose1;
  59248. private static _TempCompose2;
  59249. /**
  59250. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59251. * @param tx defines the x coordinate of the translation
  59252. * @param ty defines the y coordinate of the translation
  59253. * @param angle defines the rotation angle
  59254. * @param scaleX defines the x coordinate of the scaling
  59255. * @param scaleY defines the y coordinate of the scaling
  59256. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59257. * @param result defines the target matrix
  59258. */
  59259. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59260. }
  59261. }
  59262. declare module BABYLON.GUI {
  59263. /**
  59264. * Class used to store 2D control sizes
  59265. */
  59266. export class Measure {
  59267. /** defines left coordinate */
  59268. left: number;
  59269. /** defines top coordinate */
  59270. top: number;
  59271. /** defines width dimension */
  59272. width: number;
  59273. /** defines height dimension */
  59274. height: number;
  59275. /**
  59276. * Creates a new measure
  59277. * @param left defines left coordinate
  59278. * @param top defines top coordinate
  59279. * @param width defines width dimension
  59280. * @param height defines height dimension
  59281. */
  59282. constructor(
  59283. /** defines left coordinate */
  59284. left: number,
  59285. /** defines top coordinate */
  59286. top: number,
  59287. /** defines width dimension */
  59288. width: number,
  59289. /** defines height dimension */
  59290. height: number);
  59291. /**
  59292. * Copy from another measure
  59293. * @param other defines the other measure to copy from
  59294. */
  59295. copyFrom(other: Measure): void;
  59296. /**
  59297. * Copy from a group of 4 floats
  59298. * @param left defines left coordinate
  59299. * @param top defines top coordinate
  59300. * @param width defines width dimension
  59301. * @param height defines height dimension
  59302. */
  59303. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59304. /**
  59305. * Computes the axis aligned bounding box measure for two given measures
  59306. * @param a Input measure
  59307. * @param b Input measure
  59308. * @param result the resulting bounding measure
  59309. */
  59310. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59311. /**
  59312. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59313. * @param transform the matrix to transform the measure before computing the AABB
  59314. * @param result the resulting AABB
  59315. */
  59316. transformToRef(transform: Matrix2D, result: Measure): void;
  59317. /**
  59318. * Check equality between this measure and another one
  59319. * @param other defines the other measures
  59320. * @returns true if both measures are equals
  59321. */
  59322. isEqualsTo(other: Measure): boolean;
  59323. /**
  59324. * Creates an empty measure
  59325. * @returns a new measure
  59326. */
  59327. static Empty(): Measure;
  59328. }
  59329. }
  59330. declare module BABYLON.GUI {
  59331. /**
  59332. * Interface used to define a control that can receive focus
  59333. */
  59334. export interface IFocusableControl {
  59335. /**
  59336. * Function called when the control receives the focus
  59337. */
  59338. onFocus(): void;
  59339. /**
  59340. * Function called when the control loses the focus
  59341. */
  59342. onBlur(): void;
  59343. /**
  59344. * Function called to let the control handle keyboard events
  59345. * @param evt defines the current keyboard event
  59346. */
  59347. processKeyboard(evt: KeyboardEvent): void;
  59348. /**
  59349. * Function called to get the list of controls that should not steal the focus from this control
  59350. * @returns an array of controls
  59351. */
  59352. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59353. }
  59354. /**
  59355. * Class used to create texture to support 2D GUI elements
  59356. * @see http://doc.babylonjs.com/how_to/gui
  59357. */
  59358. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59359. private _isDirty;
  59360. private _renderObserver;
  59361. private _resizeObserver;
  59362. private _preKeyboardObserver;
  59363. private _pointerMoveObserver;
  59364. private _pointerObserver;
  59365. private _canvasPointerOutObserver;
  59366. private _background;
  59367. /** @hidden */ private _rootContainer: Container;
  59368. /** @hidden */ private _lastPickedControl: Control;
  59369. /** @hidden */ private _lastControlOver: {
  59370. [pointerId: number]: Control;
  59371. };
  59372. /** @hidden */ private _lastControlDown: {
  59373. [pointerId: number]: Control;
  59374. };
  59375. /** @hidden */ private _capturingControl: {
  59376. [pointerId: number]: Control;
  59377. };
  59378. /** @hidden */ private _shouldBlockPointer: boolean;
  59379. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59380. /** @hidden */ private _linkedControls: Control[];
  59381. private _isFullscreen;
  59382. private _fullscreenViewport;
  59383. private _idealWidth;
  59384. private _idealHeight;
  59385. private _useSmallestIdeal;
  59386. private _renderAtIdealSize;
  59387. private _focusedControl;
  59388. private _blockNextFocusCheck;
  59389. private _renderScale;
  59390. private _rootCanvas;
  59391. private _cursorChanged;
  59392. /**
  59393. * Define type to string to ensure compatibility across browsers
  59394. * Safari doesn't support DataTransfer constructor
  59395. */
  59396. private _clipboardData;
  59397. /**
  59398. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59399. */
  59400. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59401. /**
  59402. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59403. */
  59404. onControlPickedObservable: BABYLON.Observable<Control>;
  59405. /**
  59406. * BABYLON.Observable event triggered before layout is evaluated
  59407. */
  59408. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59409. /**
  59410. * BABYLON.Observable event triggered after the layout was evaluated
  59411. */
  59412. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59413. /**
  59414. * BABYLON.Observable event triggered before the texture is rendered
  59415. */
  59416. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59417. /**
  59418. * BABYLON.Observable event triggered after the texture was rendered
  59419. */
  59420. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59421. /**
  59422. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59423. */
  59424. premulAlpha: boolean;
  59425. /**
  59426. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59427. * Useful when you want more antialiasing
  59428. */
  59429. renderScale: number;
  59430. /** Gets or sets the background color */
  59431. background: string;
  59432. /**
  59433. * Gets or sets the ideal width used to design controls.
  59434. * The GUI will then rescale everything accordingly
  59435. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59436. */
  59437. idealWidth: number;
  59438. /**
  59439. * Gets or sets the ideal height used to design controls.
  59440. * The GUI will then rescale everything accordingly
  59441. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59442. */
  59443. idealHeight: number;
  59444. /**
  59445. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59446. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59447. */
  59448. useSmallestIdeal: boolean;
  59449. /**
  59450. * Gets or sets a boolean indicating if adaptive scaling must be used
  59451. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59452. */
  59453. renderAtIdealSize: boolean;
  59454. /**
  59455. * Gets the underlying layer used to render the texture when in fullscreen mode
  59456. */
  59457. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59458. /**
  59459. * Gets the root container control
  59460. */
  59461. readonly rootContainer: Container;
  59462. /**
  59463. * Returns an array containing the root container.
  59464. * This is mostly used to let the Inspector introspects the ADT
  59465. * @returns an array containing the rootContainer
  59466. */
  59467. getChildren(): Array<Container>;
  59468. /**
  59469. * Will return all controls that are inside this texture
  59470. * @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
  59471. * @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
  59472. * @return all child controls
  59473. */
  59474. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59475. /**
  59476. * Gets or sets the current focused control
  59477. */
  59478. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59479. /**
  59480. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59481. */
  59482. isForeground: boolean;
  59483. /**
  59484. * Gets or set information about clipboardData
  59485. */
  59486. clipboardData: string;
  59487. /**
  59488. * Creates a new AdvancedDynamicTexture
  59489. * @param name defines the name of the texture
  59490. * @param width defines the width of the texture
  59491. * @param height defines the height of the texture
  59492. * @param scene defines the hosting scene
  59493. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59494. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59495. */
  59496. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59497. /**
  59498. * Get the current class name of the texture useful for serialization or dynamic coding.
  59499. * @returns "AdvancedDynamicTexture"
  59500. */
  59501. getClassName(): string;
  59502. /**
  59503. * Function used to execute a function on all controls
  59504. * @param func defines the function to execute
  59505. * @param container defines the container where controls belong. If null the root container will be used
  59506. */
  59507. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59508. private _useInvalidateRectOptimization;
  59509. /**
  59510. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59511. */
  59512. useInvalidateRectOptimization: boolean;
  59513. private _invalidatedRectangle;
  59514. /**
  59515. * Invalidates a rectangle area on the gui texture
  59516. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59517. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59518. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59519. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59520. */
  59521. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59522. /**
  59523. * Marks the texture as dirty forcing a complete update
  59524. */
  59525. markAsDirty(): void;
  59526. /**
  59527. * Helper function used to create a new style
  59528. * @returns a new style
  59529. * @see http://doc.babylonjs.com/how_to/gui#styles
  59530. */
  59531. createStyle(): Style;
  59532. /**
  59533. * Adds a new control to the root container
  59534. * @param control defines the control to add
  59535. * @returns the current texture
  59536. */
  59537. addControl(control: Control): AdvancedDynamicTexture;
  59538. /**
  59539. * Removes a control from the root container
  59540. * @param control defines the control to remove
  59541. * @returns the current texture
  59542. */
  59543. removeControl(control: Control): AdvancedDynamicTexture;
  59544. /**
  59545. * Release all resources
  59546. */
  59547. dispose(): void;
  59548. private _onResize;
  59549. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59550. /**
  59551. * Get screen coordinates for a vector3
  59552. * @param position defines the position to project
  59553. * @param worldMatrix defines the world matrix to use
  59554. * @returns the projected position
  59555. */
  59556. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59557. private _checkUpdate;
  59558. private _clearMeasure;
  59559. private _render;
  59560. /** @hidden */ private _changeCursor(cursor: string): void;
  59561. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  59562. private _doPicking;
  59563. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  59564. [pointerId: number]: Control;
  59565. }, control: Control): void;
  59566. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  59567. /** Attach to all scene events required to support pointer events */
  59568. attach(): void;
  59569. /** @hidden */
  59570. private onClipboardCopy;
  59571. /** @hidden */
  59572. private onClipboardCut;
  59573. /** @hidden */
  59574. private onClipboardPaste;
  59575. /**
  59576. * Register the clipboard Events onto the canvas
  59577. */
  59578. registerClipboardEvents(): void;
  59579. /**
  59580. * Unregister the clipboard Events from the canvas
  59581. */
  59582. unRegisterClipboardEvents(): void;
  59583. /**
  59584. * Connect the texture to a hosting mesh to enable interactions
  59585. * @param mesh defines the mesh to attach to
  59586. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  59587. */
  59588. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  59589. /**
  59590. * Move the focus to a specific control
  59591. * @param control defines the control which will receive the focus
  59592. */
  59593. moveFocusToControl(control: IFocusableControl): void;
  59594. private _manageFocus;
  59595. private _attachToOnPointerOut;
  59596. /**
  59597. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  59598. * @param mesh defines the mesh which will receive the texture
  59599. * @param width defines the texture width (1024 by default)
  59600. * @param height defines the texture height (1024 by default)
  59601. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  59602. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  59603. * @returns a new AdvancedDynamicTexture
  59604. */
  59605. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  59606. /**
  59607. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  59608. * In this mode the texture will rely on a layer for its rendering.
  59609. * This allows it to be treated like any other layer.
  59610. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  59611. * LayerMask is set through advancedTexture.layer.layerMask
  59612. * @param name defines name for the texture
  59613. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  59614. * @param scene defines the hsoting scene
  59615. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  59616. * @returns a new AdvancedDynamicTexture
  59617. */
  59618. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  59619. }
  59620. }
  59621. declare module BABYLON.GUI {
  59622. /**
  59623. * Root class used for all 2D controls
  59624. * @see http://doc.babylonjs.com/how_to/gui#controls
  59625. */
  59626. export class Control {
  59627. /** defines the name of the control */
  59628. name?: string | undefined;
  59629. /**
  59630. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  59631. */
  59632. static AllowAlphaInheritance: boolean;
  59633. private _alpha;
  59634. private _alphaSet;
  59635. private _zIndex;
  59636. /** @hidden */ private _host: AdvancedDynamicTexture;
  59637. /** Gets or sets the control parent */
  59638. parent: BABYLON.Nullable<Container>;
  59639. /** @hidden */ private _currentMeasure: Measure;
  59640. private _fontFamily;
  59641. private _fontStyle;
  59642. private _fontWeight;
  59643. private _fontSize;
  59644. private _font;
  59645. /** @hidden */ private _width: ValueAndUnit;
  59646. /** @hidden */ private _height: ValueAndUnit;
  59647. /** @hidden */
  59648. protected _fontOffset: {
  59649. ascent: number;
  59650. height: number;
  59651. descent: number;
  59652. };
  59653. private _color;
  59654. private _style;
  59655. private _styleObserver;
  59656. /** @hidden */
  59657. protected _horizontalAlignment: number;
  59658. /** @hidden */
  59659. protected _verticalAlignment: number;
  59660. /** @hidden */
  59661. protected _isDirty: boolean;
  59662. /** @hidden */
  59663. protected _wasDirty: boolean;
  59664. /** @hidden */ private _tempParentMeasure: Measure;
  59665. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  59666. /** @hidden */
  59667. protected _cachedParentMeasure: Measure;
  59668. private _paddingLeft;
  59669. private _paddingRight;
  59670. private _paddingTop;
  59671. private _paddingBottom;
  59672. /** @hidden */ private _left: ValueAndUnit;
  59673. /** @hidden */ private _top: ValueAndUnit;
  59674. private _scaleX;
  59675. private _scaleY;
  59676. private _rotation;
  59677. private _transformCenterX;
  59678. private _transformCenterY;
  59679. /** @hidden */ private _transformMatrix: Matrix2D;
  59680. /** @hidden */
  59681. protected _invertTransformMatrix: Matrix2D;
  59682. /** @hidden */
  59683. protected _transformedPosition: BABYLON.Vector2;
  59684. private _isMatrixDirty;
  59685. private _cachedOffsetX;
  59686. private _cachedOffsetY;
  59687. private _isVisible;
  59688. private _isHighlighted;
  59689. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59690. private _fontSet;
  59691. private _dummyVector2;
  59692. private _downCount;
  59693. private _enterCount;
  59694. private _doNotRender;
  59695. private _downPointerIds;
  59696. protected _isEnabled: boolean;
  59697. protected _disabledColor: string;
  59698. /** @hidden */
  59699. protected _rebuildLayout: boolean;
  59700. /** @hidden */ private _isClipped: boolean;
  59701. /** @hidden */ private _tag: any;
  59702. /**
  59703. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  59704. */
  59705. uniqueId: number;
  59706. /**
  59707. * Gets or sets an object used to store user defined information for the node
  59708. */
  59709. metadata: any;
  59710. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  59711. isHitTestVisible: boolean;
  59712. /** Gets or sets a boolean indicating if the control can block pointer events */
  59713. isPointerBlocker: boolean;
  59714. /** Gets or sets a boolean indicating if the control can be focusable */
  59715. isFocusInvisible: boolean;
  59716. /**
  59717. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  59718. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  59719. */
  59720. clipChildren: boolean;
  59721. /**
  59722. * Gets or sets a boolean indicating that control content must be clipped
  59723. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  59724. */
  59725. clipContent: boolean;
  59726. /**
  59727. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  59728. */
  59729. useBitmapCache: boolean;
  59730. private _cacheData;
  59731. private _shadowOffsetX;
  59732. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  59733. shadowOffsetX: number;
  59734. private _shadowOffsetY;
  59735. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  59736. shadowOffsetY: number;
  59737. private _shadowBlur;
  59738. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  59739. shadowBlur: number;
  59740. private _shadowColor;
  59741. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  59742. shadowColor: string;
  59743. /** Gets or sets the cursor to use when the control is hovered */
  59744. hoverCursor: string;
  59745. /** @hidden */
  59746. protected _linkOffsetX: ValueAndUnit;
  59747. /** @hidden */
  59748. protected _linkOffsetY: ValueAndUnit;
  59749. /** Gets the control type name */
  59750. readonly typeName: string;
  59751. /**
  59752. * Get the current class name of the control.
  59753. * @returns current class name
  59754. */
  59755. getClassName(): string;
  59756. /**
  59757. * An event triggered when the pointer move over the control.
  59758. */
  59759. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  59760. /**
  59761. * An event triggered when the pointer move out of the control.
  59762. */
  59763. onPointerOutObservable: BABYLON.Observable<Control>;
  59764. /**
  59765. * An event triggered when the pointer taps the control
  59766. */
  59767. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  59768. /**
  59769. * An event triggered when pointer up
  59770. */
  59771. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  59772. /**
  59773. * An event triggered when a control is clicked on
  59774. */
  59775. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  59776. /**
  59777. * An event triggered when pointer enters the control
  59778. */
  59779. onPointerEnterObservable: BABYLON.Observable<Control>;
  59780. /**
  59781. * An event triggered when the control is marked as dirty
  59782. */
  59783. onDirtyObservable: BABYLON.Observable<Control>;
  59784. /**
  59785. * An event triggered before drawing the control
  59786. */
  59787. onBeforeDrawObservable: BABYLON.Observable<Control>;
  59788. /**
  59789. * An event triggered after the control was drawn
  59790. */
  59791. onAfterDrawObservable: BABYLON.Observable<Control>;
  59792. /**
  59793. * Get the hosting AdvancedDynamicTexture
  59794. */
  59795. readonly host: AdvancedDynamicTexture;
  59796. /** Gets or set information about font offsets (used to render and align text) */
  59797. fontOffset: {
  59798. ascent: number;
  59799. height: number;
  59800. descent: number;
  59801. };
  59802. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  59803. alpha: number;
  59804. /**
  59805. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  59806. */
  59807. isHighlighted: boolean;
  59808. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  59809. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59810. */
  59811. scaleX: number;
  59812. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  59813. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59814. */
  59815. scaleY: number;
  59816. /** Gets or sets the rotation angle (0 by default)
  59817. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59818. */
  59819. rotation: number;
  59820. /** Gets or sets the transformation center on Y axis (0 by default)
  59821. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59822. */
  59823. transformCenterY: number;
  59824. /** Gets or sets the transformation center on X axis (0 by default)
  59825. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59826. */
  59827. transformCenterX: number;
  59828. /**
  59829. * Gets or sets the horizontal alignment
  59830. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59831. */
  59832. horizontalAlignment: number;
  59833. /**
  59834. * Gets or sets the vertical alignment
  59835. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59836. */
  59837. verticalAlignment: number;
  59838. /**
  59839. * Gets or sets control width
  59840. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59841. */
  59842. width: string | number;
  59843. /**
  59844. * Gets or sets the control width in pixel
  59845. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59846. */
  59847. widthInPixels: number;
  59848. /**
  59849. * Gets or sets control height
  59850. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59851. */
  59852. height: string | number;
  59853. /**
  59854. * Gets or sets control height in pixel
  59855. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59856. */
  59857. heightInPixels: number;
  59858. /** Gets or set font family */
  59859. fontFamily: string;
  59860. /** Gets or sets font style */
  59861. fontStyle: string;
  59862. /** Gets or sets font weight */
  59863. fontWeight: string;
  59864. /**
  59865. * Gets or sets style
  59866. * @see http://doc.babylonjs.com/how_to/gui#styles
  59867. */
  59868. style: BABYLON.Nullable<Style>;
  59869. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  59870. /** Gets or sets font size in pixels */
  59871. fontSizeInPixels: number;
  59872. /** Gets or sets font size */
  59873. fontSize: string | number;
  59874. /** Gets or sets foreground color */
  59875. color: string;
  59876. /** Gets or sets z index which is used to reorder controls on the z axis */
  59877. zIndex: number;
  59878. /** Gets or sets a boolean indicating if the control can be rendered */
  59879. notRenderable: boolean;
  59880. /** Gets or sets a boolean indicating if the control is visible */
  59881. isVisible: boolean;
  59882. /** Gets a boolean indicating that the control needs to update its rendering */
  59883. readonly isDirty: boolean;
  59884. /**
  59885. * Gets the current linked mesh (or null if none)
  59886. */
  59887. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59888. /**
  59889. * Gets or sets a value indicating the padding to use on the left of the control
  59890. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59891. */
  59892. paddingLeft: string | number;
  59893. /**
  59894. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  59895. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59896. */
  59897. paddingLeftInPixels: number;
  59898. /**
  59899. * Gets or sets a value indicating the padding to use on the right of the control
  59900. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59901. */
  59902. paddingRight: string | number;
  59903. /**
  59904. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  59905. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59906. */
  59907. paddingRightInPixels: number;
  59908. /**
  59909. * Gets or sets a value indicating the padding to use on the top of the control
  59910. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59911. */
  59912. paddingTop: string | number;
  59913. /**
  59914. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  59915. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59916. */
  59917. paddingTopInPixels: number;
  59918. /**
  59919. * Gets or sets a value indicating the padding to use on the bottom of the control
  59920. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59921. */
  59922. paddingBottom: string | number;
  59923. /**
  59924. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  59925. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59926. */
  59927. paddingBottomInPixels: number;
  59928. /**
  59929. * Gets or sets a value indicating the left coordinate of the control
  59930. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59931. */
  59932. left: string | number;
  59933. /**
  59934. * Gets or sets a value indicating the left coordinate in pixels of the control
  59935. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59936. */
  59937. leftInPixels: number;
  59938. /**
  59939. * Gets or sets a value indicating the top coordinate of the control
  59940. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59941. */
  59942. top: string | number;
  59943. /**
  59944. * Gets or sets a value indicating the top coordinate in pixels of the control
  59945. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59946. */
  59947. topInPixels: number;
  59948. /**
  59949. * Gets or sets a value indicating the offset on X axis to the linked mesh
  59950. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59951. */
  59952. linkOffsetX: string | number;
  59953. /**
  59954. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  59955. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59956. */
  59957. linkOffsetXInPixels: number;
  59958. /**
  59959. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  59960. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59961. */
  59962. linkOffsetY: string | number;
  59963. /**
  59964. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  59965. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59966. */
  59967. linkOffsetYInPixels: number;
  59968. /** Gets the center coordinate on X axis */
  59969. readonly centerX: number;
  59970. /** Gets the center coordinate on Y axis */
  59971. readonly centerY: number;
  59972. /** Gets or sets if control is Enabled*/
  59973. isEnabled: boolean;
  59974. /** Gets or sets background color of control if it's disabled*/
  59975. disabledColor: string;
  59976. /**
  59977. * Creates a new control
  59978. * @param name defines the name of the control
  59979. */
  59980. constructor(
  59981. /** defines the name of the control */
  59982. name?: string | undefined);
  59983. /** @hidden */
  59984. protected _getTypeName(): string;
  59985. /**
  59986. * Gets the first ascendant in the hierarchy of the given type
  59987. * @param className defines the required type
  59988. * @returns the ascendant or null if not found
  59989. */
  59990. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  59991. /** @hidden */ private _resetFontCache(): void;
  59992. /**
  59993. * Determines if a container is an ascendant of the current control
  59994. * @param container defines the container to look for
  59995. * @returns true if the container is one of the ascendant of the control
  59996. */
  59997. isAscendant(container: Control): boolean;
  59998. /**
  59999. * Gets coordinates in local control space
  60000. * @param globalCoordinates defines the coordinates to transform
  60001. * @returns the new coordinates in local space
  60002. */
  60003. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60004. /**
  60005. * Gets coordinates in local control space
  60006. * @param globalCoordinates defines the coordinates to transform
  60007. * @param result defines the target vector2 where to store the result
  60008. * @returns the current control
  60009. */
  60010. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60011. /**
  60012. * Gets coordinates in parent local control space
  60013. * @param globalCoordinates defines the coordinates to transform
  60014. * @returns the new coordinates in parent local space
  60015. */
  60016. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60017. /**
  60018. * Move the current control to a vector3 position projected onto the screen.
  60019. * @param position defines the target position
  60020. * @param scene defines the hosting scene
  60021. */
  60022. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60023. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60024. /**
  60025. * Will return all controls that have this control as ascendant
  60026. * @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
  60027. * @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
  60028. * @return all child controls
  60029. */
  60030. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60031. /**
  60032. * Link current control with a target mesh
  60033. * @param mesh defines the mesh to link with
  60034. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60035. */
  60036. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60037. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60038. /** @hidden */ private _offsetLeft(offset: number): void;
  60039. /** @hidden */ private _offsetTop(offset: number): void;
  60040. /** @hidden */ private _markMatrixAsDirty(): void;
  60041. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  60042. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  60043. /** @hidden */
  60044. protected invalidateRect(): void;
  60045. /** @hidden */ private _markAsDirty(force?: boolean): void;
  60046. /** @hidden */ private _markAllAsDirty(): void;
  60047. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  60048. /** @hidden */
  60049. protected _transform(context?: CanvasRenderingContext2D): void;
  60050. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  60051. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60052. /** @hidden */
  60053. protected _applyStates(context: CanvasRenderingContext2D): void;
  60054. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60055. /** @hidden */
  60056. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60057. protected _evaluateClippingState(parentMeasure: Measure): void;
  60058. /** @hidden */ private _measure(): void;
  60059. /** @hidden */
  60060. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60061. /** @hidden */
  60062. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60063. /** @hidden */
  60064. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60065. /** @hidden */
  60066. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60067. private static _ClipMeasure;
  60068. private _tmpMeasureA;
  60069. private _clip;
  60070. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60071. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60072. /**
  60073. * Tests if a given coordinates belong to the current control
  60074. * @param x defines x coordinate to test
  60075. * @param y defines y coordinate to test
  60076. * @returns true if the coordinates are inside the control
  60077. */
  60078. contains(x: number, y: number): boolean;
  60079. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60080. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60081. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  60082. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  60083. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60084. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60085. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60086. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60087. private _prepareFont;
  60088. /** Releases associated resources */
  60089. dispose(): void;
  60090. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60091. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60092. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60093. private static _VERTICAL_ALIGNMENT_TOP;
  60094. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60095. private static _VERTICAL_ALIGNMENT_CENTER;
  60096. /** HORIZONTAL_ALIGNMENT_LEFT */
  60097. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60098. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60099. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60100. /** HORIZONTAL_ALIGNMENT_CENTER */
  60101. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60102. /** VERTICAL_ALIGNMENT_TOP */
  60103. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60104. /** VERTICAL_ALIGNMENT_BOTTOM */
  60105. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60106. /** VERTICAL_ALIGNMENT_CENTER */
  60107. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60108. private static _FontHeightSizes;
  60109. /** @hidden */ private static _GetFontOffset(font: string): {
  60110. ascent: number;
  60111. height: number;
  60112. descent: number;
  60113. };
  60114. /**
  60115. * Creates a stack panel that can be used to render headers
  60116. * @param control defines the control to associate with the header
  60117. * @param text defines the text of the header
  60118. * @param size defines the size of the header
  60119. * @param options defines options used to configure the header
  60120. * @returns a new StackPanel
  60121. * @ignore
  60122. * @hidden
  60123. */
  60124. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60125. isHorizontal: boolean;
  60126. controlFirst: boolean;
  60127. }) => any;
  60128. /** @hidden */
  60129. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60130. }
  60131. }
  60132. declare module BABYLON.GUI {
  60133. /**
  60134. * Root class for 2D containers
  60135. * @see http://doc.babylonjs.com/how_to/gui#containers
  60136. */
  60137. export class Container extends Control {
  60138. name?: string | undefined;
  60139. /** @hidden */
  60140. protected _children: Control[];
  60141. /** @hidden */
  60142. protected _measureForChildren: Measure;
  60143. /** @hidden */
  60144. protected _background: string;
  60145. /** @hidden */
  60146. protected _adaptWidthToChildren: boolean;
  60147. /** @hidden */
  60148. protected _adaptHeightToChildren: boolean;
  60149. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60150. adaptHeightToChildren: boolean;
  60151. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60152. adaptWidthToChildren: boolean;
  60153. /** Gets or sets background color */
  60154. background: string;
  60155. /** Gets the list of children */
  60156. readonly children: Control[];
  60157. /**
  60158. * Creates a new Container
  60159. * @param name defines the name of the container
  60160. */
  60161. constructor(name?: string | undefined);
  60162. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  60163. /**
  60164. * Gets a child using its name
  60165. * @param name defines the child name to look for
  60166. * @returns the child control if found
  60167. */
  60168. getChildByName(name: string): BABYLON.Nullable<Control>;
  60169. /**
  60170. * Gets a child using its type and its name
  60171. * @param name defines the child name to look for
  60172. * @param type defines the child type to look for
  60173. * @returns the child control if found
  60174. */
  60175. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60176. /**
  60177. * Search for a specific control in children
  60178. * @param control defines the control to look for
  60179. * @returns true if the control is in child list
  60180. */
  60181. containsControl(control: Control): boolean;
  60182. /**
  60183. * Adds a new control to the current container
  60184. * @param control defines the control to add
  60185. * @returns the current container
  60186. */
  60187. addControl(control: BABYLON.Nullable<Control>): Container;
  60188. /**
  60189. * Removes all controls from the current container
  60190. * @returns the current container
  60191. */
  60192. clearControls(): Container;
  60193. /**
  60194. * Removes a control from the current container
  60195. * @param control defines the control to remove
  60196. * @returns the current container
  60197. */
  60198. removeControl(control: Control): Container;
  60199. /** @hidden */ private _reOrderControl(control: Control): void;
  60200. /** @hidden */ private _offsetLeft(offset: number): void;
  60201. /** @hidden */ private _offsetTop(offset: number): void;
  60202. /** @hidden */ private _markAllAsDirty(): void;
  60203. /** @hidden */
  60204. protected _localDraw(context: CanvasRenderingContext2D): void;
  60205. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  60206. /** @hidden */
  60207. protected _beforeLayout(): void;
  60208. /** @hidden */
  60209. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60210. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60211. protected _postMeasure(): void;
  60212. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60213. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60214. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60215. /** @hidden */
  60216. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60217. /** Releases associated resources */
  60218. dispose(): void;
  60219. }
  60220. }
  60221. declare module BABYLON.GUI {
  60222. /** Class used to create rectangle container */
  60223. export class Rectangle extends Container {
  60224. name?: string | undefined;
  60225. private _thickness;
  60226. private _cornerRadius;
  60227. /** Gets or sets border thickness */
  60228. thickness: number;
  60229. /** Gets or sets the corner radius angle */
  60230. cornerRadius: number;
  60231. /**
  60232. * Creates a new Rectangle
  60233. * @param name defines the control name
  60234. */
  60235. constructor(name?: string | undefined);
  60236. protected _getTypeName(): string;
  60237. protected _localDraw(context: CanvasRenderingContext2D): void;
  60238. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60239. private _drawRoundedRect;
  60240. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60241. }
  60242. }
  60243. declare module BABYLON.GUI {
  60244. /**
  60245. * Enum that determines the text-wrapping mode to use.
  60246. */
  60247. export enum TextWrapping {
  60248. /**
  60249. * Clip the text when it's larger than Control.width; this is the default mode.
  60250. */
  60251. Clip = 0,
  60252. /**
  60253. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60254. */
  60255. WordWrap = 1,
  60256. /**
  60257. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60258. */
  60259. Ellipsis = 2
  60260. }
  60261. /**
  60262. * Class used to create text block control
  60263. */
  60264. export class TextBlock extends Control {
  60265. /**
  60266. * Defines the name of the control
  60267. */
  60268. name?: string | undefined;
  60269. private _text;
  60270. private _textWrapping;
  60271. private _textHorizontalAlignment;
  60272. private _textVerticalAlignment;
  60273. private _lines;
  60274. private _resizeToFit;
  60275. private _lineSpacing;
  60276. private _outlineWidth;
  60277. private _outlineColor;
  60278. /**
  60279. * An event triggered after the text is changed
  60280. */
  60281. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60282. /**
  60283. * An event triggered after the text was broken up into lines
  60284. */
  60285. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60286. /**
  60287. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60288. */
  60289. readonly lines: any[];
  60290. /**
  60291. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60292. */
  60293. /**
  60294. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60295. */
  60296. resizeToFit: boolean;
  60297. /**
  60298. * Gets or sets a boolean indicating if text must be wrapped
  60299. */
  60300. /**
  60301. * Gets or sets a boolean indicating if text must be wrapped
  60302. */
  60303. textWrapping: TextWrapping | boolean;
  60304. /**
  60305. * Gets or sets text to display
  60306. */
  60307. /**
  60308. * Gets or sets text to display
  60309. */
  60310. text: string;
  60311. /**
  60312. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60313. */
  60314. /**
  60315. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60316. */
  60317. textHorizontalAlignment: number;
  60318. /**
  60319. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60320. */
  60321. /**
  60322. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60323. */
  60324. textVerticalAlignment: number;
  60325. /**
  60326. * Gets or sets line spacing value
  60327. */
  60328. /**
  60329. * Gets or sets line spacing value
  60330. */
  60331. lineSpacing: string | number;
  60332. /**
  60333. * Gets or sets outlineWidth of the text to display
  60334. */
  60335. /**
  60336. * Gets or sets outlineWidth of the text to display
  60337. */
  60338. outlineWidth: number;
  60339. /**
  60340. * Gets or sets outlineColor of the text to display
  60341. */
  60342. /**
  60343. * Gets or sets outlineColor of the text to display
  60344. */
  60345. outlineColor: string;
  60346. /**
  60347. * Creates a new TextBlock object
  60348. * @param name defines the name of the control
  60349. * @param text defines the text to display (emptry string by default)
  60350. */
  60351. constructor(
  60352. /**
  60353. * Defines the name of the control
  60354. */
  60355. name?: string | undefined, text?: string);
  60356. protected _getTypeName(): string;
  60357. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60358. private _drawText;
  60359. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60360. protected _applyStates(context: CanvasRenderingContext2D): void;
  60361. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60362. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60363. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60364. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60365. protected _renderLines(context: CanvasRenderingContext2D): void;
  60366. /**
  60367. * Given a width constraint applied on the text block, find the expected height
  60368. * @returns expected height
  60369. */
  60370. computeExpectedHeight(): number;
  60371. dispose(): void;
  60372. }
  60373. }
  60374. declare module BABYLON.GUI {
  60375. /**
  60376. * Class used to create 2D images
  60377. */
  60378. export class Image extends Control {
  60379. name?: string | undefined;
  60380. private static _WorkingCanvas;
  60381. private _domImage;
  60382. private _imageWidth;
  60383. private _imageHeight;
  60384. private _loaded;
  60385. private _stretch;
  60386. private _source;
  60387. private _autoScale;
  60388. private _sourceLeft;
  60389. private _sourceTop;
  60390. private _sourceWidth;
  60391. private _sourceHeight;
  60392. private _cellWidth;
  60393. private _cellHeight;
  60394. private _cellId;
  60395. private _populateNinePatchSlicesFromImage;
  60396. private _sliceLeft;
  60397. private _sliceRight;
  60398. private _sliceTop;
  60399. private _sliceBottom;
  60400. private _detectPointerOnOpaqueOnly;
  60401. /**
  60402. * BABYLON.Observable notified when the content is loaded
  60403. */
  60404. onImageLoadedObservable: BABYLON.Observable<Image>;
  60405. /**
  60406. * Gets a boolean indicating that the content is loaded
  60407. */
  60408. readonly isLoaded: boolean;
  60409. /**
  60410. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60411. */
  60412. populateNinePatchSlicesFromImage: boolean;
  60413. /**
  60414. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60415. * Beware using this as this will comsume more memory as the image has to be stored twice
  60416. */
  60417. detectPointerOnOpaqueOnly: boolean;
  60418. /**
  60419. * Gets or sets the left value for slicing (9-patch)
  60420. */
  60421. sliceLeft: number;
  60422. /**
  60423. * Gets or sets the right value for slicing (9-patch)
  60424. */
  60425. sliceRight: number;
  60426. /**
  60427. * Gets or sets the top value for slicing (9-patch)
  60428. */
  60429. sliceTop: number;
  60430. /**
  60431. * Gets or sets the bottom value for slicing (9-patch)
  60432. */
  60433. sliceBottom: number;
  60434. /**
  60435. * Gets or sets the left coordinate in the source image
  60436. */
  60437. sourceLeft: number;
  60438. /**
  60439. * Gets or sets the top coordinate in the source image
  60440. */
  60441. sourceTop: number;
  60442. /**
  60443. * Gets or sets the width to capture in the source image
  60444. */
  60445. sourceWidth: number;
  60446. /**
  60447. * Gets or sets the height to capture in the source image
  60448. */
  60449. sourceHeight: number;
  60450. /**
  60451. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60452. * @see http://doc.babylonjs.com/how_to/gui#image
  60453. */
  60454. autoScale: boolean;
  60455. /** Gets or sets the streching mode used by the image */
  60456. stretch: number;
  60457. /**
  60458. * Gets or sets the internal DOM image used to render the control
  60459. */
  60460. domImage: HTMLImageElement;
  60461. private _onImageLoaded;
  60462. private _extractNinePatchSliceDataFromImage;
  60463. /**
  60464. * Gets or sets image source url
  60465. */
  60466. source: BABYLON.Nullable<string>;
  60467. /**
  60468. * Gets or sets the cell width to use when animation sheet is enabled
  60469. * @see http://doc.babylonjs.com/how_to/gui#image
  60470. */
  60471. cellWidth: number;
  60472. /**
  60473. * Gets or sets the cell height to use when animation sheet is enabled
  60474. * @see http://doc.babylonjs.com/how_to/gui#image
  60475. */
  60476. cellHeight: number;
  60477. /**
  60478. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60479. * @see http://doc.babylonjs.com/how_to/gui#image
  60480. */
  60481. cellId: number;
  60482. /**
  60483. * Creates a new Image
  60484. * @param name defines the control name
  60485. * @param url defines the image url
  60486. */
  60487. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60488. /**
  60489. * Tests if a given coordinates belong to the current control
  60490. * @param x defines x coordinate to test
  60491. * @param y defines y coordinate to test
  60492. * @returns true if the coordinates are inside the control
  60493. */
  60494. contains(x: number, y: number): boolean;
  60495. protected _getTypeName(): string;
  60496. /** Force the control to synchronize with its content */
  60497. synchronizeSizeWithContent(): void;
  60498. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60499. private _prepareWorkingCanvasForOpaqueDetection;
  60500. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  60501. private _renderCornerPatch;
  60502. private _renderNinePatch;
  60503. dispose(): void;
  60504. /** STRETCH_NONE */
  60505. static readonly STRETCH_NONE: number;
  60506. /** STRETCH_FILL */
  60507. static readonly STRETCH_FILL: number;
  60508. /** STRETCH_UNIFORM */
  60509. static readonly STRETCH_UNIFORM: number;
  60510. /** STRETCH_EXTEND */
  60511. static readonly STRETCH_EXTEND: number;
  60512. /** NINE_PATCH */
  60513. static readonly STRETCH_NINE_PATCH: number;
  60514. }
  60515. }
  60516. declare module BABYLON.GUI {
  60517. /**
  60518. * Class used to create 2D buttons
  60519. */
  60520. export class Button extends Rectangle {
  60521. name?: string | undefined;
  60522. /**
  60523. * Function called to generate a pointer enter animation
  60524. */
  60525. pointerEnterAnimation: () => void;
  60526. /**
  60527. * Function called to generate a pointer out animation
  60528. */
  60529. pointerOutAnimation: () => void;
  60530. /**
  60531. * Function called to generate a pointer down animation
  60532. */
  60533. pointerDownAnimation: () => void;
  60534. /**
  60535. * Function called to generate a pointer up animation
  60536. */
  60537. pointerUpAnimation: () => void;
  60538. private _image;
  60539. /**
  60540. * Returns the image part of the button (if any)
  60541. */
  60542. readonly image: BABYLON.Nullable<Image>;
  60543. private _textBlock;
  60544. /**
  60545. * Returns the image part of the button (if any)
  60546. */
  60547. readonly textBlock: BABYLON.Nullable<TextBlock>;
  60548. /**
  60549. * Creates a new Button
  60550. * @param name defines the name of the button
  60551. */
  60552. constructor(name?: string | undefined);
  60553. protected _getTypeName(): string;
  60554. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60555. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  60556. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  60557. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60558. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60559. /**
  60560. * Creates a new button made with an image and a text
  60561. * @param name defines the name of the button
  60562. * @param text defines the text of the button
  60563. * @param imageUrl defines the url of the image
  60564. * @returns a new Button
  60565. */
  60566. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  60567. /**
  60568. * Creates a new button made with an image
  60569. * @param name defines the name of the button
  60570. * @param imageUrl defines the url of the image
  60571. * @returns a new Button
  60572. */
  60573. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  60574. /**
  60575. * Creates a new button made with a text
  60576. * @param name defines the name of the button
  60577. * @param text defines the text of the button
  60578. * @returns a new Button
  60579. */
  60580. static CreateSimpleButton(name: string, text: string): Button;
  60581. /**
  60582. * Creates a new button made with an image and a centered text
  60583. * @param name defines the name of the button
  60584. * @param text defines the text of the button
  60585. * @param imageUrl defines the url of the image
  60586. * @returns a new Button
  60587. */
  60588. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  60589. }
  60590. }
  60591. declare module BABYLON.GUI {
  60592. /**
  60593. * Class used to create a 2D stack panel container
  60594. */
  60595. export class StackPanel extends Container {
  60596. name?: string | undefined;
  60597. private _isVertical;
  60598. private _manualWidth;
  60599. private _manualHeight;
  60600. private _doNotTrackManualChanges;
  60601. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  60602. isVertical: boolean;
  60603. /**
  60604. * Gets or sets panel width.
  60605. * This value should not be set when in horizontal mode as it will be computed automatically
  60606. */
  60607. width: string | number;
  60608. /**
  60609. * Gets or sets panel height.
  60610. * This value should not be set when in vertical mode as it will be computed automatically
  60611. */
  60612. height: string | number;
  60613. /**
  60614. * Creates a new StackPanel
  60615. * @param name defines control name
  60616. */
  60617. constructor(name?: string | undefined);
  60618. protected _getTypeName(): string;
  60619. /** @hidden */
  60620. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60621. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60622. protected _postMeasure(): void;
  60623. }
  60624. }
  60625. declare module BABYLON.GUI {
  60626. /**
  60627. * Class used to represent a 2D checkbox
  60628. */
  60629. export class Checkbox extends Control {
  60630. name?: string | undefined;
  60631. private _isChecked;
  60632. private _background;
  60633. private _checkSizeRatio;
  60634. private _thickness;
  60635. /** Gets or sets border thickness */
  60636. thickness: number;
  60637. /**
  60638. * BABYLON.Observable raised when isChecked property changes
  60639. */
  60640. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60641. /** Gets or sets a value indicating the ratio between overall size and check size */
  60642. checkSizeRatio: number;
  60643. /** Gets or sets background color */
  60644. background: string;
  60645. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60646. isChecked: boolean;
  60647. /**
  60648. * Creates a new CheckBox
  60649. * @param name defines the control name
  60650. */
  60651. constructor(name?: string | undefined);
  60652. protected _getTypeName(): string;
  60653. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60654. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60655. /**
  60656. * Utility function to easily create a checkbox with a header
  60657. * @param title defines the label to use for the header
  60658. * @param onValueChanged defines the callback to call when value changes
  60659. * @returns a StackPanel containing the checkbox and a textBlock
  60660. */
  60661. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  60662. }
  60663. }
  60664. declare module BABYLON.GUI {
  60665. /**
  60666. * Class used to store key control properties
  60667. */
  60668. export class KeyPropertySet {
  60669. /** Width */
  60670. width?: string;
  60671. /** Height */
  60672. height?: string;
  60673. /** Left padding */
  60674. paddingLeft?: string;
  60675. /** Right padding */
  60676. paddingRight?: string;
  60677. /** Top padding */
  60678. paddingTop?: string;
  60679. /** Bottom padding */
  60680. paddingBottom?: string;
  60681. /** Foreground color */
  60682. color?: string;
  60683. /** Background color */
  60684. background?: string;
  60685. }
  60686. /**
  60687. * Class used to create virtual keyboard
  60688. */
  60689. export class VirtualKeyboard extends StackPanel {
  60690. /** BABYLON.Observable raised when a key is pressed */
  60691. onKeyPressObservable: BABYLON.Observable<string>;
  60692. /** Gets or sets default key button width */
  60693. defaultButtonWidth: string;
  60694. /** Gets or sets default key button height */
  60695. defaultButtonHeight: string;
  60696. /** Gets or sets default key button left padding */
  60697. defaultButtonPaddingLeft: string;
  60698. /** Gets or sets default key button right padding */
  60699. defaultButtonPaddingRight: string;
  60700. /** Gets or sets default key button top padding */
  60701. defaultButtonPaddingTop: string;
  60702. /** Gets or sets default key button bottom padding */
  60703. defaultButtonPaddingBottom: string;
  60704. /** Gets or sets default key button foreground color */
  60705. defaultButtonColor: string;
  60706. /** Gets or sets default key button background color */
  60707. defaultButtonBackground: string;
  60708. /** Gets or sets shift button foreground color */
  60709. shiftButtonColor: string;
  60710. /** Gets or sets shift button thickness*/
  60711. selectedShiftThickness: number;
  60712. /** Gets shift key state */
  60713. shiftState: number;
  60714. protected _getTypeName(): string;
  60715. private _createKey;
  60716. /**
  60717. * Adds a new row of keys
  60718. * @param keys defines the list of keys to add
  60719. * @param propertySets defines the associated property sets
  60720. */
  60721. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  60722. /**
  60723. * Set the shift key to a specific state
  60724. * @param shiftState defines the new shift state
  60725. */
  60726. applyShiftState(shiftState: number): void;
  60727. private _currentlyConnectedInputText;
  60728. private _connectedInputTexts;
  60729. private _onKeyPressObserver;
  60730. /** Gets the input text control currently attached to the keyboard */
  60731. readonly connectedInputText: BABYLON.Nullable<InputText>;
  60732. /**
  60733. * Connects the keyboard with an input text control
  60734. *
  60735. * @param input defines the target control
  60736. */
  60737. connect(input: InputText): void;
  60738. /**
  60739. * Disconnects the keyboard from connected InputText controls
  60740. *
  60741. * @param input optionally defines a target control, otherwise all are disconnected
  60742. */
  60743. disconnect(input?: InputText): void;
  60744. private _removeConnectedInputObservables;
  60745. /**
  60746. * Release all resources
  60747. */
  60748. dispose(): void;
  60749. /**
  60750. * Creates a new keyboard using a default layout
  60751. *
  60752. * @param name defines control name
  60753. * @returns a new VirtualKeyboard
  60754. */
  60755. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  60756. }
  60757. }
  60758. declare module BABYLON.GUI {
  60759. /**
  60760. * Class used to create input text control
  60761. */
  60762. export class InputText extends Control implements IFocusableControl {
  60763. name?: string | undefined;
  60764. private _text;
  60765. private _placeholderText;
  60766. private _background;
  60767. private _focusedBackground;
  60768. private _focusedColor;
  60769. private _placeholderColor;
  60770. private _thickness;
  60771. private _margin;
  60772. private _autoStretchWidth;
  60773. private _maxWidth;
  60774. private _isFocused;
  60775. private _blinkTimeout;
  60776. private _blinkIsEven;
  60777. private _cursorOffset;
  60778. private _scrollLeft;
  60779. private _textWidth;
  60780. private _clickedCoordinate;
  60781. private _deadKey;
  60782. private _addKey;
  60783. private _currentKey;
  60784. private _isTextHighlightOn;
  60785. private _textHighlightColor;
  60786. private _highligherOpacity;
  60787. private _highlightedText;
  60788. private _startHighlightIndex;
  60789. private _endHighlightIndex;
  60790. private _cursorIndex;
  60791. private _onFocusSelectAll;
  60792. private _isPointerDown;
  60793. private _onClipboardObserver;
  60794. private _onPointerDblTapObserver;
  60795. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  60796. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  60797. promptMessage: string;
  60798. /** BABYLON.Observable raised when the text changes */
  60799. onTextChangedObservable: BABYLON.Observable<InputText>;
  60800. /** BABYLON.Observable raised just before an entered character is to be added */
  60801. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  60802. /** BABYLON.Observable raised when the control gets the focus */
  60803. onFocusObservable: BABYLON.Observable<InputText>;
  60804. /** BABYLON.Observable raised when the control loses the focus */
  60805. onBlurObservable: BABYLON.Observable<InputText>;
  60806. /**Observable raised when the text is highlighted */
  60807. onTextHighlightObservable: BABYLON.Observable<InputText>;
  60808. /**Observable raised when copy event is triggered */
  60809. onTextCopyObservable: BABYLON.Observable<InputText>;
  60810. /** BABYLON.Observable raised when cut event is triggered */
  60811. onTextCutObservable: BABYLON.Observable<InputText>;
  60812. /** BABYLON.Observable raised when paste event is triggered */
  60813. onTextPasteObservable: BABYLON.Observable<InputText>;
  60814. /** BABYLON.Observable raised when a key event was processed */
  60815. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  60816. /** Gets or sets the maximum width allowed by the control */
  60817. maxWidth: string | number;
  60818. /** Gets the maximum width allowed by the control in pixels */
  60819. readonly maxWidthInPixels: number;
  60820. /** Gets or sets the text highlighter transparency; default: 0.4 */
  60821. highligherOpacity: number;
  60822. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  60823. onFocusSelectAll: boolean;
  60824. /** Gets or sets the text hightlight color */
  60825. textHighlightColor: string;
  60826. /** Gets or sets control margin */
  60827. margin: string;
  60828. /** Gets control margin in pixels */
  60829. readonly marginInPixels: number;
  60830. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  60831. autoStretchWidth: boolean;
  60832. /** Gets or sets border thickness */
  60833. thickness: number;
  60834. /** Gets or sets the background color when focused */
  60835. focusedBackground: string;
  60836. /** Gets or sets the background color when focused */
  60837. focusedColor: string;
  60838. /** Gets or sets the background color */
  60839. background: string;
  60840. /** Gets or sets the placeholder color */
  60841. placeholderColor: string;
  60842. /** Gets or sets the text displayed when the control is empty */
  60843. placeholderText: string;
  60844. /** Gets or sets the dead key flag */
  60845. deadKey: boolean;
  60846. /** Gets or sets the highlight text */
  60847. highlightedText: string;
  60848. /** Gets or sets if the current key should be added */
  60849. addKey: boolean;
  60850. /** Gets or sets the value of the current key being entered */
  60851. currentKey: string;
  60852. /** Gets or sets the text displayed in the control */
  60853. text: string;
  60854. /** Gets or sets control width */
  60855. width: string | number;
  60856. /**
  60857. * Creates a new InputText
  60858. * @param name defines the control name
  60859. * @param text defines the text of the control
  60860. */
  60861. constructor(name?: string | undefined, text?: string);
  60862. /** @hidden */
  60863. onBlur(): void;
  60864. /** @hidden */
  60865. onFocus(): void;
  60866. protected _getTypeName(): string;
  60867. /**
  60868. * Function called to get the list of controls that should not steal the focus from this control
  60869. * @returns an array of controls
  60870. */
  60871. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60872. /** @hidden */
  60873. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  60874. /** @hidden */
  60875. private _updateValueFromCursorIndex;
  60876. /** @hidden */
  60877. private _processDblClick;
  60878. /** @hidden */
  60879. private _selectAllText;
  60880. /**
  60881. * Handles the keyboard event
  60882. * @param evt Defines the KeyboardEvent
  60883. */
  60884. processKeyboard(evt: KeyboardEvent): void;
  60885. /** @hidden */
  60886. private _onCopyText;
  60887. /** @hidden */
  60888. private _onCutText;
  60889. /** @hidden */
  60890. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60891. protected _beforeRenderText(text: string): string;
  60892. dispose(): void;
  60893. }
  60894. }
  60895. declare module BABYLON.GUI {
  60896. /**
  60897. * Class used to create a 2D grid container
  60898. */
  60899. export class Grid extends Container {
  60900. name?: string | undefined;
  60901. private _rowDefinitions;
  60902. private _columnDefinitions;
  60903. private _cells;
  60904. private _childControls;
  60905. /**
  60906. * Gets the number of columns
  60907. */
  60908. readonly columnCount: number;
  60909. /**
  60910. * Gets the number of rows
  60911. */
  60912. readonly rowCount: number;
  60913. /** Gets the list of children */
  60914. readonly children: Control[];
  60915. /** Gets the list of cells (e.g. the containers) */
  60916. readonly cells: {
  60917. [key: string]: Container;
  60918. };
  60919. /**
  60920. * Gets the definition of a specific row
  60921. * @param index defines the index of the row
  60922. * @returns the row definition
  60923. */
  60924. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60925. /**
  60926. * Gets the definition of a specific column
  60927. * @param index defines the index of the column
  60928. * @returns the column definition
  60929. */
  60930. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60931. /**
  60932. * Adds a new row to the grid
  60933. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60934. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  60935. * @returns the current grid
  60936. */
  60937. addRowDefinition(height: number, isPixel?: boolean): Grid;
  60938. /**
  60939. * Adds a new column to the grid
  60940. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60941. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60942. * @returns the current grid
  60943. */
  60944. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  60945. /**
  60946. * Update a row definition
  60947. * @param index defines the index of the row to update
  60948. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60949. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  60950. * @returns the current grid
  60951. */
  60952. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  60953. /**
  60954. * Update a column definition
  60955. * @param index defines the index of the column to update
  60956. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60957. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60958. * @returns the current grid
  60959. */
  60960. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  60961. /**
  60962. * Gets the list of children stored in a specific cell
  60963. * @param row defines the row to check
  60964. * @param column defines the column to check
  60965. * @returns the list of controls
  60966. */
  60967. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  60968. /**
  60969. * Gets a string representing the child cell info (row x column)
  60970. * @param child defines the control to get info from
  60971. * @returns a string containing the child cell info (row x column)
  60972. */
  60973. getChildCellInfo(child: Control): string;
  60974. private _removeCell;
  60975. private _offsetCell;
  60976. /**
  60977. * Remove a column definition at specified index
  60978. * @param index defines the index of the column to remove
  60979. * @returns the current grid
  60980. */
  60981. removeColumnDefinition(index: number): Grid;
  60982. /**
  60983. * Remove a row definition at specified index
  60984. * @param index defines the index of the row to remove
  60985. * @returns the current grid
  60986. */
  60987. removeRowDefinition(index: number): Grid;
  60988. /**
  60989. * Adds a new control to the current grid
  60990. * @param control defines the control to add
  60991. * @param row defines the row where to add the control (0 by default)
  60992. * @param column defines the column where to add the control (0 by default)
  60993. * @returns the current grid
  60994. */
  60995. addControl(control: Control, row?: number, column?: number): Grid;
  60996. /**
  60997. * Removes a control from the current container
  60998. * @param control defines the control to remove
  60999. * @returns the current container
  61000. */
  61001. removeControl(control: Control): Container;
  61002. /**
  61003. * Creates a new Grid
  61004. * @param name defines control name
  61005. */
  61006. constructor(name?: string | undefined);
  61007. protected _getTypeName(): string;
  61008. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61009. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61010. /** Releases associated resources */
  61011. dispose(): void;
  61012. }
  61013. }
  61014. declare module BABYLON.GUI {
  61015. /** Class used to create color pickers */
  61016. export class ColorPicker extends Control {
  61017. name?: string | undefined;
  61018. private static _Epsilon;
  61019. private _colorWheelCanvas;
  61020. private _value;
  61021. private _tmpColor;
  61022. private _pointerStartedOnSquare;
  61023. private _pointerStartedOnWheel;
  61024. private _squareLeft;
  61025. private _squareTop;
  61026. private _squareSize;
  61027. private _h;
  61028. private _s;
  61029. private _v;
  61030. private _lastPointerDownID;
  61031. /**
  61032. * BABYLON.Observable raised when the value changes
  61033. */
  61034. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61035. /** Gets or sets the color of the color picker */
  61036. value: BABYLON.Color3;
  61037. /**
  61038. * Gets or sets control width
  61039. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61040. */
  61041. width: string | number;
  61042. /**
  61043. * Gets or sets control height
  61044. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61045. */
  61046. /** Gets or sets control height */
  61047. height: string | number;
  61048. /** Gets or sets control size */
  61049. size: string | number;
  61050. /**
  61051. * Creates a new ColorPicker
  61052. * @param name defines the control name
  61053. */
  61054. constructor(name?: string | undefined);
  61055. protected _getTypeName(): string;
  61056. /** @hidden */
  61057. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61058. private _updateSquareProps;
  61059. private _drawGradientSquare;
  61060. private _drawCircle;
  61061. private _createColorWheelCanvas;
  61062. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  61063. private _pointerIsDown;
  61064. private _updateValueFromPointer;
  61065. private _isPointOnSquare;
  61066. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61067. /**
  61068. * This function expands the color picker by creating a color picker dialog with manual
  61069. * color value input and the ability to save colors into an array to be used later in
  61070. * subsequent launches of the dialogue.
  61071. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61072. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  61073. * @returns picked color as a hex string and the saved colors array as hex strings.
  61074. */
  61075. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61076. pickerWidth?: string;
  61077. pickerHeight?: string;
  61078. headerHeight?: string;
  61079. lastColor?: string;
  61080. swatchLimit?: number;
  61081. numSwatchesPerLine?: number;
  61082. savedColors?: Array<string>;
  61083. }): Promise<{
  61084. savedColors?: string[];
  61085. pickedColor: string;
  61086. }>;
  61087. }
  61088. }
  61089. declare module BABYLON.GUI {
  61090. /** Class used to create 2D ellipse containers */
  61091. export class Ellipse extends Container {
  61092. name?: string | undefined;
  61093. private _thickness;
  61094. /** Gets or sets border thickness */
  61095. thickness: number;
  61096. /**
  61097. * Creates a new Ellipse
  61098. * @param name defines the control name
  61099. */
  61100. constructor(name?: string | undefined);
  61101. protected _getTypeName(): string;
  61102. protected _localDraw(context: CanvasRenderingContext2D): void;
  61103. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61104. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61105. }
  61106. }
  61107. declare module BABYLON.GUI {
  61108. /**
  61109. * Class used to create a password control
  61110. */
  61111. export class InputPassword extends InputText {
  61112. protected _beforeRenderText(text: string): string;
  61113. }
  61114. }
  61115. declare module BABYLON.GUI {
  61116. /** Class used to render 2D lines */
  61117. export class Line extends Control {
  61118. name?: string | undefined;
  61119. private _lineWidth;
  61120. private _x1;
  61121. private _y1;
  61122. private _x2;
  61123. private _y2;
  61124. private _dash;
  61125. private _connectedControl;
  61126. private _connectedControlDirtyObserver;
  61127. /** Gets or sets the dash pattern */
  61128. dash: Array<number>;
  61129. /** Gets or sets the control connected with the line end */
  61130. connectedControl: Control;
  61131. /** Gets or sets start coordinates on X axis */
  61132. x1: string | number;
  61133. /** Gets or sets start coordinates on Y axis */
  61134. y1: string | number;
  61135. /** Gets or sets end coordinates on X axis */
  61136. x2: string | number;
  61137. /** Gets or sets end coordinates on Y axis */
  61138. y2: string | number;
  61139. /** Gets or sets line width */
  61140. lineWidth: number;
  61141. /** Gets or sets horizontal alignment */
  61142. horizontalAlignment: number;
  61143. /** Gets or sets vertical alignment */
  61144. verticalAlignment: number;
  61145. private readonly _effectiveX2;
  61146. private readonly _effectiveY2;
  61147. /**
  61148. * Creates a new Line
  61149. * @param name defines the control name
  61150. */
  61151. constructor(name?: string | undefined);
  61152. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  61153. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61154. /**
  61155. * Move one end of the line given 3D cartesian coordinates.
  61156. * @param position Targeted world position
  61157. * @param scene BABYLON.Scene
  61158. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61159. */
  61160. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61161. /**
  61162. * Move one end of the line to a position in screen absolute space.
  61163. * @param projectedPosition Position in screen absolute space (X, Y)
  61164. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61165. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61166. }
  61167. }
  61168. declare module BABYLON.GUI {
  61169. /**
  61170. * Class used to store a point for a MultiLine object.
  61171. * The point can be pure 2D coordinates, a mesh or a control
  61172. */
  61173. export class MultiLinePoint {
  61174. private _multiLine;
  61175. private _x;
  61176. private _y;
  61177. private _control;
  61178. private _mesh;
  61179. private _controlObserver;
  61180. private _meshObserver;
  61181. /** @hidden */ private _point: BABYLON.Vector2;
  61182. /**
  61183. * Creates a new MultiLinePoint
  61184. * @param multiLine defines the source MultiLine object
  61185. */
  61186. constructor(multiLine: MultiLine);
  61187. /** Gets or sets x coordinate */
  61188. x: string | number;
  61189. /** Gets or sets y coordinate */
  61190. y: string | number;
  61191. /** Gets or sets the control associated with this point */
  61192. control: BABYLON.Nullable<Control>;
  61193. /** Gets or sets the mesh associated with this point */
  61194. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61195. /** Resets links */
  61196. resetLinks(): void;
  61197. /**
  61198. * Gets a translation vector
  61199. * @returns the translation vector
  61200. */
  61201. translate(): BABYLON.Vector2;
  61202. private _translatePoint;
  61203. /** Release associated resources */
  61204. dispose(): void;
  61205. }
  61206. }
  61207. declare module BABYLON.GUI {
  61208. /**
  61209. * Class used to create multi line control
  61210. */
  61211. export class MultiLine extends Control {
  61212. name?: string | undefined;
  61213. private _lineWidth;
  61214. private _dash;
  61215. private _points;
  61216. private _minX;
  61217. private _minY;
  61218. private _maxX;
  61219. private _maxY;
  61220. /**
  61221. * Creates a new MultiLine
  61222. * @param name defines the control name
  61223. */
  61224. constructor(name?: string | undefined);
  61225. /** Gets or sets dash pattern */
  61226. dash: Array<number>;
  61227. /**
  61228. * Gets point stored at specified index
  61229. * @param index defines the index to look for
  61230. * @returns the requested point if found
  61231. */
  61232. getAt(index: number): MultiLinePoint;
  61233. /** Function called when a point is updated */
  61234. onPointUpdate: () => void;
  61235. /**
  61236. * Adds new points to the point collection
  61237. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61238. * @returns the list of created MultiLinePoint
  61239. */
  61240. add(...items: (AbstractMesh | Control | {
  61241. x: string | number;
  61242. y: string | number;
  61243. })[]): MultiLinePoint[];
  61244. /**
  61245. * Adds a new point to the point collection
  61246. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61247. * @returns the created MultiLinePoint
  61248. */
  61249. push(item?: (AbstractMesh | Control | {
  61250. x: string | number;
  61251. y: string | number;
  61252. })): MultiLinePoint;
  61253. /**
  61254. * Remove a specific value or point from the active point collection
  61255. * @param value defines the value or point to remove
  61256. */
  61257. remove(value: number | MultiLinePoint): void;
  61258. /**
  61259. * Resets this object to initial state (no point)
  61260. */
  61261. reset(): void;
  61262. /**
  61263. * Resets all links
  61264. */
  61265. resetLinks(): void;
  61266. /** Gets or sets line width */
  61267. lineWidth: number;
  61268. horizontalAlignment: number;
  61269. verticalAlignment: number;
  61270. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61271. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  61272. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61273. dispose(): void;
  61274. }
  61275. }
  61276. declare module BABYLON.GUI {
  61277. /**
  61278. * Class used to create radio button controls
  61279. */
  61280. export class RadioButton extends Control {
  61281. name?: string | undefined;
  61282. private _isChecked;
  61283. private _background;
  61284. private _checkSizeRatio;
  61285. private _thickness;
  61286. /** Gets or sets border thickness */
  61287. thickness: number;
  61288. /** Gets or sets group name */
  61289. group: string;
  61290. /** BABYLON.Observable raised when isChecked is changed */
  61291. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61292. /** Gets or sets a value indicating the ratio between overall size and check size */
  61293. checkSizeRatio: number;
  61294. /** Gets or sets background color */
  61295. background: string;
  61296. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61297. isChecked: boolean;
  61298. /**
  61299. * Creates a new RadioButton
  61300. * @param name defines the control name
  61301. */
  61302. constructor(name?: string | undefined);
  61303. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61304. /**
  61305. * Utility function to easily create a radio button with a header
  61306. * @param title defines the label to use for the header
  61307. * @param group defines the group to use for the radio button
  61308. * @param isChecked defines the initial state of the radio button
  61309. * @param onValueChanged defines the callback to call when value changes
  61310. * @returns a StackPanel containing the radio button and a textBlock
  61311. */
  61312. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61313. }
  61314. }
  61315. declare module BABYLON.GUI {
  61316. /**
  61317. * Class used to create slider controls
  61318. */
  61319. export class BaseSlider extends Control {
  61320. name?: string | undefined;
  61321. protected _thumbWidth: ValueAndUnit;
  61322. private _minimum;
  61323. private _maximum;
  61324. private _value;
  61325. private _isVertical;
  61326. protected _barOffset: ValueAndUnit;
  61327. private _isThumbClamped;
  61328. protected _displayThumb: boolean;
  61329. private _step;
  61330. private _lastPointerDownID;
  61331. protected _effectiveBarOffset: number;
  61332. protected _renderLeft: number;
  61333. protected _renderTop: number;
  61334. protected _renderWidth: number;
  61335. protected _renderHeight: number;
  61336. protected _backgroundBoxLength: number;
  61337. protected _backgroundBoxThickness: number;
  61338. protected _effectiveThumbThickness: number;
  61339. /** BABYLON.Observable raised when the sldier value changes */
  61340. onValueChangedObservable: BABYLON.Observable<number>;
  61341. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61342. displayThumb: boolean;
  61343. /** Gets or sets a step to apply to values (0 by default) */
  61344. step: number;
  61345. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61346. barOffset: string | number;
  61347. /** Gets main bar offset in pixels*/
  61348. readonly barOffsetInPixels: number;
  61349. /** Gets or sets thumb width */
  61350. thumbWidth: string | number;
  61351. /** Gets thumb width in pixels */
  61352. readonly thumbWidthInPixels: number;
  61353. /** Gets or sets minimum value */
  61354. minimum: number;
  61355. /** Gets or sets maximum value */
  61356. maximum: number;
  61357. /** Gets or sets current value */
  61358. value: number;
  61359. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61360. isVertical: boolean;
  61361. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61362. isThumbClamped: boolean;
  61363. /**
  61364. * Creates a new BaseSlider
  61365. * @param name defines the control name
  61366. */
  61367. constructor(name?: string | undefined);
  61368. protected _getTypeName(): string;
  61369. protected _getThumbPosition(): number;
  61370. protected _getThumbThickness(type: string): number;
  61371. protected _prepareRenderingData(type: string): void;
  61372. private _pointerIsDown;
  61373. /** @hidden */
  61374. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61375. }
  61376. }
  61377. declare module BABYLON.GUI {
  61378. /**
  61379. * Class used to create slider controls
  61380. */
  61381. export class Slider extends BaseSlider {
  61382. name?: string | undefined;
  61383. private _background;
  61384. private _borderColor;
  61385. private _isThumbCircle;
  61386. protected _displayValueBar: boolean;
  61387. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61388. displayValueBar: boolean;
  61389. /** Gets or sets border color */
  61390. borderColor: string;
  61391. /** Gets or sets background color */
  61392. background: string;
  61393. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61394. isThumbCircle: boolean;
  61395. /**
  61396. * Creates a new Slider
  61397. * @param name defines the control name
  61398. */
  61399. constructor(name?: string | undefined);
  61400. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61401. }
  61402. }
  61403. declare module BABYLON.GUI {
  61404. /** Class used to create a RadioGroup
  61405. * which contains groups of radio buttons
  61406. */
  61407. export class SelectorGroup {
  61408. /** name of SelectorGroup */
  61409. name: string;
  61410. private _groupPanel;
  61411. private _selectors;
  61412. private _groupHeader;
  61413. /**
  61414. * Creates a new SelectorGroup
  61415. * @param name of group, used as a group heading
  61416. */
  61417. constructor(
  61418. /** name of SelectorGroup */
  61419. name: string);
  61420. /** Gets the groupPanel of the SelectorGroup */
  61421. readonly groupPanel: StackPanel;
  61422. /** Gets the selectors array */
  61423. readonly selectors: StackPanel[];
  61424. /** Gets and sets the group header */
  61425. header: string;
  61426. /** @hidden */
  61427. private _addGroupHeader;
  61428. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  61429. /** Removes the selector at the given position
  61430. * @param selectorNb the position of the selector within the group
  61431. */
  61432. removeSelector(selectorNb: number): void;
  61433. }
  61434. /** Class used to create a CheckboxGroup
  61435. * which contains groups of checkbox buttons
  61436. */
  61437. export class CheckboxGroup extends SelectorGroup {
  61438. /** Adds a checkbox as a control
  61439. * @param text is the label for the selector
  61440. * @param func is the function called when the Selector is checked
  61441. * @param checked is true when Selector is checked
  61442. */
  61443. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61444. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61445. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61446. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61447. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61448. }
  61449. /** Class used to create a RadioGroup
  61450. * which contains groups of radio buttons
  61451. */
  61452. export class RadioGroup extends SelectorGroup {
  61453. private _selectNb;
  61454. /** Adds a radio button as a control
  61455. * @param label is the label for the selector
  61456. * @param func is the function called when the Selector is checked
  61457. * @param checked is true when Selector is checked
  61458. */
  61459. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61460. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61461. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61462. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61463. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61464. }
  61465. /** Class used to create a SliderGroup
  61466. * which contains groups of slider buttons
  61467. */
  61468. export class SliderGroup extends SelectorGroup {
  61469. /**
  61470. * Adds a slider to the SelectorGroup
  61471. * @param label is the label for the SliderBar
  61472. * @param func is the function called when the Slider moves
  61473. * @param unit is a string describing the units used, eg degrees or metres
  61474. * @param min is the minimum value for the Slider
  61475. * @param max is the maximum value for the Slider
  61476. * @param value is the start value for the Slider between min and max
  61477. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  61478. */
  61479. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  61480. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  61481. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  61482. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  61483. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61484. }
  61485. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  61486. * @see http://doc.babylonjs.com/how_to/selector
  61487. */
  61488. export class SelectionPanel extends Rectangle {
  61489. /** name of SelectionPanel */
  61490. name: string;
  61491. /** an array of SelectionGroups */
  61492. groups: SelectorGroup[];
  61493. private _panel;
  61494. private _buttonColor;
  61495. private _buttonBackground;
  61496. private _headerColor;
  61497. private _barColor;
  61498. private _barHeight;
  61499. private _spacerHeight;
  61500. private _labelColor;
  61501. private _groups;
  61502. private _bars;
  61503. /**
  61504. * Creates a new SelectionPanel
  61505. * @param name of SelectionPanel
  61506. * @param groups is an array of SelectionGroups
  61507. */
  61508. constructor(
  61509. /** name of SelectionPanel */
  61510. name: string,
  61511. /** an array of SelectionGroups */
  61512. groups?: SelectorGroup[]);
  61513. protected _getTypeName(): string;
  61514. /** Gets or sets the headerColor */
  61515. headerColor: string;
  61516. private _setHeaderColor;
  61517. /** Gets or sets the button color */
  61518. buttonColor: string;
  61519. private _setbuttonColor;
  61520. /** Gets or sets the label color */
  61521. labelColor: string;
  61522. private _setLabelColor;
  61523. /** Gets or sets the button background */
  61524. buttonBackground: string;
  61525. private _setButtonBackground;
  61526. /** Gets or sets the color of separator bar */
  61527. barColor: string;
  61528. private _setBarColor;
  61529. /** Gets or sets the height of separator bar */
  61530. barHeight: string;
  61531. private _setBarHeight;
  61532. /** Gets or sets the height of spacers*/
  61533. spacerHeight: string;
  61534. private _setSpacerHeight;
  61535. /** Adds a bar between groups */
  61536. private _addSpacer;
  61537. /** Add a group to the selection panel
  61538. * @param group is the selector group to add
  61539. */
  61540. addGroup(group: SelectorGroup): void;
  61541. /** Remove the group from the given position
  61542. * @param groupNb is the position of the group in the list
  61543. */
  61544. removeGroup(groupNb: number): void;
  61545. /** Change a group header label
  61546. * @param label is the new group header label
  61547. * @param groupNb is the number of the group to relabel
  61548. * */
  61549. setHeaderName(label: string, groupNb: number): void;
  61550. /** Change selector label to the one given
  61551. * @param label is the new selector label
  61552. * @param groupNb is the number of the groupcontaining the selector
  61553. * @param selectorNb is the number of the selector within a group to relabel
  61554. * */
  61555. relabel(label: string, groupNb: number, selectorNb: number): void;
  61556. /** For a given group position remove the selector at the given position
  61557. * @param groupNb is the number of the group to remove the selector from
  61558. * @param selectorNb is the number of the selector within the group
  61559. */
  61560. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  61561. /** For a given group position of correct type add a checkbox button
  61562. * @param groupNb is the number of the group to remove the selector from
  61563. * @param label is the label for the selector
  61564. * @param func is the function called when the Selector is checked
  61565. * @param checked is true when Selector is checked
  61566. */
  61567. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61568. /** For a given group position of correct type add a radio button
  61569. * @param groupNb is the number of the group to remove the selector from
  61570. * @param label is the label for the selector
  61571. * @param func is the function called when the Selector is checked
  61572. * @param checked is true when Selector is checked
  61573. */
  61574. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61575. /**
  61576. * For a given slider group add a slider
  61577. * @param groupNb is the number of the group to add the slider to
  61578. * @param label is the label for the Slider
  61579. * @param func is the function called when the Slider moves
  61580. * @param unit is a string describing the units used, eg degrees or metres
  61581. * @param min is the minimum value for the Slider
  61582. * @param max is the maximum value for the Slider
  61583. * @param value is the start value for the Slider between min and max
  61584. * @param onVal is the function used to format the value displayed, eg radians to degrees
  61585. */
  61586. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  61587. }
  61588. }
  61589. declare module BABYLON.GUI {
  61590. /**
  61591. * Class used to hold a the container for ScrollViewer
  61592. * @hidden
  61593. */
  61594. export class _ScrollViewerWindow extends Container {
  61595. parentClientWidth: number;
  61596. parentClientHeight: number;
  61597. /**
  61598. * Creates a new ScrollViewerWindow
  61599. * @param name of ScrollViewerWindow
  61600. */
  61601. constructor(name?: string);
  61602. protected _getTypeName(): string;
  61603. /** @hidden */
  61604. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61605. protected _postMeasure(): void;
  61606. }
  61607. }
  61608. declare module BABYLON.GUI {
  61609. /**
  61610. * Class used to create slider controls
  61611. */
  61612. export class ScrollBar extends BaseSlider {
  61613. name?: string | undefined;
  61614. private _background;
  61615. private _borderColor;
  61616. private _thumbMeasure;
  61617. /** Gets or sets border color */
  61618. borderColor: string;
  61619. /** Gets or sets background color */
  61620. background: string;
  61621. /**
  61622. * Creates a new Slider
  61623. * @param name defines the control name
  61624. */
  61625. constructor(name?: string | undefined);
  61626. protected _getTypeName(): string;
  61627. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  61628. private _first;
  61629. private _originX;
  61630. private _originY;
  61631. /** @hidden */
  61632. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61633. }
  61634. }
  61635. declare module BABYLON.GUI {
  61636. /**
  61637. * Class used to hold a viewer window and sliders in a grid
  61638. */
  61639. export class ScrollViewer extends Rectangle {
  61640. private _grid;
  61641. private _horizontalBarSpace;
  61642. private _verticalBarSpace;
  61643. private _dragSpace;
  61644. private _horizontalBar;
  61645. private _verticalBar;
  61646. private _barColor;
  61647. private _barBackground;
  61648. private _barSize;
  61649. private _endLeft;
  61650. private _endTop;
  61651. private _window;
  61652. private _pointerIsOver;
  61653. private _wheelPrecision;
  61654. private _onPointerObserver;
  61655. private _clientWidth;
  61656. private _clientHeight;
  61657. /**
  61658. * Gets the horizontal scrollbar
  61659. */
  61660. readonly horizontalBar: ScrollBar;
  61661. /**
  61662. * Gets the vertical scrollbar
  61663. */
  61664. readonly verticalBar: ScrollBar;
  61665. /**
  61666. * Adds a new control to the current container
  61667. * @param control defines the control to add
  61668. * @returns the current container
  61669. */
  61670. addControl(control: BABYLON.Nullable<Control>): Container;
  61671. /**
  61672. * Removes a control from the current container
  61673. * @param control defines the control to remove
  61674. * @returns the current container
  61675. */
  61676. removeControl(control: Control): Container;
  61677. /** Gets the list of children */
  61678. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  61679. /**
  61680. * Creates a new ScrollViewer
  61681. * @param name of ScrollViewer
  61682. */
  61683. constructor(name?: string);
  61684. /** Reset the scroll viewer window to initial size */
  61685. resetWindow(): void;
  61686. protected _getTypeName(): string;
  61687. private _buildClientSizes;
  61688. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61689. protected _postMeasure(): void;
  61690. /**
  61691. * Gets or sets the mouse wheel precision
  61692. * from 0 to 1 with a default value of 0.05
  61693. * */
  61694. wheelPrecision: number;
  61695. /** Gets or sets the bar color */
  61696. barColor: string;
  61697. /** Gets or sets the size of the bar */
  61698. barSize: number;
  61699. /** Gets or sets the bar background */
  61700. barBackground: string;
  61701. /** @hidden */
  61702. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  61703. /** @hidden */
  61704. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61705. /** Releases associated resources */
  61706. dispose(): void;
  61707. }
  61708. }
  61709. declare module BABYLON.GUI {
  61710. /** Class used to render a grid */
  61711. export class DisplayGrid extends Control {
  61712. name?: string | undefined;
  61713. private _cellWidth;
  61714. private _cellHeight;
  61715. private _minorLineTickness;
  61716. private _minorLineColor;
  61717. private _majorLineTickness;
  61718. private _majorLineColor;
  61719. private _majorLineFrequency;
  61720. private _background;
  61721. private _displayMajorLines;
  61722. private _displayMinorLines;
  61723. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  61724. displayMinorLines: boolean;
  61725. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  61726. displayMajorLines: boolean;
  61727. /** Gets or sets background color (Black by default) */
  61728. background: string;
  61729. /** Gets or sets the width of each cell (20 by default) */
  61730. cellWidth: number;
  61731. /** Gets or sets the height of each cell (20 by default) */
  61732. cellHeight: number;
  61733. /** Gets or sets the tickness of minor lines (1 by default) */
  61734. minorLineTickness: number;
  61735. /** Gets or sets the color of minor lines (DarkGray by default) */
  61736. minorLineColor: string;
  61737. /** Gets or sets the tickness of major lines (2 by default) */
  61738. majorLineTickness: number;
  61739. /** Gets or sets the color of major lines (White by default) */
  61740. majorLineColor: string;
  61741. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  61742. majorLineFrequency: number;
  61743. /**
  61744. * Creates a new GridDisplayRectangle
  61745. * @param name defines the control name
  61746. */
  61747. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  61748. protected _getTypeName(): string;
  61749. }
  61750. }
  61751. declare module BABYLON.GUI {
  61752. /**
  61753. * Class used to create slider controls based on images
  61754. */
  61755. export class ImageBasedSlider extends BaseSlider {
  61756. name?: string | undefined;
  61757. private _backgroundImage;
  61758. private _thumbImage;
  61759. private _valueBarImage;
  61760. private _tempMeasure;
  61761. displayThumb: boolean;
  61762. /**
  61763. * Gets or sets the image used to render the background
  61764. */
  61765. backgroundImage: Image;
  61766. /**
  61767. * Gets or sets the image used to render the value bar
  61768. */
  61769. valueBarImage: Image;
  61770. /**
  61771. * Gets or sets the image used to render the thumb
  61772. */
  61773. thumbImage: Image;
  61774. /**
  61775. * Creates a new ImageBasedSlider
  61776. * @param name defines the control name
  61777. */
  61778. constructor(name?: string | undefined);
  61779. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  61780. }
  61781. }
  61782. declare module BABYLON.GUI {
  61783. /**
  61784. * Forcing an export so that this code will execute
  61785. * @hidden
  61786. */
  61787. const name = "Statics";
  61788. }
  61789. declare module BABYLON.GUI {
  61790. /**
  61791. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  61792. */
  61793. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  61794. /**
  61795. * Define the instrumented AdvancedDynamicTexture.
  61796. */
  61797. texture: AdvancedDynamicTexture;
  61798. private _captureRenderTime;
  61799. private _renderTime;
  61800. private _captureLayoutTime;
  61801. private _layoutTime;
  61802. private _onBeginRenderObserver;
  61803. private _onEndRenderObserver;
  61804. private _onBeginLayoutObserver;
  61805. private _onEndLayoutObserver;
  61806. /**
  61807. * Gets the perf counter used to capture render time
  61808. */
  61809. readonly renderTimeCounter: BABYLON.PerfCounter;
  61810. /**
  61811. * Gets the perf counter used to capture layout time
  61812. */
  61813. readonly layoutTimeCounter: BABYLON.PerfCounter;
  61814. /**
  61815. * Enable or disable the render time capture
  61816. */
  61817. captureRenderTime: boolean;
  61818. /**
  61819. * Enable or disable the layout time capture
  61820. */
  61821. captureLayoutTime: boolean;
  61822. /**
  61823. * Instantiates a new advanced dynamic texture instrumentation.
  61824. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  61825. * @param texture Defines the AdvancedDynamicTexture to instrument
  61826. */
  61827. constructor(
  61828. /**
  61829. * Define the instrumented AdvancedDynamicTexture.
  61830. */
  61831. texture: AdvancedDynamicTexture);
  61832. /**
  61833. * Dispose and release associated resources.
  61834. */
  61835. dispose(): void;
  61836. }
  61837. }
  61838. declare module BABYLON.GUI {
  61839. /**
  61840. * Class used to create containers for controls
  61841. */
  61842. export class Container3D extends Control3D {
  61843. private _blockLayout;
  61844. /**
  61845. * Gets the list of child controls
  61846. */
  61847. protected _children: Control3D[];
  61848. /**
  61849. * Gets the list of child controls
  61850. */
  61851. readonly children: Array<Control3D>;
  61852. /**
  61853. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  61854. * This is helpful to optimize layout operation when adding multiple children in a row
  61855. */
  61856. blockLayout: boolean;
  61857. /**
  61858. * Creates a new container
  61859. * @param name defines the container name
  61860. */
  61861. constructor(name?: string);
  61862. /**
  61863. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  61864. * @returns the current container
  61865. */
  61866. updateLayout(): Container3D;
  61867. /**
  61868. * Gets a boolean indicating if the given control is in the children of this control
  61869. * @param control defines the control to check
  61870. * @returns true if the control is in the child list
  61871. */
  61872. containsControl(control: Control3D): boolean;
  61873. /**
  61874. * Adds a control to the children of this control
  61875. * @param control defines the control to add
  61876. * @returns the current container
  61877. */
  61878. addControl(control: Control3D): Container3D;
  61879. /**
  61880. * This function will be called everytime a new control is added
  61881. */
  61882. protected _arrangeChildren(): void;
  61883. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61884. /**
  61885. * Removes a control from the children of this control
  61886. * @param control defines the control to remove
  61887. * @returns the current container
  61888. */
  61889. removeControl(control: Control3D): Container3D;
  61890. protected _getTypeName(): string;
  61891. /**
  61892. * Releases all associated resources
  61893. */
  61894. dispose(): void;
  61895. /** Control rotation will remain unchanged */
  61896. static readonly UNSET_ORIENTATION: number;
  61897. /** Control will rotate to make it look at sphere central axis */
  61898. static readonly FACEORIGIN_ORIENTATION: number;
  61899. /** Control will rotate to make it look back at sphere central axis */
  61900. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  61901. /** Control will rotate to look at z axis (0, 0, 1) */
  61902. static readonly FACEFORWARD_ORIENTATION: number;
  61903. /** Control will rotate to look at negative z axis (0, 0, -1) */
  61904. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  61905. }
  61906. }
  61907. declare module BABYLON.GUI {
  61908. /**
  61909. * Class used to manage 3D user interface
  61910. * @see http://doc.babylonjs.com/how_to/gui3d
  61911. */
  61912. export class GUI3DManager implements BABYLON.IDisposable {
  61913. private _scene;
  61914. private _sceneDisposeObserver;
  61915. private _utilityLayer;
  61916. private _rootContainer;
  61917. private _pointerObserver;
  61918. private _pointerOutObserver;
  61919. /** @hidden */ private _lastPickedControl: Control3D;
  61920. /** @hidden */ private _lastControlOver: {
  61921. [pointerId: number]: Control3D;
  61922. };
  61923. /** @hidden */ private _lastControlDown: {
  61924. [pointerId: number]: Control3D;
  61925. };
  61926. /**
  61927. * BABYLON.Observable raised when the point picked by the pointer events changed
  61928. */
  61929. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  61930. /** @hidden */ private _sharedMaterials: {
  61931. [key: string]: BABYLON.Material;
  61932. };
  61933. /** Gets the hosting scene */
  61934. readonly scene: BABYLON.Scene;
  61935. /** Gets associated utility layer */
  61936. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  61937. /**
  61938. * Creates a new GUI3DManager
  61939. * @param scene
  61940. */
  61941. constructor(scene?: BABYLON.Scene);
  61942. private _handlePointerOut;
  61943. private _doPicking;
  61944. /**
  61945. * Gets the root container
  61946. */
  61947. readonly rootContainer: Container3D;
  61948. /**
  61949. * Gets a boolean indicating if the given control is in the root child list
  61950. * @param control defines the control to check
  61951. * @returns true if the control is in the root child list
  61952. */
  61953. containsControl(control: Control3D): boolean;
  61954. /**
  61955. * Adds a control to the root child list
  61956. * @param control defines the control to add
  61957. * @returns the current manager
  61958. */
  61959. addControl(control: Control3D): GUI3DManager;
  61960. /**
  61961. * Removes a control from the root child list
  61962. * @param control defines the control to remove
  61963. * @returns the current container
  61964. */
  61965. removeControl(control: Control3D): GUI3DManager;
  61966. /**
  61967. * Releases all associated resources
  61968. */
  61969. dispose(): void;
  61970. }
  61971. }
  61972. declare module BABYLON.GUI {
  61973. /**
  61974. * Class used to transport BABYLON.Vector3 information for pointer events
  61975. */
  61976. export class Vector3WithInfo extends BABYLON.Vector3 {
  61977. /** defines the current mouse button index */
  61978. buttonIndex: number;
  61979. /**
  61980. * Creates a new Vector3WithInfo
  61981. * @param source defines the vector3 data to transport
  61982. * @param buttonIndex defines the current mouse button index
  61983. */
  61984. constructor(source: BABYLON.Vector3,
  61985. /** defines the current mouse button index */
  61986. buttonIndex?: number);
  61987. }
  61988. }
  61989. declare module BABYLON.GUI {
  61990. /**
  61991. * Class used as base class for controls
  61992. */
  61993. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  61994. /** Defines the control name */
  61995. name?: string | undefined;
  61996. /** @hidden */ private _host: GUI3DManager;
  61997. private _node;
  61998. private _downCount;
  61999. private _enterCount;
  62000. private _downPointerIds;
  62001. private _isVisible;
  62002. /** Gets or sets the control position in world space */
  62003. position: BABYLON.Vector3;
  62004. /** Gets or sets the control scaling in world space */
  62005. scaling: BABYLON.Vector3;
  62006. /** Callback used to start pointer enter animation */
  62007. pointerEnterAnimation: () => void;
  62008. /** Callback used to start pointer out animation */
  62009. pointerOutAnimation: () => void;
  62010. /** Callback used to start pointer down animation */
  62011. pointerDownAnimation: () => void;
  62012. /** Callback used to start pointer up animation */
  62013. pointerUpAnimation: () => void;
  62014. /**
  62015. * An event triggered when the pointer move over the control
  62016. */
  62017. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62018. /**
  62019. * An event triggered when the pointer move out of the control
  62020. */
  62021. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62022. /**
  62023. * An event triggered when the pointer taps the control
  62024. */
  62025. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62026. /**
  62027. * An event triggered when pointer is up
  62028. */
  62029. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62030. /**
  62031. * An event triggered when a control is clicked on (with a mouse)
  62032. */
  62033. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62034. /**
  62035. * An event triggered when pointer enters the control
  62036. */
  62037. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62038. /**
  62039. * Gets or sets the parent container
  62040. */
  62041. parent: BABYLON.Nullable<Container3D>;
  62042. private _behaviors;
  62043. /**
  62044. * Gets the list of attached behaviors
  62045. * @see http://doc.babylonjs.com/features/behaviour
  62046. */
  62047. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62048. /**
  62049. * Attach a behavior to the control
  62050. * @see http://doc.babylonjs.com/features/behaviour
  62051. * @param behavior defines the behavior to attach
  62052. * @returns the current control
  62053. */
  62054. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62055. /**
  62056. * Remove an attached behavior
  62057. * @see http://doc.babylonjs.com/features/behaviour
  62058. * @param behavior defines the behavior to attach
  62059. * @returns the current control
  62060. */
  62061. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62062. /**
  62063. * Gets an attached behavior by name
  62064. * @param name defines the name of the behavior to look for
  62065. * @see http://doc.babylonjs.com/features/behaviour
  62066. * @returns null if behavior was not found else the requested behavior
  62067. */
  62068. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62069. /** Gets or sets a boolean indicating if the control is visible */
  62070. isVisible: boolean;
  62071. /**
  62072. * Creates a new control
  62073. * @param name defines the control name
  62074. */
  62075. constructor(
  62076. /** Defines the control name */
  62077. name?: string | undefined);
  62078. /**
  62079. * Gets a string representing the class name
  62080. */
  62081. readonly typeName: string;
  62082. /**
  62083. * Get the current class name of the control.
  62084. * @returns current class name
  62085. */
  62086. getClassName(): string;
  62087. protected _getTypeName(): string;
  62088. /**
  62089. * Gets the transform node used by this control
  62090. */
  62091. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62092. /**
  62093. * Gets the mesh used to render this control
  62094. */
  62095. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62096. /**
  62097. * Link the control as child of the given node
  62098. * @param node defines the node to link to. Use null to unlink the control
  62099. * @returns the current control
  62100. */
  62101. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62102. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  62103. /**
  62104. * Node creation.
  62105. * Can be overriden by children
  62106. * @param scene defines the scene where the node must be attached
  62107. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  62108. */
  62109. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62110. /**
  62111. * Affect a material to the given mesh
  62112. * @param mesh defines the mesh which will represent the control
  62113. */
  62114. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62115. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  62116. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  62117. /** @hidden */ private _onPointerOut(target: Control3D): void;
  62118. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62119. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62120. /** @hidden */
  62121. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62122. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62123. /** @hidden */ private _disposeNode(): void;
  62124. /**
  62125. * Releases all associated resources
  62126. */
  62127. dispose(): void;
  62128. }
  62129. }
  62130. declare module BABYLON.GUI {
  62131. /**
  62132. * Class used as a root to all buttons
  62133. */
  62134. export class AbstractButton3D extends Control3D {
  62135. /**
  62136. * Creates a new button
  62137. * @param name defines the control name
  62138. */
  62139. constructor(name?: string);
  62140. protected _getTypeName(): string;
  62141. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62142. }
  62143. }
  62144. declare module BABYLON.GUI {
  62145. /**
  62146. * Class used to create a button in 3D
  62147. */
  62148. export class Button3D extends AbstractButton3D {
  62149. /** @hidden */
  62150. protected _currentMaterial: BABYLON.Material;
  62151. private _facadeTexture;
  62152. private _content;
  62153. private _contentResolution;
  62154. private _contentScaleRatio;
  62155. /**
  62156. * Gets or sets the texture resolution used to render content (512 by default)
  62157. */
  62158. contentResolution: BABYLON.int;
  62159. /**
  62160. * Gets or sets the texture scale ratio used to render content (2 by default)
  62161. */
  62162. contentScaleRatio: number;
  62163. protected _disposeFacadeTexture(): void;
  62164. protected _resetContent(): void;
  62165. /**
  62166. * Creates a new button
  62167. * @param name defines the control name
  62168. */
  62169. constructor(name?: string);
  62170. /**
  62171. * Gets or sets the GUI 2D content used to display the button's facade
  62172. */
  62173. content: Control;
  62174. /**
  62175. * Apply the facade texture (created from the content property).
  62176. * This function can be overloaded by child classes
  62177. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62178. */
  62179. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62180. protected _getTypeName(): string;
  62181. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62182. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62183. /**
  62184. * Releases all associated resources
  62185. */
  62186. dispose(): void;
  62187. }
  62188. }
  62189. declare module BABYLON.GUI {
  62190. /**
  62191. * Abstract class used to create a container panel deployed on the surface of a volume
  62192. */
  62193. export abstract class VolumeBasedPanel extends Container3D {
  62194. private _columns;
  62195. private _rows;
  62196. private _rowThenColum;
  62197. private _orientation;
  62198. protected _cellWidth: number;
  62199. protected _cellHeight: number;
  62200. /**
  62201. * Gets or sets the distance between elements
  62202. */
  62203. margin: number;
  62204. /**
  62205. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62206. * | Value | Type | Description |
  62207. * | ----- | ----------------------------------- | ----------- |
  62208. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62209. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62210. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62211. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62212. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62213. */
  62214. orientation: number;
  62215. /**
  62216. * Gets or sets the number of columns requested (10 by default).
  62217. * The panel will automatically compute the number of rows based on number of child controls.
  62218. */
  62219. columns: BABYLON.int;
  62220. /**
  62221. * Gets or sets a the number of rows requested.
  62222. * The panel will automatically compute the number of columns based on number of child controls.
  62223. */
  62224. rows: BABYLON.int;
  62225. /**
  62226. * Creates new VolumeBasedPanel
  62227. */
  62228. constructor();
  62229. protected _arrangeChildren(): void;
  62230. /** Child classes must implement this function to provide correct control positioning */
  62231. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62232. /** Child classes can implement this function to provide additional processing */
  62233. protected _finalProcessing(): void;
  62234. }
  62235. }
  62236. declare module BABYLON.GUI {
  62237. /**
  62238. * Class used to create a container panel deployed on the surface of a cylinder
  62239. */
  62240. export class CylinderPanel extends VolumeBasedPanel {
  62241. private _radius;
  62242. /**
  62243. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62244. */
  62245. radius: BABYLON.float;
  62246. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62247. private _cylindricalMapping;
  62248. }
  62249. }
  62250. declare module BABYLON.GUI {
  62251. /** @hidden */
  62252. export var fluentVertexShader: {
  62253. name: string;
  62254. shader: string;
  62255. };
  62256. }
  62257. declare module BABYLON.GUI {
  62258. /** @hidden */
  62259. export var fluentPixelShader: {
  62260. name: string;
  62261. shader: string;
  62262. };
  62263. }
  62264. declare module BABYLON.GUI {
  62265. /** @hidden */
  62266. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62267. INNERGLOW: boolean;
  62268. BORDER: boolean;
  62269. HOVERLIGHT: boolean;
  62270. TEXTURE: boolean;
  62271. constructor();
  62272. }
  62273. /**
  62274. * Class used to render controls with fluent desgin
  62275. */
  62276. export class FluentMaterial extends BABYLON.PushMaterial {
  62277. /**
  62278. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62279. */
  62280. innerGlowColorIntensity: number;
  62281. /**
  62282. * Gets or sets the inner glow color (white by default)
  62283. */
  62284. innerGlowColor: BABYLON.Color3;
  62285. /**
  62286. * Gets or sets alpha value (default is 1.0)
  62287. */
  62288. alpha: number;
  62289. /**
  62290. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62291. */
  62292. albedoColor: BABYLON.Color3;
  62293. /**
  62294. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62295. */
  62296. renderBorders: boolean;
  62297. /**
  62298. * Gets or sets border width (default is 0.5)
  62299. */
  62300. borderWidth: number;
  62301. /**
  62302. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62303. */
  62304. edgeSmoothingValue: number;
  62305. /**
  62306. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62307. */
  62308. borderMinValue: number;
  62309. /**
  62310. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62311. */
  62312. renderHoverLight: boolean;
  62313. /**
  62314. * Gets or sets the radius used to render the hover light (default is 1.0)
  62315. */
  62316. hoverRadius: number;
  62317. /**
  62318. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62319. */
  62320. hoverColor: BABYLON.Color4;
  62321. /**
  62322. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62323. */
  62324. hoverPosition: BABYLON.Vector3;
  62325. private _albedoTexture;
  62326. /** Gets or sets the texture to use for albedo color */
  62327. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62328. /**
  62329. * Creates a new Fluent material
  62330. * @param name defines the name of the material
  62331. * @param scene defines the hosting scene
  62332. */
  62333. constructor(name: string, scene: BABYLON.Scene);
  62334. needAlphaBlending(): boolean;
  62335. needAlphaTesting(): boolean;
  62336. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62337. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62338. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62339. getActiveTextures(): BABYLON.BaseTexture[];
  62340. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62341. dispose(forceDisposeEffect?: boolean): void;
  62342. clone(name: string): FluentMaterial;
  62343. serialize(): any;
  62344. getClassName(): string;
  62345. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62346. }
  62347. }
  62348. declare module BABYLON.GUI {
  62349. /**
  62350. * Class used to create a holographic button in 3D
  62351. */
  62352. export class HolographicButton extends Button3D {
  62353. private _backPlate;
  62354. private _textPlate;
  62355. private _frontPlate;
  62356. private _text;
  62357. private _imageUrl;
  62358. private _shareMaterials;
  62359. private _frontMaterial;
  62360. private _backMaterial;
  62361. private _plateMaterial;
  62362. private _pickedPointObserver;
  62363. private _tooltipFade;
  62364. private _tooltipTextBlock;
  62365. private _tooltipTexture;
  62366. private _tooltipMesh;
  62367. private _tooltipHoverObserver;
  62368. private _tooltipOutObserver;
  62369. private _disposeTooltip;
  62370. /**
  62371. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62372. */
  62373. tooltipText: BABYLON.Nullable<string>;
  62374. /**
  62375. * Gets or sets text for the button
  62376. */
  62377. text: string;
  62378. /**
  62379. * Gets or sets the image url for the button
  62380. */
  62381. imageUrl: string;
  62382. /**
  62383. * Gets the back material used by this button
  62384. */
  62385. readonly backMaterial: FluentMaterial;
  62386. /**
  62387. * Gets the front material used by this button
  62388. */
  62389. readonly frontMaterial: FluentMaterial;
  62390. /**
  62391. * Gets the plate material used by this button
  62392. */
  62393. readonly plateMaterial: BABYLON.StandardMaterial;
  62394. /**
  62395. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62396. */
  62397. readonly shareMaterials: boolean;
  62398. /**
  62399. * Creates a new button
  62400. * @param name defines the control name
  62401. */
  62402. constructor(name?: string, shareMaterials?: boolean);
  62403. protected _getTypeName(): string;
  62404. private _rebuildContent;
  62405. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62406. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62407. private _createBackMaterial;
  62408. private _createFrontMaterial;
  62409. private _createPlateMaterial;
  62410. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62411. /**
  62412. * Releases all associated resources
  62413. */
  62414. dispose(): void;
  62415. }
  62416. }
  62417. declare module BABYLON.GUI {
  62418. /**
  62419. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62420. */
  62421. export class MeshButton3D extends Button3D {
  62422. /** @hidden */
  62423. protected _currentMesh: BABYLON.Mesh;
  62424. /**
  62425. * Creates a new 3D button based on a mesh
  62426. * @param mesh mesh to become a 3D button
  62427. * @param name defines the control name
  62428. */
  62429. constructor(mesh: BABYLON.Mesh, name?: string);
  62430. protected _getTypeName(): string;
  62431. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62432. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62433. }
  62434. }
  62435. declare module BABYLON.GUI {
  62436. /**
  62437. * Class used to create a container panel deployed on the surface of a plane
  62438. */
  62439. export class PlanePanel extends VolumeBasedPanel {
  62440. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62441. }
  62442. }
  62443. declare module BABYLON.GUI {
  62444. /**
  62445. * Class used to create a container panel where items get randomized planar mapping
  62446. */
  62447. export class ScatterPanel extends VolumeBasedPanel {
  62448. private _iteration;
  62449. /**
  62450. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  62451. */
  62452. iteration: BABYLON.float;
  62453. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62454. private _scatterMapping;
  62455. protected _finalProcessing(): void;
  62456. }
  62457. }
  62458. declare module BABYLON.GUI {
  62459. /**
  62460. * Class used to create a container panel deployed on the surface of a sphere
  62461. */
  62462. export class SpherePanel extends VolumeBasedPanel {
  62463. private _radius;
  62464. /**
  62465. * Gets or sets the radius of the sphere where to project controls (5 by default)
  62466. */
  62467. radius: BABYLON.float;
  62468. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62469. private _sphericalMapping;
  62470. }
  62471. }
  62472. declare module BABYLON.GUI {
  62473. /**
  62474. * Class used to create a stack panel in 3D on XY plane
  62475. */
  62476. export class StackPanel3D extends Container3D {
  62477. private _isVertical;
  62478. /**
  62479. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  62480. */
  62481. isVertical: boolean;
  62482. /**
  62483. * Gets or sets the distance between elements
  62484. */
  62485. margin: number;
  62486. /**
  62487. * Creates new StackPanel
  62488. * @param isVertical
  62489. */
  62490. constructor(isVertical?: boolean);
  62491. protected _arrangeChildren(): void;
  62492. }
  62493. }
  62494. declare module BABYLON {
  62495. /**
  62496. * Mode that determines the coordinate system to use.
  62497. */
  62498. export enum GLTFLoaderCoordinateSystemMode {
  62499. /**
  62500. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  62501. */
  62502. AUTO = 0,
  62503. /**
  62504. * Sets the useRightHandedSystem flag on the scene.
  62505. */
  62506. FORCE_RIGHT_HANDED = 1
  62507. }
  62508. /**
  62509. * Mode that determines what animations will start.
  62510. */
  62511. export enum GLTFLoaderAnimationStartMode {
  62512. /**
  62513. * No animation will start.
  62514. */
  62515. NONE = 0,
  62516. /**
  62517. * The first animation will start.
  62518. */
  62519. FIRST = 1,
  62520. /**
  62521. * All animations will start.
  62522. */
  62523. ALL = 2
  62524. }
  62525. /**
  62526. * Interface that contains the data for the glTF asset.
  62527. */
  62528. export interface IGLTFLoaderData {
  62529. /**
  62530. * Object that represents the glTF JSON.
  62531. */
  62532. json: Object;
  62533. /**
  62534. * The BIN chunk of a binary glTF.
  62535. */
  62536. bin: Nullable<ArrayBufferView>;
  62537. }
  62538. /**
  62539. * Interface for extending the loader.
  62540. */
  62541. export interface IGLTFLoaderExtension {
  62542. /**
  62543. * The name of this extension.
  62544. */
  62545. readonly name: string;
  62546. /**
  62547. * Defines whether this extension is enabled.
  62548. */
  62549. enabled: boolean;
  62550. }
  62551. /**
  62552. * Loader state.
  62553. */
  62554. export enum GLTFLoaderState {
  62555. /**
  62556. * The asset is loading.
  62557. */
  62558. LOADING = 0,
  62559. /**
  62560. * The asset is ready for rendering.
  62561. */
  62562. READY = 1,
  62563. /**
  62564. * The asset is completely loaded.
  62565. */
  62566. COMPLETE = 2
  62567. }
  62568. /** @hidden */
  62569. export interface IGLTFLoader extends IDisposable {
  62570. readonly state: Nullable<GLTFLoaderState>;
  62571. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  62572. meshes: AbstractMesh[];
  62573. particleSystems: IParticleSystem[];
  62574. skeletons: Skeleton[];
  62575. animationGroups: AnimationGroup[];
  62576. }>;
  62577. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  62578. }
  62579. /**
  62580. * File loader for loading glTF files into a scene.
  62581. */
  62582. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  62583. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62584. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62585. /**
  62586. * Raised when the asset has been parsed
  62587. */
  62588. onParsedObservable: Observable<IGLTFLoaderData>;
  62589. private _onParsedObserver;
  62590. /**
  62591. * Raised when the asset has been parsed
  62592. */
  62593. onParsed: (loaderData: IGLTFLoaderData) => void;
  62594. /**
  62595. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  62596. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  62597. * Defaults to true.
  62598. * @hidden
  62599. */
  62600. static IncrementalLoading: boolean;
  62601. /**
  62602. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  62603. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  62604. * @hidden
  62605. */
  62606. static HomogeneousCoordinates: boolean;
  62607. /**
  62608. * The coordinate system mode. Defaults to AUTO.
  62609. */
  62610. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  62611. /**
  62612. * The animation start mode. Defaults to FIRST.
  62613. */
  62614. animationStartMode: GLTFLoaderAnimationStartMode;
  62615. /**
  62616. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  62617. */
  62618. compileMaterials: boolean;
  62619. /**
  62620. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  62621. */
  62622. useClipPlane: boolean;
  62623. /**
  62624. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  62625. */
  62626. compileShadowGenerators: boolean;
  62627. /**
  62628. * Defines if the Alpha blended materials are only applied as coverage.
  62629. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  62630. * If true, no extra effects are applied to transparent pixels.
  62631. */
  62632. transparencyAsCoverage: boolean;
  62633. /**
  62634. * Function called before loading a url referenced by the asset.
  62635. */
  62636. preprocessUrlAsync: (url: string) => Promise<string>;
  62637. /**
  62638. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62639. */
  62640. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  62641. private _onMeshLoadedObserver;
  62642. /**
  62643. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62644. */
  62645. onMeshLoaded: (mesh: AbstractMesh) => void;
  62646. /**
  62647. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  62648. */
  62649. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  62650. private _onTextureLoadedObserver;
  62651. /**
  62652. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  62653. */
  62654. onTextureLoaded: (texture: BaseTexture) => void;
  62655. /**
  62656. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  62657. */
  62658. readonly onMaterialLoadedObservable: Observable<Material>;
  62659. private _onMaterialLoadedObserver;
  62660. /**
  62661. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  62662. */
  62663. onMaterialLoaded: (material: Material) => void;
  62664. /**
  62665. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  62666. */
  62667. readonly onCameraLoadedObservable: Observable<Camera>;
  62668. private _onCameraLoadedObserver;
  62669. /**
  62670. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  62671. */
  62672. onCameraLoaded: (camera: Camera) => void;
  62673. /**
  62674. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  62675. * For assets with LODs, raised when all of the LODs are complete.
  62676. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62677. */
  62678. readonly onCompleteObservable: Observable<void>;
  62679. private _onCompleteObserver;
  62680. /**
  62681. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  62682. * For assets with LODs, raised when all of the LODs are complete.
  62683. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62684. */
  62685. onComplete: () => void;
  62686. /**
  62687. * Observable raised when an error occurs.
  62688. */
  62689. readonly onErrorObservable: Observable<any>;
  62690. private _onErrorObserver;
  62691. /**
  62692. * Callback raised when an error occurs.
  62693. */
  62694. onError: (reason: any) => void;
  62695. /**
  62696. * Observable raised after the loader is disposed.
  62697. */
  62698. readonly onDisposeObservable: Observable<void>;
  62699. private _onDisposeObserver;
  62700. /**
  62701. * Callback raised after the loader is disposed.
  62702. */
  62703. onDispose: () => void;
  62704. /**
  62705. * Observable raised after a loader extension is created.
  62706. * Set additional options for a loader extension in this event.
  62707. */
  62708. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  62709. private _onExtensionLoadedObserver;
  62710. /**
  62711. * Callback raised after a loader extension is created.
  62712. */
  62713. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  62714. /**
  62715. * Defines if the loader logging is enabled.
  62716. */
  62717. loggingEnabled: boolean;
  62718. /**
  62719. * Defines if the loader should capture performance counters.
  62720. */
  62721. capturePerformanceCounters: boolean;
  62722. /**
  62723. * Defines if the loader should validate the asset.
  62724. */
  62725. validate: boolean;
  62726. /**
  62727. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  62728. */
  62729. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  62730. private _onValidatedObserver;
  62731. /**
  62732. * Callback raised after a loader extension is created.
  62733. */
  62734. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  62735. private _loader;
  62736. /**
  62737. * Name of the loader ("gltf")
  62738. */
  62739. name: string;
  62740. /**
  62741. * Supported file extensions of the loader (.gltf, .glb)
  62742. */
  62743. extensions: ISceneLoaderPluginExtensions;
  62744. /**
  62745. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  62746. */
  62747. dispose(): void;
  62748. /** @hidden */ private _clear(): void;
  62749. /**
  62750. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  62751. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  62752. * @param scene the scene the meshes should be added to
  62753. * @param data the glTF data to load
  62754. * @param rootUrl root url to load from
  62755. * @param onProgress event that fires when loading progress has occured
  62756. * @param fileName Defines the name of the file to load
  62757. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  62758. */
  62759. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  62760. meshes: AbstractMesh[];
  62761. particleSystems: IParticleSystem[];
  62762. skeletons: Skeleton[];
  62763. animationGroups: AnimationGroup[];
  62764. }>;
  62765. /**
  62766. * Imports all objects from the loaded glTF data and adds them to the scene
  62767. * @param scene the scene the objects should be added to
  62768. * @param data the glTF data to load
  62769. * @param rootUrl root url to load from
  62770. * @param onProgress event that fires when loading progress has occured
  62771. * @param fileName Defines the name of the file to load
  62772. * @returns a promise which completes when objects have been loaded to the scene
  62773. */
  62774. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  62775. /**
  62776. * Load into an asset container.
  62777. * @param scene The scene to load into
  62778. * @param data The data to import
  62779. * @param rootUrl The root url for scene and resources
  62780. * @param onProgress The callback when the load progresses
  62781. * @param fileName Defines the name of the file to load
  62782. * @returns The loaded asset container
  62783. */
  62784. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  62785. /**
  62786. * If the data string can be loaded directly.
  62787. * @param data string contianing the file data
  62788. * @returns if the data can be loaded directly
  62789. */
  62790. canDirectLoad(data: string): boolean;
  62791. /**
  62792. * Rewrites a url by combining a root url and response url.
  62793. */
  62794. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  62795. /**
  62796. * Instantiates a glTF file loader plugin.
  62797. * @returns the created plugin
  62798. */
  62799. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  62800. /**
  62801. * The loader state or null if the loader is not active.
  62802. */
  62803. readonly loaderState: Nullable<GLTFLoaderState>;
  62804. /**
  62805. * Returns a promise that resolves when the asset is completely loaded.
  62806. * @returns a promise that resolves when the asset is completely loaded.
  62807. */
  62808. whenCompleteAsync(): Promise<void>;
  62809. private _parseAsync;
  62810. private _validateAsync;
  62811. private _getLoader;
  62812. private _unpackBinary;
  62813. private _unpackBinaryV1;
  62814. private _unpackBinaryV2;
  62815. private static _parseVersion;
  62816. private static _compareVersion;
  62817. private static _decodeBufferToText;
  62818. private static readonly _logSpaces;
  62819. private _logIndentLevel;
  62820. private _loggingEnabled;
  62821. /** @hidden */ private _log: (message: string) => void;
  62822. /** @hidden */ private _logOpen(message: string): void;
  62823. /** @hidden */ private _logClose(): void;
  62824. private _logEnabled;
  62825. private _logDisabled;
  62826. private _capturePerformanceCounters;
  62827. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  62828. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  62829. private _startPerformanceCounterEnabled;
  62830. private _startPerformanceCounterDisabled;
  62831. private _endPerformanceCounterEnabled;
  62832. private _endPerformanceCounterDisabled;
  62833. }
  62834. }
  62835. declare module BABYLON.GLTF1 {
  62836. /**
  62837. * Enums
  62838. * @hidden
  62839. */
  62840. export enum EComponentType {
  62841. BYTE = 5120,
  62842. UNSIGNED_BYTE = 5121,
  62843. SHORT = 5122,
  62844. UNSIGNED_SHORT = 5123,
  62845. FLOAT = 5126
  62846. }
  62847. /** @hidden */
  62848. export enum EShaderType {
  62849. FRAGMENT = 35632,
  62850. VERTEX = 35633
  62851. }
  62852. /** @hidden */
  62853. export enum EParameterType {
  62854. BYTE = 5120,
  62855. UNSIGNED_BYTE = 5121,
  62856. SHORT = 5122,
  62857. UNSIGNED_SHORT = 5123,
  62858. INT = 5124,
  62859. UNSIGNED_INT = 5125,
  62860. FLOAT = 5126,
  62861. FLOAT_VEC2 = 35664,
  62862. FLOAT_VEC3 = 35665,
  62863. FLOAT_VEC4 = 35666,
  62864. INT_VEC2 = 35667,
  62865. INT_VEC3 = 35668,
  62866. INT_VEC4 = 35669,
  62867. BOOL = 35670,
  62868. BOOL_VEC2 = 35671,
  62869. BOOL_VEC3 = 35672,
  62870. BOOL_VEC4 = 35673,
  62871. FLOAT_MAT2 = 35674,
  62872. FLOAT_MAT3 = 35675,
  62873. FLOAT_MAT4 = 35676,
  62874. SAMPLER_2D = 35678
  62875. }
  62876. /** @hidden */
  62877. export enum ETextureWrapMode {
  62878. CLAMP_TO_EDGE = 33071,
  62879. MIRRORED_REPEAT = 33648,
  62880. REPEAT = 10497
  62881. }
  62882. /** @hidden */
  62883. export enum ETextureFilterType {
  62884. NEAREST = 9728,
  62885. LINEAR = 9728,
  62886. NEAREST_MIPMAP_NEAREST = 9984,
  62887. LINEAR_MIPMAP_NEAREST = 9985,
  62888. NEAREST_MIPMAP_LINEAR = 9986,
  62889. LINEAR_MIPMAP_LINEAR = 9987
  62890. }
  62891. /** @hidden */
  62892. export enum ETextureFormat {
  62893. ALPHA = 6406,
  62894. RGB = 6407,
  62895. RGBA = 6408,
  62896. LUMINANCE = 6409,
  62897. LUMINANCE_ALPHA = 6410
  62898. }
  62899. /** @hidden */
  62900. export enum ECullingType {
  62901. FRONT = 1028,
  62902. BACK = 1029,
  62903. FRONT_AND_BACK = 1032
  62904. }
  62905. /** @hidden */
  62906. export enum EBlendingFunction {
  62907. ZERO = 0,
  62908. ONE = 1,
  62909. SRC_COLOR = 768,
  62910. ONE_MINUS_SRC_COLOR = 769,
  62911. DST_COLOR = 774,
  62912. ONE_MINUS_DST_COLOR = 775,
  62913. SRC_ALPHA = 770,
  62914. ONE_MINUS_SRC_ALPHA = 771,
  62915. DST_ALPHA = 772,
  62916. ONE_MINUS_DST_ALPHA = 773,
  62917. CONSTANT_COLOR = 32769,
  62918. ONE_MINUS_CONSTANT_COLOR = 32770,
  62919. CONSTANT_ALPHA = 32771,
  62920. ONE_MINUS_CONSTANT_ALPHA = 32772,
  62921. SRC_ALPHA_SATURATE = 776
  62922. }
  62923. /** @hidden */
  62924. export interface IGLTFProperty {
  62925. extensions?: {
  62926. [key: string]: any;
  62927. };
  62928. extras?: Object;
  62929. }
  62930. /** @hidden */
  62931. export interface IGLTFChildRootProperty extends IGLTFProperty {
  62932. name?: string;
  62933. }
  62934. /** @hidden */
  62935. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  62936. bufferView: string;
  62937. byteOffset: number;
  62938. byteStride: number;
  62939. count: number;
  62940. type: string;
  62941. componentType: EComponentType;
  62942. max?: number[];
  62943. min?: number[];
  62944. name?: string;
  62945. }
  62946. /** @hidden */
  62947. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  62948. buffer: string;
  62949. byteOffset: number;
  62950. byteLength: number;
  62951. byteStride: number;
  62952. target?: number;
  62953. }
  62954. /** @hidden */
  62955. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  62956. uri: string;
  62957. byteLength?: number;
  62958. type?: string;
  62959. }
  62960. /** @hidden */
  62961. export interface IGLTFShader extends IGLTFChildRootProperty {
  62962. uri: string;
  62963. type: EShaderType;
  62964. }
  62965. /** @hidden */
  62966. export interface IGLTFProgram extends IGLTFChildRootProperty {
  62967. attributes: string[];
  62968. fragmentShader: string;
  62969. vertexShader: string;
  62970. }
  62971. /** @hidden */
  62972. export interface IGLTFTechniqueParameter {
  62973. type: number;
  62974. count?: number;
  62975. semantic?: string;
  62976. node?: string;
  62977. value?: number | boolean | string | Array<any>;
  62978. source?: string;
  62979. babylonValue?: any;
  62980. }
  62981. /** @hidden */
  62982. export interface IGLTFTechniqueCommonProfile {
  62983. lightingModel: string;
  62984. texcoordBindings: Object;
  62985. parameters?: Array<any>;
  62986. }
  62987. /** @hidden */
  62988. export interface IGLTFTechniqueStatesFunctions {
  62989. blendColor?: number[];
  62990. blendEquationSeparate?: number[];
  62991. blendFuncSeparate?: number[];
  62992. colorMask: boolean[];
  62993. cullFace: number[];
  62994. }
  62995. /** @hidden */
  62996. export interface IGLTFTechniqueStates {
  62997. enable: number[];
  62998. functions: IGLTFTechniqueStatesFunctions;
  62999. }
  63000. /** @hidden */
  63001. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63002. parameters: {
  63003. [key: string]: IGLTFTechniqueParameter;
  63004. };
  63005. program: string;
  63006. attributes: {
  63007. [key: string]: string;
  63008. };
  63009. uniforms: {
  63010. [key: string]: string;
  63011. };
  63012. states: IGLTFTechniqueStates;
  63013. }
  63014. /** @hidden */
  63015. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63016. technique?: string;
  63017. values: string[];
  63018. }
  63019. /** @hidden */
  63020. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63021. attributes: {
  63022. [key: string]: string;
  63023. };
  63024. indices: string;
  63025. material: string;
  63026. mode?: number;
  63027. }
  63028. /** @hidden */
  63029. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63030. primitives: IGLTFMeshPrimitive[];
  63031. }
  63032. /** @hidden */
  63033. export interface IGLTFImage extends IGLTFChildRootProperty {
  63034. uri: string;
  63035. }
  63036. /** @hidden */
  63037. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63038. magFilter?: number;
  63039. minFilter?: number;
  63040. wrapS?: number;
  63041. wrapT?: number;
  63042. }
  63043. /** @hidden */
  63044. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63045. sampler: string;
  63046. source: string;
  63047. format?: ETextureFormat;
  63048. internalFormat?: ETextureFormat;
  63049. target?: number;
  63050. type?: number;
  63051. babylonTexture?: Texture;
  63052. }
  63053. /** @hidden */
  63054. export interface IGLTFAmbienLight {
  63055. color?: number[];
  63056. }
  63057. /** @hidden */
  63058. export interface IGLTFDirectionalLight {
  63059. color?: number[];
  63060. }
  63061. /** @hidden */
  63062. export interface IGLTFPointLight {
  63063. color?: number[];
  63064. constantAttenuation?: number;
  63065. linearAttenuation?: number;
  63066. quadraticAttenuation?: number;
  63067. }
  63068. /** @hidden */
  63069. export interface IGLTFSpotLight {
  63070. color?: number[];
  63071. constantAttenuation?: number;
  63072. fallOfAngle?: number;
  63073. fallOffExponent?: number;
  63074. linearAttenuation?: number;
  63075. quadraticAttenuation?: number;
  63076. }
  63077. /** @hidden */
  63078. export interface IGLTFLight extends IGLTFChildRootProperty {
  63079. type: string;
  63080. }
  63081. /** @hidden */
  63082. export interface IGLTFCameraOrthographic {
  63083. xmag: number;
  63084. ymag: number;
  63085. zfar: number;
  63086. znear: number;
  63087. }
  63088. /** @hidden */
  63089. export interface IGLTFCameraPerspective {
  63090. aspectRatio: number;
  63091. yfov: number;
  63092. zfar: number;
  63093. znear: number;
  63094. }
  63095. /** @hidden */
  63096. export interface IGLTFCamera extends IGLTFChildRootProperty {
  63097. type: string;
  63098. }
  63099. /** @hidden */
  63100. export interface IGLTFAnimationChannelTarget {
  63101. id: string;
  63102. path: string;
  63103. }
  63104. /** @hidden */
  63105. export interface IGLTFAnimationChannel {
  63106. sampler: string;
  63107. target: IGLTFAnimationChannelTarget;
  63108. }
  63109. /** @hidden */
  63110. export interface IGLTFAnimationSampler {
  63111. input: string;
  63112. output: string;
  63113. interpolation?: string;
  63114. }
  63115. /** @hidden */
  63116. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  63117. channels?: IGLTFAnimationChannel[];
  63118. parameters?: {
  63119. [key: string]: string;
  63120. };
  63121. samplers?: {
  63122. [key: string]: IGLTFAnimationSampler;
  63123. };
  63124. }
  63125. /** @hidden */
  63126. export interface IGLTFNodeInstanceSkin {
  63127. skeletons: string[];
  63128. skin: string;
  63129. meshes: string[];
  63130. }
  63131. /** @hidden */
  63132. export interface IGLTFSkins extends IGLTFChildRootProperty {
  63133. bindShapeMatrix: number[];
  63134. inverseBindMatrices: string;
  63135. jointNames: string[];
  63136. babylonSkeleton?: Skeleton;
  63137. }
  63138. /** @hidden */
  63139. export interface IGLTFNode extends IGLTFChildRootProperty {
  63140. camera?: string;
  63141. children: string[];
  63142. skin?: string;
  63143. jointName?: string;
  63144. light?: string;
  63145. matrix: number[];
  63146. mesh?: string;
  63147. meshes?: string[];
  63148. rotation?: number[];
  63149. scale?: number[];
  63150. translation?: number[];
  63151. babylonNode?: Node;
  63152. }
  63153. /** @hidden */
  63154. export interface IGLTFScene extends IGLTFChildRootProperty {
  63155. nodes: string[];
  63156. }
  63157. /** @hidden */
  63158. export interface IGLTFRuntime {
  63159. extensions: {
  63160. [key: string]: any;
  63161. };
  63162. accessors: {
  63163. [key: string]: IGLTFAccessor;
  63164. };
  63165. buffers: {
  63166. [key: string]: IGLTFBuffer;
  63167. };
  63168. bufferViews: {
  63169. [key: string]: IGLTFBufferView;
  63170. };
  63171. meshes: {
  63172. [key: string]: IGLTFMesh;
  63173. };
  63174. lights: {
  63175. [key: string]: IGLTFLight;
  63176. };
  63177. cameras: {
  63178. [key: string]: IGLTFCamera;
  63179. };
  63180. nodes: {
  63181. [key: string]: IGLTFNode;
  63182. };
  63183. images: {
  63184. [key: string]: IGLTFImage;
  63185. };
  63186. textures: {
  63187. [key: string]: IGLTFTexture;
  63188. };
  63189. shaders: {
  63190. [key: string]: IGLTFShader;
  63191. };
  63192. programs: {
  63193. [key: string]: IGLTFProgram;
  63194. };
  63195. samplers: {
  63196. [key: string]: IGLTFSampler;
  63197. };
  63198. techniques: {
  63199. [key: string]: IGLTFTechnique;
  63200. };
  63201. materials: {
  63202. [key: string]: IGLTFMaterial;
  63203. };
  63204. animations: {
  63205. [key: string]: IGLTFAnimation;
  63206. };
  63207. skins: {
  63208. [key: string]: IGLTFSkins;
  63209. };
  63210. currentScene?: Object;
  63211. scenes: {
  63212. [key: string]: IGLTFScene;
  63213. };
  63214. extensionsUsed: string[];
  63215. extensionsRequired?: string[];
  63216. buffersCount: number;
  63217. shaderscount: number;
  63218. scene: Scene;
  63219. rootUrl: string;
  63220. loadedBufferCount: number;
  63221. loadedBufferViews: {
  63222. [name: string]: ArrayBufferView;
  63223. };
  63224. loadedShaderCount: number;
  63225. importOnlyMeshes: boolean;
  63226. importMeshesNames?: string[];
  63227. dummyNodes: Node[];
  63228. }
  63229. /** @hidden */
  63230. export interface INodeToRoot {
  63231. bone: Bone;
  63232. node: IGLTFNode;
  63233. id: string;
  63234. }
  63235. /** @hidden */
  63236. export interface IJointNode {
  63237. node: IGLTFNode;
  63238. id: string;
  63239. }
  63240. }
  63241. declare module BABYLON.GLTF1 {
  63242. /**
  63243. * Utils functions for GLTF
  63244. * @hidden
  63245. */
  63246. export class GLTFUtils {
  63247. /**
  63248. * Sets the given "parameter" matrix
  63249. * @param scene: the Scene object
  63250. * @param source: the source node where to pick the matrix
  63251. * @param parameter: the GLTF technique parameter
  63252. * @param uniformName: the name of the shader's uniform
  63253. * @param shaderMaterial: the shader material
  63254. */
  63255. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63256. /**
  63257. * Sets the given "parameter" matrix
  63258. * @param shaderMaterial: the shader material
  63259. * @param uniform: the name of the shader's uniform
  63260. * @param value: the value of the uniform
  63261. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63262. */
  63263. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63264. /**
  63265. * Returns the wrap mode of the texture
  63266. * @param mode: the mode value
  63267. */
  63268. static GetWrapMode(mode: number): number;
  63269. /**
  63270. * Returns the byte stride giving an accessor
  63271. * @param accessor: the GLTF accessor objet
  63272. */
  63273. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63274. /**
  63275. * Returns the texture filter mode giving a mode value
  63276. * @param mode: the filter mode value
  63277. */
  63278. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63279. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63280. /**
  63281. * Returns a buffer from its accessor
  63282. * @param gltfRuntime: the GLTF runtime
  63283. * @param accessor: the GLTF accessor
  63284. */
  63285. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63286. /**
  63287. * Decodes a buffer view into a string
  63288. * @param view: the buffer view
  63289. */
  63290. static DecodeBufferToText(view: ArrayBufferView): string;
  63291. /**
  63292. * Returns the default material of gltf. Related to
  63293. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63294. * @param scene: the Babylon.js scene
  63295. */
  63296. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63297. private static _DefaultMaterial;
  63298. }
  63299. }
  63300. declare module BABYLON.GLTF1 {
  63301. /**
  63302. * Implementation of the base glTF spec
  63303. * @hidden
  63304. */
  63305. export class GLTFLoaderBase {
  63306. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63307. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63308. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63309. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63310. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63311. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63312. }
  63313. /**
  63314. * glTF V1 Loader
  63315. * @hidden
  63316. */
  63317. export class GLTFLoader implements IGLTFLoader {
  63318. static Extensions: {
  63319. [name: string]: GLTFLoaderExtension;
  63320. };
  63321. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63322. state: Nullable<GLTFLoaderState>;
  63323. dispose(): void;
  63324. private _importMeshAsync;
  63325. /**
  63326. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63327. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63328. * @param scene the scene the meshes should be added to
  63329. * @param data gltf data containing information of the meshes in a loaded file
  63330. * @param rootUrl root url to load from
  63331. * @param onProgress event that fires when loading progress has occured
  63332. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63333. */
  63334. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63335. meshes: AbstractMesh[];
  63336. particleSystems: IParticleSystem[];
  63337. skeletons: Skeleton[];
  63338. animationGroups: AnimationGroup[];
  63339. }>;
  63340. private _loadAsync;
  63341. /**
  63342. * Imports all objects from a loaded gltf file and adds them to the scene
  63343. * @param scene the scene the objects should be added to
  63344. * @param data gltf data containing information of the meshes in a loaded file
  63345. * @param rootUrl root url to load from
  63346. * @param onProgress event that fires when loading progress has occured
  63347. * @returns a promise which completes when objects have been loaded to the scene
  63348. */
  63349. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63350. private _loadShadersAsync;
  63351. private _loadBuffersAsync;
  63352. private _createNodes;
  63353. }
  63354. /** @hidden */
  63355. export abstract class GLTFLoaderExtension {
  63356. private _name;
  63357. constructor(name: string);
  63358. readonly name: string;
  63359. /**
  63360. * Defines an override for loading the runtime
  63361. * Return true to stop further extensions from loading the runtime
  63362. */
  63363. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63364. /**
  63365. * Defines an onverride for creating gltf runtime
  63366. * Return true to stop further extensions from creating the runtime
  63367. */
  63368. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63369. /**
  63370. * Defines an override for loading buffers
  63371. * Return true to stop further extensions from loading this buffer
  63372. */
  63373. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63374. /**
  63375. * Defines an override for loading texture buffers
  63376. * Return true to stop further extensions from loading this texture data
  63377. */
  63378. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63379. /**
  63380. * Defines an override for creating textures
  63381. * Return true to stop further extensions from loading this texture
  63382. */
  63383. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63384. /**
  63385. * Defines an override for loading shader strings
  63386. * Return true to stop further extensions from loading this shader data
  63387. */
  63388. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63389. /**
  63390. * Defines an override for loading materials
  63391. * Return true to stop further extensions from loading this material
  63392. */
  63393. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63394. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63395. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63396. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63397. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63398. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63399. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63400. private static LoadTextureBufferAsync;
  63401. private static CreateTextureAsync;
  63402. private static ApplyExtensions;
  63403. }
  63404. }
  63405. declare module BABYLON.GLTF1 {
  63406. /** @hidden */
  63407. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63408. private _bin;
  63409. constructor();
  63410. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63411. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63412. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63413. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63414. }
  63415. }
  63416. declare module BABYLON.GLTF1 {
  63417. /** @hidden */
  63418. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63419. constructor();
  63420. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63421. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63422. private _loadTexture;
  63423. }
  63424. }
  63425. declare module BABYLON.GLTF2.Loader {
  63426. /**
  63427. * Loader interface with an index field.
  63428. */
  63429. export interface IArrayItem {
  63430. /**
  63431. * The index of this item in the array.
  63432. */
  63433. index: number;
  63434. }
  63435. /**
  63436. * Loader interface with additional members.
  63437. */
  63438. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  63439. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63440. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  63441. }
  63442. /**
  63443. * Loader interface with additional members.
  63444. */
  63445. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  63446. }
  63447. /** @hidden */
  63448. export interface _IAnimationSamplerData {
  63449. input: Float32Array;
  63450. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  63451. output: Float32Array;
  63452. }
  63453. /**
  63454. * Loader interface with additional members.
  63455. */
  63456. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  63457. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  63458. }
  63459. /**
  63460. * Loader interface with additional members.
  63461. */
  63462. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  63463. channels: IAnimationChannel[];
  63464. samplers: IAnimationSampler[];
  63465. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  63466. }
  63467. /**
  63468. * Loader interface with additional members.
  63469. */
  63470. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  63471. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63472. }
  63473. /**
  63474. * Loader interface with additional members.
  63475. */
  63476. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  63477. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63478. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  63479. }
  63480. /**
  63481. * Loader interface with additional members.
  63482. */
  63483. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  63484. }
  63485. /**
  63486. * Loader interface with additional members.
  63487. */
  63488. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  63489. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  63490. }
  63491. /**
  63492. * Loader interface with additional members.
  63493. */
  63494. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  63495. }
  63496. /**
  63497. * Loader interface with additional members.
  63498. */
  63499. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  63500. }
  63501. /**
  63502. * Loader interface with additional members.
  63503. */
  63504. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  63505. baseColorTexture?: ITextureInfo;
  63506. metallicRoughnessTexture?: ITextureInfo;
  63507. }
  63508. /**
  63509. * Loader interface with additional members.
  63510. */
  63511. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  63512. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63513. normalTexture?: IMaterialNormalTextureInfo;
  63514. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63515. emissiveTexture?: ITextureInfo;
  63516. /** @hidden */ private _data?: {
  63517. [babylonDrawMode: number]: {
  63518. babylonMaterial: Material;
  63519. babylonMeshes: AbstractMesh[];
  63520. promise: Promise<void>;
  63521. };
  63522. };
  63523. }
  63524. /**
  63525. * Loader interface with additional members.
  63526. */
  63527. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  63528. primitives: IMeshPrimitive[];
  63529. }
  63530. /**
  63531. * Loader interface with additional members.
  63532. */
  63533. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  63534. /** @hidden */ private _instanceData?: {
  63535. babylonSourceMesh: Mesh;
  63536. promise: Promise<any>;
  63537. };
  63538. }
  63539. /**
  63540. * Loader interface with additional members.
  63541. */
  63542. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  63543. /**
  63544. * The parent glTF node.
  63545. */
  63546. parent?: INode;
  63547. /** @hidden */ private _babylonTransformNode?: TransformNode;
  63548. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  63549. /** @hidden */ private _babylonBones?: Bone[];
  63550. /** @hidden */ private _numMorphTargets?: number;
  63551. }
  63552. /** @hidden */
  63553. export interface _ISamplerData {
  63554. noMipMaps: boolean;
  63555. samplingMode: number;
  63556. wrapU: number;
  63557. wrapV: number;
  63558. }
  63559. /**
  63560. * Loader interface with additional members.
  63561. */
  63562. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  63563. /** @hidden */ private _data?: _ISamplerData;
  63564. }
  63565. /**
  63566. * Loader interface with additional members.
  63567. */
  63568. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  63569. }
  63570. /**
  63571. * Loader interface with additional members.
  63572. */
  63573. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  63574. /** @hidden */ private _data?: {
  63575. babylonSkeleton: Skeleton;
  63576. promise: Promise<void>;
  63577. };
  63578. }
  63579. /**
  63580. * Loader interface with additional members.
  63581. */
  63582. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  63583. }
  63584. /**
  63585. * Loader interface with additional members.
  63586. */
  63587. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  63588. }
  63589. /**
  63590. * Loader interface with additional members.
  63591. */
  63592. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  63593. accessors?: IAccessor[];
  63594. animations?: IAnimation[];
  63595. buffers?: IBuffer[];
  63596. bufferViews?: IBufferView[];
  63597. cameras?: ICamera[];
  63598. images?: IImage[];
  63599. materials?: IMaterial[];
  63600. meshes?: IMesh[];
  63601. nodes?: INode[];
  63602. samplers?: ISampler[];
  63603. scenes?: IScene[];
  63604. skins?: ISkin[];
  63605. textures?: ITexture[];
  63606. }
  63607. }
  63608. declare module BABYLON.GLTF2 {
  63609. /**
  63610. * Interface for a glTF loader extension.
  63611. */
  63612. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  63613. /**
  63614. * Called after the loader state changes to LOADING.
  63615. */
  63616. onLoading?(): void;
  63617. /**
  63618. * Called after the loader state changes to READY.
  63619. */
  63620. onReady?(): void;
  63621. /**
  63622. * Define this method to modify the default behavior when loading scenes.
  63623. * @param context The context when loading the asset
  63624. * @param scene The glTF scene property
  63625. * @returns A promise that resolves when the load is complete or null if not handled
  63626. */
  63627. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  63628. /**
  63629. * Define this method to modify the default behavior when loading nodes.
  63630. * @param context The context when loading the asset
  63631. * @param node The glTF node property
  63632. * @param assign A function called synchronously after parsing the glTF properties
  63633. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  63634. */
  63635. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63636. /**
  63637. * Define this method to modify the default behavior when loading cameras.
  63638. * @param context The context when loading the asset
  63639. * @param camera The glTF camera property
  63640. * @param assign A function called synchronously after parsing the glTF properties
  63641. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  63642. */
  63643. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  63644. /**
  63645. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  63646. * @param context The context when loading the asset
  63647. * @param primitive The glTF mesh primitive property
  63648. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  63649. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63650. /**
  63651. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63652. * @param context The context when loading the asset
  63653. * @param name The mesh name when loading the asset
  63654. * @param node The glTF node when loading the asset
  63655. * @param mesh The glTF mesh when loading the asset
  63656. * @param primitive The glTF mesh primitive property
  63657. * @param assign A function called synchronously after parsing the glTF properties
  63658. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63659. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63660. /**
  63661. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  63662. * @param context The context when loading the asset
  63663. * @param material The glTF material property
  63664. * @param assign A function called synchronously after parsing the glTF properties
  63665. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  63666. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  63667. /**
  63668. * Define this method to modify the default behavior when creating materials.
  63669. * @param context The context when loading the asset
  63670. * @param material The glTF material property
  63671. * @param babylonDrawMode The draw mode for the Babylon material
  63672. * @returns The Babylon material or null if not handled
  63673. */
  63674. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  63675. /**
  63676. * Define this method to modify the default behavior when loading material properties.
  63677. * @param context The context when loading the asset
  63678. * @param material The glTF material property
  63679. * @param babylonMaterial The Babylon material
  63680. * @returns A promise that resolves when the load is complete or null if not handled
  63681. */
  63682. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63683. /**
  63684. * Define this method to modify the default behavior when loading texture infos.
  63685. * @param context The context when loading the asset
  63686. * @param textureInfo The glTF texture info property
  63687. * @param assign A function called synchronously after parsing the glTF properties
  63688. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  63689. */
  63690. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63691. /**
  63692. * Define this method to modify the default behavior when loading animations.
  63693. * @param context The context when loading the asset
  63694. * @param animation The glTF animation property
  63695. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  63696. */
  63697. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  63698. /**
  63699. * @hidden Define this method to modify the default behavior when loading skins.
  63700. * @param context The context when loading the asset
  63701. * @param node The glTF node property
  63702. * @param skin The glTF skin property
  63703. * @returns A promise that resolves when the load is complete or null if not handled
  63704. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  63705. /**
  63706. * @hidden Define this method to modify the default behavior when loading uris.
  63707. * @param context The context when loading the asset
  63708. * @param property The glTF property associated with the uri
  63709. * @param uri The uri to load
  63710. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  63711. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  63712. }
  63713. }
  63714. declare module BABYLON.GLTF2 {
  63715. /**
  63716. * Helper class for working with arrays when loading the glTF asset
  63717. */
  63718. export class ArrayItem {
  63719. /**
  63720. * Gets an item from the given array.
  63721. * @param context The context when loading the asset
  63722. * @param array The array to get the item from
  63723. * @param index The index to the array
  63724. * @returns The array item
  63725. */
  63726. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  63727. /**
  63728. * Assign an `index` field to each item of the given array.
  63729. * @param array The array of items
  63730. */
  63731. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  63732. }
  63733. /**
  63734. * The glTF 2.0 loader
  63735. */
  63736. export class GLTFLoader implements IGLTFLoader {
  63737. /** @hidden */ private _completePromises: Promise<any>[];
  63738. private _disposed;
  63739. private _parent;
  63740. private _state;
  63741. private _extensions;
  63742. private _rootUrl;
  63743. private _fileName;
  63744. private _uniqueRootUrl;
  63745. private _gltf;
  63746. private _babylonScene;
  63747. private _rootBabylonMesh;
  63748. private _defaultBabylonMaterialData;
  63749. private _progressCallback?;
  63750. private _requests;
  63751. private static readonly _DefaultSampler;
  63752. private static _ExtensionNames;
  63753. private static _ExtensionFactories;
  63754. /**
  63755. * Registers a loader extension.
  63756. * @param name The name of the loader extension.
  63757. * @param factory The factory function that creates the loader extension.
  63758. */
  63759. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  63760. /**
  63761. * Unregisters a loader extension.
  63762. * @param name The name of the loader extenion.
  63763. * @returns A boolean indicating whether the extension has been unregistered
  63764. */
  63765. static UnregisterExtension(name: string): boolean;
  63766. /**
  63767. * Gets the loader state.
  63768. */
  63769. readonly state: Nullable<GLTFLoaderState>;
  63770. /**
  63771. * The glTF object parsed from the JSON.
  63772. */
  63773. readonly gltf: IGLTF;
  63774. /**
  63775. * The Babylon scene when loading the asset.
  63776. */
  63777. readonly babylonScene: Scene;
  63778. /**
  63779. * The root Babylon mesh when loading the asset.
  63780. */
  63781. readonly rootBabylonMesh: Mesh;
  63782. /** @hidden */
  63783. constructor(parent: GLTFFileLoader);
  63784. /** @hidden */
  63785. dispose(): void;
  63786. /** @hidden */
  63787. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63788. meshes: AbstractMesh[];
  63789. particleSystems: IParticleSystem[];
  63790. skeletons: Skeleton[];
  63791. animationGroups: AnimationGroup[];
  63792. }>;
  63793. /** @hidden */
  63794. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63795. private _loadAsync;
  63796. private _loadData;
  63797. private _setupData;
  63798. private _loadExtensions;
  63799. private _checkExtensions;
  63800. private _setState;
  63801. private _createRootNode;
  63802. /**
  63803. * Loads a glTF scene.
  63804. * @param context The context when loading the asset
  63805. * @param scene The glTF scene property
  63806. * @returns A promise that resolves when the load is complete
  63807. */
  63808. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  63809. private _forEachPrimitive;
  63810. private _getMeshes;
  63811. private _getSkeletons;
  63812. private _getAnimationGroups;
  63813. private _startAnimations;
  63814. /**
  63815. * Loads a glTF node.
  63816. * @param context The context when loading the asset
  63817. * @param node The glTF node property
  63818. * @param assign A function called synchronously after parsing the glTF properties
  63819. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  63820. */
  63821. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  63822. private _loadMeshAsync;
  63823. /**
  63824. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63825. * @param context The context when loading the asset
  63826. * @param name The mesh name when loading the asset
  63827. * @param node The glTF node when loading the asset
  63828. * @param mesh The glTF mesh when loading the asset
  63829. * @param primitive The glTF mesh primitive property
  63830. * @param assign A function called synchronously after parsing the glTF properties
  63831. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63832. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63833. private _loadVertexDataAsync;
  63834. private _createMorphTargets;
  63835. private _loadMorphTargetsAsync;
  63836. private _loadMorphTargetVertexDataAsync;
  63837. private static _LoadTransform;
  63838. private _loadSkinAsync;
  63839. private _loadBones;
  63840. private _loadBone;
  63841. private _loadSkinInverseBindMatricesDataAsync;
  63842. private _updateBoneMatrices;
  63843. private _getNodeMatrix;
  63844. /**
  63845. * Loads a glTF camera.
  63846. * @param context The context when loading the asset
  63847. * @param camera The glTF camera property
  63848. * @param assign A function called synchronously after parsing the glTF properties
  63849. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  63850. */
  63851. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  63852. private _loadAnimationsAsync;
  63853. /**
  63854. * Loads a glTF animation.
  63855. * @param context The context when loading the asset
  63856. * @param animation The glTF animation property
  63857. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  63858. */
  63859. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  63860. /**
  63861. * @hidden Loads a glTF animation channel.
  63862. * @param context The context when loading the asset
  63863. * @param animationContext The context of the animation when loading the asset
  63864. * @param animation The glTF animation property
  63865. * @param channel The glTF animation channel property
  63866. * @param babylonAnimationGroup The babylon animation group property
  63867. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  63868. * @returns A void promise when the channel load is complete
  63869. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  63870. private _loadAnimationSamplerAsync;
  63871. private _loadBufferAsync;
  63872. /**
  63873. * Loads a glTF buffer view.
  63874. * @param context The context when loading the asset
  63875. * @param bufferView The glTF buffer view property
  63876. * @returns A promise that resolves with the loaded data when the load is complete
  63877. */
  63878. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  63879. private _loadIndicesAccessorAsync;
  63880. private _loadFloatAccessorAsync;
  63881. private _loadVertexBufferViewAsync;
  63882. private _loadVertexAccessorAsync;
  63883. private _loadMaterialMetallicRoughnessPropertiesAsync;
  63884. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  63885. private _createDefaultMaterial;
  63886. /**
  63887. * Creates a Babylon material from a glTF material.
  63888. * @param context The context when loading the asset
  63889. * @param material The glTF material property
  63890. * @param babylonDrawMode The draw mode for the Babylon material
  63891. * @returns The Babylon material
  63892. */
  63893. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  63894. /**
  63895. * Loads properties from a glTF material into a Babylon material.
  63896. * @param context The context when loading the asset
  63897. * @param material The glTF material property
  63898. * @param babylonMaterial The Babylon material
  63899. * @returns A promise that resolves when the load is complete
  63900. */
  63901. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63902. /**
  63903. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  63904. * @param context The context when loading the asset
  63905. * @param material The glTF material property
  63906. * @param babylonMaterial The Babylon material
  63907. * @returns A promise that resolves when the load is complete
  63908. */
  63909. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63910. /**
  63911. * Loads the alpha properties from a glTF material into a Babylon material.
  63912. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  63913. * @param context The context when loading the asset
  63914. * @param material The glTF material property
  63915. * @param babylonMaterial The Babylon material
  63916. */
  63917. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  63918. /**
  63919. * Loads a glTF texture info.
  63920. * @param context The context when loading the asset
  63921. * @param textureInfo The glTF texture info property
  63922. * @param assign A function called synchronously after parsing the glTF properties
  63923. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  63924. */
  63925. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  63926. private _loadTextureAsync;
  63927. private _loadSampler;
  63928. /**
  63929. * Loads a glTF image.
  63930. * @param context The context when loading the asset
  63931. * @param image The glTF image property
  63932. * @returns A promise that resolves with the loaded data when the load is complete
  63933. */
  63934. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  63935. /**
  63936. * Loads a glTF uri.
  63937. * @param context The context when loading the asset
  63938. * @param property The glTF property associated with the uri
  63939. * @param uri The base64 or relative uri
  63940. * @returns A promise that resolves with the loaded data when the load is complete
  63941. */
  63942. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  63943. private _onProgress;
  63944. /**
  63945. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  63946. * @param babylonObject the Babylon object with metadata
  63947. * @param pointer the JSON pointer
  63948. */
  63949. static AddPointerMetadata(babylonObject: {
  63950. metadata: any;
  63951. }, pointer: string): void;
  63952. private static _GetTextureWrapMode;
  63953. private static _GetTextureSamplingMode;
  63954. private static _GetTypedArray;
  63955. private static _GetNumComponents;
  63956. private static _ValidateUri;
  63957. private static _GetDrawMode;
  63958. private _compileMaterialsAsync;
  63959. private _compileShadowGeneratorsAsync;
  63960. private _forEachExtensions;
  63961. private _applyExtensions;
  63962. private _extensionsOnLoading;
  63963. private _extensionsOnReady;
  63964. private _extensionsLoadSceneAsync;
  63965. private _extensionsLoadNodeAsync;
  63966. private _extensionsLoadCameraAsync;
  63967. private _extensionsLoadVertexDataAsync;
  63968. private _extensionsLoadMeshPrimitiveAsync;
  63969. private _extensionsLoadMaterialAsync;
  63970. private _extensionsCreateMaterial;
  63971. private _extensionsLoadMaterialPropertiesAsync;
  63972. private _extensionsLoadTextureInfoAsync;
  63973. private _extensionsLoadAnimationAsync;
  63974. private _extensionsLoadSkinAsync;
  63975. private _extensionsLoadUriAsync;
  63976. /**
  63977. * Helper method called by a loader extension to load an glTF extension.
  63978. * @param context The context when loading the asset
  63979. * @param property The glTF property to load the extension from
  63980. * @param extensionName The name of the extension to load
  63981. * @param actionAsync The action to run
  63982. * @returns The promise returned by actionAsync or null if the extension does not exist
  63983. */
  63984. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63985. /**
  63986. * Helper method called by a loader extension to load a glTF extra.
  63987. * @param context The context when loading the asset
  63988. * @param property The glTF property to load the extra from
  63989. * @param extensionName The name of the extension to load
  63990. * @param actionAsync The action to run
  63991. * @returns The promise returned by actionAsync or null if the extra does not exist
  63992. */
  63993. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63994. /**
  63995. * Increments the indentation level and logs a message.
  63996. * @param message The message to log
  63997. */
  63998. logOpen(message: string): void;
  63999. /**
  64000. * Decrements the indentation level.
  64001. */
  64002. logClose(): void;
  64003. /**
  64004. * Logs a message
  64005. * @param message The message to log
  64006. */
  64007. log(message: string): void;
  64008. /**
  64009. * Starts a performance counter.
  64010. * @param counterName The name of the performance counter
  64011. */
  64012. startPerformanceCounter(counterName: string): void;
  64013. /**
  64014. * Ends a performance counter.
  64015. * @param counterName The name of the performance counter
  64016. */
  64017. endPerformanceCounter(counterName: string): void;
  64018. }
  64019. }
  64020. declare module BABYLON.GLTF2.Loader.Extensions {
  64021. /**
  64022. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64023. */
  64024. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64025. /** The name of this extension. */
  64026. readonly name: string;
  64027. /** Defines whether this extension is enabled. */
  64028. enabled: boolean;
  64029. private _loader;
  64030. private _lights?;
  64031. /** @hidden */
  64032. constructor(loader: GLTFLoader);
  64033. /** @hidden */
  64034. dispose(): void;
  64035. /** @hidden */
  64036. onLoading(): void;
  64037. /** @hidden */
  64038. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64039. private _loadLightAsync;
  64040. }
  64041. }
  64042. declare module BABYLON.GLTF2.Loader.Extensions {
  64043. /**
  64044. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64045. */
  64046. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64047. /** The name of this extension. */
  64048. readonly name: string;
  64049. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64050. dracoCompression?: DracoCompression;
  64051. /** Defines whether this extension is enabled. */
  64052. enabled: boolean;
  64053. private _loader;
  64054. /** @hidden */
  64055. constructor(loader: GLTFLoader);
  64056. /** @hidden */
  64057. dispose(): void;
  64058. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64059. }
  64060. }
  64061. declare module BABYLON.GLTF2.Loader.Extensions {
  64062. /**
  64063. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  64064. */
  64065. export class KHR_lights implements IGLTFLoaderExtension {
  64066. /** The name of this extension. */
  64067. readonly name: string;
  64068. /** Defines whether this extension is enabled. */
  64069. enabled: boolean;
  64070. private _loader;
  64071. private _lights?;
  64072. /** @hidden */
  64073. constructor(loader: GLTFLoader);
  64074. /** @hidden */
  64075. dispose(): void;
  64076. /** @hidden */
  64077. onLoading(): void;
  64078. /** @hidden */
  64079. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64080. }
  64081. }
  64082. declare module BABYLON.GLTF2.Loader.Extensions {
  64083. /**
  64084. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  64085. */
  64086. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  64087. /** The name of this extension. */
  64088. readonly name: string;
  64089. /** Defines whether this extension is enabled. */
  64090. enabled: boolean;
  64091. private _loader;
  64092. /** @hidden */
  64093. constructor(loader: GLTFLoader);
  64094. /** @hidden */
  64095. dispose(): void;
  64096. /** @hidden */
  64097. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64098. private _loadSpecularGlossinessPropertiesAsync;
  64099. }
  64100. }
  64101. declare module BABYLON.GLTF2.Loader.Extensions {
  64102. /**
  64103. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  64104. */
  64105. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  64106. /** The name of this extension. */
  64107. readonly name: string;
  64108. /** Defines whether this extension is enabled. */
  64109. enabled: boolean;
  64110. private _loader;
  64111. /** @hidden */
  64112. constructor(loader: GLTFLoader);
  64113. /** @hidden */
  64114. dispose(): void;
  64115. /** @hidden */
  64116. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64117. private _loadUnlitPropertiesAsync;
  64118. }
  64119. }
  64120. declare module BABYLON.GLTF2.Loader.Extensions {
  64121. /**
  64122. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  64123. */
  64124. export class KHR_texture_transform implements IGLTFLoaderExtension {
  64125. /** The name of this extension. */
  64126. readonly name: string;
  64127. /** Defines whether this extension is enabled. */
  64128. enabled: boolean;
  64129. private _loader;
  64130. /** @hidden */
  64131. constructor(loader: GLTFLoader);
  64132. /** @hidden */
  64133. dispose(): void;
  64134. /** @hidden */
  64135. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64136. }
  64137. }
  64138. declare module BABYLON.GLTF2.Loader.Extensions {
  64139. /**
  64140. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  64141. */
  64142. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  64143. /** The name of this extension. */
  64144. readonly name: string;
  64145. /** Defines whether this extension is enabled. */
  64146. enabled: boolean;
  64147. private _loader;
  64148. private _clips;
  64149. private _emitters;
  64150. /** @hidden */
  64151. constructor(loader: GLTFLoader);
  64152. /** @hidden */
  64153. dispose(): void;
  64154. /** @hidden */
  64155. onLoading(): void;
  64156. /** @hidden */
  64157. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64158. /** @hidden */
  64159. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64160. /** @hidden */
  64161. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64162. private _loadClipAsync;
  64163. private _loadEmitterAsync;
  64164. private _getEventAction;
  64165. private _loadAnimationEventAsync;
  64166. }
  64167. }
  64168. declare module BABYLON.GLTF2.Loader.Extensions {
  64169. /**
  64170. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64171. */
  64172. export class MSFT_lod implements IGLTFLoaderExtension {
  64173. /** The name of this extension. */
  64174. readonly name: string;
  64175. /** Defines whether this extension is enabled. */
  64176. enabled: boolean;
  64177. /**
  64178. * Maximum number of LODs to load, starting from the lowest LOD.
  64179. */
  64180. maxLODsToLoad: number;
  64181. /**
  64182. * Observable raised when all node LODs of one level are loaded.
  64183. * The event data is the index of the loaded LOD starting from zero.
  64184. * Dispose the loader to cancel the loading of the next level of LODs.
  64185. */
  64186. onNodeLODsLoadedObservable: Observable<number>;
  64187. /**
  64188. * Observable raised when all material LODs of one level are loaded.
  64189. * The event data is the index of the loaded LOD starting from zero.
  64190. * Dispose the loader to cancel the loading of the next level of LODs.
  64191. */
  64192. onMaterialLODsLoadedObservable: Observable<number>;
  64193. private _loader;
  64194. private _nodeIndexLOD;
  64195. private _nodeSignalLODs;
  64196. private _nodePromiseLODs;
  64197. private _materialIndexLOD;
  64198. private _materialSignalLODs;
  64199. private _materialPromiseLODs;
  64200. /** @hidden */
  64201. constructor(loader: GLTFLoader);
  64202. /** @hidden */
  64203. dispose(): void;
  64204. /** @hidden */
  64205. onReady(): void;
  64206. /** @hidden */
  64207. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64208. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64209. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64210. /**
  64211. * Gets an array of LOD properties from lowest to highest.
  64212. */
  64213. private _getLODs;
  64214. private _disposeUnusedMaterials;
  64215. }
  64216. }
  64217. declare module BABYLON.GLTF2.Loader.Extensions {
  64218. /** @hidden */
  64219. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64220. readonly name: string;
  64221. enabled: boolean;
  64222. private _loader;
  64223. constructor(loader: GLTFLoader);
  64224. dispose(): void;
  64225. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64226. }
  64227. }
  64228. declare module BABYLON.GLTF2.Loader.Extensions {
  64229. /** @hidden */
  64230. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64231. readonly name: string;
  64232. enabled: boolean;
  64233. private _loader;
  64234. constructor(loader: GLTFLoader);
  64235. dispose(): void;
  64236. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64237. }
  64238. }
  64239. declare module BABYLON.GLTF2.Loader.Extensions {
  64240. /**
  64241. * Store glTF extras (if present) in BJS objects' metadata
  64242. */
  64243. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  64244. /** The name of this extension. */
  64245. readonly name: string;
  64246. /** Defines whether this extension is enabled. */
  64247. enabled: boolean;
  64248. private _loader;
  64249. private _assignExtras;
  64250. /** @hidden */
  64251. constructor(loader: GLTFLoader);
  64252. /** @hidden */
  64253. dispose(): void;
  64254. /** @hidden */
  64255. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64256. /** @hidden */
  64257. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64258. /** @hidden */
  64259. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * Class reading and parsing the MTL file bundled with the obj file.
  64265. */
  64266. export class MTLFileLoader {
  64267. /**
  64268. * All material loaded from the mtl will be set here
  64269. */
  64270. materials: StandardMaterial[];
  64271. /**
  64272. * This function will read the mtl file and create each material described inside
  64273. * This function could be improve by adding :
  64274. * -some component missing (Ni, Tf...)
  64275. * -including the specific options available
  64276. *
  64277. * @param scene defines the scene the material will be created in
  64278. * @param data defines the mtl data to parse
  64279. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64280. */
  64281. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64282. /**
  64283. * Gets the texture for the material.
  64284. *
  64285. * If the material is imported from input file,
  64286. * We sanitize the url to ensure it takes the textre from aside the material.
  64287. *
  64288. * @param rootUrl The root url to load from
  64289. * @param value The value stored in the mtl
  64290. * @return The Texture
  64291. */
  64292. private static _getTexture;
  64293. }
  64294. /**
  64295. * Options for loading OBJ/MTL files
  64296. */
  64297. type MeshLoadOptions = {
  64298. /**
  64299. * Defines if UVs are optimized by default during load.
  64300. */
  64301. OptimizeWithUV: boolean;
  64302. /**
  64303. * Defines custom scaling of UV coordinates of loaded meshes.
  64304. */
  64305. UVScaling: Vector2;
  64306. /**
  64307. * Invert model on y-axis (does a model scaling inversion)
  64308. */
  64309. InvertY: boolean;
  64310. /**
  64311. * Invert Y-Axis of referenced textures on load
  64312. */
  64313. InvertTextureY: boolean;
  64314. /**
  64315. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64316. */
  64317. ImportVertexColors: boolean;
  64318. /**
  64319. * Compute the normals for the model, even if normals are present in the file.
  64320. */
  64321. ComputeNormals: boolean;
  64322. /**
  64323. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64324. */
  64325. SkipMaterials: boolean;
  64326. /**
  64327. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64328. */
  64329. MaterialLoadingFailsSilently: boolean;
  64330. };
  64331. /**
  64332. * OBJ file type loader.
  64333. * This is a babylon scene loader plugin.
  64334. */
  64335. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64336. /**
  64337. * Defines if UVs are optimized by default during load.
  64338. */
  64339. static OPTIMIZE_WITH_UV: boolean;
  64340. /**
  64341. * Invert model on y-axis (does a model scaling inversion)
  64342. */
  64343. static INVERT_Y: boolean;
  64344. /**
  64345. * Invert Y-Axis of referenced textures on load
  64346. */
  64347. static INVERT_TEXTURE_Y: boolean;
  64348. /**
  64349. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64350. */
  64351. static IMPORT_VERTEX_COLORS: boolean;
  64352. /**
  64353. * Compute the normals for the model, even if normals are present in the file.
  64354. */
  64355. static COMPUTE_NORMALS: boolean;
  64356. /**
  64357. * Defines custom scaling of UV coordinates of loaded meshes.
  64358. */
  64359. static UV_SCALING: Vector2;
  64360. /**
  64361. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64362. */
  64363. static SKIP_MATERIALS: boolean;
  64364. /**
  64365. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64366. *
  64367. * Defaults to true for backwards compatibility.
  64368. */
  64369. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64370. /**
  64371. * Defines the name of the plugin.
  64372. */
  64373. name: string;
  64374. /**
  64375. * Defines the extension the plugin is able to load.
  64376. */
  64377. extensions: string;
  64378. /** @hidden */
  64379. obj: RegExp;
  64380. /** @hidden */
  64381. group: RegExp;
  64382. /** @hidden */
  64383. mtllib: RegExp;
  64384. /** @hidden */
  64385. usemtl: RegExp;
  64386. /** @hidden */
  64387. smooth: RegExp;
  64388. /** @hidden */
  64389. vertexPattern: RegExp;
  64390. /** @hidden */
  64391. normalPattern: RegExp;
  64392. /** @hidden */
  64393. uvPattern: RegExp;
  64394. /** @hidden */
  64395. facePattern1: RegExp;
  64396. /** @hidden */
  64397. facePattern2: RegExp;
  64398. /** @hidden */
  64399. facePattern3: RegExp;
  64400. /** @hidden */
  64401. facePattern4: RegExp;
  64402. /** @hidden */
  64403. facePattern5: RegExp;
  64404. private _meshLoadOptions;
  64405. /**
  64406. * Creates loader for .OBJ files
  64407. *
  64408. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64409. */
  64410. constructor(meshLoadOptions?: MeshLoadOptions);
  64411. private static readonly currentMeshLoadOptions;
  64412. /**
  64413. * Calls synchronously the MTL file attached to this obj.
  64414. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64415. * Without this function materials are not displayed in the first frame (but displayed after).
  64416. * In consequence it is impossible to get material information in your HTML file
  64417. *
  64418. * @param url The URL of the MTL file
  64419. * @param rootUrl
  64420. * @param onSuccess Callback function to be called when the MTL file is loaded
  64421. * @private
  64422. */
  64423. private _loadMTL;
  64424. /**
  64425. * Instantiates a OBJ file loader plugin.
  64426. * @returns the created plugin
  64427. */
  64428. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64429. /**
  64430. * If the data string can be loaded directly.
  64431. *
  64432. * @param data string containing the file data
  64433. * @returns if the data can be loaded directly
  64434. */
  64435. canDirectLoad(data: string): boolean;
  64436. /**
  64437. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  64438. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64439. * @param scene the scene the meshes should be added to
  64440. * @param data the OBJ data to load
  64441. * @param rootUrl root url to load from
  64442. * @param onProgress event that fires when loading progress has occured
  64443. * @param fileName Defines the name of the file to load
  64444. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64445. */
  64446. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64447. meshes: AbstractMesh[];
  64448. particleSystems: IParticleSystem[];
  64449. skeletons: Skeleton[];
  64450. animationGroups: AnimationGroup[];
  64451. }>;
  64452. /**
  64453. * Imports all objects from the loaded OBJ data and adds them to the scene
  64454. * @param scene the scene the objects should be added to
  64455. * @param data the OBJ data to load
  64456. * @param rootUrl root url to load from
  64457. * @param onProgress event that fires when loading progress has occured
  64458. * @param fileName Defines the name of the file to load
  64459. * @returns a promise which completes when objects have been loaded to the scene
  64460. */
  64461. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64462. /**
  64463. * Load into an asset container.
  64464. * @param scene The scene to load into
  64465. * @param data The data to import
  64466. * @param rootUrl The root url for scene and resources
  64467. * @param onProgress The callback when the load progresses
  64468. * @param fileName Defines the name of the file to load
  64469. * @returns The loaded asset container
  64470. */
  64471. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64472. /**
  64473. * Read the OBJ file and create an Array of meshes.
  64474. * Each mesh contains all information given by the OBJ and the MTL file.
  64475. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  64476. *
  64477. * @param meshesNames
  64478. * @param scene Scene The scene where are displayed the data
  64479. * @param data String The content of the obj file
  64480. * @param rootUrl String The path to the folder
  64481. * @returns Array<AbstractMesh>
  64482. * @private
  64483. */
  64484. private _parseSolid;
  64485. }
  64486. }
  64487. declare module BABYLON {
  64488. /**
  64489. * STL file type loader.
  64490. * This is a babylon scene loader plugin.
  64491. */
  64492. export class STLFileLoader implements ISceneLoaderPlugin {
  64493. /** @hidden */
  64494. solidPattern: RegExp;
  64495. /** @hidden */
  64496. facetsPattern: RegExp;
  64497. /** @hidden */
  64498. normalPattern: RegExp;
  64499. /** @hidden */
  64500. vertexPattern: RegExp;
  64501. /**
  64502. * Defines the name of the plugin.
  64503. */
  64504. name: string;
  64505. /**
  64506. * Defines the extensions the stl loader is able to load.
  64507. * force data to come in as an ArrayBuffer
  64508. * we'll convert to string if it looks like it's an ASCII .stl
  64509. */
  64510. extensions: ISceneLoaderPluginExtensions;
  64511. /**
  64512. * Import meshes into a scene.
  64513. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  64514. * @param scene The scene to import into
  64515. * @param data The data to import
  64516. * @param rootUrl The root url for scene and resources
  64517. * @param meshes The meshes array to import into
  64518. * @param particleSystems The particle systems array to import into
  64519. * @param skeletons The skeletons array to import into
  64520. * @param onError The callback when import fails
  64521. * @returns True if successful or false otherwise
  64522. */
  64523. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  64524. /**
  64525. * Load into a scene.
  64526. * @param scene The scene to load into
  64527. * @param data The data to import
  64528. * @param rootUrl The root url for scene and resources
  64529. * @param onError The callback when import fails
  64530. * @returns true if successful or false otherwise
  64531. */
  64532. load(scene: Scene, data: any, rootUrl: string): boolean;
  64533. /**
  64534. * Load into an asset container.
  64535. * @param scene The scene to load into
  64536. * @param data The data to import
  64537. * @param rootUrl The root url for scene and resources
  64538. * @param onError The callback when import fails
  64539. * @returns The loaded asset container
  64540. */
  64541. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  64542. private _isBinary;
  64543. private _parseBinary;
  64544. private _parseASCII;
  64545. }
  64546. }
  64547. declare module BABYLON {
  64548. /**
  64549. * Class for generating OBJ data from a Babylon scene.
  64550. */
  64551. export class OBJExport {
  64552. /**
  64553. * Exports the geometry of a Mesh array in .OBJ file format (text)
  64554. * @param mesh defines the list of meshes to serialize
  64555. * @param materials defines if materials should be exported
  64556. * @param matlibname defines the name of the associated mtl file
  64557. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  64558. * @returns the OBJ content
  64559. */
  64560. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  64561. /**
  64562. * Exports the material(s) of a mesh in .MTL file format (text)
  64563. * @param mesh defines the mesh to extract the material from
  64564. * @returns the mtl content
  64565. */
  64566. static MTL(mesh: Mesh): string;
  64567. }
  64568. }
  64569. declare module BABYLON {
  64570. /** @hidden */
  64571. export var __IGLTFExporterExtension: number;
  64572. /**
  64573. * Interface for extending the exporter
  64574. * @hidden
  64575. */
  64576. export interface IGLTFExporterExtension {
  64577. /**
  64578. * The name of this extension
  64579. */
  64580. readonly name: string;
  64581. /**
  64582. * Defines whether this extension is enabled
  64583. */
  64584. enabled: boolean;
  64585. /**
  64586. * Defines whether this extension is required
  64587. */
  64588. required: boolean;
  64589. }
  64590. }
  64591. declare module BABYLON.GLTF2.Exporter {
  64592. /** @hidden */
  64593. export var __IGLTFExporterExtensionV2: number;
  64594. /**
  64595. * Interface for a glTF exporter extension
  64596. * @hidden
  64597. */
  64598. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  64599. /**
  64600. * Define this method to modify the default behavior before exporting a texture
  64601. * @param context The context when loading the asset
  64602. * @param babylonTexture The glTF texture info property
  64603. * @param mimeType The mime-type of the generated image
  64604. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  64605. */
  64606. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64607. /**
  64608. * Define this method to modify the default behavior when exporting texture info
  64609. * @param context The context when loading the asset
  64610. * @param meshPrimitive glTF mesh primitive
  64611. * @param babylonSubMesh Babylon submesh
  64612. * @param binaryWriter glTF serializer binary writer instance
  64613. * @returns nullable IMeshPrimitive promise
  64614. */
  64615. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  64616. /**
  64617. * Define this method to modify the default behavior when exporting a node
  64618. * @param context The context when exporting the node
  64619. * @param node glTF node
  64620. * @param babylonNode BabylonJS node
  64621. * @returns nullable INode promise
  64622. */
  64623. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64624. /**
  64625. * Called after the exporter state changes to EXPORTING
  64626. */
  64627. onExporting?(): void;
  64628. }
  64629. }
  64630. declare module BABYLON.GLTF2.Exporter {
  64631. /**
  64632. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  64633. * @hidden
  64634. */
  64635. export class _GLTFMaterialExporter {
  64636. /**
  64637. * Represents the dielectric specular values for R, G and B
  64638. */
  64639. private static readonly _DielectricSpecular;
  64640. /**
  64641. * Allows the maximum specular power to be defined for material calculations
  64642. */
  64643. private static readonly _MaxSpecularPower;
  64644. /**
  64645. * Mapping to store textures
  64646. */
  64647. private _textureMap;
  64648. /**
  64649. * Numeric tolerance value
  64650. */
  64651. private static readonly _Epsilon;
  64652. /**
  64653. * Reference to the glTF Exporter
  64654. */
  64655. private _exporter;
  64656. constructor(exporter: _Exporter);
  64657. /**
  64658. * Specifies if two colors are approximately equal in value
  64659. * @param color1 first color to compare to
  64660. * @param color2 second color to compare to
  64661. * @param epsilon threshold value
  64662. */
  64663. private static FuzzyEquals;
  64664. /**
  64665. * Gets the materials from a Babylon scene and converts them to glTF materials
  64666. * @param scene babylonjs scene
  64667. * @param mimeType texture mime type
  64668. * @param images array of images
  64669. * @param textures array of textures
  64670. * @param materials array of materials
  64671. * @param imageData mapping of texture names to base64 textures
  64672. * @param hasTextureCoords specifies if texture coordinates are present on the material
  64673. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64674. /**
  64675. * Makes a copy of the glTF material without the texture parameters
  64676. * @param originalMaterial original glTF material
  64677. * @returns glTF material without texture parameters
  64678. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  64679. /**
  64680. * Specifies if the material has any texture parameters present
  64681. * @param material glTF Material
  64682. * @returns boolean specifying if texture parameters are present
  64683. */ private _hasTexturesPresent(material: IMaterial): boolean;
  64684. /**
  64685. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  64686. * @param babylonStandardMaterial
  64687. * @returns glTF Metallic Roughness Material representation
  64688. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  64689. /**
  64690. * Computes the metallic factor
  64691. * @param diffuse diffused value
  64692. * @param specular specular value
  64693. * @param oneMinusSpecularStrength one minus the specular strength
  64694. * @returns metallic value
  64695. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  64696. /**
  64697. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  64698. * @param glTFMaterial glTF material
  64699. * @param babylonMaterial Babylon material
  64700. */
  64701. private static _SetAlphaMode;
  64702. /**
  64703. * Converts a Babylon Standard Material to a glTF Material
  64704. * @param babylonStandardMaterial BJS Standard Material
  64705. * @param mimeType mime type to use for the textures
  64706. * @param images array of glTF image interfaces
  64707. * @param textures array of glTF texture interfaces
  64708. * @param materials array of glTF material interfaces
  64709. * @param imageData map of image file name to data
  64710. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64711. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64712. /**
  64713. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64714. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  64715. * @param mimeType mime type to use for the textures
  64716. * @param images array of glTF image interfaces
  64717. * @param textures array of glTF texture interfaces
  64718. * @param materials array of glTF material interfaces
  64719. * @param imageData map of image file name to data
  64720. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64721. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64722. /**
  64723. * Converts an image typed array buffer to a base64 image
  64724. * @param buffer typed array buffer
  64725. * @param width width of the image
  64726. * @param height height of the image
  64727. * @param mimeType mimetype of the image
  64728. * @returns base64 image string
  64729. */
  64730. private _createBase64FromCanvasAsync;
  64731. /**
  64732. * Generates a white texture based on the specified width and height
  64733. * @param width width of the texture in pixels
  64734. * @param height height of the texture in pixels
  64735. * @param scene babylonjs scene
  64736. * @returns white texture
  64737. */
  64738. private _createWhiteTexture;
  64739. /**
  64740. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  64741. * @param texture1 first texture to resize
  64742. * @param texture2 second texture to resize
  64743. * @param scene babylonjs scene
  64744. * @returns resized textures or null
  64745. */
  64746. private _resizeTexturesToSameDimensions;
  64747. /**
  64748. * Converts an array of pixels to a Float32Array
  64749. * Throws an error if the pixel format is not supported
  64750. * @param pixels - array buffer containing pixel values
  64751. * @returns Float32 of pixels
  64752. */
  64753. private _convertPixelArrayToFloat32;
  64754. /**
  64755. * Convert Specular Glossiness Textures to Metallic Roughness
  64756. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  64757. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  64758. * @param diffuseTexture texture used to store diffuse information
  64759. * @param specularGlossinessTexture texture used to store specular and glossiness information
  64760. * @param factors specular glossiness material factors
  64761. * @param mimeType the mime type to use for the texture
  64762. * @returns pbr metallic roughness interface or null
  64763. */
  64764. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  64765. /**
  64766. * Converts specular glossiness material properties to metallic roughness
  64767. * @param specularGlossiness interface with specular glossiness material properties
  64768. * @returns interface with metallic roughness material properties
  64769. */
  64770. private _convertSpecularGlossinessToMetallicRoughness;
  64771. /**
  64772. * Calculates the surface reflectance, independent of lighting conditions
  64773. * @param color Color source to calculate brightness from
  64774. * @returns number representing the perceived brightness, or zero if color is undefined
  64775. */
  64776. private _getPerceivedBrightness;
  64777. /**
  64778. * Returns the maximum color component value
  64779. * @param color
  64780. * @returns maximum color component value, or zero if color is null or undefined
  64781. */
  64782. private _getMaxComponent;
  64783. /**
  64784. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  64785. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64786. * @param mimeType mime type to use for the textures
  64787. * @param images array of glTF image interfaces
  64788. * @param textures array of glTF texture interfaces
  64789. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64790. * @param imageData map of image file name to data
  64791. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64792. * @returns glTF PBR Metallic Roughness factors
  64793. */
  64794. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  64795. private _getGLTFTextureSampler;
  64796. private _getGLTFTextureWrapMode;
  64797. private _getGLTFTextureWrapModesSampler;
  64798. /**
  64799. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  64800. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64801. * @param mimeType mime type to use for the textures
  64802. * @param images array of glTF image interfaces
  64803. * @param textures array of glTF texture interfaces
  64804. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64805. * @param imageData map of image file name to data
  64806. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64807. * @returns glTF PBR Metallic Roughness factors
  64808. */
  64809. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  64810. /**
  64811. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64812. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64813. * @param mimeType mime type to use for the textures
  64814. * @param images array of glTF image interfaces
  64815. * @param textures array of glTF texture interfaces
  64816. * @param materials array of glTF material interfaces
  64817. * @param imageData map of image file name to data
  64818. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64819. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64820. private setMetallicRoughnessPbrMaterial;
  64821. private getPixelsFromTexture;
  64822. /**
  64823. * Extracts a texture from a Babylon texture into file data and glTF data
  64824. * @param babylonTexture Babylon texture to extract
  64825. * @param mimeType Mime Type of the babylonTexture
  64826. * @return glTF texture info, or null if the texture format is not supported
  64827. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  64828. /**
  64829. * Builds a texture from base64 string
  64830. * @param base64Texture base64 texture string
  64831. * @param baseTextureName Name to use for the texture
  64832. * @param mimeType image mime type for the texture
  64833. * @param images array of images
  64834. * @param textures array of textures
  64835. * @param imageData map of image data
  64836. * @returns glTF texture info, or null if the texture format is not supported
  64837. */
  64838. private _getTextureInfoFromBase64;
  64839. }
  64840. }
  64841. declare module BABYLON {
  64842. /**
  64843. * Class for holding and downloading glTF file data
  64844. */
  64845. export class GLTFData {
  64846. /**
  64847. * Object which contains the file name as the key and its data as the value
  64848. */
  64849. glTFFiles: {
  64850. [fileName: string]: string | Blob;
  64851. };
  64852. /**
  64853. * Initializes the glTF file object
  64854. */
  64855. constructor();
  64856. /**
  64857. * Downloads the glTF data as files based on their names and data
  64858. */
  64859. downloadFiles(): void;
  64860. }
  64861. }
  64862. declare module BABYLON {
  64863. /**
  64864. * Holds a collection of exporter options and parameters
  64865. */
  64866. export interface IExportOptions {
  64867. /**
  64868. * Function which indicates whether a babylon node should be exported or not
  64869. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  64870. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  64871. */
  64872. shouldExportNode?(node: Node): boolean;
  64873. /**
  64874. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  64875. * @param metadata source metadata to read from
  64876. * @returns the data to store to glTF node extras
  64877. */
  64878. metadataSelector?(metadata: any): any;
  64879. /**
  64880. * The sample rate to bake animation curves
  64881. */
  64882. animationSampleRate?: number;
  64883. /**
  64884. * Begin serialization without waiting for the scene to be ready
  64885. */
  64886. exportWithoutWaitingForScene?: boolean;
  64887. }
  64888. /**
  64889. * Class for generating glTF data from a Babylon scene.
  64890. */
  64891. export class GLTF2Export {
  64892. /**
  64893. * Exports the geometry of the scene to .gltf file format asynchronously
  64894. * @param scene Babylon scene with scene hierarchy information
  64895. * @param filePrefix File prefix to use when generating the glTF file
  64896. * @param options Exporter options
  64897. * @returns Returns an object with a .gltf file and associates texture names
  64898. * as keys and their data and paths as values
  64899. */
  64900. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64901. private static _PreExportAsync;
  64902. private static _PostExportAsync;
  64903. /**
  64904. * Exports the geometry of the scene to .glb file format asychronously
  64905. * @param scene Babylon scene with scene hierarchy information
  64906. * @param filePrefix File prefix to use when generating glb file
  64907. * @param options Exporter options
  64908. * @returns Returns an object with a .glb filename as key and data as value
  64909. */
  64910. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64911. }
  64912. }
  64913. declare module BABYLON.GLTF2.Exporter {
  64914. /**
  64915. * @hidden
  64916. */
  64917. export class _GLTFUtilities {
  64918. /**
  64919. * Creates a buffer view based on the supplied arguments
  64920. * @param bufferIndex index value of the specified buffer
  64921. * @param byteOffset byte offset value
  64922. * @param byteLength byte length of the bufferView
  64923. * @param byteStride byte distance between conequential elements
  64924. * @param name name of the buffer view
  64925. * @returns bufferView for glTF
  64926. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  64927. /**
  64928. * Creates an accessor based on the supplied arguments
  64929. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  64930. * @param name The name of the accessor
  64931. * @param type The type of the accessor
  64932. * @param componentType The datatype of components in the attribute
  64933. * @param count The number of attributes referenced by this accessor
  64934. * @param byteOffset The offset relative to the start of the bufferView in bytes
  64935. * @param min Minimum value of each component in this attribute
  64936. * @param max Maximum value of each component in this attribute
  64937. * @returns accessor for glTF
  64938. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  64939. /**
  64940. * Calculates the minimum and maximum values of an array of position floats
  64941. * @param positions Positions array of a mesh
  64942. * @param vertexStart Starting vertex offset to calculate min and max values
  64943. * @param vertexCount Number of vertices to check for min and max values
  64944. * @returns min number array and max number array
  64945. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  64946. min: number[];
  64947. max: number[];
  64948. };
  64949. /**
  64950. * Converts a new right-handed Vector3
  64951. * @param vector vector3 array
  64952. * @returns right-handed Vector3
  64953. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  64954. /**
  64955. * Converts a Vector3 to right-handed
  64956. * @param vector Vector3 to convert to right-handed
  64957. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  64958. /**
  64959. * Converts a three element number array to right-handed
  64960. * @param vector number array to convert to right-handed
  64961. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  64962. /**
  64963. * Converts a new right-handed Vector3
  64964. * @param vector vector3 array
  64965. * @returns right-handed Vector3
  64966. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  64967. /**
  64968. * Converts a Vector3 to right-handed
  64969. * @param vector Vector3 to convert to right-handed
  64970. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  64971. /**
  64972. * Converts a three element number array to right-handed
  64973. * @param vector number array to convert to right-handed
  64974. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  64975. /**
  64976. * Converts a Vector4 to right-handed
  64977. * @param vector Vector4 to convert to right-handed
  64978. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  64979. /**
  64980. * Converts a Vector4 to right-handed
  64981. * @param vector Vector4 to convert to right-handed
  64982. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  64983. /**
  64984. * Converts a Quaternion to right-handed
  64985. * @param quaternion Source quaternion to convert to right-handed
  64986. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  64987. /**
  64988. * Converts a Quaternion to right-handed
  64989. * @param quaternion Source quaternion to convert to right-handed
  64990. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  64991. }
  64992. }
  64993. declare module BABYLON.GLTF2.Exporter {
  64994. /**
  64995. * Converts Babylon Scene into glTF 2.0.
  64996. * @hidden
  64997. */
  64998. export class _Exporter {
  64999. /**
  65000. * Stores the glTF to export
  65001. */ private _glTF: IGLTF;
  65002. /**
  65003. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65004. */ private _bufferViews: IBufferView[];
  65005. /**
  65006. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65007. */ private _accessors: IAccessor[];
  65008. /**
  65009. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65010. */
  65011. private _nodes;
  65012. /**
  65013. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65014. */
  65015. private _scenes;
  65016. /**
  65017. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65018. */
  65019. private _meshes;
  65020. /**
  65021. * Stores all the generated material information, which represents the appearance of each primitive
  65022. */ private _materials: IMaterial[]; private _materialMap: {
  65023. [materialID: number]: number;
  65024. };
  65025. /**
  65026. * Stores all the generated texture information, which is referenced by glTF materials
  65027. */ private _textures: ITexture[];
  65028. /**
  65029. * Stores all the generated image information, which is referenced by glTF textures
  65030. */ private _images: IImage[];
  65031. /**
  65032. * Stores all the texture samplers
  65033. */ private _samplers: ISampler[];
  65034. /**
  65035. * Stores all the generated animation samplers, which is referenced by glTF animations
  65036. */
  65037. /**
  65038. * Stores the animations for glTF models
  65039. */
  65040. private _animations;
  65041. /**
  65042. * Stores the total amount of bytes stored in the glTF buffer
  65043. */
  65044. private _totalByteLength;
  65045. /**
  65046. * Stores a reference to the Babylon scene containing the source geometry and material information
  65047. */ private _babylonScene: Scene;
  65048. /**
  65049. * Stores a map of the image data, where the key is the file name and the value
  65050. * is the image data
  65051. */ private _imageData: {
  65052. [fileName: string]: {
  65053. data: Uint8Array;
  65054. mimeType: ImageMimeType;
  65055. };
  65056. };
  65057. /**
  65058. * Stores a map of the unique id of a node to its index in the node array
  65059. */
  65060. private _nodeMap;
  65061. /**
  65062. * Specifies if the Babylon scene should be converted to right-handed on export
  65063. */ private _convertToRightHandedSystem: boolean;
  65064. /**
  65065. * Baked animation sample rate
  65066. */
  65067. private _animationSampleRate;
  65068. private _options;
  65069. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  65070. private _extensions;
  65071. private static _ExtensionNames;
  65072. private static _ExtensionFactories;
  65073. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65074. private _forEachExtensions;
  65075. private _extensionsOnExporting;
  65076. /**
  65077. * Load glTF serializer extensions
  65078. */
  65079. private _loadExtensions;
  65080. /**
  65081. * Creates a glTF Exporter instance, which can accept optional exporter options
  65082. * @param babylonScene Babylon scene object
  65083. * @param options Options to modify the behavior of the exporter
  65084. */
  65085. constructor(babylonScene: Scene, options?: IExportOptions);
  65086. /**
  65087. * Registers a glTF exporter extension
  65088. * @param name Name of the extension to export
  65089. * @param factory The factory function that creates the exporter extension
  65090. */
  65091. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  65092. /**
  65093. * Un-registers an exporter extension
  65094. * @param name The name fo the exporter extension
  65095. * @returns A boolean indicating whether the extension has been un-registered
  65096. */
  65097. static UnregisterExtension(name: string): boolean;
  65098. /**
  65099. * Lazy load a local engine with premultiplied alpha set to false
  65100. */ private _getLocalEngine(): Engine;
  65101. private reorderIndicesBasedOnPrimitiveMode;
  65102. /**
  65103. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  65104. * clock-wise during export to glTF
  65105. * @param submesh BabylonJS submesh
  65106. * @param primitiveMode Primitive mode of the mesh
  65107. * @param sideOrientation the winding order of the submesh
  65108. * @param vertexBufferKind The type of vertex attribute
  65109. * @param meshAttributeArray The vertex attribute data
  65110. * @param byteOffset The offset to the binary data
  65111. * @param binaryWriter The binary data for the glTF file
  65112. */
  65113. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  65114. /**
  65115. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  65116. * clock-wise during export to glTF
  65117. * @param submesh BabylonJS submesh
  65118. * @param primitiveMode Primitive mode of the mesh
  65119. * @param sideOrientation the winding order of the submesh
  65120. * @param vertexBufferKind The type of vertex attribute
  65121. * @param meshAttributeArray The vertex attribute data
  65122. * @param byteOffset The offset to the binary data
  65123. * @param binaryWriter The binary data for the glTF file
  65124. */
  65125. private reorderTriangleFillMode;
  65126. /**
  65127. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  65128. * clock-wise during export to glTF
  65129. * @param submesh BabylonJS submesh
  65130. * @param primitiveMode Primitive mode of the mesh
  65131. * @param sideOrientation the winding order of the submesh
  65132. * @param vertexBufferKind The type of vertex attribute
  65133. * @param meshAttributeArray The vertex attribute data
  65134. * @param byteOffset The offset to the binary data
  65135. * @param binaryWriter The binary data for the glTF file
  65136. */
  65137. private reorderTriangleStripDrawMode;
  65138. /**
  65139. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  65140. * clock-wise during export to glTF
  65141. * @param submesh BabylonJS submesh
  65142. * @param primitiveMode Primitive mode of the mesh
  65143. * @param sideOrientation the winding order of the submesh
  65144. * @param vertexBufferKind The type of vertex attribute
  65145. * @param meshAttributeArray The vertex attribute data
  65146. * @param byteOffset The offset to the binary data
  65147. * @param binaryWriter The binary data for the glTF file
  65148. */
  65149. private reorderTriangleFanMode;
  65150. /**
  65151. * Writes the vertex attribute data to binary
  65152. * @param vertices The vertices to write to the binary writer
  65153. * @param byteOffset The offset into the binary writer to overwrite binary data
  65154. * @param vertexAttributeKind The vertex attribute type
  65155. * @param meshAttributeArray The vertex attribute data
  65156. * @param binaryWriter The writer containing the binary data
  65157. */
  65158. private writeVertexAttributeData;
  65159. /**
  65160. * Writes mesh attribute data to a data buffer
  65161. * Returns the bytelength of the data
  65162. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  65163. * @param meshAttributeArray Array containing the attribute data
  65164. * @param binaryWriter The buffer to write the binary data to
  65165. * @param indices Used to specify the order of the vertex data
  65166. */
  65167. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  65168. /**
  65169. * Generates glTF json data
  65170. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  65171. * @param glTFPrefix Text to use when prefixing a glTF file
  65172. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  65173. * @returns json data as string
  65174. */
  65175. private generateJSON;
  65176. /**
  65177. * Generates data for .gltf and .bin files based on the glTF prefix string
  65178. * @param glTFPrefix Text to use when prefixing a glTF file
  65179. * @returns GLTFData with glTF file data
  65180. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  65181. /**
  65182. * Creates a binary buffer for glTF
  65183. * @returns array buffer for binary data
  65184. */
  65185. private _generateBinaryAsync;
  65186. /**
  65187. * Pads the number to a multiple of 4
  65188. * @param num number to pad
  65189. * @returns padded number
  65190. */
  65191. private _getPadding;
  65192. /**
  65193. * Generates a glb file from the json and binary data
  65194. * Returns an object with the glb file name as the key and data as the value
  65195. * @param glTFPrefix
  65196. * @returns object with glb filename as key and data as value
  65197. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65198. /**
  65199. * Sets the TRS for each node
  65200. * @param node glTF Node for storing the transformation data
  65201. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65202. */
  65203. private setNodeTransformation;
  65204. private getVertexBufferFromMesh;
  65205. /**
  65206. * Creates a bufferview based on the vertices type for the Babylon mesh
  65207. * @param kind Indicates the type of vertices data
  65208. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65209. * @param binaryWriter The buffer to write the bufferview data to
  65210. */
  65211. private createBufferViewKind;
  65212. /**
  65213. * The primitive mode of the Babylon mesh
  65214. * @param babylonMesh The BabylonJS mesh
  65215. */
  65216. private getMeshPrimitiveMode;
  65217. /**
  65218. * Sets the primitive mode of the glTF mesh primitive
  65219. * @param meshPrimitive glTF mesh primitive
  65220. * @param primitiveMode The primitive mode
  65221. */
  65222. private setPrimitiveMode;
  65223. /**
  65224. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65225. * @param meshPrimitive glTF mesh primitive
  65226. * @param attributeKind vertex attribute
  65227. * @returns boolean specifying if uv coordinates are present
  65228. */
  65229. private setAttributeKind;
  65230. /**
  65231. * Sets data for the primitive attributes of each submesh
  65232. * @param mesh glTF Mesh object to store the primitive attribute information
  65233. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65234. * @param binaryWriter Buffer to write the attribute data to
  65235. */
  65236. private setPrimitiveAttributesAsync;
  65237. /**
  65238. * Creates a glTF scene based on the array of meshes
  65239. * Returns the the total byte offset
  65240. * @param babylonScene Babylon scene to get the mesh data from
  65241. * @param binaryWriter Buffer to write binary data to
  65242. */
  65243. private createSceneAsync;
  65244. /**
  65245. * Creates a mapping of Node unique id to node index and handles animations
  65246. * @param babylonScene Babylon Scene
  65247. * @param nodes Babylon transform nodes
  65248. * @param binaryWriter Buffer to write binary data to
  65249. * @returns Node mapping of unique id to index
  65250. */
  65251. private createNodeMapAndAnimationsAsync;
  65252. /**
  65253. * Creates a glTF node from a Babylon mesh
  65254. * @param babylonMesh Source Babylon mesh
  65255. * @param binaryWriter Buffer for storing geometry data
  65256. * @returns glTF node
  65257. */
  65258. private createNodeAsync;
  65259. }
  65260. /**
  65261. * @hidden
  65262. *
  65263. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65264. */
  65265. export class _BinaryWriter {
  65266. /**
  65267. * Array buffer which stores all binary data
  65268. */
  65269. private _arrayBuffer;
  65270. /**
  65271. * View of the array buffer
  65272. */
  65273. private _dataView;
  65274. /**
  65275. * byte offset of data in array buffer
  65276. */
  65277. private _byteOffset;
  65278. /**
  65279. * Initialize binary writer with an initial byte length
  65280. * @param byteLength Initial byte length of the array buffer
  65281. */
  65282. constructor(byteLength: number);
  65283. /**
  65284. * Resize the array buffer to the specified byte length
  65285. * @param byteLength
  65286. */
  65287. private resizeBuffer;
  65288. /**
  65289. * Get an array buffer with the length of the byte offset
  65290. * @returns ArrayBuffer resized to the byte offset
  65291. */
  65292. getArrayBuffer(): ArrayBuffer;
  65293. /**
  65294. * Get the byte offset of the array buffer
  65295. * @returns byte offset
  65296. */
  65297. getByteOffset(): number;
  65298. /**
  65299. * Stores an UInt8 in the array buffer
  65300. * @param entry
  65301. * @param byteOffset If defined, specifies where to set the value as an offset.
  65302. */
  65303. setUInt8(entry: number, byteOffset?: number): void;
  65304. /**
  65305. * Gets an UInt32 in the array buffer
  65306. * @param entry
  65307. * @param byteOffset If defined, specifies where to set the value as an offset.
  65308. */
  65309. getUInt32(byteOffset: number): number;
  65310. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65311. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65312. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65313. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65314. /**
  65315. * Stores a Float32 in the array buffer
  65316. * @param entry
  65317. */
  65318. setFloat32(entry: number, byteOffset?: number): void;
  65319. /**
  65320. * Stores an UInt32 in the array buffer
  65321. * @param entry
  65322. * @param byteOffset If defined, specifies where to set the value as an offset.
  65323. */
  65324. setUInt32(entry: number, byteOffset?: number): void;
  65325. }
  65326. }
  65327. declare module BABYLON.GLTF2.Exporter {
  65328. /**
  65329. * @hidden
  65330. * Interface to store animation data.
  65331. */
  65332. export interface _IAnimationData {
  65333. /**
  65334. * Keyframe data.
  65335. */
  65336. inputs: number[];
  65337. /**
  65338. * Value data.
  65339. */
  65340. outputs: number[][];
  65341. /**
  65342. * Animation interpolation data.
  65343. */
  65344. samplerInterpolation: AnimationSamplerInterpolation;
  65345. /**
  65346. * Minimum keyframe value.
  65347. */
  65348. inputsMin: number;
  65349. /**
  65350. * Maximum keyframe value.
  65351. */
  65352. inputsMax: number;
  65353. }
  65354. /**
  65355. * @hidden
  65356. */
  65357. export interface _IAnimationInfo {
  65358. /**
  65359. * The target channel for the animation
  65360. */
  65361. animationChannelTargetPath: AnimationChannelTargetPath;
  65362. /**
  65363. * The glTF accessor type for the data.
  65364. */
  65365. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65366. /**
  65367. * Specifies if quaternions should be used.
  65368. */
  65369. useQuaternion: boolean;
  65370. }
  65371. /**
  65372. * @hidden
  65373. * Utility class for generating glTF animation data from BabylonJS.
  65374. */
  65375. export class _GLTFAnimation {
  65376. /**
  65377. * @ignore
  65378. *
  65379. * Creates glTF channel animation from BabylonJS animation.
  65380. * @param babylonTransformNode - BabylonJS mesh.
  65381. * @param animation - animation.
  65382. * @param animationChannelTargetPath - The target animation channel.
  65383. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65384. * @param useQuaternion - Specifies if quaternions are used.
  65385. * @returns nullable IAnimationData
  65386. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65387. private static _DeduceAnimationInfo;
  65388. /**
  65389. * @ignore
  65390. * Create node animations from the transform node animations
  65391. * @param babylonNode
  65392. * @param runtimeGLTFAnimation
  65393. * @param idleGLTFAnimations
  65394. * @param nodeMap
  65395. * @param nodes
  65396. * @param binaryWriter
  65397. * @param bufferViews
  65398. * @param accessors
  65399. * @param convertToRightHandedSystem
  65400. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  65401. [key: number]: number;
  65402. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65403. /**
  65404. * @ignore
  65405. * Create node animations from the animation groups
  65406. * @param babylonScene
  65407. * @param glTFAnimations
  65408. * @param nodeMap
  65409. * @param nodes
  65410. * @param binaryWriter
  65411. * @param bufferViews
  65412. * @param accessors
  65413. * @param convertToRightHandedSystem
  65414. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  65415. [key: number]: number;
  65416. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65417. private static AddAnimation;
  65418. /**
  65419. * Create a baked animation
  65420. * @param babylonTransformNode BabylonJS mesh
  65421. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  65422. * @param animationChannelTargetPath animation target channel
  65423. * @param minFrame minimum animation frame
  65424. * @param maxFrame maximum animation frame
  65425. * @param fps frames per second of the animation
  65426. * @param inputs input key frames of the animation
  65427. * @param outputs output key frame data of the animation
  65428. * @param convertToRightHandedSystem converts the values to right-handed
  65429. * @param useQuaternion specifies if quaternions should be used
  65430. */
  65431. private static _CreateBakedAnimation;
  65432. private static _ConvertFactorToVector3OrQuaternion;
  65433. private static _SetInterpolatedValue;
  65434. /**
  65435. * Creates linear animation from the animation key frames
  65436. * @param babylonTransformNode BabylonJS mesh
  65437. * @param animation BabylonJS animation
  65438. * @param animationChannelTargetPath The target animation channel
  65439. * @param frameDelta The difference between the last and first frame of the animation
  65440. * @param inputs Array to store the key frame times
  65441. * @param outputs Array to store the key frame data
  65442. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65443. * @param useQuaternion Specifies if quaternions are used in the animation
  65444. */
  65445. private static _CreateLinearOrStepAnimation;
  65446. /**
  65447. * Creates cubic spline animation from the animation key frames
  65448. * @param babylonTransformNode BabylonJS mesh
  65449. * @param animation BabylonJS animation
  65450. * @param animationChannelTargetPath The target animation channel
  65451. * @param frameDelta The difference between the last and first frame of the animation
  65452. * @param inputs Array to store the key frame times
  65453. * @param outputs Array to store the key frame data
  65454. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65455. * @param useQuaternion Specifies if quaternions are used in the animation
  65456. */
  65457. private static _CreateCubicSplineAnimation;
  65458. private static _GetBasePositionRotationOrScale;
  65459. /**
  65460. * Adds a key frame value
  65461. * @param keyFrame
  65462. * @param animation
  65463. * @param outputs
  65464. * @param animationChannelTargetPath
  65465. * @param basePositionRotationOrScale
  65466. * @param convertToRightHandedSystem
  65467. * @param useQuaternion
  65468. */
  65469. private static _AddKeyframeValue;
  65470. /**
  65471. * Determine the interpolation based on the key frames
  65472. * @param keyFrames
  65473. * @param animationChannelTargetPath
  65474. * @param useQuaternion
  65475. */
  65476. private static _DeduceInterpolation;
  65477. /**
  65478. * Adds an input tangent or output tangent to the output data
  65479. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  65480. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  65481. * @param outputs The animation data by keyframe
  65482. * @param animationChannelTargetPath The target animation channel
  65483. * @param interpolation The interpolation type
  65484. * @param keyFrame The key frame with the animation data
  65485. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  65486. * @param useQuaternion Specifies if quaternions are used
  65487. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  65488. */
  65489. private static AddSplineTangent;
  65490. /**
  65491. * Get the minimum and maximum key frames' frame values
  65492. * @param keyFrames animation key frames
  65493. * @returns the minimum and maximum key frame value
  65494. */
  65495. private static calculateMinMaxKeyFrames;
  65496. }
  65497. }
  65498. declare module BABYLON.GLTF2.Exporter {
  65499. /** @hidden */
  65500. export var textureTransformPixelShader: {
  65501. name: string;
  65502. shader: string;
  65503. };
  65504. }
  65505. declare module BABYLON.GLTF2.Exporter.Extensions {
  65506. /**
  65507. * @hidden
  65508. */
  65509. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  65510. /** Name of this extension */
  65511. readonly name: string;
  65512. /** Defines whether this extension is enabled */
  65513. enabled: boolean;
  65514. /** Defines whether this extension is required */
  65515. required: boolean;
  65516. /** Reference to the glTF exporter */
  65517. private _exporter;
  65518. constructor(exporter: _Exporter);
  65519. dispose(): void;
  65520. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65521. /**
  65522. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  65523. * @param babylonTexture
  65524. * @param offset
  65525. * @param rotation
  65526. * @param scale
  65527. * @param scene
  65528. */
  65529. private _textureTransformTextureAsync;
  65530. }
  65531. }
  65532. declare module BABYLON.GLTF2.Exporter.Extensions {
  65533. /**
  65534. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  65535. */
  65536. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  65537. /** The name of this extension. */
  65538. readonly name: string;
  65539. /** Defines whether this extension is enabled. */
  65540. enabled: boolean;
  65541. /** Defines whether this extension is required */
  65542. required: boolean;
  65543. /** Reference to the glTF exporter */
  65544. private _exporter;
  65545. private _lights;
  65546. /** @hidden */
  65547. constructor(exporter: _Exporter);
  65548. /** @hidden */
  65549. dispose(): void;
  65550. /** @hidden */
  65551. onExporting(): void;
  65552. /**
  65553. * Define this method to modify the default behavior when exporting a node
  65554. * @param context The context when exporting the node
  65555. * @param node glTF node
  65556. * @param babylonNode BabylonJS node
  65557. * @returns nullable INode promise
  65558. */
  65559. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65560. }
  65561. }
  65562. declare module BABYLON {
  65563. /**
  65564. * Class for generating STL data from a Babylon scene.
  65565. */
  65566. export class STLExport {
  65567. /**
  65568. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  65569. * @param meshes list defines the mesh to serialize
  65570. * @param download triggers the automatic download of the file.
  65571. * @param fileName changes the downloads fileName.
  65572. * @param binary changes the STL to a binary type.
  65573. * @param isLittleEndian toggle for binary type exporter.
  65574. * @returns the STL as UTF8 string
  65575. */
  65576. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  65577. }
  65578. }
  65579. /**
  65580. * @ignoreChildren
  65581. * @ignore
  65582. */
  65583. declare module "babylonjs-gltf2interface" {
  65584. export = BABYLON.GLTF2;
  65585. }
  65586. /**
  65587. * Module for glTF 2.0 Interface
  65588. * @ignoreChildren
  65589. * @ignore
  65590. */
  65591. declare module BABYLON.GLTF2 {
  65592. /**
  65593. * The datatype of the components in the attribute
  65594. */
  65595. const enum AccessorComponentType {
  65596. /**
  65597. * Byte
  65598. */
  65599. BYTE = 5120,
  65600. /**
  65601. * Unsigned Byte
  65602. */
  65603. UNSIGNED_BYTE = 5121,
  65604. /**
  65605. * Short
  65606. */
  65607. SHORT = 5122,
  65608. /**
  65609. * Unsigned Short
  65610. */
  65611. UNSIGNED_SHORT = 5123,
  65612. /**
  65613. * Unsigned Int
  65614. */
  65615. UNSIGNED_INT = 5125,
  65616. /**
  65617. * Float
  65618. */
  65619. FLOAT = 5126,
  65620. }
  65621. /**
  65622. * Specifies if the attirbute is a scalar, vector, or matrix
  65623. */
  65624. const enum AccessorType {
  65625. /**
  65626. * Scalar
  65627. */
  65628. SCALAR = "SCALAR",
  65629. /**
  65630. * Vector2
  65631. */
  65632. VEC2 = "VEC2",
  65633. /**
  65634. * Vector3
  65635. */
  65636. VEC3 = "VEC3",
  65637. /**
  65638. * Vector4
  65639. */
  65640. VEC4 = "VEC4",
  65641. /**
  65642. * Matrix2x2
  65643. */
  65644. MAT2 = "MAT2",
  65645. /**
  65646. * Matrix3x3
  65647. */
  65648. MAT3 = "MAT3",
  65649. /**
  65650. * Matrix4x4
  65651. */
  65652. MAT4 = "MAT4",
  65653. }
  65654. /**
  65655. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65656. */
  65657. const enum AnimationChannelTargetPath {
  65658. /**
  65659. * Translation
  65660. */
  65661. TRANSLATION = "translation",
  65662. /**
  65663. * Rotation
  65664. */
  65665. ROTATION = "rotation",
  65666. /**
  65667. * Scale
  65668. */
  65669. SCALE = "scale",
  65670. /**
  65671. * Weights
  65672. */
  65673. WEIGHTS = "weights",
  65674. }
  65675. /**
  65676. * Interpolation algorithm
  65677. */
  65678. const enum AnimationSamplerInterpolation {
  65679. /**
  65680. * The animated values are linearly interpolated between keyframes
  65681. */
  65682. LINEAR = "LINEAR",
  65683. /**
  65684. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  65685. */
  65686. STEP = "STEP",
  65687. /**
  65688. * The animation's interpolation is computed using a cubic spline with specified tangents
  65689. */
  65690. CUBICSPLINE = "CUBICSPLINE",
  65691. }
  65692. /**
  65693. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65694. */
  65695. const enum CameraType {
  65696. /**
  65697. * A perspective camera containing properties to create a perspective projection matrix
  65698. */
  65699. PERSPECTIVE = "perspective",
  65700. /**
  65701. * An orthographic camera containing properties to create an orthographic projection matrix
  65702. */
  65703. ORTHOGRAPHIC = "orthographic",
  65704. }
  65705. /**
  65706. * The mime-type of the image
  65707. */
  65708. const enum ImageMimeType {
  65709. /**
  65710. * JPEG Mime-type
  65711. */
  65712. JPEG = "image/jpeg",
  65713. /**
  65714. * PNG Mime-type
  65715. */
  65716. PNG = "image/png",
  65717. }
  65718. /**
  65719. * The alpha rendering mode of the material
  65720. */
  65721. const enum MaterialAlphaMode {
  65722. /**
  65723. * The alpha value is ignored and the rendered output is fully opaque
  65724. */
  65725. OPAQUE = "OPAQUE",
  65726. /**
  65727. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  65728. */
  65729. MASK = "MASK",
  65730. /**
  65731. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  65732. */
  65733. BLEND = "BLEND",
  65734. }
  65735. /**
  65736. * The type of the primitives to render
  65737. */
  65738. const enum MeshPrimitiveMode {
  65739. /**
  65740. * Points
  65741. */
  65742. POINTS = 0,
  65743. /**
  65744. * Lines
  65745. */
  65746. LINES = 1,
  65747. /**
  65748. * Line Loop
  65749. */
  65750. LINE_LOOP = 2,
  65751. /**
  65752. * Line Strip
  65753. */
  65754. LINE_STRIP = 3,
  65755. /**
  65756. * Triangles
  65757. */
  65758. TRIANGLES = 4,
  65759. /**
  65760. * Triangle Strip
  65761. */
  65762. TRIANGLE_STRIP = 5,
  65763. /**
  65764. * Triangle Fan
  65765. */
  65766. TRIANGLE_FAN = 6,
  65767. }
  65768. /**
  65769. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  65770. */
  65771. const enum TextureMagFilter {
  65772. /**
  65773. * Nearest
  65774. */
  65775. NEAREST = 9728,
  65776. /**
  65777. * Linear
  65778. */
  65779. LINEAR = 9729,
  65780. }
  65781. /**
  65782. * Minification filter. All valid values correspond to WebGL enums
  65783. */
  65784. const enum TextureMinFilter {
  65785. /**
  65786. * Nearest
  65787. */
  65788. NEAREST = 9728,
  65789. /**
  65790. * Linear
  65791. */
  65792. LINEAR = 9729,
  65793. /**
  65794. * Nearest Mip-Map Nearest
  65795. */
  65796. NEAREST_MIPMAP_NEAREST = 9984,
  65797. /**
  65798. * Linear Mipmap Nearest
  65799. */
  65800. LINEAR_MIPMAP_NEAREST = 9985,
  65801. /**
  65802. * Nearest Mipmap Linear
  65803. */
  65804. NEAREST_MIPMAP_LINEAR = 9986,
  65805. /**
  65806. * Linear Mipmap Linear
  65807. */
  65808. LINEAR_MIPMAP_LINEAR = 9987,
  65809. }
  65810. /**
  65811. * S (U) wrapping mode. All valid values correspond to WebGL enums
  65812. */
  65813. const enum TextureWrapMode {
  65814. /**
  65815. * Clamp to Edge
  65816. */
  65817. CLAMP_TO_EDGE = 33071,
  65818. /**
  65819. * Mirrored Repeat
  65820. */
  65821. MIRRORED_REPEAT = 33648,
  65822. /**
  65823. * Repeat
  65824. */
  65825. REPEAT = 10497,
  65826. }
  65827. /**
  65828. * glTF Property
  65829. */
  65830. interface IProperty {
  65831. /**
  65832. * Dictionary object with extension-specific objects
  65833. */
  65834. extensions?: {
  65835. [key: string]: any;
  65836. };
  65837. /**
  65838. * Application-Specific data
  65839. */
  65840. extras?: any;
  65841. }
  65842. /**
  65843. * glTF Child of Root Property
  65844. */
  65845. interface IChildRootProperty extends IProperty {
  65846. /**
  65847. * The user-defined name of this object
  65848. */
  65849. name?: string;
  65850. }
  65851. /**
  65852. * Indices of those attributes that deviate from their initialization value
  65853. */
  65854. interface IAccessorSparseIndices extends IProperty {
  65855. /**
  65856. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65857. */
  65858. bufferView: number;
  65859. /**
  65860. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65861. */
  65862. byteOffset?: number;
  65863. /**
  65864. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  65865. */
  65866. componentType: AccessorComponentType;
  65867. }
  65868. /**
  65869. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  65870. */
  65871. interface IAccessorSparseValues extends IProperty {
  65872. /**
  65873. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65874. */
  65875. bufferView: number;
  65876. /**
  65877. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65878. */
  65879. byteOffset?: number;
  65880. }
  65881. /**
  65882. * Sparse storage of attributes that deviate from their initialization value
  65883. */
  65884. interface IAccessorSparse extends IProperty {
  65885. /**
  65886. * The number of attributes encoded in this sparse accessor
  65887. */
  65888. count: number;
  65889. /**
  65890. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  65891. */
  65892. indices: IAccessorSparseIndices;
  65893. /**
  65894. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  65895. */
  65896. values: IAccessorSparseValues;
  65897. }
  65898. /**
  65899. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  65900. */
  65901. interface IAccessor extends IChildRootProperty {
  65902. /**
  65903. * The index of the bufferview
  65904. */
  65905. bufferView?: number;
  65906. /**
  65907. * The offset relative to the start of the bufferView in bytes
  65908. */
  65909. byteOffset?: number;
  65910. /**
  65911. * The datatype of components in the attribute
  65912. */
  65913. componentType: AccessorComponentType;
  65914. /**
  65915. * Specifies whether integer data values should be normalized
  65916. */
  65917. normalized?: boolean;
  65918. /**
  65919. * The number of attributes referenced by this accessor
  65920. */
  65921. count: number;
  65922. /**
  65923. * Specifies if the attribute is a scalar, vector, or matrix
  65924. */
  65925. type: AccessorType;
  65926. /**
  65927. * Maximum value of each component in this attribute
  65928. */
  65929. max?: number[];
  65930. /**
  65931. * Minimum value of each component in this attribute
  65932. */
  65933. min?: number[];
  65934. /**
  65935. * Sparse storage of attributes that deviate from their initialization value
  65936. */
  65937. sparse?: IAccessorSparse;
  65938. }
  65939. /**
  65940. * Targets an animation's sampler at a node's property
  65941. */
  65942. interface IAnimationChannel extends IProperty {
  65943. /**
  65944. * The index of a sampler in this animation used to compute the value for the target
  65945. */
  65946. sampler: number;
  65947. /**
  65948. * The index of the node and TRS property to target
  65949. */
  65950. target: IAnimationChannelTarget;
  65951. }
  65952. /**
  65953. * The index of the node and TRS property that an animation channel targets
  65954. */
  65955. interface IAnimationChannelTarget extends IProperty {
  65956. /**
  65957. * The index of the node to target
  65958. */
  65959. node: number;
  65960. /**
  65961. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65962. */
  65963. path: AnimationChannelTargetPath;
  65964. }
  65965. /**
  65966. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  65967. */
  65968. interface IAnimationSampler extends IProperty {
  65969. /**
  65970. * The index of an accessor containing keyframe input values, e.g., time
  65971. */
  65972. input: number;
  65973. /**
  65974. * Interpolation algorithm
  65975. */
  65976. interpolation?: AnimationSamplerInterpolation;
  65977. /**
  65978. * The index of an accessor, containing keyframe output values
  65979. */
  65980. output: number;
  65981. }
  65982. /**
  65983. * A keyframe animation
  65984. */
  65985. interface IAnimation extends IChildRootProperty {
  65986. /**
  65987. * An array of channels, each of which targets an animation's sampler at a node's property
  65988. */
  65989. channels: IAnimationChannel[];
  65990. /**
  65991. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  65992. */
  65993. samplers: IAnimationSampler[];
  65994. }
  65995. /**
  65996. * Metadata about the glTF asset
  65997. */
  65998. interface IAsset extends IChildRootProperty {
  65999. /**
  66000. * A copyright message suitable for display to credit the content creator
  66001. */
  66002. copyright?: string;
  66003. /**
  66004. * Tool that generated this glTF model. Useful for debugging
  66005. */
  66006. generator?: string;
  66007. /**
  66008. * The glTF version that this asset targets
  66009. */
  66010. version: string;
  66011. /**
  66012. * The minimum glTF version that this asset targets
  66013. */
  66014. minVersion?: string;
  66015. }
  66016. /**
  66017. * A buffer points to binary geometry, animation, or skins
  66018. */
  66019. interface IBuffer extends IChildRootProperty {
  66020. /**
  66021. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  66022. */
  66023. uri?: string;
  66024. /**
  66025. * The length of the buffer in bytes
  66026. */
  66027. byteLength: number;
  66028. }
  66029. /**
  66030. * A view into a buffer generally representing a subset of the buffer
  66031. */
  66032. interface IBufferView extends IChildRootProperty {
  66033. /**
  66034. * The index of the buffer
  66035. */
  66036. buffer: number;
  66037. /**
  66038. * The offset into the buffer in bytes
  66039. */
  66040. byteOffset?: number;
  66041. /**
  66042. * The lenth of the bufferView in bytes
  66043. */
  66044. byteLength: number;
  66045. /**
  66046. * The stride, in bytes
  66047. */
  66048. byteStride?: number;
  66049. }
  66050. /**
  66051. * An orthographic camera containing properties to create an orthographic projection matrix
  66052. */
  66053. interface ICameraOrthographic extends IProperty {
  66054. /**
  66055. * The floating-point horizontal magnification of the view. Must not be zero
  66056. */
  66057. xmag: number;
  66058. /**
  66059. * The floating-point vertical magnification of the view. Must not be zero
  66060. */
  66061. ymag: number;
  66062. /**
  66063. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  66064. */
  66065. zfar: number;
  66066. /**
  66067. * The floating-point distance to the near clipping plane
  66068. */
  66069. znear: number;
  66070. }
  66071. /**
  66072. * A perspective camera containing properties to create a perspective projection matrix
  66073. */
  66074. interface ICameraPerspective extends IProperty {
  66075. /**
  66076. * The floating-point aspect ratio of the field of view
  66077. */
  66078. aspectRatio?: number;
  66079. /**
  66080. * The floating-point vertical field of view in radians
  66081. */
  66082. yfov: number;
  66083. /**
  66084. * The floating-point distance to the far clipping plane
  66085. */
  66086. zfar?: number;
  66087. /**
  66088. * The floating-point distance to the near clipping plane
  66089. */
  66090. znear: number;
  66091. }
  66092. /**
  66093. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66094. */
  66095. interface ICamera extends IChildRootProperty {
  66096. /**
  66097. * An orthographic camera containing properties to create an orthographic projection matrix
  66098. */
  66099. orthographic?: ICameraOrthographic;
  66100. /**
  66101. * A perspective camera containing properties to create a perspective projection matrix
  66102. */
  66103. perspective?: ICameraPerspective;
  66104. /**
  66105. * Specifies if the camera uses a perspective or orthographic projection
  66106. */
  66107. type: CameraType;
  66108. }
  66109. /**
  66110. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  66111. */
  66112. interface IImage extends IChildRootProperty {
  66113. /**
  66114. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  66115. */
  66116. uri?: string;
  66117. /**
  66118. * The image's MIME type
  66119. */
  66120. mimeType?: ImageMimeType;
  66121. /**
  66122. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  66123. */
  66124. bufferView?: number;
  66125. }
  66126. /**
  66127. * Material Normal Texture Info
  66128. */
  66129. interface IMaterialNormalTextureInfo extends ITextureInfo {
  66130. /**
  66131. * The scalar multiplier applied to each normal vector of the normal texture
  66132. */
  66133. scale?: number;
  66134. }
  66135. /**
  66136. * Material Occlusion Texture Info
  66137. */
  66138. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  66139. /**
  66140. * A scalar multiplier controlling the amount of occlusion applied
  66141. */
  66142. strength?: number;
  66143. }
  66144. /**
  66145. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  66146. */
  66147. interface IMaterialPbrMetallicRoughness {
  66148. /**
  66149. * The material's base color factor
  66150. */
  66151. baseColorFactor?: number[];
  66152. /**
  66153. * The base color texture
  66154. */
  66155. baseColorTexture?: ITextureInfo;
  66156. /**
  66157. * The metalness of the material
  66158. */
  66159. metallicFactor?: number;
  66160. /**
  66161. * The roughness of the material
  66162. */
  66163. roughnessFactor?: number;
  66164. /**
  66165. * The metallic-roughness texture
  66166. */
  66167. metallicRoughnessTexture?: ITextureInfo;
  66168. }
  66169. /**
  66170. * The material appearance of a primitive
  66171. */
  66172. interface IMaterial extends IChildRootProperty {
  66173. /**
  66174. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  66175. */
  66176. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66177. /**
  66178. * The normal map texture
  66179. */
  66180. normalTexture?: IMaterialNormalTextureInfo;
  66181. /**
  66182. * The occlusion map texture
  66183. */
  66184. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66185. /**
  66186. * The emissive map texture
  66187. */
  66188. emissiveTexture?: ITextureInfo;
  66189. /**
  66190. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  66191. */
  66192. emissiveFactor?: number[];
  66193. /**
  66194. * The alpha rendering mode of the material
  66195. */
  66196. alphaMode?: MaterialAlphaMode;
  66197. /**
  66198. * The alpha cutoff value of the material
  66199. */
  66200. alphaCutoff?: number;
  66201. /**
  66202. * Specifies whether the material is double sided
  66203. */
  66204. doubleSided?: boolean;
  66205. }
  66206. /**
  66207. * Geometry to be rendered with the given material
  66208. */
  66209. interface IMeshPrimitive extends IProperty {
  66210. /**
  66211. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66212. */
  66213. attributes: {
  66214. [name: string]: number;
  66215. };
  66216. /**
  66217. * The index of the accessor that contains the indices
  66218. */
  66219. indices?: number;
  66220. /**
  66221. * The index of the material to apply to this primitive when rendering
  66222. */
  66223. material?: number;
  66224. /**
  66225. * The type of primitives to render. All valid values correspond to WebGL enums
  66226. */
  66227. mode?: MeshPrimitiveMode;
  66228. /**
  66229. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  66230. */
  66231. targets?: {
  66232. [name: string]: number;
  66233. }[];
  66234. }
  66235. /**
  66236. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66237. */
  66238. interface IMesh extends IChildRootProperty {
  66239. /**
  66240. * An array of primitives, each defining geometry to be rendered with a material
  66241. */
  66242. primitives: IMeshPrimitive[];
  66243. /**
  66244. * Array of weights to be applied to the Morph Targets
  66245. */
  66246. weights?: number[];
  66247. }
  66248. /**
  66249. * A node in the node hierarchy
  66250. */
  66251. interface INode extends IChildRootProperty {
  66252. /**
  66253. * The index of the camera referenced by this node
  66254. */
  66255. camera?: number;
  66256. /**
  66257. * The indices of this node's children
  66258. */
  66259. children?: number[];
  66260. /**
  66261. * The index of the skin referenced by this node
  66262. */
  66263. skin?: number;
  66264. /**
  66265. * A floating-point 4x4 transformation matrix stored in column-major order
  66266. */
  66267. matrix?: number[];
  66268. /**
  66269. * The index of the mesh in this node
  66270. */
  66271. mesh?: number;
  66272. /**
  66273. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66274. */
  66275. rotation?: number[];
  66276. /**
  66277. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66278. */
  66279. scale?: number[];
  66280. /**
  66281. * The node's translation along the x, y, and z axes
  66282. */
  66283. translation?: number[];
  66284. /**
  66285. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66286. */
  66287. weights?: number[];
  66288. }
  66289. /**
  66290. * Texture sampler properties for filtering and wrapping modes
  66291. */
  66292. interface ISampler extends IChildRootProperty {
  66293. /**
  66294. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66295. */
  66296. magFilter?: TextureMagFilter;
  66297. /**
  66298. * Minification filter. All valid values correspond to WebGL enums
  66299. */
  66300. minFilter?: TextureMinFilter;
  66301. /**
  66302. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66303. */
  66304. wrapS?: TextureWrapMode;
  66305. /**
  66306. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66307. */
  66308. wrapT?: TextureWrapMode;
  66309. }
  66310. /**
  66311. * The root nodes of a scene
  66312. */
  66313. interface IScene extends IChildRootProperty {
  66314. /**
  66315. * The indices of each root node
  66316. */
  66317. nodes: number[];
  66318. }
  66319. /**
  66320. * Joints and matrices defining a skin
  66321. */
  66322. interface ISkin extends IChildRootProperty {
  66323. /**
  66324. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  66325. */
  66326. inverseBindMatrices?: number;
  66327. /**
  66328. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66329. */
  66330. skeleton?: number;
  66331. /**
  66332. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  66333. */
  66334. joints: number[];
  66335. }
  66336. /**
  66337. * A texture and its sampler
  66338. */
  66339. interface ITexture extends IChildRootProperty {
  66340. /**
  66341. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66342. */
  66343. sampler?: number;
  66344. /**
  66345. * The index of the image used by this texture
  66346. */
  66347. source: number;
  66348. }
  66349. /**
  66350. * Reference to a texture
  66351. */
  66352. interface ITextureInfo extends IProperty {
  66353. /**
  66354. * The index of the texture
  66355. */
  66356. index: number;
  66357. /**
  66358. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66359. */
  66360. texCoord?: number;
  66361. }
  66362. /**
  66363. * The root object for a glTF asset
  66364. */
  66365. interface IGLTF extends IProperty {
  66366. /**
  66367. * An array of accessors. An accessor is a typed view into a bufferView
  66368. */
  66369. accessors?: IAccessor[];
  66370. /**
  66371. * An array of keyframe animations
  66372. */
  66373. animations?: IAnimation[];
  66374. /**
  66375. * Metadata about the glTF asset
  66376. */
  66377. asset: IAsset;
  66378. /**
  66379. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66380. */
  66381. buffers?: IBuffer[];
  66382. /**
  66383. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66384. */
  66385. bufferViews?: IBufferView[];
  66386. /**
  66387. * An array of cameras
  66388. */
  66389. cameras?: ICamera[];
  66390. /**
  66391. * Names of glTF extensions used somewhere in this asset
  66392. */
  66393. extensionsUsed?: string[];
  66394. /**
  66395. * Names of glTF extensions required to properly load this asset
  66396. */
  66397. extensionsRequired?: string[];
  66398. /**
  66399. * An array of images. An image defines data used to create a texture
  66400. */
  66401. images?: IImage[];
  66402. /**
  66403. * An array of materials. A material defines the appearance of a primitive
  66404. */
  66405. materials?: IMaterial[];
  66406. /**
  66407. * An array of meshes. A mesh is a set of primitives to be rendered
  66408. */
  66409. meshes?: IMesh[];
  66410. /**
  66411. * An array of nodes
  66412. */
  66413. nodes?: INode[];
  66414. /**
  66415. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  66416. */
  66417. samplers?: ISampler[];
  66418. /**
  66419. * The index of the default scene
  66420. */
  66421. scene?: number;
  66422. /**
  66423. * An array of scenes
  66424. */
  66425. scenes?: IScene[];
  66426. /**
  66427. * An array of skins. A skin is defined by joints and matrices
  66428. */
  66429. skins?: ISkin[];
  66430. /**
  66431. * An array of textures
  66432. */
  66433. textures?: ITexture[];
  66434. }
  66435. /**
  66436. * The glTF validation results
  66437. */
  66438. interface IGLTFValidationResults {
  66439. info: {
  66440. generator: string;
  66441. hasAnimations: boolean;
  66442. hasDefaultScene: boolean;
  66443. hasMaterials: boolean;
  66444. hasMorphTargets: boolean;
  66445. hasSkins: boolean;
  66446. hasTextures: boolean;
  66447. maxAttributesUsed: number;
  66448. primitivesCount: number
  66449. };
  66450. issues: {
  66451. messages: Array<string>;
  66452. numErrors: number;
  66453. numHints: number;
  66454. numInfos: number;
  66455. numWarnings: number;
  66456. truncated: boolean
  66457. };
  66458. mimeType: string;
  66459. uri: string;
  66460. validatedAt: string;
  66461. validatorVersion: string;
  66462. }
  66463. /**
  66464. * The glTF validation options
  66465. */
  66466. interface IGLTFValidationOptions {
  66467. uri?: string;
  66468. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  66469. validateAccessorData?: boolean;
  66470. maxIssues?: number;
  66471. ignoredIssues?: Array<string>;
  66472. severityOverrides?: Object;
  66473. }
  66474. /**
  66475. * The glTF validator object
  66476. */
  66477. interface IGLTFValidator {
  66478. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66479. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66480. }
  66481. }
  66482. declare module BABYLON {
  66483. /** @hidden */
  66484. export var cellPixelShader: {
  66485. name: string;
  66486. shader: string;
  66487. };
  66488. }
  66489. declare module BABYLON {
  66490. /** @hidden */
  66491. export var cellVertexShader: {
  66492. name: string;
  66493. shader: string;
  66494. };
  66495. }
  66496. declare module BABYLON {
  66497. export class CellMaterial extends BABYLON.PushMaterial {
  66498. private _diffuseTexture;
  66499. diffuseTexture: BABYLON.BaseTexture;
  66500. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  66501. computeHighLevel: boolean;
  66502. private _disableLighting;
  66503. disableLighting: boolean;
  66504. private _maxSimultaneousLights;
  66505. maxSimultaneousLights: number;
  66506. private _renderId;
  66507. constructor(name: string, scene: BABYLON.Scene);
  66508. needAlphaBlending(): boolean;
  66509. needAlphaTesting(): boolean;
  66510. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66511. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66512. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66513. getAnimatables(): BABYLON.IAnimatable[];
  66514. getActiveTextures(): BABYLON.BaseTexture[];
  66515. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66516. dispose(forceDisposeEffect?: boolean): void;
  66517. getClassName(): string;
  66518. clone(name: string): CellMaterial;
  66519. serialize(): any;
  66520. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  66521. }
  66522. }
  66523. declare module BABYLON {
  66524. export class CustomShaderStructure {
  66525. FragmentStore: string;
  66526. VertexStore: string;
  66527. constructor();
  66528. }
  66529. export class ShaderSpecialParts {
  66530. constructor();
  66531. Fragment_Begin: string;
  66532. Fragment_Definitions: string;
  66533. Fragment_MainBegin: string;
  66534. Fragment_Custom_Diffuse: string;
  66535. Fragment_Before_Lights: string;
  66536. Fragment_Before_Fog: string;
  66537. Fragment_Custom_Alpha: string;
  66538. Fragment_Before_FragColor: string;
  66539. Vertex_Begin: string;
  66540. Vertex_Definitions: string;
  66541. Vertex_MainBegin: string;
  66542. Vertex_Before_PositionUpdated: string;
  66543. Vertex_Before_NormalUpdated: string;
  66544. Vertex_MainEnd: string;
  66545. }
  66546. export class CustomMaterial extends BABYLON.StandardMaterial {
  66547. static ShaderIndexer: number;
  66548. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  66549. FragmentShader: string;
  66550. VertexShader: string;
  66551. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66552. ReviewUniform(name: string, arr: string[]): string[];
  66553. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  66554. constructor(name: string, scene: BABYLON.Scene);
  66555. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  66556. Fragment_Begin(shaderPart: string): CustomMaterial;
  66557. Fragment_Definitions(shaderPart: string): CustomMaterial;
  66558. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  66559. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  66560. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  66561. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  66562. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  66563. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  66564. Vertex_Begin(shaderPart: string): CustomMaterial;
  66565. Vertex_Definitions(shaderPart: string): CustomMaterial;
  66566. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  66567. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  66568. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  66569. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  66570. }
  66571. }
  66572. declare module BABYLON {
  66573. export class ShaderAlebdoParts {
  66574. constructor();
  66575. Fragment_Begin: string;
  66576. Fragment_Definitions: string;
  66577. Fragment_MainBegin: string;
  66578. Fragment_Custom_Albedo: string;
  66579. Fragment_Before_Lights: string;
  66580. Fragment_Custom_MetallicRoughness: string;
  66581. Fragment_Custom_MicroSurface: string;
  66582. Fragment_Before_Fog: string;
  66583. Fragment_Custom_Alpha: string;
  66584. Fragment_Before_FragColor: string;
  66585. Vertex_Begin: string;
  66586. Vertex_Definitions: string;
  66587. Vertex_MainBegin: string;
  66588. Vertex_Before_PositionUpdated: string;
  66589. Vertex_Before_NormalUpdated: string;
  66590. Vertex_MainEnd: string;
  66591. }
  66592. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  66593. static ShaderIndexer: number;
  66594. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  66595. FragmentShader: string;
  66596. VertexShader: string;
  66597. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66598. ReviewUniform(name: string, arr: string[]): string[];
  66599. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  66600. constructor(name: string, scene: BABYLON.Scene);
  66601. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  66602. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  66603. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  66604. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  66605. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  66606. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  66607. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  66608. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  66609. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  66610. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  66611. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  66612. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  66613. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  66614. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  66615. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  66616. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  66617. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  66618. }
  66619. }
  66620. declare module BABYLON {
  66621. /** @hidden */
  66622. export var firePixelShader: {
  66623. name: string;
  66624. shader: string;
  66625. };
  66626. }
  66627. declare module BABYLON {
  66628. /** @hidden */
  66629. export var fireVertexShader: {
  66630. name: string;
  66631. shader: string;
  66632. };
  66633. }
  66634. declare module BABYLON {
  66635. export class FireMaterial extends BABYLON.PushMaterial {
  66636. private _diffuseTexture;
  66637. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66638. private _distortionTexture;
  66639. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66640. private _opacityTexture;
  66641. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66642. diffuseColor: BABYLON.Color3;
  66643. speed: number;
  66644. private _scaledDiffuse;
  66645. private _renderId;
  66646. private _lastTime;
  66647. constructor(name: string, scene: BABYLON.Scene);
  66648. needAlphaBlending(): boolean;
  66649. needAlphaTesting(): boolean;
  66650. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66651. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66652. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66653. getAnimatables(): BABYLON.IAnimatable[];
  66654. getActiveTextures(): BABYLON.BaseTexture[];
  66655. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66656. getClassName(): string;
  66657. dispose(forceDisposeEffect?: boolean): void;
  66658. clone(name: string): FireMaterial;
  66659. serialize(): any;
  66660. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  66661. }
  66662. }
  66663. declare module BABYLON {
  66664. /** @hidden */
  66665. export var furPixelShader: {
  66666. name: string;
  66667. shader: string;
  66668. };
  66669. }
  66670. declare module BABYLON {
  66671. /** @hidden */
  66672. export var furVertexShader: {
  66673. name: string;
  66674. shader: string;
  66675. };
  66676. }
  66677. declare module BABYLON {
  66678. export class FurMaterial extends BABYLON.PushMaterial {
  66679. private _diffuseTexture;
  66680. diffuseTexture: BABYLON.BaseTexture;
  66681. private _heightTexture;
  66682. heightTexture: BABYLON.BaseTexture;
  66683. diffuseColor: BABYLON.Color3;
  66684. furLength: number;
  66685. furAngle: number;
  66686. furColor: BABYLON.Color3;
  66687. furOffset: number;
  66688. furSpacing: number;
  66689. furGravity: BABYLON.Vector3;
  66690. furSpeed: number;
  66691. furDensity: number;
  66692. furOcclusion: number;
  66693. furTexture: BABYLON.DynamicTexture;
  66694. private _disableLighting;
  66695. disableLighting: boolean;
  66696. private _maxSimultaneousLights;
  66697. maxSimultaneousLights: number;
  66698. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  66699. private _renderId;
  66700. private _furTime;
  66701. constructor(name: string, scene: BABYLON.Scene);
  66702. furTime: number;
  66703. needAlphaBlending(): boolean;
  66704. needAlphaTesting(): boolean;
  66705. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66706. updateFur(): void;
  66707. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66708. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66709. getAnimatables(): BABYLON.IAnimatable[];
  66710. getActiveTextures(): BABYLON.BaseTexture[];
  66711. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66712. dispose(forceDisposeEffect?: boolean): void;
  66713. clone(name: string): FurMaterial;
  66714. serialize(): any;
  66715. getClassName(): string;
  66716. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  66717. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  66718. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  66719. }
  66720. }
  66721. declare module BABYLON {
  66722. /** @hidden */
  66723. export var gradientPixelShader: {
  66724. name: string;
  66725. shader: string;
  66726. };
  66727. }
  66728. declare module BABYLON {
  66729. /** @hidden */
  66730. export var gradientVertexShader: {
  66731. name: string;
  66732. shader: string;
  66733. };
  66734. }
  66735. declare module BABYLON {
  66736. export class GradientMaterial extends BABYLON.PushMaterial {
  66737. private _maxSimultaneousLights;
  66738. maxSimultaneousLights: number;
  66739. topColor: BABYLON.Color3;
  66740. topColorAlpha: number;
  66741. bottomColor: BABYLON.Color3;
  66742. bottomColorAlpha: number;
  66743. offset: number;
  66744. scale: number;
  66745. smoothness: number;
  66746. private _disableLighting;
  66747. disableLighting: boolean;
  66748. private _renderId;
  66749. constructor(name: string, scene: BABYLON.Scene);
  66750. needAlphaBlending(): boolean;
  66751. needAlphaTesting(): boolean;
  66752. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66753. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66754. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66755. getAnimatables(): BABYLON.IAnimatable[];
  66756. dispose(forceDisposeEffect?: boolean): void;
  66757. clone(name: string): GradientMaterial;
  66758. serialize(): any;
  66759. getClassName(): string;
  66760. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  66761. }
  66762. }
  66763. declare module BABYLON {
  66764. /** @hidden */
  66765. export var gridPixelShader: {
  66766. name: string;
  66767. shader: string;
  66768. };
  66769. }
  66770. declare module BABYLON {
  66771. /** @hidden */
  66772. export var gridVertexShader: {
  66773. name: string;
  66774. shader: string;
  66775. };
  66776. }
  66777. declare module BABYLON {
  66778. /**
  66779. * The grid materials allows you to wrap any shape with a grid.
  66780. * Colors are customizable.
  66781. */
  66782. export class GridMaterial extends BABYLON.PushMaterial {
  66783. /**
  66784. * Main color of the grid (e.g. between lines)
  66785. */
  66786. mainColor: BABYLON.Color3;
  66787. /**
  66788. * Color of the grid lines.
  66789. */
  66790. lineColor: BABYLON.Color3;
  66791. /**
  66792. * The scale of the grid compared to unit.
  66793. */
  66794. gridRatio: number;
  66795. /**
  66796. * Allows setting an offset for the grid lines.
  66797. */
  66798. gridOffset: BABYLON.Vector3;
  66799. /**
  66800. * The frequency of thicker lines.
  66801. */
  66802. majorUnitFrequency: number;
  66803. /**
  66804. * The visibility of minor units in the grid.
  66805. */
  66806. minorUnitVisibility: number;
  66807. /**
  66808. * The grid opacity outside of the lines.
  66809. */
  66810. opacity: number;
  66811. /**
  66812. * Determine RBG output is premultiplied by alpha value.
  66813. */
  66814. preMultiplyAlpha: boolean;
  66815. private _opacityTexture;
  66816. opacityTexture: BABYLON.BaseTexture;
  66817. private _gridControl;
  66818. private _renderId;
  66819. /**
  66820. * constructor
  66821. * @param name The name given to the material in order to identify it afterwards.
  66822. * @param scene The scene the material is used in.
  66823. */
  66824. constructor(name: string, scene: BABYLON.Scene);
  66825. /**
  66826. * Returns wehter or not the grid requires alpha blending.
  66827. */
  66828. needAlphaBlending(): boolean;
  66829. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66830. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66831. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66832. /**
  66833. * Dispose the material and its associated resources.
  66834. * @param forceDisposeEffect will also dispose the used effect when true
  66835. */
  66836. dispose(forceDisposeEffect?: boolean): void;
  66837. clone(name: string): GridMaterial;
  66838. serialize(): any;
  66839. getClassName(): string;
  66840. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  66841. }
  66842. }
  66843. declare module BABYLON {
  66844. /** @hidden */
  66845. export var lavaPixelShader: {
  66846. name: string;
  66847. shader: string;
  66848. };
  66849. }
  66850. declare module BABYLON {
  66851. /** @hidden */
  66852. export var lavaVertexShader: {
  66853. name: string;
  66854. shader: string;
  66855. };
  66856. }
  66857. declare module BABYLON {
  66858. export class LavaMaterial extends BABYLON.PushMaterial {
  66859. private _diffuseTexture;
  66860. diffuseTexture: BABYLON.BaseTexture;
  66861. noiseTexture: BABYLON.BaseTexture;
  66862. fogColor: BABYLON.Color3;
  66863. speed: number;
  66864. movingSpeed: number;
  66865. lowFrequencySpeed: number;
  66866. fogDensity: number;
  66867. private _lastTime;
  66868. diffuseColor: BABYLON.Color3;
  66869. private _disableLighting;
  66870. disableLighting: boolean;
  66871. private _unlit;
  66872. unlit: boolean;
  66873. private _maxSimultaneousLights;
  66874. maxSimultaneousLights: number;
  66875. private _scaledDiffuse;
  66876. private _renderId;
  66877. constructor(name: string, scene: BABYLON.Scene);
  66878. needAlphaBlending(): boolean;
  66879. needAlphaTesting(): boolean;
  66880. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66881. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66882. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66883. getAnimatables(): BABYLON.IAnimatable[];
  66884. getActiveTextures(): BABYLON.BaseTexture[];
  66885. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66886. dispose(forceDisposeEffect?: boolean): void;
  66887. clone(name: string): LavaMaterial;
  66888. serialize(): any;
  66889. getClassName(): string;
  66890. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  66891. }
  66892. }
  66893. declare module BABYLON {
  66894. /** @hidden */
  66895. export var mixPixelShader: {
  66896. name: string;
  66897. shader: string;
  66898. };
  66899. }
  66900. declare module BABYLON {
  66901. /** @hidden */
  66902. export var mixVertexShader: {
  66903. name: string;
  66904. shader: string;
  66905. };
  66906. }
  66907. declare module BABYLON {
  66908. export class MixMaterial extends BABYLON.PushMaterial {
  66909. /**
  66910. * Mix textures
  66911. */
  66912. private _mixTexture1;
  66913. mixTexture1: BABYLON.BaseTexture;
  66914. private _mixTexture2;
  66915. mixTexture2: BABYLON.BaseTexture;
  66916. /**
  66917. * Diffuse textures
  66918. */
  66919. private _diffuseTexture1;
  66920. diffuseTexture1: BABYLON.Texture;
  66921. private _diffuseTexture2;
  66922. diffuseTexture2: BABYLON.Texture;
  66923. private _diffuseTexture3;
  66924. diffuseTexture3: BABYLON.Texture;
  66925. private _diffuseTexture4;
  66926. diffuseTexture4: BABYLON.Texture;
  66927. private _diffuseTexture5;
  66928. diffuseTexture5: BABYLON.Texture;
  66929. private _diffuseTexture6;
  66930. diffuseTexture6: BABYLON.Texture;
  66931. private _diffuseTexture7;
  66932. diffuseTexture7: BABYLON.Texture;
  66933. private _diffuseTexture8;
  66934. diffuseTexture8: BABYLON.Texture;
  66935. /**
  66936. * Uniforms
  66937. */
  66938. diffuseColor: BABYLON.Color3;
  66939. specularColor: BABYLON.Color3;
  66940. specularPower: number;
  66941. private _disableLighting;
  66942. disableLighting: boolean;
  66943. private _maxSimultaneousLights;
  66944. maxSimultaneousLights: number;
  66945. private _renderId;
  66946. constructor(name: string, scene: BABYLON.Scene);
  66947. needAlphaBlending(): boolean;
  66948. needAlphaTesting(): boolean;
  66949. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66950. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66951. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66952. getAnimatables(): BABYLON.IAnimatable[];
  66953. getActiveTextures(): BABYLON.BaseTexture[];
  66954. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66955. dispose(forceDisposeEffect?: boolean): void;
  66956. clone(name: string): MixMaterial;
  66957. serialize(): any;
  66958. getClassName(): string;
  66959. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  66960. }
  66961. }
  66962. declare module BABYLON {
  66963. /** @hidden */
  66964. export var normalPixelShader: {
  66965. name: string;
  66966. shader: string;
  66967. };
  66968. }
  66969. declare module BABYLON {
  66970. /** @hidden */
  66971. export var normalVertexShader: {
  66972. name: string;
  66973. shader: string;
  66974. };
  66975. }
  66976. declare module BABYLON {
  66977. export class NormalMaterial extends BABYLON.PushMaterial {
  66978. private _diffuseTexture;
  66979. diffuseTexture: BABYLON.BaseTexture;
  66980. diffuseColor: BABYLON.Color3;
  66981. private _disableLighting;
  66982. disableLighting: boolean;
  66983. private _maxSimultaneousLights;
  66984. maxSimultaneousLights: number;
  66985. private _renderId;
  66986. constructor(name: string, scene: BABYLON.Scene);
  66987. needAlphaBlending(): boolean;
  66988. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66989. needAlphaTesting(): boolean;
  66990. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66993. getAnimatables(): BABYLON.IAnimatable[];
  66994. getActiveTextures(): BABYLON.BaseTexture[];
  66995. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66996. dispose(forceDisposeEffect?: boolean): void;
  66997. clone(name: string): NormalMaterial;
  66998. serialize(): any;
  66999. getClassName(): string;
  67000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67001. }
  67002. }
  67003. declare module BABYLON {
  67004. /** @hidden */
  67005. export var shadowOnlyPixelShader: {
  67006. name: string;
  67007. shader: string;
  67008. };
  67009. }
  67010. declare module BABYLON {
  67011. /** @hidden */
  67012. export var shadowOnlyVertexShader: {
  67013. name: string;
  67014. shader: string;
  67015. };
  67016. }
  67017. declare module BABYLON {
  67018. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67019. private _renderId;
  67020. private _activeLight;
  67021. constructor(name: string, scene: BABYLON.Scene);
  67022. shadowColor: BABYLON.Color3;
  67023. needAlphaBlending(): boolean;
  67024. needAlphaTesting(): boolean;
  67025. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67026. activeLight: BABYLON.IShadowLight;
  67027. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67028. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67029. clone(name: string): ShadowOnlyMaterial;
  67030. serialize(): any;
  67031. getClassName(): string;
  67032. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  67033. }
  67034. }
  67035. declare module BABYLON {
  67036. /** @hidden */
  67037. export var simplePixelShader: {
  67038. name: string;
  67039. shader: string;
  67040. };
  67041. }
  67042. declare module BABYLON {
  67043. /** @hidden */
  67044. export var simpleVertexShader: {
  67045. name: string;
  67046. shader: string;
  67047. };
  67048. }
  67049. declare module BABYLON {
  67050. export class SimpleMaterial extends BABYLON.PushMaterial {
  67051. private _diffuseTexture;
  67052. diffuseTexture: BABYLON.BaseTexture;
  67053. diffuseColor: BABYLON.Color3;
  67054. private _disableLighting;
  67055. disableLighting: boolean;
  67056. private _maxSimultaneousLights;
  67057. maxSimultaneousLights: number;
  67058. private _renderId;
  67059. constructor(name: string, scene: BABYLON.Scene);
  67060. needAlphaBlending(): boolean;
  67061. needAlphaTesting(): boolean;
  67062. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67063. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67064. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67065. getAnimatables(): BABYLON.IAnimatable[];
  67066. getActiveTextures(): BABYLON.BaseTexture[];
  67067. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67068. dispose(forceDisposeEffect?: boolean): void;
  67069. clone(name: string): SimpleMaterial;
  67070. serialize(): any;
  67071. getClassName(): string;
  67072. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  67073. }
  67074. }
  67075. declare module BABYLON {
  67076. /** @hidden */
  67077. export var skyPixelShader: {
  67078. name: string;
  67079. shader: string;
  67080. };
  67081. }
  67082. declare module BABYLON {
  67083. /** @hidden */
  67084. export var skyVertexShader: {
  67085. name: string;
  67086. shader: string;
  67087. };
  67088. }
  67089. declare module BABYLON {
  67090. /**
  67091. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  67092. * @see https://doc.babylonjs.com/extensions/sky
  67093. */
  67094. export class SkyMaterial extends BABYLON.PushMaterial {
  67095. /**
  67096. * Defines the overall luminance of sky in interval ]0, 1[.
  67097. */
  67098. luminance: number;
  67099. /**
  67100. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  67101. */
  67102. turbidity: number;
  67103. /**
  67104. * Defines the sky appearance (light intensity).
  67105. */
  67106. rayleigh: number;
  67107. /**
  67108. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  67109. */
  67110. mieCoefficient: number;
  67111. /**
  67112. * Defines the amount of haze particles following the Mie scattering theory.
  67113. */
  67114. mieDirectionalG: number;
  67115. /**
  67116. * Defines the distance of the sun according to the active scene camera.
  67117. */
  67118. distance: number;
  67119. /**
  67120. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  67121. * "inclined".
  67122. */
  67123. inclination: number;
  67124. /**
  67125. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  67126. * an object direction and a reference direction.
  67127. */
  67128. azimuth: number;
  67129. /**
  67130. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  67131. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  67132. */
  67133. sunPosition: BABYLON.Vector3;
  67134. /**
  67135. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  67136. * .sunPosition property.
  67137. */
  67138. useSunPosition: boolean;
  67139. /**
  67140. * Defines an offset vector used to get a horizon offset.
  67141. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  67142. */
  67143. cameraOffset: BABYLON.Vector3;
  67144. private _cameraPosition;
  67145. private _renderId;
  67146. /**
  67147. * Instantiates a new sky material.
  67148. * This material allows to create dynamic and texture free
  67149. * effects for skyboxes by taking care of the atmosphere state.
  67150. * @see https://doc.babylonjs.com/extensions/sky
  67151. * @param name Define the name of the material in the scene
  67152. * @param scene Define the scene the material belong to
  67153. */
  67154. constructor(name: string, scene: BABYLON.Scene);
  67155. /**
  67156. * Specifies if the material will require alpha blending
  67157. * @returns a boolean specifying if alpha blending is needed
  67158. */
  67159. needAlphaBlending(): boolean;
  67160. /**
  67161. * Specifies if this material should be rendered in alpha test mode
  67162. * @returns false as the sky material doesn't need alpha testing.
  67163. */
  67164. needAlphaTesting(): boolean;
  67165. /**
  67166. * Get the texture used for alpha test purpose.
  67167. * @returns null as the sky material has no texture.
  67168. */
  67169. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67170. /**
  67171. * Get if the submesh is ready to be used and all its information available.
  67172. * Child classes can use it to update shaders
  67173. * @param mesh defines the mesh to check
  67174. * @param subMesh defines which submesh to check
  67175. * @param useInstances specifies that instances should be used
  67176. * @returns a boolean indicating that the submesh is ready or not
  67177. */
  67178. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67179. /**
  67180. * Binds the submesh to this material by preparing the effect and shader to draw
  67181. * @param world defines the world transformation matrix
  67182. * @param mesh defines the mesh containing the submesh
  67183. * @param subMesh defines the submesh to bind the material to
  67184. */
  67185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67186. /**
  67187. * Get the list of animatables in the material.
  67188. * @returns the list of animatables object used in the material
  67189. */
  67190. getAnimatables(): BABYLON.IAnimatable[];
  67191. /**
  67192. * Disposes the material
  67193. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67194. */
  67195. dispose(forceDisposeEffect?: boolean): void;
  67196. /**
  67197. * Makes a duplicate of the material, and gives it a new name
  67198. * @param name defines the new name for the duplicated material
  67199. * @returns the cloned material
  67200. */
  67201. clone(name: string): SkyMaterial;
  67202. /**
  67203. * Serializes this material in a JSON representation
  67204. * @returns the serialized material object
  67205. */
  67206. serialize(): any;
  67207. /**
  67208. * Gets the current class name of the material e.g. "SkyMaterial"
  67209. * Mainly use in serialization.
  67210. * @returns the class name
  67211. */
  67212. getClassName(): string;
  67213. /**
  67214. * Creates a sky material from parsed material data
  67215. * @param source defines the JSON representation of the material
  67216. * @param scene defines the hosting scene
  67217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67218. * @returns a new sky material
  67219. */
  67220. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67221. }
  67222. }
  67223. declare module BABYLON {
  67224. /** @hidden */
  67225. export var terrainPixelShader: {
  67226. name: string;
  67227. shader: string;
  67228. };
  67229. }
  67230. declare module BABYLON {
  67231. /** @hidden */
  67232. export var terrainVertexShader: {
  67233. name: string;
  67234. shader: string;
  67235. };
  67236. }
  67237. declare module BABYLON {
  67238. export class TerrainMaterial extends BABYLON.PushMaterial {
  67239. private _mixTexture;
  67240. mixTexture: BABYLON.BaseTexture;
  67241. private _diffuseTexture1;
  67242. diffuseTexture1: BABYLON.Texture;
  67243. private _diffuseTexture2;
  67244. diffuseTexture2: BABYLON.Texture;
  67245. private _diffuseTexture3;
  67246. diffuseTexture3: BABYLON.Texture;
  67247. private _bumpTexture1;
  67248. bumpTexture1: BABYLON.Texture;
  67249. private _bumpTexture2;
  67250. bumpTexture2: BABYLON.Texture;
  67251. private _bumpTexture3;
  67252. bumpTexture3: BABYLON.Texture;
  67253. diffuseColor: BABYLON.Color3;
  67254. specularColor: BABYLON.Color3;
  67255. specularPower: number;
  67256. private _disableLighting;
  67257. disableLighting: boolean;
  67258. private _maxSimultaneousLights;
  67259. maxSimultaneousLights: number;
  67260. private _renderId;
  67261. constructor(name: string, scene: BABYLON.Scene);
  67262. needAlphaBlending(): boolean;
  67263. needAlphaTesting(): boolean;
  67264. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67267. getAnimatables(): BABYLON.IAnimatable[];
  67268. getActiveTextures(): BABYLON.BaseTexture[];
  67269. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67270. dispose(forceDisposeEffect?: boolean): void;
  67271. clone(name: string): TerrainMaterial;
  67272. serialize(): any;
  67273. getClassName(): string;
  67274. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67275. }
  67276. }
  67277. declare module BABYLON {
  67278. /** @hidden */
  67279. export var triplanarPixelShader: {
  67280. name: string;
  67281. shader: string;
  67282. };
  67283. }
  67284. declare module BABYLON {
  67285. /** @hidden */
  67286. export var triplanarVertexShader: {
  67287. name: string;
  67288. shader: string;
  67289. };
  67290. }
  67291. declare module BABYLON {
  67292. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67293. mixTexture: BABYLON.BaseTexture;
  67294. private _diffuseTextureX;
  67295. diffuseTextureX: BABYLON.BaseTexture;
  67296. private _diffuseTextureY;
  67297. diffuseTextureY: BABYLON.BaseTexture;
  67298. private _diffuseTextureZ;
  67299. diffuseTextureZ: BABYLON.BaseTexture;
  67300. private _normalTextureX;
  67301. normalTextureX: BABYLON.BaseTexture;
  67302. private _normalTextureY;
  67303. normalTextureY: BABYLON.BaseTexture;
  67304. private _normalTextureZ;
  67305. normalTextureZ: BABYLON.BaseTexture;
  67306. tileSize: number;
  67307. diffuseColor: BABYLON.Color3;
  67308. specularColor: BABYLON.Color3;
  67309. specularPower: number;
  67310. private _disableLighting;
  67311. disableLighting: boolean;
  67312. private _maxSimultaneousLights;
  67313. maxSimultaneousLights: number;
  67314. private _renderId;
  67315. constructor(name: string, scene: BABYLON.Scene);
  67316. needAlphaBlending(): boolean;
  67317. needAlphaTesting(): boolean;
  67318. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67319. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67320. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67321. getAnimatables(): BABYLON.IAnimatable[];
  67322. getActiveTextures(): BABYLON.BaseTexture[];
  67323. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67324. dispose(forceDisposeEffect?: boolean): void;
  67325. clone(name: string): TriPlanarMaterial;
  67326. serialize(): any;
  67327. getClassName(): string;
  67328. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67329. }
  67330. }
  67331. declare module BABYLON {
  67332. /** @hidden */
  67333. export var waterPixelShader: {
  67334. name: string;
  67335. shader: string;
  67336. };
  67337. }
  67338. declare module BABYLON {
  67339. /** @hidden */
  67340. export var waterVertexShader: {
  67341. name: string;
  67342. shader: string;
  67343. };
  67344. }
  67345. declare module BABYLON {
  67346. export class WaterMaterial extends BABYLON.PushMaterial {
  67347. renderTargetSize: BABYLON.Vector2;
  67348. private _bumpTexture;
  67349. bumpTexture: BABYLON.BaseTexture;
  67350. diffuseColor: BABYLON.Color3;
  67351. specularColor: BABYLON.Color3;
  67352. specularPower: number;
  67353. private _disableLighting;
  67354. disableLighting: boolean;
  67355. private _maxSimultaneousLights;
  67356. maxSimultaneousLights: number;
  67357. /**
  67358. * @param {number}: Represents the wind force
  67359. */
  67360. windForce: number;
  67361. /**
  67362. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67363. */
  67364. windDirection: BABYLON.Vector2;
  67365. /**
  67366. * @param {number}: Wave height, represents the height of the waves
  67367. */
  67368. waveHeight: number;
  67369. /**
  67370. * @param {number}: Bump height, represents the bump height related to the bump map
  67371. */
  67372. bumpHeight: number;
  67373. /**
  67374. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67375. */
  67376. private _bumpSuperimpose;
  67377. bumpSuperimpose: boolean;
  67378. /**
  67379. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  67380. */
  67381. private _fresnelSeparate;
  67382. fresnelSeparate: boolean;
  67383. /**
  67384. * @param {boolean}: bump Waves modify the reflection.
  67385. */
  67386. private _bumpAffectsReflection;
  67387. bumpAffectsReflection: boolean;
  67388. /**
  67389. * @param {number}: The water color blended with the refraction (near)
  67390. */
  67391. waterColor: BABYLON.Color3;
  67392. /**
  67393. * @param {number}: The blend factor related to the water color
  67394. */
  67395. colorBlendFactor: number;
  67396. /**
  67397. * @param {number}: The water color blended with the reflection (far)
  67398. */
  67399. waterColor2: BABYLON.Color3;
  67400. /**
  67401. * @param {number}: The blend factor related to the water color (reflection, far)
  67402. */
  67403. colorBlendFactor2: number;
  67404. /**
  67405. * @param {number}: Represents the maximum length of a wave
  67406. */
  67407. waveLength: number;
  67408. /**
  67409. * @param {number}: Defines the waves speed
  67410. */
  67411. waveSpeed: number;
  67412. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  67413. private _mesh;
  67414. private _refractionRTT;
  67415. private _reflectionRTT;
  67416. private _reflectionTransform;
  67417. private _lastTime;
  67418. private _lastDeltaTime;
  67419. private _renderId;
  67420. private _useLogarithmicDepth;
  67421. private _waitingRenderList;
  67422. /**
  67423. * Gets a boolean indicating that current material needs to register RTT
  67424. */
  67425. readonly hasRenderTargetTextures: boolean;
  67426. /**
  67427. * Constructor
  67428. */
  67429. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  67430. useLogarithmicDepth: boolean;
  67431. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67432. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67433. addToRenderList(node: any): void;
  67434. enableRenderTargets(enable: boolean): void;
  67435. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  67436. readonly renderTargetsEnabled: boolean;
  67437. needAlphaBlending(): boolean;
  67438. needAlphaTesting(): boolean;
  67439. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67440. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67442. private _createRenderTargets;
  67443. getAnimatables(): BABYLON.IAnimatable[];
  67444. getActiveTextures(): BABYLON.BaseTexture[];
  67445. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67446. dispose(forceDisposeEffect?: boolean): void;
  67447. clone(name: string): WaterMaterial;
  67448. serialize(): any;
  67449. getClassName(): string;
  67450. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  67451. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  67452. }
  67453. }
  67454. declare module BABYLON {
  67455. /** @hidden */
  67456. export var asciiartPixelShader: {
  67457. name: string;
  67458. shader: string;
  67459. };
  67460. }
  67461. declare module BABYLON {
  67462. /**
  67463. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  67464. *
  67465. * It basically takes care rendering the font front the given font size to a texture.
  67466. * This is used later on in the postprocess.
  67467. */
  67468. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  67469. private _font;
  67470. private _text;
  67471. private _charSize;
  67472. /**
  67473. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67474. */
  67475. readonly charSize: number;
  67476. /**
  67477. * Create a new instance of the Ascii Art FontTexture class
  67478. * @param name the name of the texture
  67479. * @param font the font to use, use the W3C CSS notation
  67480. * @param text the caracter set to use in the rendering.
  67481. * @param scene the scene that owns the texture
  67482. */
  67483. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67484. /**
  67485. * Gets the max char width of a font.
  67486. * @param font the font to use, use the W3C CSS notation
  67487. * @return the max char width
  67488. */
  67489. private getFontWidth;
  67490. /**
  67491. * Gets the max char height of a font.
  67492. * @param font the font to use, use the W3C CSS notation
  67493. * @return the max char height
  67494. */
  67495. private getFontHeight;
  67496. /**
  67497. * Clones the current AsciiArtTexture.
  67498. * @return the clone of the texture.
  67499. */
  67500. clone(): AsciiArtFontTexture;
  67501. /**
  67502. * Parses a json object representing the texture and returns an instance of it.
  67503. * @param source the source JSON representation
  67504. * @param scene the scene to create the texture for
  67505. * @return the parsed texture
  67506. */
  67507. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  67508. }
  67509. /**
  67510. * Option available in the Ascii Art Post Process.
  67511. */
  67512. export interface IAsciiArtPostProcessOptions {
  67513. /**
  67514. * The font to use following the w3c font definition.
  67515. */
  67516. font?: string;
  67517. /**
  67518. * The character set to use in the postprocess.
  67519. */
  67520. characterSet?: string;
  67521. /**
  67522. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67523. * This number is defined between 0 and 1;
  67524. */
  67525. mixToTile?: number;
  67526. /**
  67527. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67528. * This number is defined between 0 and 1;
  67529. */
  67530. mixToNormal?: number;
  67531. }
  67532. /**
  67533. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  67534. *
  67535. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67536. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  67537. */
  67538. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  67539. /**
  67540. * The font texture used to render the char in the post process.
  67541. */
  67542. private _asciiArtFontTexture;
  67543. /**
  67544. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67545. * This number is defined between 0 and 1;
  67546. */
  67547. mixToTile: number;
  67548. /**
  67549. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67550. * This number is defined between 0 and 1;
  67551. */
  67552. mixToNormal: number;
  67553. /**
  67554. * Instantiates a new Ascii Art Post Process.
  67555. * @param name the name to give to the postprocess
  67556. * @camera the camera to apply the post process to.
  67557. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  67558. */
  67559. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  67560. }
  67561. }
  67562. declare module BABYLON {
  67563. /** @hidden */
  67564. export var digitalrainPixelShader: {
  67565. name: string;
  67566. shader: string;
  67567. };
  67568. }
  67569. declare module BABYLON {
  67570. /**
  67571. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  67572. *
  67573. * It basically takes care rendering the font front the given font size to a texture.
  67574. * This is used later on in the postprocess.
  67575. */
  67576. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  67577. private _font;
  67578. private _text;
  67579. private _charSize;
  67580. /**
  67581. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67582. */
  67583. readonly charSize: number;
  67584. /**
  67585. * Create a new instance of the Digital Rain FontTexture class
  67586. * @param name the name of the texture
  67587. * @param font the font to use, use the W3C CSS notation
  67588. * @param text the caracter set to use in the rendering.
  67589. * @param scene the scene that owns the texture
  67590. */
  67591. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67592. /**
  67593. * Gets the max char width of a font.
  67594. * @param font the font to use, use the W3C CSS notation
  67595. * @return the max char width
  67596. */
  67597. private getFontWidth;
  67598. /**
  67599. * Gets the max char height of a font.
  67600. * @param font the font to use, use the W3C CSS notation
  67601. * @return the max char height
  67602. */
  67603. private getFontHeight;
  67604. /**
  67605. * Clones the current DigitalRainFontTexture.
  67606. * @return the clone of the texture.
  67607. */
  67608. clone(): DigitalRainFontTexture;
  67609. /**
  67610. * Parses a json object representing the texture and returns an instance of it.
  67611. * @param source the source JSON representation
  67612. * @param scene the scene to create the texture for
  67613. * @return the parsed texture
  67614. */
  67615. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  67616. }
  67617. /**
  67618. * Option available in the Digital Rain Post Process.
  67619. */
  67620. export interface IDigitalRainPostProcessOptions {
  67621. /**
  67622. * The font to use following the w3c font definition.
  67623. */
  67624. font?: string;
  67625. /**
  67626. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67627. * This number is defined between 0 and 1;
  67628. */
  67629. mixToTile?: number;
  67630. /**
  67631. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67632. * This number is defined between 0 and 1;
  67633. */
  67634. mixToNormal?: number;
  67635. }
  67636. /**
  67637. * DigitalRainPostProcess helps rendering everithing in digital rain.
  67638. *
  67639. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67640. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  67641. */
  67642. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  67643. /**
  67644. * The font texture used to render the char in the post process.
  67645. */
  67646. private _digitalRainFontTexture;
  67647. /**
  67648. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67649. * This number is defined between 0 and 1;
  67650. */
  67651. mixToTile: number;
  67652. /**
  67653. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67654. * This number is defined between 0 and 1;
  67655. */
  67656. mixToNormal: number;
  67657. /**
  67658. * Instantiates a new Digital Rain Post Process.
  67659. * @param name the name to give to the postprocess
  67660. * @camera the camera to apply the post process to.
  67661. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  67662. */
  67663. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  67664. }
  67665. }
  67666. declare module BABYLON {
  67667. /** @hidden */
  67668. export var oceanPostProcessPixelShader: {
  67669. name: string;
  67670. shader: string;
  67671. };
  67672. }
  67673. declare module BABYLON {
  67674. /**
  67675. * Option available in the Ocean Post Process.
  67676. */
  67677. export interface IOceanPostProcessOptions {
  67678. /**
  67679. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67680. */
  67681. reflectionSize?: number | {
  67682. width: number;
  67683. height: number;
  67684. } | {
  67685. ratio: number;
  67686. };
  67687. /**
  67688. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67689. */
  67690. refractionSize?: number | {
  67691. width: number;
  67692. height: number;
  67693. } | {
  67694. ratio: number;
  67695. };
  67696. }
  67697. /**
  67698. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  67699. *
  67700. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67701. * Example usage:
  67702. * var pp = new OceanPostProcess("myOcean", camera);
  67703. * pp.reflectionEnabled = true;
  67704. * pp.refractionEnabled = true;
  67705. */
  67706. export class OceanPostProcess extends BABYLON.PostProcess {
  67707. /**
  67708. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  67709. */
  67710. /**
  67711. * Sets weither or not the real-time reflection is enabled on the ocean.
  67712. * Is set to true, the reflection mirror texture will be used as reflection texture.
  67713. */
  67714. reflectionEnabled: boolean;
  67715. /**
  67716. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  67717. */
  67718. /**
  67719. * Sets weither or not the real-time refraction is enabled on the ocean.
  67720. * Is set to true, the refraction render target texture will be used as refraction texture.
  67721. */
  67722. refractionEnabled: boolean;
  67723. /**
  67724. * Gets wether or not the post-processes is supported by the running hardware.
  67725. * This requires draw buffer supports.
  67726. */
  67727. readonly isSupported: boolean;
  67728. /**
  67729. * This is the reflection mirror texture used to display reflections on the ocean.
  67730. * By default, render list is empty.
  67731. */
  67732. reflectionTexture: BABYLON.MirrorTexture;
  67733. /**
  67734. * This is the refraction render target texture used to display refraction on the ocean.
  67735. * By default, render list is empty.
  67736. */
  67737. refractionTexture: BABYLON.RenderTargetTexture;
  67738. private _time;
  67739. private _cameraRotation;
  67740. private _cameraViewMatrix;
  67741. private _reflectionEnabled;
  67742. private _refractionEnabled;
  67743. private _geometryRenderer;
  67744. /**
  67745. * Instantiates a new Ocean Post Process.
  67746. * @param name the name to give to the postprocess.
  67747. * @camera the camera to apply the post process to.
  67748. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  67749. */
  67750. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  67751. /**
  67752. * Returns the appropriate defines according to the current configuration.
  67753. */
  67754. private _getDefines;
  67755. /**
  67756. * Computes the current camera rotation as the shader requires a camera rotation.
  67757. */
  67758. private _computeCameraRotation;
  67759. }
  67760. }
  67761. declare module BABYLON {
  67762. /** @hidden */
  67763. export var brickProceduralTexturePixelShader: {
  67764. name: string;
  67765. shader: string;
  67766. };
  67767. }
  67768. declare module BABYLON {
  67769. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  67770. private _numberOfBricksHeight;
  67771. private _numberOfBricksWidth;
  67772. private _jointColor;
  67773. private _brickColor;
  67774. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67775. updateShaderUniforms(): void;
  67776. numberOfBricksHeight: number;
  67777. numberOfBricksWidth: number;
  67778. jointColor: BABYLON.Color3;
  67779. brickColor: BABYLON.Color3;
  67780. /**
  67781. * Serializes this brick procedural texture
  67782. * @returns a serialized brick procedural texture object
  67783. */
  67784. serialize(): any;
  67785. /**
  67786. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  67787. * @param parsedTexture defines parsed texture data
  67788. * @param scene defines the current scene
  67789. * @param rootUrl defines the root URL containing brick procedural texture information
  67790. * @returns a parsed Brick Procedural BABYLON.Texture
  67791. */
  67792. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  67793. }
  67794. }
  67795. declare module BABYLON {
  67796. /** @hidden */
  67797. export var cloudProceduralTexturePixelShader: {
  67798. name: string;
  67799. shader: string;
  67800. };
  67801. }
  67802. declare module BABYLON {
  67803. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  67804. private _skyColor;
  67805. private _cloudColor;
  67806. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67807. updateShaderUniforms(): void;
  67808. skyColor: BABYLON.Color4;
  67809. cloudColor: BABYLON.Color4;
  67810. /**
  67811. * Serializes this cloud procedural texture
  67812. * @returns a serialized cloud procedural texture object
  67813. */
  67814. serialize(): any;
  67815. /**
  67816. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  67817. * @param parsedTexture defines parsed texture data
  67818. * @param scene defines the current scene
  67819. * @param rootUrl defines the root URL containing cloud procedural texture information
  67820. * @returns a parsed Cloud Procedural BABYLON.Texture
  67821. */
  67822. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  67823. }
  67824. }
  67825. declare module BABYLON {
  67826. /** @hidden */
  67827. export var fireProceduralTexturePixelShader: {
  67828. name: string;
  67829. shader: string;
  67830. };
  67831. }
  67832. declare module BABYLON {
  67833. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  67834. private _time;
  67835. private _speed;
  67836. private _autoGenerateTime;
  67837. private _fireColors;
  67838. private _alphaThreshold;
  67839. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67840. updateShaderUniforms(): void;
  67841. render(useCameraPostProcess?: boolean): void;
  67842. static readonly PurpleFireColors: BABYLON.Color3[];
  67843. static readonly GreenFireColors: BABYLON.Color3[];
  67844. static readonly RedFireColors: BABYLON.Color3[];
  67845. static readonly BlueFireColors: BABYLON.Color3[];
  67846. autoGenerateTime: boolean;
  67847. fireColors: BABYLON.Color3[];
  67848. time: number;
  67849. speed: BABYLON.Vector2;
  67850. alphaThreshold: number;
  67851. /**
  67852. * Serializes this fire procedural texture
  67853. * @returns a serialized fire procedural texture object
  67854. */
  67855. serialize(): any;
  67856. /**
  67857. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  67858. * @param parsedTexture defines parsed texture data
  67859. * @param scene defines the current scene
  67860. * @param rootUrl defines the root URL containing fire procedural texture information
  67861. * @returns a parsed Fire Procedural BABYLON.Texture
  67862. */
  67863. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  67864. }
  67865. }
  67866. declare module BABYLON {
  67867. /** @hidden */
  67868. export var grassProceduralTexturePixelShader: {
  67869. name: string;
  67870. shader: string;
  67871. };
  67872. }
  67873. declare module BABYLON {
  67874. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  67875. private _grassColors;
  67876. private _groundColor;
  67877. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67878. updateShaderUniforms(): void;
  67879. grassColors: BABYLON.Color3[];
  67880. groundColor: BABYLON.Color3;
  67881. /**
  67882. * Serializes this grass procedural texture
  67883. * @returns a serialized grass procedural texture object
  67884. */
  67885. serialize(): any;
  67886. /**
  67887. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  67888. * @param parsedTexture defines parsed texture data
  67889. * @param scene defines the current scene
  67890. * @param rootUrl defines the root URL containing grass procedural texture information
  67891. * @returns a parsed Grass Procedural BABYLON.Texture
  67892. */
  67893. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  67894. }
  67895. }
  67896. declare module BABYLON {
  67897. /** @hidden */
  67898. export var marbleProceduralTexturePixelShader: {
  67899. name: string;
  67900. shader: string;
  67901. };
  67902. }
  67903. declare module BABYLON {
  67904. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  67905. private _numberOfTilesHeight;
  67906. private _numberOfTilesWidth;
  67907. private _amplitude;
  67908. private _jointColor;
  67909. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67910. updateShaderUniforms(): void;
  67911. numberOfTilesHeight: number;
  67912. amplitude: number;
  67913. numberOfTilesWidth: number;
  67914. jointColor: BABYLON.Color3;
  67915. /**
  67916. * Serializes this marble procedural texture
  67917. * @returns a serialized marble procedural texture object
  67918. */
  67919. serialize(): any;
  67920. /**
  67921. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  67922. * @param parsedTexture defines parsed texture data
  67923. * @param scene defines the current scene
  67924. * @param rootUrl defines the root URL containing marble procedural texture information
  67925. * @returns a parsed Marble Procedural BABYLON.Texture
  67926. */
  67927. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  67928. }
  67929. }
  67930. declare module BABYLON {
  67931. /** @hidden */
  67932. export var normalMapProceduralTexturePixelShader: {
  67933. name: string;
  67934. shader: string;
  67935. };
  67936. }
  67937. declare module BABYLON {
  67938. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  67939. private _baseTexture;
  67940. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67941. updateShaderUniforms(): void;
  67942. render(useCameraPostProcess?: boolean): void;
  67943. resize(size: any, generateMipMaps: any): void;
  67944. baseTexture: BABYLON.Texture;
  67945. /**
  67946. * Serializes this normal map procedural texture
  67947. * @returns a serialized normal map procedural texture object
  67948. */
  67949. serialize(): any;
  67950. /**
  67951. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  67952. * @param parsedTexture defines parsed texture data
  67953. * @param scene defines the current scene
  67954. * @param rootUrl defines the root URL containing normal map procedural texture information
  67955. * @returns a parsed Normal Map Procedural BABYLON.Texture
  67956. */
  67957. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  67958. }
  67959. }
  67960. declare module BABYLON {
  67961. /** @hidden */
  67962. export var perlinNoiseProceduralTexturePixelShader: {
  67963. name: string;
  67964. shader: string;
  67965. };
  67966. }
  67967. declare module BABYLON {
  67968. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  67969. time: number;
  67970. timeScale: number;
  67971. translationSpeed: number;
  67972. private _currentTranslation;
  67973. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67974. updateShaderUniforms(): void;
  67975. render(useCameraPostProcess?: boolean): void;
  67976. resize(size: any, generateMipMaps: any): void;
  67977. /**
  67978. * Serializes this perlin noise procedural texture
  67979. * @returns a serialized perlin noise procedural texture object
  67980. */
  67981. serialize(): any;
  67982. /**
  67983. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  67984. * @param parsedTexture defines parsed texture data
  67985. * @param scene defines the current scene
  67986. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  67987. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  67988. */
  67989. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  67990. }
  67991. }
  67992. declare module BABYLON {
  67993. /** @hidden */
  67994. export var roadProceduralTexturePixelShader: {
  67995. name: string;
  67996. shader: string;
  67997. };
  67998. }
  67999. declare module BABYLON {
  68000. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68001. private _roadColor;
  68002. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68003. updateShaderUniforms(): void;
  68004. roadColor: BABYLON.Color3;
  68005. /**
  68006. * Serializes this road procedural texture
  68007. * @returns a serialized road procedural texture object
  68008. */
  68009. serialize(): any;
  68010. /**
  68011. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68012. * @param parsedTexture defines parsed texture data
  68013. * @param scene defines the current scene
  68014. * @param rootUrl defines the root URL containing road procedural texture information
  68015. * @returns a parsed Road Procedural BABYLON.Texture
  68016. */
  68017. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68018. }
  68019. }
  68020. declare module BABYLON {
  68021. /** @hidden */
  68022. export var starfieldProceduralTexturePixelShader: {
  68023. name: string;
  68024. shader: string;
  68025. };
  68026. }
  68027. declare module BABYLON {
  68028. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  68029. private _time;
  68030. private _alpha;
  68031. private _beta;
  68032. private _zoom;
  68033. private _formuparam;
  68034. private _stepsize;
  68035. private _tile;
  68036. private _brightness;
  68037. private _darkmatter;
  68038. private _distfading;
  68039. private _saturation;
  68040. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68041. updateShaderUniforms(): void;
  68042. time: number;
  68043. alpha: number;
  68044. beta: number;
  68045. formuparam: number;
  68046. stepsize: number;
  68047. zoom: number;
  68048. tile: number;
  68049. brightness: number;
  68050. darkmatter: number;
  68051. distfading: number;
  68052. saturation: number;
  68053. /**
  68054. * Serializes this starfield procedural texture
  68055. * @returns a serialized starfield procedural texture object
  68056. */
  68057. serialize(): any;
  68058. /**
  68059. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  68060. * @param parsedTexture defines parsed texture data
  68061. * @param scene defines the current scene
  68062. * @param rootUrl defines the root URL containing startfield procedural texture information
  68063. * @returns a parsed Starfield Procedural BABYLON.Texture
  68064. */
  68065. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  68066. }
  68067. }
  68068. declare module BABYLON {
  68069. /** @hidden */
  68070. export var woodProceduralTexturePixelShader: {
  68071. name: string;
  68072. shader: string;
  68073. };
  68074. }
  68075. declare module BABYLON {
  68076. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  68077. private _ampScale;
  68078. private _woodColor;
  68079. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68080. updateShaderUniforms(): void;
  68081. ampScale: number;
  68082. woodColor: BABYLON.Color3;
  68083. /**
  68084. * Serializes this wood procedural texture
  68085. * @returns a serialized wood procedural texture object
  68086. */
  68087. serialize(): any;
  68088. /**
  68089. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  68090. * @param parsedTexture defines parsed texture data
  68091. * @param scene defines the current scene
  68092. * @param rootUrl defines the root URL containing wood procedural texture information
  68093. * @returns a parsed Wood Procedural BABYLON.Texture
  68094. */
  68095. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  68096. }
  68097. }