babylon.d.txt 2.8 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359
  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 the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * 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"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * 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)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * 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
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Adds the translation vector (using 3 floats) in the current matrix
  2941. * @param x defines the 1st component of the translation
  2942. * @param y defines the 2nd component of the translation
  2943. * @param z defines the 3rd component of the translation
  2944. * @returns the current updated matrix
  2945. */
  2946. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2947. /**
  2948. * Inserts the translation vector in the current matrix
  2949. * @param vector3 defines the translation to insert
  2950. * @returns the current updated matrix
  2951. */
  2952. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2953. /**
  2954. * Gets the translation value of the current matrix
  2955. * @returns a new Vector3 as the extracted translation from the matrix
  2956. */
  2957. getTranslation(): Vector3;
  2958. /**
  2959. * Fill a Vector3 with the extracted translation from the matrix
  2960. * @param result defines the Vector3 where to store the translation
  2961. * @returns the current matrix
  2962. */
  2963. getTranslationToRef(result: Vector3): Matrix;
  2964. /**
  2965. * Remove rotation and scaling part from the matrix
  2966. * @returns the updated matrix
  2967. */
  2968. removeRotationAndScaling(): Matrix;
  2969. /**
  2970. * Multiply two matrices
  2971. * @param other defines the second operand
  2972. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2973. */
  2974. multiply(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Copy the current matrix from the given one
  2977. * @param other defines the source matrix
  2978. * @returns the current updated matrix
  2979. */
  2980. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2981. /**
  2982. * Populates the given array from the starting index with the current matrix values
  2983. * @param array defines the target array
  2984. * @param offset defines the offset in the target array where to start storing values
  2985. * @returns the current matrix
  2986. */
  2987. copyToArray(array: Float32Array, offset?: number): Matrix;
  2988. /**
  2989. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2990. * @param other defines the second operand
  2991. * @param result defines the matrix where to store the multiplication
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2995. /**
  2996. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2997. * @param other defines the second operand
  2998. * @param result defines the array where to store the multiplication
  2999. * @param offset defines the offset in the target array where to start storing values
  3000. * @returns the current matrix
  3001. */
  3002. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3003. /**
  3004. * Check equality between this matrix and a second one
  3005. * @param value defines the second matrix to compare
  3006. * @returns true is the current matrix and the given one values are strictly equal
  3007. */
  3008. equals(value: DeepImmutable<Matrix>): boolean;
  3009. /**
  3010. * Clone the current matrix
  3011. * @returns a new matrix from the current matrix
  3012. */
  3013. clone(): Matrix;
  3014. /**
  3015. * Returns the name of the current matrix class
  3016. * @returns the string "Matrix"
  3017. */
  3018. getClassName(): string;
  3019. /**
  3020. * Gets the hash code of the current matrix
  3021. * @returns the hash code
  3022. */
  3023. getHashCode(): number;
  3024. /**
  3025. * Decomposes the current Matrix into a translation, rotation and scaling components
  3026. * @param scale defines the scale vector3 given as a reference to update
  3027. * @param rotation defines the rotation quaternion given as a reference to update
  3028. * @param translation defines the translation vector3 given as a reference to update
  3029. * @returns true if operation was successful
  3030. */
  3031. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3032. /**
  3033. * Gets specific row of the matrix
  3034. * @param index defines the number of the row to get
  3035. * @returns the index-th row of the current matrix as a new Vector4
  3036. */
  3037. getRow(index: number): Nullable<Vector4>;
  3038. /**
  3039. * Sets the index-th row of the current matrix to the vector4 values
  3040. * @param index defines the number of the row to set
  3041. * @param row defines the target vector4
  3042. * @returns the updated current matrix
  3043. */
  3044. setRow(index: number, row: Vector4): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix
  3047. * @returns the new transposed matrix
  3048. */
  3049. transpose(): Matrix;
  3050. /**
  3051. * Compute the transpose of the matrix and store it in a given matrix
  3052. * @param result defines the target matrix
  3053. * @returns the current matrix
  3054. */
  3055. transposeToRef(result: Matrix): Matrix;
  3056. /**
  3057. * Sets the index-th row of the current matrix with the given 4 x float values
  3058. * @param index defines the row index
  3059. * @param x defines the x component to set
  3060. * @param y defines the y component to set
  3061. * @param z defines the z component to set
  3062. * @param w defines the w component to set
  3063. * @returns the updated current matrix
  3064. */
  3065. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3066. /**
  3067. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3068. * @param scale defines the scale factor
  3069. * @returns a new matrix
  3070. */
  3071. scale(scale: number): Matrix;
  3072. /**
  3073. * Scale the current matrix values by a factor to a given result matrix
  3074. * @param scale defines the scale factor
  3075. * @param result defines the matrix to store the result
  3076. * @returns the current matrix
  3077. */
  3078. scaleToRef(scale: number, result: Matrix): Matrix;
  3079. /**
  3080. * Scale the current matrix values by a factor and add the result to a given matrix
  3081. * @param scale defines the scale factor
  3082. * @param result defines the Matrix to store the result
  3083. * @returns the current matrix
  3084. */
  3085. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3086. /**
  3087. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3088. * @param ref matrix to store the result
  3089. */
  3090. toNormalMatrix(ref: Matrix): void;
  3091. /**
  3092. * Gets only rotation part of the current matrix
  3093. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3094. */
  3095. getRotationMatrix(): Matrix;
  3096. /**
  3097. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3098. * @param result defines the target matrix to store data to
  3099. * @returns the current matrix
  3100. */
  3101. getRotationMatrixToRef(result: Matrix): Matrix;
  3102. /**
  3103. * Toggles model matrix from being right handed to left handed in place and vice versa
  3104. */
  3105. toggleModelMatrixHandInPlace(): void;
  3106. /**
  3107. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleProjectionMatrixHandInPlace(): void;
  3110. /**
  3111. * Creates a matrix from an array
  3112. * @param array defines the source array
  3113. * @param offset defines an offset in the source array
  3114. * @returns a new Matrix set from the starting index of the given array
  3115. */
  3116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3117. /**
  3118. * Copy the content of an array into a given matrix
  3119. * @param array defines the source array
  3120. * @param offset defines an offset in the source array
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3124. /**
  3125. * Stores an array into a matrix after having multiplied each component by a given factor
  3126. * @param array defines the source array
  3127. * @param offset defines the offset in the source array
  3128. * @param scale defines the scaling factor
  3129. * @param result defines the target matrix
  3130. */
  3131. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3132. /**
  3133. * Gets an identity matrix that must not be updated
  3134. */
  3135. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3136. /**
  3137. * Stores a list of values (16) inside a given matrix
  3138. * @param initialM11 defines 1st value of 1st row
  3139. * @param initialM12 defines 2nd value of 1st row
  3140. * @param initialM13 defines 3rd value of 1st row
  3141. * @param initialM14 defines 4th value of 1st row
  3142. * @param initialM21 defines 1st value of 2nd row
  3143. * @param initialM22 defines 2nd value of 2nd row
  3144. * @param initialM23 defines 3rd value of 2nd row
  3145. * @param initialM24 defines 4th value of 2nd row
  3146. * @param initialM31 defines 1st value of 3rd row
  3147. * @param initialM32 defines 2nd value of 3rd row
  3148. * @param initialM33 defines 3rd value of 3rd row
  3149. * @param initialM34 defines 4th value of 3rd row
  3150. * @param initialM41 defines 1st value of 4th row
  3151. * @param initialM42 defines 2nd value of 4th row
  3152. * @param initialM43 defines 3rd value of 4th row
  3153. * @param initialM44 defines 4th value of 4th row
  3154. * @param result defines the target matrix
  3155. */
  3156. 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;
  3157. /**
  3158. * Creates new matrix from a list of values (16)
  3159. * @param initialM11 defines 1st value of 1st row
  3160. * @param initialM12 defines 2nd value of 1st row
  3161. * @param initialM13 defines 3rd value of 1st row
  3162. * @param initialM14 defines 4th value of 1st row
  3163. * @param initialM21 defines 1st value of 2nd row
  3164. * @param initialM22 defines 2nd value of 2nd row
  3165. * @param initialM23 defines 3rd value of 2nd row
  3166. * @param initialM24 defines 4th value of 2nd row
  3167. * @param initialM31 defines 1st value of 3rd row
  3168. * @param initialM32 defines 2nd value of 3rd row
  3169. * @param initialM33 defines 3rd value of 3rd row
  3170. * @param initialM34 defines 4th value of 3rd row
  3171. * @param initialM41 defines 1st value of 4th row
  3172. * @param initialM42 defines 2nd value of 4th row
  3173. * @param initialM43 defines 3rd value of 4th row
  3174. * @param initialM44 defines 4th value of 4th row
  3175. * @returns the new matrix
  3176. */
  3177. 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;
  3178. /**
  3179. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @returns a new matrix
  3184. */
  3185. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3186. /**
  3187. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3188. * @param scale defines the scale vector3
  3189. * @param rotation defines the rotation quaternion
  3190. * @param translation defines the translation vector3
  3191. * @param result defines the target matrix
  3192. */
  3193. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a new identity matrix
  3196. * @returns a new identity matrix
  3197. */
  3198. static Identity(): Matrix;
  3199. /**
  3200. * Creates a new identity matrix and stores the result in a given matrix
  3201. * @param result defines the target matrix
  3202. */
  3203. static IdentityToRef(result: Matrix): void;
  3204. /**
  3205. * Creates a new zero matrix
  3206. * @returns a new zero matrix
  3207. */
  3208. static Zero(): Matrix;
  3209. /**
  3210. * Creates a new rotation matrix for "angle" radians around the X axis
  3211. * @param angle defines the angle (in radians) to use
  3212. * @return the new matrix
  3213. */
  3214. static RotationX(angle: number): Matrix;
  3215. /**
  3216. * Creates a new matrix as the invert of a given matrix
  3217. * @param source defines the source matrix
  3218. * @returns the new matrix
  3219. */
  3220. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3223. * @param angle defines the angle (in radians) to use
  3224. * @param result defines the target matrix
  3225. */
  3226. static RotationXToRef(angle: number, result: Matrix): void;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis
  3229. * @param angle defines the angle (in radians) to use
  3230. * @return the new matrix
  3231. */
  3232. static RotationY(angle: number): Matrix;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3235. * @param angle defines the angle (in radians) to use
  3236. * @param result defines the target matrix
  3237. */
  3238. static RotationYToRef(angle: number, result: Matrix): void;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis
  3241. * @param angle defines the angle (in radians) to use
  3242. * @return the new matrix
  3243. */
  3244. static RotationZ(angle: number): Matrix;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3247. * @param angle defines the angle (in radians) to use
  3248. * @param result defines the target matrix
  3249. */
  3250. static RotationZToRef(angle: number, result: Matrix): void;
  3251. /**
  3252. * Creates a new rotation matrix for "angle" radians around the given axis
  3253. * @param axis defines the axis to use
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3260. * @param axis defines the axis to use
  3261. * @param angle defines the angle (in radians) to use
  3262. * @param result defines the target matrix
  3263. */
  3264. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3265. /**
  3266. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3267. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3268. * @param from defines the vector to align
  3269. * @param to defines the vector to align to
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3273. /**
  3274. * Creates a rotation matrix
  3275. * @param yaw defines the yaw angle in radians (Y axis)
  3276. * @param pitch defines the pitch angle in radians (X axis)
  3277. * @param roll defines the roll angle in radians (X axis)
  3278. * @returns the new rotation matrix
  3279. */
  3280. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3281. /**
  3282. * Creates a rotation matrix and stores it in a given matrix
  3283. * @param yaw defines the yaw angle in radians (Y axis)
  3284. * @param pitch defines the pitch angle in radians (X axis)
  3285. * @param roll defines the roll angle in radians (X axis)
  3286. * @param result defines the target matrix
  3287. */
  3288. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3289. /**
  3290. * Creates a scaling matrix
  3291. * @param x defines the scale factor on X axis
  3292. * @param y defines the scale factor on Y axis
  3293. * @param z defines the scale factor on Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Scaling(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a scaling matrix and stores it in a given matrix
  3299. * @param x defines the scale factor on X axis
  3300. * @param y defines the scale factor on Y axis
  3301. * @param z defines the scale factor on Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Creates a translation matrix
  3307. * @param x defines the translation on X axis
  3308. * @param y defines the translation on Y axis
  3309. * @param z defines the translationon Z axis
  3310. * @returns the new matrix
  3311. */
  3312. static Translation(x: number, y: number, z: number): Matrix;
  3313. /**
  3314. * Creates a translation matrix and stores it in a given matrix
  3315. * @param x defines the translation on X axis
  3316. * @param y defines the translation on Y axis
  3317. * @param z defines the translationon Z axis
  3318. * @param result defines the target matrix
  3319. */
  3320. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3321. /**
  3322. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3323. * @param startValue defines the start value
  3324. * @param endValue defines the end value
  3325. * @param gradient defines the gradient factor
  3326. * @returns the new matrix
  3327. */
  3328. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3329. /**
  3330. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3331. * @param startValue defines the start value
  3332. * @param endValue defines the end value
  3333. * @param gradient defines the gradient factor
  3334. * @param result defines the Matrix object where to store data
  3335. */
  3336. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3337. /**
  3338. * Builds a new matrix whose values are computed by:
  3339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3342. * @param startValue defines the first matrix
  3343. * @param endValue defines the second matrix
  3344. * @param gradient defines the gradient between the two matrices
  3345. * @returns the new matrix
  3346. */
  3347. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3348. /**
  3349. * Update a matrix to values which are computed by:
  3350. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3351. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3352. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3353. * @param startValue defines the first matrix
  3354. * @param endValue defines the second matrix
  3355. * @param gradient defines the gradient between the two matrices
  3356. * @param result defines the target matrix
  3357. */
  3358. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3359. /**
  3360. * 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"
  3361. * This function works in left handed mode
  3362. * @param eye defines the final position of the entity
  3363. * @param target defines where the entity should look at
  3364. * @param up defines the up vector for the entity
  3365. * @returns the new matrix
  3366. */
  3367. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3368. /**
  3369. * 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".
  3370. * This function works in left handed mode
  3371. * @param eye defines the final position of the entity
  3372. * @param target defines where the entity should look at
  3373. * @param up defines the up vector for the entity
  3374. * @param result defines the target matrix
  3375. */
  3376. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3377. /**
  3378. * 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"
  3379. * This function works in right handed mode
  3380. * @param eye defines the final position of the entity
  3381. * @param target defines where the entity should look at
  3382. * @param up defines the up vector for the entity
  3383. * @returns the new matrix
  3384. */
  3385. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3386. /**
  3387. * 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".
  3388. * This function works in right handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @param result defines the target matrix
  3393. */
  3394. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3395. /**
  3396. * Create a left-handed orthographic projection matrix
  3397. * @param width defines the viewport width
  3398. * @param height defines the viewport height
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @returns a new matrix as a left-handed orthographic projection matrix
  3402. */
  3403. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3404. /**
  3405. * Store a left-handed orthographic projection to a given matrix
  3406. * @param width defines the viewport width
  3407. * @param height defines the viewport height
  3408. * @param znear defines the near clip plane
  3409. * @param zfar defines the far clip plane
  3410. * @param result defines the target matrix
  3411. */
  3412. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3413. /**
  3414. * Create a left-handed orthographic projection matrix
  3415. * @param left defines the viewport left coordinate
  3416. * @param right defines the viewport right coordinate
  3417. * @param bottom defines the viewport bottom coordinate
  3418. * @param top defines the viewport top coordinate
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a left-handed orthographic projection matrix
  3422. */
  3423. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Stores a left-handed orthographic projection into a given matrix
  3426. * @param left defines the viewport left coordinate
  3427. * @param right defines the viewport right coordinate
  3428. * @param bottom defines the viewport bottom coordinate
  3429. * @param top defines the viewport top coordinate
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @param result defines the target matrix
  3433. */
  3434. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3435. /**
  3436. * Creates a right-handed orthographic projection matrix
  3437. * @param left defines the viewport left coordinate
  3438. * @param right defines the viewport right coordinate
  3439. * @param bottom defines the viewport bottom coordinate
  3440. * @param top defines the viewport top coordinate
  3441. * @param znear defines the near clip plane
  3442. * @param zfar defines the far clip plane
  3443. * @returns a new matrix as a right-handed orthographic projection matrix
  3444. */
  3445. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3446. /**
  3447. * Stores a right-handed orthographic projection into a given matrix
  3448. * @param left defines the viewport left coordinate
  3449. * @param right defines the viewport right coordinate
  3450. * @param bottom defines the viewport bottom coordinate
  3451. * @param top defines the viewport top coordinate
  3452. * @param znear defines the near clip plane
  3453. * @param zfar defines the far clip plane
  3454. * @param result defines the target matrix
  3455. */
  3456. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3457. /**
  3458. * Creates a left-handed perspective projection matrix
  3459. * @param width defines the viewport width
  3460. * @param height defines the viewport height
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @returns a new matrix as a left-handed perspective projection matrix
  3464. */
  3465. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3466. /**
  3467. * Creates a left-handed perspective projection matrix
  3468. * @param fov defines the horizontal field of view
  3469. * @param aspect defines the aspect ratio
  3470. * @param znear defines the near clip plane
  3471. * @param zfar defines the far clip plane
  3472. * @returns a new matrix as a left-handed perspective projection matrix
  3473. */
  3474. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3475. /**
  3476. * Stores a left-handed perspective projection into a given matrix
  3477. * @param fov defines the horizontal field of view
  3478. * @param aspect defines the aspect ratio
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3483. */
  3484. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3485. /**
  3486. * Creates a right-handed perspective projection matrix
  3487. * @param fov defines the horizontal field of view
  3488. * @param aspect defines the aspect ratio
  3489. * @param znear defines the near clip plane
  3490. * @param zfar defines the far clip plane
  3491. * @returns a new matrix as a right-handed perspective projection matrix
  3492. */
  3493. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3494. /**
  3495. * Stores a right-handed perspective projection into a given matrix
  3496. * @param fov defines the horizontal field of view
  3497. * @param aspect defines the aspect ratio
  3498. * @param znear defines the near clip plane
  3499. * @param zfar defines the far clip plane
  3500. * @param result defines the target matrix
  3501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3502. */
  3503. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3504. /**
  3505. * Stores a perspective projection for WebVR info a given matrix
  3506. * @param fov defines the field of view
  3507. * @param znear defines the near clip plane
  3508. * @param zfar defines the far clip plane
  3509. * @param result defines the target matrix
  3510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3511. */
  3512. static PerspectiveFovWebVRToRef(fov: {
  3513. upDegrees: number;
  3514. downDegrees: number;
  3515. leftDegrees: number;
  3516. rightDegrees: number;
  3517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3518. /**
  3519. * Computes a complete transformation matrix
  3520. * @param viewport defines the viewport to use
  3521. * @param world defines the world matrix
  3522. * @param view defines the view matrix
  3523. * @param projection defines the projection matrix
  3524. * @param zmin defines the near clip plane
  3525. * @param zmax defines the far clip plane
  3526. * @returns the transformation matrix
  3527. */
  3528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3529. /**
  3530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3531. * @param matrix defines the matrix to use
  3532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3533. */
  3534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3535. /**
  3536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3537. * @param matrix defines the matrix to use
  3538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3539. */
  3540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3541. /**
  3542. * Compute the transpose of a given matrix
  3543. * @param matrix defines the matrix to transpose
  3544. * @returns the new matrix
  3545. */
  3546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3547. /**
  3548. * Compute the transpose of a matrix and store it in a target matrix
  3549. * @param matrix defines the matrix to transpose
  3550. * @param result defines the target matrix
  3551. */
  3552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3553. /**
  3554. * Computes a reflection matrix from a plane
  3555. * @param plane defines the reflection plane
  3556. * @returns a new matrix
  3557. */
  3558. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3559. /**
  3560. * Computes a reflection matrix from a plane
  3561. * @param plane defines the reflection plane
  3562. * @param result defines the target matrix
  3563. */
  3564. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3565. /**
  3566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3567. * @param xaxis defines the value of the 1st axis
  3568. * @param yaxis defines the value of the 2nd axis
  3569. * @param zaxis defines the value of the 3rd axis
  3570. * @param result defines the target matrix
  3571. */
  3572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3573. /**
  3574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3575. * @param quat defines the quaternion to use
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3579. }
  3580. /**
  3581. * Represens a plane by the equation ax + by + cz + d = 0
  3582. */
  3583. export class Plane {
  3584. /**
  3585. * Normal of the plane (a,b,c)
  3586. */
  3587. normal: Vector3;
  3588. /**
  3589. * d component of the plane
  3590. */
  3591. d: number;
  3592. /**
  3593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3594. * @param a a component of the plane
  3595. * @param b b component of the plane
  3596. * @param c c component of the plane
  3597. * @param d d component of the plane
  3598. */
  3599. constructor(a: number, b: number, c: number, d: number);
  3600. /**
  3601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3602. */
  3603. asArray(): number[];
  3604. /**
  3605. * @returns a new plane copied from the current Plane.
  3606. */
  3607. clone(): Plane;
  3608. /**
  3609. * @returns the string "Plane".
  3610. */
  3611. getClassName(): string;
  3612. /**
  3613. * @returns the Plane hash code.
  3614. */
  3615. getHashCode(): number;
  3616. /**
  3617. * Normalize the current Plane in place.
  3618. * @returns the updated Plane.
  3619. */
  3620. normalize(): Plane;
  3621. /**
  3622. * Applies a transformation the plane and returns the result
  3623. * @param transformation the transformation matrix to be applied to the plane
  3624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3625. */
  3626. transform(transformation: DeepImmutable<Matrix>): Plane;
  3627. /**
  3628. * Calcualtte the dot product between the point and the plane normal
  3629. * @param point point to calculate the dot product with
  3630. * @returns the dot product (float) of the point coordinates and the plane normal.
  3631. */
  3632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3633. /**
  3634. * Updates the current Plane from the plane defined by the three given points.
  3635. * @param point1 one of the points used to contruct the plane
  3636. * @param point2 one of the points used to contruct the plane
  3637. * @param point3 one of the points used to contruct the plane
  3638. * @returns the updated Plane.
  3639. */
  3640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3641. /**
  3642. * Checks if the plane is facing a given direction
  3643. * @param direction the direction to check if the plane is facing
  3644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3645. * @returns True is the vector "direction" is the same side than the plane normal.
  3646. */
  3647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3648. /**
  3649. * Calculates the distance to a point
  3650. * @param point point to calculate distance to
  3651. * @returns the signed distance (float) from the given point to the Plane.
  3652. */
  3653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3654. /**
  3655. * Creates a plane from an array
  3656. * @param array the array to create a plane from
  3657. * @returns a new Plane from the given array.
  3658. */
  3659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3660. /**
  3661. * Creates a plane from three points
  3662. * @param point1 point used to create the plane
  3663. * @param point2 point used to create the plane
  3664. * @param point3 point used to create the plane
  3665. * @returns a new Plane defined by the three given points.
  3666. */
  3667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Creates a plane from an origin point and a normal
  3670. * @param origin origin of the plane to be constructed
  3671. * @param normal normal of the plane to be constructed
  3672. * @returns a new Plane the normal vector to this plane at the given origin point.
  3673. * Note : the vector "normal" is updated because normalized.
  3674. */
  3675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3676. /**
  3677. * Calculates the distance from a plane and a point
  3678. * @param origin origin of the plane to be constructed
  3679. * @param normal normal of the plane to be constructed
  3680. * @param point point to calculate distance to
  3681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3682. */
  3683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3684. }
  3685. /**
  3686. * Class used to represent a viewport on screen
  3687. */
  3688. export class Viewport {
  3689. /** viewport left coordinate */
  3690. x: number;
  3691. /** viewport top coordinate */
  3692. y: number;
  3693. /**viewport width */
  3694. width: number;
  3695. /** viewport height */
  3696. height: number;
  3697. /**
  3698. * Creates a Viewport object located at (x, y) and sized (width, height)
  3699. * @param x defines viewport left coordinate
  3700. * @param y defines viewport top coordinate
  3701. * @param width defines the viewport width
  3702. * @param height defines the viewport height
  3703. */
  3704. constructor(
  3705. /** viewport left coordinate */
  3706. x: number,
  3707. /** viewport top coordinate */
  3708. y: number,
  3709. /**viewport width */
  3710. width: number,
  3711. /** viewport height */
  3712. height: number);
  3713. /**
  3714. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3715. * @param renderWidth defines the rendering width
  3716. * @param renderHeight defines the rendering height
  3717. * @returns a new Viewport
  3718. */
  3719. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3720. /**
  3721. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3722. * @param renderWidth defines the rendering width
  3723. * @param renderHeight defines the rendering height
  3724. * @param ref defines the target viewport
  3725. * @returns the current viewport
  3726. */
  3727. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3728. /**
  3729. * Returns a new Viewport copied from the current one
  3730. * @returns a new Viewport
  3731. */
  3732. clone(): Viewport;
  3733. }
  3734. /**
  3735. * Reprasents a camera frustum
  3736. */
  3737. export class Frustum {
  3738. /**
  3739. * Gets the planes representing the frustum
  3740. * @param transform matrix to be applied to the returned planes
  3741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3742. */
  3743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3744. /**
  3745. * Gets the near frustum plane transformed by the transform matrix
  3746. * @param transform transformation matrix to be applied to the resulting frustum plane
  3747. * @param frustumPlane the resuling frustum plane
  3748. */
  3749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3750. /**
  3751. * Gets the far frustum plane transformed by the transform matrix
  3752. * @param transform transformation matrix to be applied to the resulting frustum plane
  3753. * @param frustumPlane the resuling frustum plane
  3754. */
  3755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3756. /**
  3757. * Gets the left frustum plane transformed by the transform matrix
  3758. * @param transform transformation matrix to be applied to the resulting frustum plane
  3759. * @param frustumPlane the resuling frustum plane
  3760. */
  3761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3762. /**
  3763. * Gets the right frustum plane transformed by the transform matrix
  3764. * @param transform transformation matrix to be applied to the resulting frustum plane
  3765. * @param frustumPlane the resuling frustum plane
  3766. */
  3767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3768. /**
  3769. * Gets the top frustum plane transformed by the transform matrix
  3770. * @param transform transformation matrix to be applied to the resulting frustum plane
  3771. * @param frustumPlane the resuling frustum plane
  3772. */
  3773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3774. /**
  3775. * Gets the bottom frustum plane transformed by the transform matrix
  3776. * @param transform transformation matrix to be applied to the resulting frustum plane
  3777. * @param frustumPlane the resuling frustum plane
  3778. */
  3779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3780. /**
  3781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3782. * @param transform transformation matrix to be applied to the resulting frustum planes
  3783. * @param frustumPlanes the resuling frustum planes
  3784. */
  3785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3786. }
  3787. /** Defines supported spaces */
  3788. export enum Space {
  3789. /** Local (object) space */
  3790. LOCAL = 0,
  3791. /** World space */
  3792. WORLD = 1,
  3793. /** Bone space */
  3794. BONE = 2
  3795. }
  3796. /** Defines the 3 main axes */
  3797. export class Axis {
  3798. /** X axis */
  3799. static X: Vector3;
  3800. /** Y axis */
  3801. static Y: Vector3;
  3802. /** Z axis */
  3803. static Z: Vector3;
  3804. }
  3805. /** Class used to represent a Bezier curve */
  3806. export class BezierCurve {
  3807. /**
  3808. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3809. * @param t defines the time
  3810. * @param x1 defines the left coordinate on X axis
  3811. * @param y1 defines the left coordinate on Y axis
  3812. * @param x2 defines the right coordinate on X axis
  3813. * @param y2 defines the right coordinate on Y axis
  3814. * @returns the interpolated value
  3815. */
  3816. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3817. }
  3818. /**
  3819. * Defines potential orientation for back face culling
  3820. */
  3821. export enum Orientation {
  3822. /**
  3823. * Clockwise
  3824. */
  3825. CW = 0,
  3826. /** Counter clockwise */
  3827. CCW = 1
  3828. }
  3829. /**
  3830. * Defines angle representation
  3831. */
  3832. export class Angle {
  3833. private _radians;
  3834. /**
  3835. * Creates an Angle object of "radians" radians (float).
  3836. * @param radians the angle in radians
  3837. */
  3838. constructor(radians: number);
  3839. /**
  3840. * Get value in degrees
  3841. * @returns the Angle value in degrees (float)
  3842. */
  3843. degrees(): number;
  3844. /**
  3845. * Get value in radians
  3846. * @returns the Angle value in radians (float)
  3847. */
  3848. radians(): number;
  3849. /**
  3850. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3851. * @param a defines first vector
  3852. * @param b defines second vector
  3853. * @returns a new Angle
  3854. */
  3855. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3856. /**
  3857. * Gets a new Angle object from the given float in radians
  3858. * @param radians defines the angle value in radians
  3859. * @returns a new Angle
  3860. */
  3861. static FromRadians(radians: number): Angle;
  3862. /**
  3863. * Gets a new Angle object from the given float in degrees
  3864. * @param degrees defines the angle value in degrees
  3865. * @returns a new Angle
  3866. */
  3867. static FromDegrees(degrees: number): Angle;
  3868. }
  3869. /**
  3870. * This represents an arc in a 2d space.
  3871. */
  3872. export class Arc2 {
  3873. /** Defines the start point of the arc */
  3874. startPoint: Vector2;
  3875. /** Defines the mid point of the arc */
  3876. midPoint: Vector2;
  3877. /** Defines the end point of the arc */
  3878. endPoint: Vector2;
  3879. /**
  3880. * Defines the center point of the arc.
  3881. */
  3882. centerPoint: Vector2;
  3883. /**
  3884. * Defines the radius of the arc.
  3885. */
  3886. radius: number;
  3887. /**
  3888. * Defines the angle of the arc (from mid point to end point).
  3889. */
  3890. angle: Angle;
  3891. /**
  3892. * Defines the start angle of the arc (from start point to middle point).
  3893. */
  3894. startAngle: Angle;
  3895. /**
  3896. * Defines the orientation of the arc (clock wise/counter clock wise).
  3897. */
  3898. orientation: Orientation;
  3899. /**
  3900. * Creates an Arc object from the three given points : start, middle and end.
  3901. * @param startPoint Defines the start point of the arc
  3902. * @param midPoint Defines the midlle point of the arc
  3903. * @param endPoint Defines the end point of the arc
  3904. */
  3905. constructor(
  3906. /** Defines the start point of the arc */
  3907. startPoint: Vector2,
  3908. /** Defines the mid point of the arc */
  3909. midPoint: Vector2,
  3910. /** Defines the end point of the arc */
  3911. endPoint: Vector2);
  3912. }
  3913. /**
  3914. * Represents a 2D path made up of multiple 2D points
  3915. */
  3916. export class Path2 {
  3917. private _points;
  3918. private _length;
  3919. /**
  3920. * If the path start and end point are the same
  3921. */
  3922. closed: boolean;
  3923. /**
  3924. * Creates a Path2 object from the starting 2D coordinates x and y.
  3925. * @param x the starting points x value
  3926. * @param y the starting points y value
  3927. */
  3928. constructor(x: number, y: number);
  3929. /**
  3930. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3931. * @param x the added points x value
  3932. * @param y the added points y value
  3933. * @returns the updated Path2.
  3934. */
  3935. addLineTo(x: number, y: number): Path2;
  3936. /**
  3937. * 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.
  3938. * @param midX middle point x value
  3939. * @param midY middle point y value
  3940. * @param endX end point x value
  3941. * @param endY end point y value
  3942. * @param numberOfSegments (default: 36)
  3943. * @returns the updated Path2.
  3944. */
  3945. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3946. /**
  3947. * Closes the Path2.
  3948. * @returns the Path2.
  3949. */
  3950. close(): Path2;
  3951. /**
  3952. * Gets the sum of the distance between each sequential point in the path
  3953. * @returns the Path2 total length (float).
  3954. */
  3955. length(): number;
  3956. /**
  3957. * Gets the points which construct the path
  3958. * @returns the Path2 internal array of points.
  3959. */
  3960. getPoints(): Vector2[];
  3961. /**
  3962. * Retreives the point at the distance aways from the starting point
  3963. * @param normalizedLengthPosition the length along the path to retreive the point from
  3964. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3965. */
  3966. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3967. /**
  3968. * Creates a new path starting from an x and y position
  3969. * @param x starting x value
  3970. * @param y starting y value
  3971. * @returns a new Path2 starting at the coordinates (x, y).
  3972. */
  3973. static StartingAt(x: number, y: number): Path2;
  3974. }
  3975. /**
  3976. * Represents a 3D path made up of multiple 3D points
  3977. */
  3978. export class Path3D {
  3979. /**
  3980. * an array of Vector3, the curve axis of the Path3D
  3981. */
  3982. path: Vector3[];
  3983. private _curve;
  3984. private _distances;
  3985. private _tangents;
  3986. private _normals;
  3987. private _binormals;
  3988. private _raw;
  3989. /**
  3990. * new Path3D(path, normal, raw)
  3991. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3992. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3993. * @param path an array of Vector3, the curve axis of the Path3D
  3994. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3995. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3996. */
  3997. constructor(
  3998. /**
  3999. * an array of Vector3, the curve axis of the Path3D
  4000. */
  4001. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4002. /**
  4003. * Returns the Path3D array of successive Vector3 designing its curve.
  4004. * @returns the Path3D array of successive Vector3 designing its curve.
  4005. */
  4006. getCurve(): Vector3[];
  4007. /**
  4008. * Returns an array populated with tangent vectors on each Path3D curve point.
  4009. * @returns an array populated with tangent vectors on each Path3D curve point.
  4010. */
  4011. getTangents(): Vector3[];
  4012. /**
  4013. * Returns an array populated with normal vectors on each Path3D curve point.
  4014. * @returns an array populated with normal vectors on each Path3D curve point.
  4015. */
  4016. getNormals(): Vector3[];
  4017. /**
  4018. * Returns an array populated with binormal vectors on each Path3D curve point.
  4019. * @returns an array populated with binormal vectors on each Path3D curve point.
  4020. */
  4021. getBinormals(): Vector3[];
  4022. /**
  4023. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4024. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4025. */
  4026. getDistances(): number[];
  4027. /**
  4028. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4029. * @param path path which all values are copied into the curves points
  4030. * @param firstNormal which should be projected onto the curve
  4031. * @returns the same object updated.
  4032. */
  4033. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4034. private _compute;
  4035. private _getFirstNonNullVector;
  4036. private _getLastNonNullVector;
  4037. private _normalVector;
  4038. }
  4039. /**
  4040. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4041. * A Curve3 is designed from a series of successive Vector3.
  4042. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4043. */
  4044. export class Curve3 {
  4045. private _points;
  4046. private _length;
  4047. /**
  4048. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4049. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4050. * @param v1 (Vector3) the control point
  4051. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4052. * @param nbPoints (integer) the wanted number of points in the curve
  4053. * @returns the created Curve3
  4054. */
  4055. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4056. /**
  4057. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4058. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4059. * @param v1 (Vector3) the first control point
  4060. * @param v2 (Vector3) the second control point
  4061. * @param v3 (Vector3) the end point of the Cubic Bezier
  4062. * @param nbPoints (integer) the wanted number of points in the curve
  4063. * @returns the created Curve3
  4064. */
  4065. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4066. /**
  4067. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4068. * @param p1 (Vector3) the origin point of the Hermite Spline
  4069. * @param t1 (Vector3) the tangent vector at the origin point
  4070. * @param p2 (Vector3) the end point of the Hermite Spline
  4071. * @param t2 (Vector3) the tangent vector at the end point
  4072. * @param nbPoints (integer) the wanted number of points in the curve
  4073. * @returns the created Curve3
  4074. */
  4075. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4076. /**
  4077. * Returns a Curve3 object along a CatmullRom Spline curve :
  4078. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4079. * @param nbPoints (integer) the wanted number of points between each curve control points
  4080. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4081. * @returns the created Curve3
  4082. */
  4083. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4084. /**
  4085. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4086. * A Curve3 is designed from a series of successive Vector3.
  4087. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4088. * @param points points which make up the curve
  4089. */
  4090. constructor(points: Vector3[]);
  4091. /**
  4092. * @returns the Curve3 stored array of successive Vector3
  4093. */
  4094. getPoints(): Vector3[];
  4095. /**
  4096. * @returns the computed length (float) of the curve.
  4097. */
  4098. length(): number;
  4099. /**
  4100. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4101. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4102. * curveA and curveB keep unchanged.
  4103. * @param curve the curve to continue from this curve
  4104. * @returns the newly constructed curve
  4105. */
  4106. continue(curve: DeepImmutable<Curve3>): Curve3;
  4107. private _computeLength;
  4108. }
  4109. /**
  4110. * Contains position and normal vectors for a vertex
  4111. */
  4112. export class PositionNormalVertex {
  4113. /** the position of the vertex (defaut: 0,0,0) */
  4114. position: Vector3;
  4115. /** the normal of the vertex (defaut: 0,1,0) */
  4116. normal: Vector3;
  4117. /**
  4118. * Creates a PositionNormalVertex
  4119. * @param position the position of the vertex (defaut: 0,0,0)
  4120. * @param normal the normal of the vertex (defaut: 0,1,0)
  4121. */
  4122. constructor(
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position?: Vector3,
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal?: Vector3);
  4127. /**
  4128. * Clones the PositionNormalVertex
  4129. * @returns the cloned PositionNormalVertex
  4130. */
  4131. clone(): PositionNormalVertex;
  4132. }
  4133. /**
  4134. * Contains position, normal and uv vectors for a vertex
  4135. */
  4136. export class PositionNormalTextureVertex {
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position: Vector3;
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal: Vector3;
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv: Vector2;
  4143. /**
  4144. * Creates a PositionNormalTextureVertex
  4145. * @param position the position of the vertex (defaut: 0,0,0)
  4146. * @param normal the normal of the vertex (defaut: 0,1,0)
  4147. * @param uv the uv of the vertex (default: 0,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3,
  4154. /** the uv of the vertex (default: 0,0) */
  4155. uv?: Vector2);
  4156. /**
  4157. * Clones the PositionNormalTextureVertex
  4158. * @returns the cloned PositionNormalTextureVertex
  4159. */
  4160. clone(): PositionNormalTextureVertex;
  4161. }
  4162. /**
  4163. * @hidden
  4164. */
  4165. export class Tmp {
  4166. static Color3: Color3[];
  4167. static Color4: Color4[];
  4168. static Vector2: Vector2[];
  4169. static Vector3: Vector3[];
  4170. static Vector4: Vector4[];
  4171. static Quaternion: Quaternion[];
  4172. static Matrix: Matrix[];
  4173. }
  4174. }
  4175. declare module BABYLON {
  4176. /**
  4177. * Class used to enable access to offline support
  4178. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4179. */
  4180. export interface IOfflineProvider {
  4181. /**
  4182. * Gets a boolean indicating if scene must be saved in the database
  4183. */
  4184. enableSceneOffline: boolean;
  4185. /**
  4186. * Gets a boolean indicating if textures must be saved in the database
  4187. */
  4188. enableTexturesOffline: boolean;
  4189. /**
  4190. * Open the offline support and make it available
  4191. * @param successCallback defines the callback to call on success
  4192. * @param errorCallback defines the callback to call on error
  4193. */
  4194. open(successCallback: () => void, errorCallback: () => void): void;
  4195. /**
  4196. * Loads an image from the offline support
  4197. * @param url defines the url to load from
  4198. * @param image defines the target DOM image
  4199. */
  4200. loadImage(url: string, image: HTMLImageElement): void;
  4201. /**
  4202. * Loads a file from offline support
  4203. * @param url defines the URL to load from
  4204. * @param sceneLoaded defines a callback to call on success
  4205. * @param progressCallBack defines a callback to call when progress changed
  4206. * @param errorCallback defines a callback to call on error
  4207. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4208. */
  4209. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4210. }
  4211. }
  4212. declare module BABYLON {
  4213. /**
  4214. * A class serves as a medium between the observable and its observers
  4215. */
  4216. export class EventState {
  4217. /**
  4218. * Create a new EventState
  4219. * @param mask defines the mask associated with this state
  4220. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4221. * @param target defines the original target of the state
  4222. * @param currentTarget defines the current target of the state
  4223. */
  4224. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4225. /**
  4226. * Initialize the current event state
  4227. * @param mask defines the mask associated with this state
  4228. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4229. * @param target defines the original target of the state
  4230. * @param currentTarget defines the current target of the state
  4231. * @returns the current event state
  4232. */
  4233. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4234. /**
  4235. * An Observer can set this property to true to prevent subsequent observers of being notified
  4236. */
  4237. skipNextObservers: boolean;
  4238. /**
  4239. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4240. */
  4241. mask: number;
  4242. /**
  4243. * The object that originally notified the event
  4244. */
  4245. target?: any;
  4246. /**
  4247. * The current object in the bubbling phase
  4248. */
  4249. currentTarget?: any;
  4250. /**
  4251. * This will be populated with the return value of the last function that was executed.
  4252. * If it is the first function in the callback chain it will be the event data.
  4253. */
  4254. lastReturnValue?: any;
  4255. }
  4256. /**
  4257. * Represent an Observer registered to a given Observable object.
  4258. */
  4259. export class Observer<T> {
  4260. /**
  4261. * Defines the callback to call when the observer is notified
  4262. */
  4263. callback: (eventData: T, eventState: EventState) => void;
  4264. /**
  4265. * Defines the mask of the observer (used to filter notifications)
  4266. */
  4267. mask: number;
  4268. /**
  4269. * Defines the current scope used to restore the JS context
  4270. */
  4271. scope: any;
  4272. /** @hidden */ willBeUnregistered: boolean;
  4273. /**
  4274. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4275. */
  4276. unregisterOnNextCall: boolean;
  4277. /**
  4278. * Creates a new observer
  4279. * @param callback defines the callback to call when the observer is notified
  4280. * @param mask defines the mask of the observer (used to filter notifications)
  4281. * @param scope defines the current scope used to restore the JS context
  4282. */
  4283. constructor(
  4284. /**
  4285. * Defines the callback to call when the observer is notified
  4286. */
  4287. callback: (eventData: T, eventState: EventState) => void,
  4288. /**
  4289. * Defines the mask of the observer (used to filter notifications)
  4290. */
  4291. mask: number,
  4292. /**
  4293. * Defines the current scope used to restore the JS context
  4294. */
  4295. scope?: any);
  4296. }
  4297. /**
  4298. * Represent a list of observers registered to multiple Observables object.
  4299. */
  4300. export class MultiObserver<T> {
  4301. private _observers;
  4302. private _observables;
  4303. /**
  4304. * Release associated resources
  4305. */
  4306. dispose(): void;
  4307. /**
  4308. * Raise a callback when one of the observable will notify
  4309. * @param observables defines a list of observables to watch
  4310. * @param callback defines the callback to call on notification
  4311. * @param mask defines the mask used to filter notifications
  4312. * @param scope defines the current scope used to restore the JS context
  4313. * @returns the new MultiObserver
  4314. */
  4315. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4316. }
  4317. /**
  4318. * The Observable class is a simple implementation of the Observable pattern.
  4319. *
  4320. * 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.
  4321. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4322. * 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).
  4323. * 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.
  4324. */
  4325. export class Observable<T> {
  4326. private _observers;
  4327. private _eventState;
  4328. private _onObserverAdded;
  4329. /**
  4330. * Creates a new observable
  4331. * @param onObserverAdded defines a callback to call when a new observer is added
  4332. */
  4333. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4334. /**
  4335. * Create a new Observer with the specified callback
  4336. * @param callback the callback that will be executed for that Observer
  4337. * @param mask the mask used to filter observers
  4338. * @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.
  4339. * @param scope optional scope for the callback to be called from
  4340. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4341. * @returns the new observer created for the callback
  4342. */
  4343. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4344. /**
  4345. * Create a new Observer with the specified callback and unregisters after the next notification
  4346. * @param callback the callback that will be executed for that Observer
  4347. * @returns the new observer created for the callback
  4348. */
  4349. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4350. /**
  4351. * Remove an Observer from the Observable object
  4352. * @param observer the instance of the Observer to remove
  4353. * @returns false if it doesn't belong to this Observable
  4354. */
  4355. remove(observer: Nullable<Observer<T>>): boolean;
  4356. /**
  4357. * Remove a callback from the Observable object
  4358. * @param callback the callback to remove
  4359. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4360. * @returns false if it doesn't belong to this Observable
  4361. */
  4362. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4363. private _deferUnregister;
  4364. private _remove;
  4365. /**
  4366. * Moves the observable to the top of the observer list making it get called first when notified
  4367. * @param observer the observer to move
  4368. */
  4369. makeObserverTopPriority(observer: Observer<T>): void;
  4370. /**
  4371. * Moves the observable to the bottom of the observer list making it get called last when notified
  4372. * @param observer the observer to move
  4373. */
  4374. makeObserverBottomPriority(observer: Observer<T>): void;
  4375. /**
  4376. * Notify all Observers by calling their respective callback with the given data
  4377. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4378. * @param eventData defines the data to send to all observers
  4379. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4380. * @param target defines the original target of the state
  4381. * @param currentTarget defines the current target of the state
  4382. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4383. */
  4384. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4385. /**
  4386. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4387. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4388. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4389. * and it is crucial that all callbacks will be executed.
  4390. * The order of the callbacks is kept, callbacks are not executed parallel.
  4391. *
  4392. * @param eventData The data to be sent to each callback
  4393. * @param mask is used to filter observers defaults to -1
  4394. * @param target defines the callback target (see EventState)
  4395. * @param currentTarget defines he current object in the bubbling phase
  4396. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4397. */
  4398. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4399. /**
  4400. * Notify a specific observer
  4401. * @param observer defines the observer to notify
  4402. * @param eventData defines the data to be sent to each callback
  4403. * @param mask is used to filter observers defaults to -1
  4404. */
  4405. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4406. /**
  4407. * Gets a boolean indicating if the observable has at least one observer
  4408. * @returns true is the Observable has at least one Observer registered
  4409. */
  4410. hasObservers(): boolean;
  4411. /**
  4412. * Clear the list of observers
  4413. */
  4414. clear(): void;
  4415. /**
  4416. * Clone the current observable
  4417. * @returns a new observable
  4418. */
  4419. clone(): Observable<T>;
  4420. /**
  4421. * Does this observable handles observer registered with a given mask
  4422. * @param mask defines the mask to be tested
  4423. * @return whether or not one observer registered with the given mask is handeled
  4424. **/
  4425. hasSpecificMask(mask?: number): boolean;
  4426. }
  4427. }
  4428. declare module BABYLON {
  4429. /**
  4430. * Class used to help managing file picking and drag'n'drop
  4431. * File Storage
  4432. */
  4433. export class FilesInputStore {
  4434. /**
  4435. * List of files ready to be loaded
  4436. */
  4437. static FilesToLoad: {
  4438. [key: string]: File;
  4439. };
  4440. }
  4441. }
  4442. declare module BABYLON {
  4443. /** Defines the cross module used constants to avoid circular dependncies */
  4444. export class Constants {
  4445. /** Defines that alpha blending is disabled */
  4446. static readonly ALPHA_DISABLE: number;
  4447. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4448. static readonly ALPHA_ADD: number;
  4449. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4450. static readonly ALPHA_COMBINE: number;
  4451. /** Defines that alpha blending to DEST - SRC * DEST */
  4452. static readonly ALPHA_SUBTRACT: number;
  4453. /** Defines that alpha blending to SRC * DEST */
  4454. static readonly ALPHA_MULTIPLY: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4456. static readonly ALPHA_MAXIMIZED: number;
  4457. /** Defines that alpha blending to SRC + DEST */
  4458. static readonly ALPHA_ONEONE: number;
  4459. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4460. static readonly ALPHA_PREMULTIPLIED: number;
  4461. /**
  4462. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4463. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4464. */
  4465. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4466. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4467. static readonly ALPHA_INTERPOLATE: number;
  4468. /**
  4469. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4470. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4471. */
  4472. static readonly ALPHA_SCREENMODE: number;
  4473. /** Defines that the ressource is not delayed*/
  4474. static readonly DELAYLOADSTATE_NONE: number;
  4475. /** Defines that the ressource was successfully delay loaded */
  4476. static readonly DELAYLOADSTATE_LOADED: number;
  4477. /** Defines that the ressource is currently delay loading */
  4478. static readonly DELAYLOADSTATE_LOADING: number;
  4479. /** Defines that the ressource is delayed and has not started loading */
  4480. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4482. static readonly NEVER: number;
  4483. /** 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 */
  4484. static readonly ALWAYS: number;
  4485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4486. static readonly LESS: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4488. static readonly EQUAL: number;
  4489. /** 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 */
  4490. static readonly LEQUAL: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4492. static readonly GREATER: number;
  4493. /** 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 */
  4494. static readonly GEQUAL: number;
  4495. /** 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 */
  4496. static readonly NOTEQUAL: number;
  4497. /** Passed to stencilOperation to specify that stencil value must be kept */
  4498. static readonly KEEP: number;
  4499. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4500. static readonly REPLACE: number;
  4501. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4502. static readonly INCR: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4504. static readonly DECR: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4506. static readonly INVERT: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4508. static readonly INCR_WRAP: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4510. static readonly DECR_WRAP: number;
  4511. /** Texture is not repeating outside of 0..1 UVs */
  4512. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4513. /** Texture is repeating outside of 0..1 UVs */
  4514. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4515. /** Texture is repeating and mirrored */
  4516. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4517. /** ALPHA */
  4518. static readonly TEXTUREFORMAT_ALPHA: number;
  4519. /** LUMINANCE */
  4520. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4521. /** LUMINANCE_ALPHA */
  4522. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4523. /** RGB */
  4524. static readonly TEXTUREFORMAT_RGB: number;
  4525. /** RGBA */
  4526. static readonly TEXTUREFORMAT_RGBA: number;
  4527. /** RED */
  4528. static readonly TEXTUREFORMAT_RED: number;
  4529. /** RED (2nd reference) */
  4530. static readonly TEXTUREFORMAT_R: number;
  4531. /** RG */
  4532. static readonly TEXTUREFORMAT_RG: number;
  4533. /** RED_INTEGER */
  4534. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4535. /** RED_INTEGER (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4537. /** RG_INTEGER */
  4538. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4539. /** RGB_INTEGER */
  4540. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4541. /** RGBA_INTEGER */
  4542. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4543. /** UNSIGNED_BYTE */
  4544. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4545. /** UNSIGNED_BYTE (2nd reference) */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4547. /** FLOAT */
  4548. static readonly TEXTURETYPE_FLOAT: number;
  4549. /** HALF_FLOAT */
  4550. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4551. /** BYTE */
  4552. static readonly TEXTURETYPE_BYTE: number;
  4553. /** SHORT */
  4554. static readonly TEXTURETYPE_SHORT: number;
  4555. /** UNSIGNED_SHORT */
  4556. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4557. /** INT */
  4558. static readonly TEXTURETYPE_INT: number;
  4559. /** UNSIGNED_INT */
  4560. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4561. /** UNSIGNED_SHORT_4_4_4_4 */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4563. /** UNSIGNED_SHORT_5_5_5_1 */
  4564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4565. /** UNSIGNED_SHORT_5_6_5 */
  4566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4567. /** UNSIGNED_INT_2_10_10_10_REV */
  4568. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4569. /** UNSIGNED_INT_24_8 */
  4570. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4571. /** UNSIGNED_INT_10F_11F_11F_REV */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4573. /** UNSIGNED_INT_5_9_9_9_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4575. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4576. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4577. /** nearest is mag = nearest and min = nearest and mip = linear */
  4578. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4580. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4581. /** Trilinear is mag = linear and min = linear and mip = linear */
  4582. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4589. /** mag = nearest and min = nearest and mip = nearest */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4591. /** mag = nearest and min = linear and mip = nearest */
  4592. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4593. /** mag = nearest and min = linear and mip = linear */
  4594. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = linear and mip = none */
  4596. static readonly TEXTURE_NEAREST_LINEAR: number;
  4597. /** mag = nearest and min = nearest and mip = none */
  4598. static readonly TEXTURE_NEAREST_NEAREST: number;
  4599. /** mag = linear and min = nearest and mip = nearest */
  4600. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4601. /** mag = linear and min = nearest and mip = linear */
  4602. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4603. /** mag = linear and min = linear and mip = none */
  4604. static readonly TEXTURE_LINEAR_LINEAR: number;
  4605. /** mag = linear and min = nearest and mip = none */
  4606. static readonly TEXTURE_LINEAR_NEAREST: number;
  4607. /** Explicit coordinates mode */
  4608. static readonly TEXTURE_EXPLICIT_MODE: number;
  4609. /** Spherical coordinates mode */
  4610. static readonly TEXTURE_SPHERICAL_MODE: number;
  4611. /** Planar coordinates mode */
  4612. static readonly TEXTURE_PLANAR_MODE: number;
  4613. /** Cubic coordinates mode */
  4614. static readonly TEXTURE_CUBIC_MODE: number;
  4615. /** Projection coordinates mode */
  4616. static readonly TEXTURE_PROJECTION_MODE: number;
  4617. /** Skybox coordinates mode */
  4618. static readonly TEXTURE_SKYBOX_MODE: number;
  4619. /** Inverse Cubic coordinates mode */
  4620. static readonly TEXTURE_INVCUBIC_MODE: number;
  4621. /** Equirectangular coordinates mode */
  4622. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4623. /** Equirectangular Fixed coordinates mode */
  4624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4625. /** Equirectangular Fixed Mirrored coordinates mode */
  4626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4627. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4628. static readonly SCALEMODE_FLOOR: number;
  4629. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4630. static readonly SCALEMODE_NEAREST: number;
  4631. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4632. static readonly SCALEMODE_CEILING: number;
  4633. /**
  4634. * The dirty texture flag value
  4635. */
  4636. static readonly MATERIAL_TextureDirtyFlag: number;
  4637. /**
  4638. * The dirty light flag value
  4639. */
  4640. static readonly MATERIAL_LightDirtyFlag: number;
  4641. /**
  4642. * The dirty fresnel flag value
  4643. */
  4644. static readonly MATERIAL_FresnelDirtyFlag: number;
  4645. /**
  4646. * The dirty attribute flag value
  4647. */
  4648. static readonly MATERIAL_AttributesDirtyFlag: number;
  4649. /**
  4650. * The dirty misc flag value
  4651. */
  4652. static readonly MATERIAL_MiscDirtyFlag: number;
  4653. /**
  4654. * The all dirty flag value
  4655. */
  4656. static readonly MATERIAL_AllDirtyFlag: number;
  4657. /**
  4658. * Returns the triangle fill mode
  4659. */
  4660. static readonly MATERIAL_TriangleFillMode: number;
  4661. /**
  4662. * Returns the wireframe mode
  4663. */
  4664. static readonly MATERIAL_WireFrameFillMode: number;
  4665. /**
  4666. * Returns the point fill mode
  4667. */
  4668. static readonly MATERIAL_PointFillMode: number;
  4669. /**
  4670. * Returns the point list draw mode
  4671. */
  4672. static readonly MATERIAL_PointListDrawMode: number;
  4673. /**
  4674. * Returns the line list draw mode
  4675. */
  4676. static readonly MATERIAL_LineListDrawMode: number;
  4677. /**
  4678. * Returns the line loop draw mode
  4679. */
  4680. static readonly MATERIAL_LineLoopDrawMode: number;
  4681. /**
  4682. * Returns the line strip draw mode
  4683. */
  4684. static readonly MATERIAL_LineStripDrawMode: number;
  4685. /**
  4686. * Returns the triangle strip draw mode
  4687. */
  4688. static readonly MATERIAL_TriangleStripDrawMode: number;
  4689. /**
  4690. * Returns the triangle fan draw mode
  4691. */
  4692. static readonly MATERIAL_TriangleFanDrawMode: number;
  4693. /**
  4694. * Stores the clock-wise side orientation
  4695. */
  4696. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4697. /**
  4698. * Stores the counter clock-wise side orientation
  4699. */
  4700. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4701. /**
  4702. * Nothing
  4703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4704. */
  4705. static readonly ACTION_NothingTrigger: number;
  4706. /**
  4707. * On pick
  4708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4709. */
  4710. static readonly ACTION_OnPickTrigger: number;
  4711. /**
  4712. * On left pick
  4713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4714. */
  4715. static readonly ACTION_OnLeftPickTrigger: number;
  4716. /**
  4717. * On right pick
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnRightPickTrigger: number;
  4721. /**
  4722. * On center pick
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnCenterPickTrigger: number;
  4726. /**
  4727. * On pick down
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickDownTrigger: number;
  4731. /**
  4732. * On double pick
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnDoublePickTrigger: number;
  4736. /**
  4737. * On pick up
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickUpTrigger: number;
  4741. /**
  4742. * On pick out.
  4743. * This trigger will only be raised if you also declared a OnPickDown
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickOutTrigger: number;
  4747. /**
  4748. * On long press
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnLongPressTrigger: number;
  4752. /**
  4753. * On pointer over
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPointerOverTrigger: number;
  4757. /**
  4758. * On pointer out
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnPointerOutTrigger: number;
  4762. /**
  4763. * On every frame
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnEveryFrameTrigger: number;
  4767. /**
  4768. * On intersection enter
  4769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4770. */
  4771. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4772. /**
  4773. * On intersection exit
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnIntersectionExitTrigger: number;
  4777. /**
  4778. * On key down
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnKeyDownTrigger: number;
  4782. /**
  4783. * On key up
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnKeyUpTrigger: number;
  4787. /**
  4788. * Billboard mode will only apply to Y axis
  4789. */
  4790. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4791. /**
  4792. * Billboard mode will apply to all axes
  4793. */
  4794. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4795. /**
  4796. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4797. */
  4798. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4799. /**
  4800. * Gets or sets base Assets URL
  4801. */
  4802. static readonly PARTICLES_BaseAssetsUrl: string;
  4803. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4804. * Test order :
  4805. * Is the bounding sphere outside the frustum ?
  4806. * If not, are the bounding box vertices outside the frustum ?
  4807. * It not, then the cullable object is in the frustum.
  4808. */
  4809. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4810. /** Culling strategy : Bounding Sphere Only.
  4811. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4812. * It's also less accurate than the standard because some not visible objects can still be selected.
  4813. * Test : is the bounding sphere outside the frustum ?
  4814. * If not, then the cullable object is in the frustum.
  4815. */
  4816. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4817. /** Culling strategy : Optimistic Inclusion.
  4818. * This in an inclusion test first, then the standard exclusion test.
  4819. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4820. * 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.
  4821. * Anyway, it's as accurate as the standard strategy.
  4822. * Test :
  4823. * Is the cullable object bounding sphere center in the frustum ?
  4824. * If not, apply the default culling strategy.
  4825. */
  4826. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4827. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4828. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4829. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4830. * 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.
  4831. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4832. * Test :
  4833. * Is the cullable object bounding sphere center in the frustum ?
  4834. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4837. /**
  4838. * No logging while loading
  4839. */
  4840. static readonly SCENELOADER_NO_LOGGING: number;
  4841. /**
  4842. * Minimal logging while loading
  4843. */
  4844. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4845. /**
  4846. * Summary logging while loading
  4847. */
  4848. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4849. /**
  4850. * Detailled logging while loading
  4851. */
  4852. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4853. }
  4854. }
  4855. declare module BABYLON {
  4856. /**
  4857. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4858. * Babylon.js
  4859. */
  4860. export class DomManagement {
  4861. /**
  4862. * Checks if the window object exists
  4863. * @returns true if the window object exists
  4864. */
  4865. static IsWindowObjectExist(): boolean;
  4866. /**
  4867. * Extracts text content from a DOM element hierarchy
  4868. * @param element defines the root element
  4869. * @returns a string
  4870. */
  4871. static GetDOMTextContent(element: HTMLElement): string;
  4872. }
  4873. }
  4874. declare module BABYLON {
  4875. /**
  4876. * Logger used througouht the application to allow configuration of
  4877. * the log level required for the messages.
  4878. */
  4879. export class Logger {
  4880. /**
  4881. * No log
  4882. */
  4883. static readonly NoneLogLevel: number;
  4884. /**
  4885. * Only message logs
  4886. */
  4887. static readonly MessageLogLevel: number;
  4888. /**
  4889. * Only warning logs
  4890. */
  4891. static readonly WarningLogLevel: number;
  4892. /**
  4893. * Only error logs
  4894. */
  4895. static readonly ErrorLogLevel: number;
  4896. /**
  4897. * All logs
  4898. */
  4899. static readonly AllLogLevel: number;
  4900. private static _LogCache;
  4901. /**
  4902. * Gets a value indicating the number of loading errors
  4903. * @ignorenaming
  4904. */
  4905. static errorsCount: number;
  4906. /**
  4907. * Callback called when a new log is added
  4908. */
  4909. static OnNewCacheEntry: (entry: string) => void;
  4910. private static _AddLogEntry;
  4911. private static _FormatMessage;
  4912. private static _LogDisabled;
  4913. private static _LogEnabled;
  4914. private static _WarnDisabled;
  4915. private static _WarnEnabled;
  4916. private static _ErrorDisabled;
  4917. private static _ErrorEnabled;
  4918. /**
  4919. * Log a message to the console
  4920. */
  4921. static Log: (message: string) => void;
  4922. /**
  4923. * Write a warning message to the console
  4924. */
  4925. static Warn: (message: string) => void;
  4926. /**
  4927. * Write an error message to the console
  4928. */
  4929. static Error: (message: string) => void;
  4930. /**
  4931. * Gets current log cache (list of logs)
  4932. */
  4933. static readonly LogCache: string;
  4934. /**
  4935. * Clears the log cache
  4936. */
  4937. static ClearLogCache(): void;
  4938. /**
  4939. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4940. */
  4941. static LogLevels: number;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /** @hidden */
  4946. export class _TypeStore {
  4947. /** @hidden */
  4948. static RegisteredTypes: {
  4949. [key: string]: Object;
  4950. };
  4951. /** @hidden */
  4952. static GetClass(fqdn: string): any;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /**
  4957. * Class containing a set of static utilities functions for deep copy.
  4958. */
  4959. export class DeepCopier {
  4960. /**
  4961. * Tries to copy an object by duplicating every property
  4962. * @param source defines the source object
  4963. * @param destination defines the target object
  4964. * @param doNotCopyList defines a list of properties to avoid
  4965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4966. */
  4967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /**
  4972. * Class containing a set of static utilities functions for precision date
  4973. */
  4974. export class PrecisionDate {
  4975. /**
  4976. * Gets either window.performance.now() if supported or Date.now() else
  4977. */
  4978. static readonly Now: number;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /** @hidden */
  4983. export class _DevTools {
  4984. static WarnImport(name: string): string;
  4985. }
  4986. }
  4987. declare module BABYLON {
  4988. /**
  4989. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4990. */
  4991. export class WebRequest {
  4992. private _xhr;
  4993. /**
  4994. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4995. * i.e. when loading files, where the server/service expects an Authorization header
  4996. */
  4997. static CustomRequestHeaders: {
  4998. [key: string]: string;
  4999. };
  5000. /**
  5001. * Add callback functions in this array to update all the requests before they get sent to the network
  5002. */
  5003. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5004. private _injectCustomRequestHeaders;
  5005. /**
  5006. * Gets or sets a function to be called when loading progress changes
  5007. */
  5008. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5009. /**
  5010. * Returns client's state
  5011. */
  5012. readonly readyState: number;
  5013. /**
  5014. * Returns client's status
  5015. */
  5016. readonly status: number;
  5017. /**
  5018. * Returns client's status as a text
  5019. */
  5020. readonly statusText: string;
  5021. /**
  5022. * Returns client's response
  5023. */
  5024. readonly response: any;
  5025. /**
  5026. * Returns client's response url
  5027. */
  5028. readonly responseURL: string;
  5029. /**
  5030. * Returns client's response as text
  5031. */
  5032. readonly responseText: string;
  5033. /**
  5034. * Gets or sets the expected response type
  5035. */
  5036. responseType: XMLHttpRequestResponseType;
  5037. /** @hidden */
  5038. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5039. /** @hidden */
  5040. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5041. /**
  5042. * Cancels any network activity
  5043. */
  5044. abort(): void;
  5045. /**
  5046. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5047. * @param body defines an optional request body
  5048. */
  5049. send(body?: Document | BodyInit | null): void;
  5050. /**
  5051. * Sets the request method, request URL
  5052. * @param method defines the method to use (GET, POST, etc..)
  5053. * @param url defines the url to connect with
  5054. */
  5055. open(method: string, url: string): void;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to evalaute queries containing `and` and `or` operators
  5061. */
  5062. export class AndOrNotEvaluator {
  5063. /**
  5064. * Evaluate a query
  5065. * @param query defines the query to evaluate
  5066. * @param evaluateCallback defines the callback used to filter result
  5067. * @returns true if the query matches
  5068. */
  5069. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5070. private static _HandleParenthesisContent;
  5071. private static _SimplifyNegation;
  5072. }
  5073. }
  5074. declare module BABYLON {
  5075. /**
  5076. * Class used to store custom tags
  5077. */
  5078. export class Tags {
  5079. /**
  5080. * Adds support for tags on the given object
  5081. * @param obj defines the object to use
  5082. */
  5083. static EnableFor(obj: any): void;
  5084. /**
  5085. * Removes tags support
  5086. * @param obj defines the object to use
  5087. */
  5088. static DisableFor(obj: any): void;
  5089. /**
  5090. * Gets a boolean indicating if the given object has tags
  5091. * @param obj defines the object to use
  5092. * @returns a boolean
  5093. */
  5094. static HasTags(obj: any): boolean;
  5095. /**
  5096. * Gets the tags available on a given object
  5097. * @param obj defines the object to use
  5098. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5099. * @returns the tags
  5100. */
  5101. static GetTags(obj: any, asString?: boolean): any;
  5102. /**
  5103. * Adds tags to an object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5106. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5107. */
  5108. static AddTagsTo(obj: any, tagsString: string): void;
  5109. /**
  5110. * @hidden
  5111. */ private static _AddTagTo(obj: any, tag: string): void;
  5112. /**
  5113. * Removes specific tags from a specific object
  5114. * @param obj defines the object to use
  5115. * @param tagsString defines the tags to remove
  5116. */
  5117. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5118. /**
  5119. * @hidden
  5120. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5121. /**
  5122. * Defines if tags hosted on an object match a given query
  5123. * @param obj defines the object to use
  5124. * @param tagsQuery defines the tag query
  5125. * @returns a boolean
  5126. */
  5127. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. /**
  5132. * Manages the defines for the Material
  5133. */
  5134. export class MaterialDefines {
  5135. private _keys;
  5136. private _isDirty;
  5137. /** @hidden */ renderId: number;
  5138. /** @hidden */ areLightsDirty: boolean;
  5139. /** @hidden */ areAttributesDirty: boolean;
  5140. /** @hidden */ areTexturesDirty: boolean;
  5141. /** @hidden */ areFresnelDirty: boolean;
  5142. /** @hidden */ areMiscDirty: boolean;
  5143. /** @hidden */ areImageProcessingDirty: boolean;
  5144. /** @hidden */ normals: boolean;
  5145. /** @hidden */ uvs: boolean;
  5146. /** @hidden */ needNormals: boolean;
  5147. /** @hidden */ needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Class used to store and describe the pipeline context associated with an effect
  5217. */
  5218. export interface IPipelineContext {
  5219. /**
  5220. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5221. */
  5222. isAsync: boolean;
  5223. /**
  5224. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5225. */
  5226. isReady: boolean;
  5227. /** @hidden */ handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store gfx data (like WebGLBuffer)
  5233. */
  5234. export class DataBuffer {
  5235. /**
  5236. * Gets or sets the number of objects referencing this buffer
  5237. */
  5238. references: number;
  5239. /** Gets or sets the size of the underlying buffer */
  5240. capacity: number;
  5241. /**
  5242. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5243. */
  5244. is32Bits: boolean;
  5245. /**
  5246. * Gets the underlying buffer
  5247. */
  5248. readonly underlyingResource: any;
  5249. }
  5250. }
  5251. declare module BABYLON {
  5252. /**
  5253. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5254. */
  5255. export class PerformanceMonitor {
  5256. private _enabled;
  5257. private _rollingFrameTime;
  5258. private _lastFrameTimeMs;
  5259. /**
  5260. * constructor
  5261. * @param frameSampleSize The number of samples required to saturate the sliding window
  5262. */
  5263. constructor(frameSampleSize?: number);
  5264. /**
  5265. * Samples current frame
  5266. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5267. */
  5268. sampleFrame(timeMs?: number): void;
  5269. /**
  5270. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5271. */
  5272. readonly averageFrameTime: number;
  5273. /**
  5274. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5275. */
  5276. readonly averageFrameTimeVariance: number;
  5277. /**
  5278. * Returns the frame time of the most recent frame
  5279. */
  5280. readonly instantaneousFrameTime: number;
  5281. /**
  5282. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5283. */
  5284. readonly averageFPS: number;
  5285. /**
  5286. * Returns the average framerate in frames per second using the most recent frame time
  5287. */
  5288. readonly instantaneousFPS: number;
  5289. /**
  5290. * Returns true if enough samples have been taken to completely fill the sliding window
  5291. */
  5292. readonly isSaturated: boolean;
  5293. /**
  5294. * Enables contributions to the sliding window sample set
  5295. */
  5296. enable(): void;
  5297. /**
  5298. * Disables contributions to the sliding window sample set
  5299. * Samples will not be interpolated over the disabled period
  5300. */
  5301. disable(): void;
  5302. /**
  5303. * Returns true if sampling is enabled
  5304. */
  5305. readonly isEnabled: boolean;
  5306. /**
  5307. * Resets performance monitor
  5308. */
  5309. reset(): void;
  5310. }
  5311. /**
  5312. * RollingAverage
  5313. *
  5314. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5315. */
  5316. export class RollingAverage {
  5317. /**
  5318. * Current average
  5319. */
  5320. average: number;
  5321. /**
  5322. * Current variance
  5323. */
  5324. variance: number;
  5325. protected _samples: Array<number>;
  5326. protected _sampleCount: number;
  5327. protected _pos: number;
  5328. protected _m2: number;
  5329. /**
  5330. * constructor
  5331. * @param length The number of samples required to saturate the sliding window
  5332. */
  5333. constructor(length: number);
  5334. /**
  5335. * Adds a sample to the sample set
  5336. * @param v The sample value
  5337. */
  5338. add(v: number): void;
  5339. /**
  5340. * Returns previously added values or null if outside of history or outside the sliding window domain
  5341. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5342. * @return Value previously recorded with add() or null if outside of range
  5343. */
  5344. history(i: number): number;
  5345. /**
  5346. * Returns true if enough samples have been taken to completely fill the sliding window
  5347. * @return true if sample-set saturated
  5348. */
  5349. isSaturated(): boolean;
  5350. /**
  5351. * Resets the rolling average (equivalent to 0 samples taken so far)
  5352. */
  5353. reset(): void;
  5354. /**
  5355. * Wraps a value around the sample range boundaries
  5356. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5357. * @return Wrapped position in sample range
  5358. */
  5359. protected _wrapPosition(i: number): number;
  5360. }
  5361. }
  5362. declare module BABYLON {
  5363. /**
  5364. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5365. * The underlying implementation relies on an associative array to ensure the best performances.
  5366. * The value can be anything including 'null' but except 'undefined'
  5367. */
  5368. export class StringDictionary<T> {
  5369. /**
  5370. * This will clear this dictionary and copy the content from the 'source' one.
  5371. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5372. * @param source the dictionary to take the content from and copy to this dictionary
  5373. */
  5374. copyFrom(source: StringDictionary<T>): void;
  5375. /**
  5376. * Get a value based from its key
  5377. * @param key the given key to get the matching value from
  5378. * @return the value if found, otherwise undefined is returned
  5379. */
  5380. get(key: string): T | undefined;
  5381. /**
  5382. * Get a value from its key or add it if it doesn't exist.
  5383. * This method will ensure you that a given key/data will be present in the dictionary.
  5384. * @param key the given key to get the matching value from
  5385. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5386. * The factory will only be invoked if there's no data for the given key.
  5387. * @return the value corresponding to the key.
  5388. */
  5389. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5390. /**
  5391. * Get a value from its key if present in the dictionary otherwise add it
  5392. * @param key the key to get the value from
  5393. * @param val if there's no such key/value pair in the dictionary add it with this value
  5394. * @return the value corresponding to the key
  5395. */
  5396. getOrAdd(key: string, val: T): T;
  5397. /**
  5398. * Check if there's a given key in the dictionary
  5399. * @param key the key to check for
  5400. * @return true if the key is present, false otherwise
  5401. */
  5402. contains(key: string): boolean;
  5403. /**
  5404. * Add a new key and its corresponding value
  5405. * @param key the key to add
  5406. * @param value the value corresponding to the key
  5407. * @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
  5408. */
  5409. add(key: string, value: T): boolean;
  5410. /**
  5411. * Update a specific value associated to a key
  5412. * @param key defines the key to use
  5413. * @param value defines the value to store
  5414. * @returns true if the value was updated (or false if the key was not found)
  5415. */
  5416. set(key: string, value: T): boolean;
  5417. /**
  5418. * Get the element of the given key and remove it from the dictionary
  5419. * @param key defines the key to search
  5420. * @returns the value associated with the key or null if not found
  5421. */
  5422. getAndRemove(key: string): Nullable<T>;
  5423. /**
  5424. * Remove a key/value from the dictionary.
  5425. * @param key the key to remove
  5426. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5427. */
  5428. remove(key: string): boolean;
  5429. /**
  5430. * Clear the whole content of the dictionary
  5431. */
  5432. clear(): void;
  5433. /**
  5434. * Gets the current count
  5435. */
  5436. readonly count: number;
  5437. /**
  5438. * Execute a callback on each key/val of the dictionary.
  5439. * Note that you can remove any element in this dictionary in the callback implementation
  5440. * @param callback the callback to execute on a given key/value pair
  5441. */
  5442. forEach(callback: (key: string, val: T) => void): void;
  5443. /**
  5444. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5445. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5446. * Note that you can remove any element in this dictionary in the callback implementation
  5447. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5448. * @returns the first item
  5449. */
  5450. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5451. private _count;
  5452. private _data;
  5453. }
  5454. }
  5455. declare module BABYLON {
  5456. /**
  5457. * Helper class that provides a small promise polyfill
  5458. */
  5459. export class PromisePolyfill {
  5460. /**
  5461. * Static function used to check if the polyfill is required
  5462. * If this is the case then the function will inject the polyfill to window.Promise
  5463. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5464. */
  5465. static Apply(force?: boolean): void;
  5466. }
  5467. }
  5468. declare module BABYLON {
  5469. /**
  5470. * Class used to store data that will be store in GPU memory
  5471. */
  5472. export class Buffer {
  5473. private _engine;
  5474. private _buffer;
  5475. /** @hidden */ data: Nullable<DataArray>;
  5476. private _updatable;
  5477. private _instanced;
  5478. /**
  5479. * Gets the byte stride.
  5480. */
  5481. readonly byteStride: number;
  5482. /**
  5483. * Constructor
  5484. * @param engine the engine
  5485. * @param data the data to use for this buffer
  5486. * @param updatable whether the data is updatable
  5487. * @param stride the stride (optional)
  5488. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5489. * @param instanced whether the buffer is instanced (optional)
  5490. * @param useBytes set to true if the stride in in bytes (optional)
  5491. */
  5492. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5493. /**
  5494. * Create a new VertexBuffer based on the current buffer
  5495. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5496. * @param offset defines offset in the buffer (0 by default)
  5497. * @param size defines the size in floats of attributes (position is 3 for instance)
  5498. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5499. * @param instanced defines if the vertex buffer contains indexed data
  5500. * @param useBytes defines if the offset and stride are in bytes
  5501. * @returns the new vertex buffer
  5502. */
  5503. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5504. /**
  5505. * Gets a boolean indicating if the Buffer is updatable?
  5506. * @returns true if the buffer is updatable
  5507. */
  5508. isUpdatable(): boolean;
  5509. /**
  5510. * Gets current buffer's data
  5511. * @returns a DataArray or null
  5512. */
  5513. getData(): Nullable<DataArray>;
  5514. /**
  5515. * Gets underlying native buffer
  5516. * @returns underlying native buffer
  5517. */
  5518. getBuffer(): Nullable<DataBuffer>;
  5519. /**
  5520. * Gets the stride in float32 units (i.e. byte stride / 4).
  5521. * May not be an integer if the byte stride is not divisible by 4.
  5522. * DEPRECATED. Use byteStride instead.
  5523. * @returns the stride in float32 units
  5524. */
  5525. getStrideSize(): number;
  5526. /**
  5527. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5528. * @param data defines the data to store
  5529. */
  5530. create(data?: Nullable<DataArray>): void;
  5531. /** @hidden */ rebuild(): void;
  5532. /**
  5533. * Update current buffer data
  5534. * @param data defines the data to store
  5535. */
  5536. update(data: DataArray): void;
  5537. /**
  5538. * Updates the data directly.
  5539. * @param data the new data
  5540. * @param offset the new offset
  5541. * @param vertexCount the vertex count (optional)
  5542. * @param useBytes set to true if the offset is in bytes
  5543. */
  5544. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5545. /**
  5546. * Release all resources
  5547. */
  5548. dispose(): void;
  5549. }
  5550. /**
  5551. * Specialized buffer used to store vertex data
  5552. */
  5553. export class VertexBuffer {
  5554. /** @hidden */ buffer: Buffer;
  5555. private _kind;
  5556. private _size;
  5557. private _ownsBuffer;
  5558. private _instanced;
  5559. private _instanceDivisor;
  5560. /**
  5561. * The byte type.
  5562. */
  5563. static readonly BYTE: number;
  5564. /**
  5565. * The unsigned byte type.
  5566. */
  5567. static readonly UNSIGNED_BYTE: number;
  5568. /**
  5569. * The short type.
  5570. */
  5571. static readonly SHORT: number;
  5572. /**
  5573. * The unsigned short type.
  5574. */
  5575. static readonly UNSIGNED_SHORT: number;
  5576. /**
  5577. * The integer type.
  5578. */
  5579. static readonly INT: number;
  5580. /**
  5581. * The unsigned integer type.
  5582. */
  5583. static readonly UNSIGNED_INT: number;
  5584. /**
  5585. * The float type.
  5586. */
  5587. static readonly FLOAT: number;
  5588. /**
  5589. * Gets or sets the instance divisor when in instanced mode
  5590. */
  5591. instanceDivisor: number;
  5592. /**
  5593. * Gets the byte stride.
  5594. */
  5595. readonly byteStride: number;
  5596. /**
  5597. * Gets the byte offset.
  5598. */
  5599. readonly byteOffset: number;
  5600. /**
  5601. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5602. */
  5603. readonly normalized: boolean;
  5604. /**
  5605. * Gets the data type of each component in the array.
  5606. */
  5607. readonly type: number;
  5608. /**
  5609. * Constructor
  5610. * @param engine the engine
  5611. * @param data the data to use for this vertex buffer
  5612. * @param kind the vertex buffer kind
  5613. * @param updatable whether the data is updatable
  5614. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5615. * @param stride the stride (optional)
  5616. * @param instanced whether the buffer is instanced (optional)
  5617. * @param offset the offset of the data (optional)
  5618. * @param size the number of components (optional)
  5619. * @param type the type of the component (optional)
  5620. * @param normalized whether the data contains normalized data (optional)
  5621. * @param useBytes set to true if stride and offset are in bytes (optional)
  5622. */
  5623. 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);
  5624. /** @hidden */ rebuild(): void;
  5625. /**
  5626. * Returns the kind of the VertexBuffer (string)
  5627. * @returns a string
  5628. */
  5629. getKind(): string;
  5630. /**
  5631. * Gets a boolean indicating if the VertexBuffer is updatable?
  5632. * @returns true if the buffer is updatable
  5633. */
  5634. isUpdatable(): boolean;
  5635. /**
  5636. * Gets current buffer's data
  5637. * @returns a DataArray or null
  5638. */
  5639. getData(): Nullable<DataArray>;
  5640. /**
  5641. * Gets underlying native buffer
  5642. * @returns underlying native buffer
  5643. */
  5644. getBuffer(): Nullable<DataBuffer>;
  5645. /**
  5646. * Gets the stride in float32 units (i.e. byte stride / 4).
  5647. * May not be an integer if the byte stride is not divisible by 4.
  5648. * DEPRECATED. Use byteStride instead.
  5649. * @returns the stride in float32 units
  5650. */
  5651. getStrideSize(): number;
  5652. /**
  5653. * Returns the offset as a multiple of the type byte length.
  5654. * DEPRECATED. Use byteOffset instead.
  5655. * @returns the offset in bytes
  5656. */
  5657. getOffset(): number;
  5658. /**
  5659. * Returns the number of components per vertex attribute (integer)
  5660. * @returns the size in float
  5661. */
  5662. getSize(): number;
  5663. /**
  5664. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5665. * @returns true if this buffer is instanced
  5666. */
  5667. getIsInstanced(): boolean;
  5668. /**
  5669. * Returns the instancing divisor, zero for non-instanced (integer).
  5670. * @returns a number
  5671. */
  5672. getInstanceDivisor(): number;
  5673. /**
  5674. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5675. * @param data defines the data to store
  5676. */
  5677. create(data?: DataArray): void;
  5678. /**
  5679. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5680. * This function will create a new buffer if the current one is not updatable
  5681. * @param data defines the data to store
  5682. */
  5683. update(data: DataArray): void;
  5684. /**
  5685. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5686. * Returns the directly updated WebGLBuffer.
  5687. * @param data the new data
  5688. * @param offset the new offset
  5689. * @param useBytes set to true if the offset is in bytes
  5690. */
  5691. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5692. /**
  5693. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5694. */
  5695. dispose(): void;
  5696. /**
  5697. * Enumerates each value of this vertex buffer as numbers.
  5698. * @param count the number of values to enumerate
  5699. * @param callback the callback function called for each value
  5700. */
  5701. forEach(count: number, callback: (value: number, index: number) => void): void;
  5702. /**
  5703. * Positions
  5704. */
  5705. static readonly PositionKind: string;
  5706. /**
  5707. * Normals
  5708. */
  5709. static readonly NormalKind: string;
  5710. /**
  5711. * Tangents
  5712. */
  5713. static readonly TangentKind: string;
  5714. /**
  5715. * Texture coordinates
  5716. */
  5717. static readonly UVKind: string;
  5718. /**
  5719. * Texture coordinates 2
  5720. */
  5721. static readonly UV2Kind: string;
  5722. /**
  5723. * Texture coordinates 3
  5724. */
  5725. static readonly UV3Kind: string;
  5726. /**
  5727. * Texture coordinates 4
  5728. */
  5729. static readonly UV4Kind: string;
  5730. /**
  5731. * Texture coordinates 5
  5732. */
  5733. static readonly UV5Kind: string;
  5734. /**
  5735. * Texture coordinates 6
  5736. */
  5737. static readonly UV6Kind: string;
  5738. /**
  5739. * Colors
  5740. */
  5741. static readonly ColorKind: string;
  5742. /**
  5743. * Matrix indices (for bones)
  5744. */
  5745. static readonly MatricesIndicesKind: string;
  5746. /**
  5747. * Matrix weights (for bones)
  5748. */
  5749. static readonly MatricesWeightsKind: string;
  5750. /**
  5751. * Additional matrix indices (for bones)
  5752. */
  5753. static readonly MatricesIndicesExtraKind: string;
  5754. /**
  5755. * Additional matrix weights (for bones)
  5756. */
  5757. static readonly MatricesWeightsExtraKind: string;
  5758. /**
  5759. * Deduces the stride given a kind.
  5760. * @param kind The kind string to deduce
  5761. * @returns The deduced stride
  5762. */
  5763. static DeduceStride(kind: string): number;
  5764. /**
  5765. * Gets the byte length of the given type.
  5766. * @param type the type
  5767. * @returns the number of bytes
  5768. */
  5769. static GetTypeByteLength(type: number): number;
  5770. /**
  5771. * Enumerates each value of the given parameters as numbers.
  5772. * @param data the data to enumerate
  5773. * @param byteOffset the byte offset of the data
  5774. * @param byteStride the byte stride of the data
  5775. * @param componentCount the number of components per element
  5776. * @param componentType the type of the component
  5777. * @param count the total number of components
  5778. * @param normalized whether the data is normalized
  5779. * @param callback the callback function called for each value
  5780. */
  5781. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5782. private static _GetFloatValue;
  5783. }
  5784. }
  5785. declare module BABYLON {
  5786. /**
  5787. * Class representing spherical harmonics coefficients to the 3rd degree
  5788. */
  5789. export class SphericalHarmonics {
  5790. /**
  5791. * Defines whether or not the harmonics have been prescaled for rendering.
  5792. */
  5793. preScaled: boolean;
  5794. /**
  5795. * The l0,0 coefficients of the spherical harmonics
  5796. */
  5797. l00: Vector3;
  5798. /**
  5799. * The l1,-1 coefficients of the spherical harmonics
  5800. */
  5801. l1_1: Vector3;
  5802. /**
  5803. * The l1,0 coefficients of the spherical harmonics
  5804. */
  5805. l10: Vector3;
  5806. /**
  5807. * The l1,1 coefficients of the spherical harmonics
  5808. */
  5809. l11: Vector3;
  5810. /**
  5811. * The l2,-2 coefficients of the spherical harmonics
  5812. */
  5813. l2_2: Vector3;
  5814. /**
  5815. * The l2,-1 coefficients of the spherical harmonics
  5816. */
  5817. l2_1: Vector3;
  5818. /**
  5819. * The l2,0 coefficients of the spherical harmonics
  5820. */
  5821. l20: Vector3;
  5822. /**
  5823. * The l2,1 coefficients of the spherical harmonics
  5824. */
  5825. l21: Vector3;
  5826. /**
  5827. * The l2,2 coefficients of the spherical harmonics
  5828. */
  5829. l22: Vector3;
  5830. /**
  5831. * Adds a light to the spherical harmonics
  5832. * @param direction the direction of the light
  5833. * @param color the color of the light
  5834. * @param deltaSolidAngle the delta solid angle of the light
  5835. */
  5836. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5837. /**
  5838. * Scales the spherical harmonics by the given amount
  5839. * @param scale the amount to scale
  5840. */
  5841. scaleInPlace(scale: number): void;
  5842. /**
  5843. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5844. *
  5845. * ```
  5846. * E_lm = A_l * L_lm
  5847. * ```
  5848. *
  5849. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5850. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5851. * the scaling factors are given in equation 9.
  5852. */
  5853. convertIncidentRadianceToIrradiance(): void;
  5854. /**
  5855. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5856. *
  5857. * ```
  5858. * L = (1/pi) * E * rho
  5859. * ```
  5860. *
  5861. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5862. */
  5863. convertIrradianceToLambertianRadiance(): void;
  5864. /**
  5865. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5866. * required operations at run time.
  5867. *
  5868. * This is simply done by scaling back the SH with Ylm constants parameter.
  5869. * The trigonometric part being applied by the shader at run time.
  5870. */
  5871. preScaleForRendering(): void;
  5872. /**
  5873. * Constructs a spherical harmonics from an array.
  5874. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5875. * @returns the spherical harmonics
  5876. */
  5877. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5878. /**
  5879. * Gets the spherical harmonics from polynomial
  5880. * @param polynomial the spherical polynomial
  5881. * @returns the spherical harmonics
  5882. */
  5883. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5884. }
  5885. /**
  5886. * Class representing spherical polynomial coefficients to the 3rd degree
  5887. */
  5888. export class SphericalPolynomial {
  5889. private _harmonics;
  5890. /**
  5891. * The spherical harmonics used to create the polynomials.
  5892. */
  5893. readonly preScaledHarmonics: SphericalHarmonics;
  5894. /**
  5895. * The x coefficients of the spherical polynomial
  5896. */
  5897. x: Vector3;
  5898. /**
  5899. * The y coefficients of the spherical polynomial
  5900. */
  5901. y: Vector3;
  5902. /**
  5903. * The z coefficients of the spherical polynomial
  5904. */
  5905. z: Vector3;
  5906. /**
  5907. * The xx coefficients of the spherical polynomial
  5908. */
  5909. xx: Vector3;
  5910. /**
  5911. * The yy coefficients of the spherical polynomial
  5912. */
  5913. yy: Vector3;
  5914. /**
  5915. * The zz coefficients of the spherical polynomial
  5916. */
  5917. zz: Vector3;
  5918. /**
  5919. * The xy coefficients of the spherical polynomial
  5920. */
  5921. xy: Vector3;
  5922. /**
  5923. * The yz coefficients of the spherical polynomial
  5924. */
  5925. yz: Vector3;
  5926. /**
  5927. * The zx coefficients of the spherical polynomial
  5928. */
  5929. zx: Vector3;
  5930. /**
  5931. * Adds an ambient color to the spherical polynomial
  5932. * @param color the color to add
  5933. */
  5934. addAmbient(color: Color3): void;
  5935. /**
  5936. * Scales the spherical polynomial by the given amount
  5937. * @param scale the amount to scale
  5938. */
  5939. scaleInPlace(scale: number): void;
  5940. /**
  5941. * Gets the spherical polynomial from harmonics
  5942. * @param harmonics the spherical harmonics
  5943. * @returns the spherical polynomial
  5944. */
  5945. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5946. /**
  5947. * Constructs a spherical polynomial from an array.
  5948. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5949. * @returns the spherical polynomial
  5950. */
  5951. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5952. }
  5953. }
  5954. declare module BABYLON {
  5955. /**
  5956. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5957. */
  5958. export interface CubeMapInfo {
  5959. /**
  5960. * The pixel array for the front face.
  5961. * This is stored in format, left to right, up to down format.
  5962. */
  5963. front: Nullable<ArrayBufferView>;
  5964. /**
  5965. * The pixel array for the back face.
  5966. * This is stored in format, left to right, up to down format.
  5967. */
  5968. back: Nullable<ArrayBufferView>;
  5969. /**
  5970. * The pixel array for the left face.
  5971. * This is stored in format, left to right, up to down format.
  5972. */
  5973. left: Nullable<ArrayBufferView>;
  5974. /**
  5975. * The pixel array for the right face.
  5976. * This is stored in format, left to right, up to down format.
  5977. */
  5978. right: Nullable<ArrayBufferView>;
  5979. /**
  5980. * The pixel array for the up face.
  5981. * This is stored in format, left to right, up to down format.
  5982. */
  5983. up: Nullable<ArrayBufferView>;
  5984. /**
  5985. * The pixel array for the down face.
  5986. * This is stored in format, left to right, up to down format.
  5987. */
  5988. down: Nullable<ArrayBufferView>;
  5989. /**
  5990. * The size of the cubemap stored.
  5991. *
  5992. * Each faces will be size * size pixels.
  5993. */
  5994. size: number;
  5995. /**
  5996. * The format of the texture.
  5997. *
  5998. * RGBA, RGB.
  5999. */
  6000. format: number;
  6001. /**
  6002. * The type of the texture data.
  6003. *
  6004. * UNSIGNED_INT, FLOAT.
  6005. */
  6006. type: number;
  6007. /**
  6008. * Specifies whether the texture is in gamma space.
  6009. */
  6010. gammaSpace: boolean;
  6011. }
  6012. /**
  6013. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6014. */
  6015. export class PanoramaToCubeMapTools {
  6016. private static FACE_FRONT;
  6017. private static FACE_BACK;
  6018. private static FACE_RIGHT;
  6019. private static FACE_LEFT;
  6020. private static FACE_DOWN;
  6021. private static FACE_UP;
  6022. /**
  6023. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6024. *
  6025. * @param float32Array The source data.
  6026. * @param inputWidth The width of the input panorama.
  6027. * @param inputHeight The height of the input panorama.
  6028. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6029. * @return The cubemap data
  6030. */
  6031. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6032. private static CreateCubemapTexture;
  6033. private static CalcProjectionSpherical;
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Helper class dealing with the extraction of spherical polynomial dataArray
  6039. * from a cube map.
  6040. */
  6041. export class CubeMapToSphericalPolynomialTools {
  6042. private static FileFaces;
  6043. /**
  6044. * Converts a texture to the according Spherical Polynomial data.
  6045. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6046. *
  6047. * @param texture The texture to extract the information from.
  6048. * @return The Spherical Polynomial data.
  6049. */
  6050. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6051. /**
  6052. * Converts a cubemap to the according Spherical Polynomial data.
  6053. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6054. *
  6055. * @param cubeInfo The Cube map to extract the information from.
  6056. * @return The Spherical Polynomial data.
  6057. */
  6058. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6064. * during the life time of the application.
  6065. */
  6066. export class EngineStore {
  6067. /** Gets the list of created engines */
  6068. static Instances: Engine[];
  6069. /**
  6070. * Gets the latest created engine
  6071. */
  6072. static readonly LastCreatedEngine: Nullable<Engine>;
  6073. /**
  6074. * Gets the latest created scene
  6075. */
  6076. static readonly LastCreatedScene: Nullable<Scene>;
  6077. }
  6078. }
  6079. declare module BABYLON {
  6080. /**
  6081. * Define options used to create a render target texture
  6082. */
  6083. export class RenderTargetCreationOptions {
  6084. /**
  6085. * Specifies is mipmaps must be generated
  6086. */
  6087. generateMipMaps?: boolean;
  6088. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6089. generateDepthBuffer?: boolean;
  6090. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6091. generateStencilBuffer?: boolean;
  6092. /** Defines texture type (int by default) */
  6093. type?: number;
  6094. /** Defines sampling mode (trilinear by default) */
  6095. samplingMode?: number;
  6096. /** Defines format (RGBA by default) */
  6097. format?: number;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * @hidden
  6103. **/
  6104. export class _AlphaState {
  6105. private _isAlphaBlendDirty;
  6106. private _isBlendFunctionParametersDirty;
  6107. private _isBlendEquationParametersDirty;
  6108. private _isBlendConstantsDirty;
  6109. private _alphaBlend;
  6110. private _blendFunctionParameters;
  6111. private _blendEquationParameters;
  6112. private _blendConstants;
  6113. /**
  6114. * Initializes the state.
  6115. */
  6116. constructor();
  6117. readonly isDirty: boolean;
  6118. alphaBlend: boolean;
  6119. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6120. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6121. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6122. reset(): void;
  6123. apply(gl: WebGLRenderingContext): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @hidden
  6129. **/
  6130. export class _DepthCullingState {
  6131. private _isDepthTestDirty;
  6132. private _isDepthMaskDirty;
  6133. private _isDepthFuncDirty;
  6134. private _isCullFaceDirty;
  6135. private _isCullDirty;
  6136. private _isZOffsetDirty;
  6137. private _isFrontFaceDirty;
  6138. private _depthTest;
  6139. private _depthMask;
  6140. private _depthFunc;
  6141. private _cull;
  6142. private _cullFace;
  6143. private _zOffset;
  6144. private _frontFace;
  6145. /**
  6146. * Initializes the state.
  6147. */
  6148. constructor();
  6149. readonly isDirty: boolean;
  6150. zOffset: number;
  6151. cullFace: Nullable<number>;
  6152. cull: Nullable<boolean>;
  6153. depthFunc: Nullable<number>;
  6154. depthMask: boolean;
  6155. depthTest: boolean;
  6156. frontFace: Nullable<number>;
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module BABYLON {
  6162. /**
  6163. * @hidden
  6164. **/
  6165. export class _StencilState {
  6166. /** 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 */
  6167. static readonly ALWAYS: number;
  6168. /** Passed to stencilOperation to specify that stencil value must be kept */
  6169. static readonly KEEP: number;
  6170. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6171. static readonly REPLACE: number;
  6172. private _isStencilTestDirty;
  6173. private _isStencilMaskDirty;
  6174. private _isStencilFuncDirty;
  6175. private _isStencilOpDirty;
  6176. private _stencilTest;
  6177. private _stencilMask;
  6178. private _stencilFunc;
  6179. private _stencilFuncRef;
  6180. private _stencilFuncMask;
  6181. private _stencilOpStencilFail;
  6182. private _stencilOpDepthFail;
  6183. private _stencilOpStencilDepthPass;
  6184. readonly isDirty: boolean;
  6185. stencilFunc: number;
  6186. stencilFuncRef: number;
  6187. stencilFuncMask: number;
  6188. stencilOpStencilFail: number;
  6189. stencilOpDepthFail: number;
  6190. stencilOpStencilDepthPass: number;
  6191. stencilMask: number;
  6192. stencilTest: boolean;
  6193. constructor();
  6194. reset(): void;
  6195. apply(gl: WebGLRenderingContext): void;
  6196. }
  6197. }
  6198. declare module BABYLON {
  6199. /**
  6200. * @hidden
  6201. **/
  6202. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6203. }
  6204. }
  6205. declare module BABYLON {
  6206. /**
  6207. * Class used to store data associated with WebGL texture data for the engine
  6208. * This class should not be used directly
  6209. */
  6210. export class InternalTexture {
  6211. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6212. /**
  6213. * The source of the texture data is unknown
  6214. */
  6215. static DATASOURCE_UNKNOWN: number;
  6216. /**
  6217. * Texture data comes from an URL
  6218. */
  6219. static DATASOURCE_URL: number;
  6220. /**
  6221. * Texture data is only used for temporary storage
  6222. */
  6223. static DATASOURCE_TEMP: number;
  6224. /**
  6225. * Texture data comes from raw data (ArrayBuffer)
  6226. */
  6227. static DATASOURCE_RAW: number;
  6228. /**
  6229. * Texture content is dynamic (video or dynamic texture)
  6230. */
  6231. static DATASOURCE_DYNAMIC: number;
  6232. /**
  6233. * Texture content is generated by rendering to it
  6234. */
  6235. static DATASOURCE_RENDERTARGET: number;
  6236. /**
  6237. * Texture content is part of a multi render target process
  6238. */
  6239. static DATASOURCE_MULTIRENDERTARGET: number;
  6240. /**
  6241. * Texture data comes from a cube data file
  6242. */
  6243. static DATASOURCE_CUBE: number;
  6244. /**
  6245. * Texture data comes from a raw cube data
  6246. */
  6247. static DATASOURCE_CUBERAW: number;
  6248. /**
  6249. * Texture data come from a prefiltered cube data file
  6250. */
  6251. static DATASOURCE_CUBEPREFILTERED: number;
  6252. /**
  6253. * Texture content is raw 3D data
  6254. */
  6255. static DATASOURCE_RAW3D: number;
  6256. /**
  6257. * Texture content is a depth texture
  6258. */
  6259. static DATASOURCE_DEPTHTEXTURE: number;
  6260. /**
  6261. * Texture data comes from a raw cube data encoded with RGBD
  6262. */
  6263. static DATASOURCE_CUBERAW_RGBD: number;
  6264. /**
  6265. * Defines if the texture is ready
  6266. */
  6267. isReady: boolean;
  6268. /**
  6269. * Defines if the texture is a cube texture
  6270. */
  6271. isCube: boolean;
  6272. /**
  6273. * Defines if the texture contains 3D data
  6274. */
  6275. is3D: boolean;
  6276. /**
  6277. * Defines if the texture contains multiview data
  6278. */
  6279. isMultiview: boolean;
  6280. /**
  6281. * Gets the URL used to load this texture
  6282. */
  6283. url: string;
  6284. /**
  6285. * Gets the sampling mode of the texture
  6286. */
  6287. samplingMode: number;
  6288. /**
  6289. * Gets a boolean indicating if the texture needs mipmaps generation
  6290. */
  6291. generateMipMaps: boolean;
  6292. /**
  6293. * Gets the number of samples used by the texture (WebGL2+ only)
  6294. */
  6295. samples: number;
  6296. /**
  6297. * Gets the type of the texture (int, float...)
  6298. */
  6299. type: number;
  6300. /**
  6301. * Gets the format of the texture (RGB, RGBA...)
  6302. */
  6303. format: number;
  6304. /**
  6305. * Observable called when the texture is loaded
  6306. */
  6307. onLoadedObservable: Observable<InternalTexture>;
  6308. /**
  6309. * Gets the width of the texture
  6310. */
  6311. width: number;
  6312. /**
  6313. * Gets the height of the texture
  6314. */
  6315. height: number;
  6316. /**
  6317. * Gets the depth of the texture
  6318. */
  6319. depth: number;
  6320. /**
  6321. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseWidth: number;
  6324. /**
  6325. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseHeight: number;
  6328. /**
  6329. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6330. */
  6331. baseDepth: number;
  6332. /**
  6333. * Gets a boolean indicating if the texture is inverted on Y axis
  6334. */
  6335. invertY: boolean;
  6336. /** @hidden */ invertVScale: boolean;
  6337. /** @hidden */ associatedChannel: number;
  6338. /** @hidden */ dataSource: number;
  6339. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6341. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6342. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6343. /** @hidden */ size: number;
  6344. /** @hidden */ extension: string;
  6345. /** @hidden */ files: Nullable<string[]>;
  6346. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  6347. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  6348. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6349. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6350. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6351. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6352. /** @hidden */ attachments: Nullable<number[]>;
  6353. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6354. /** @hidden */ cachedWrapU: Nullable<number>;
  6355. /** @hidden */ cachedWrapV: Nullable<number>;
  6356. /** @hidden */ cachedWrapR: Nullable<number>;
  6357. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6358. /** @hidden */ isDisabled: boolean;
  6359. /** @hidden */ compression: Nullable<string>;
  6360. /** @hidden */ generateStencilBuffer: boolean;
  6361. /** @hidden */ generateDepthBuffer: boolean;
  6362. /** @hidden */ comparisonFunction: number;
  6363. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6364. /** @hidden */ lodGenerationScale: number;
  6365. /** @hidden */ lodGenerationOffset: number;
  6366. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6367. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6368. /** @hidden */ lodTextureHigh: Nullable<BaseTexture>;
  6369. /** @hidden */ lodTextureMid: Nullable<BaseTexture>;
  6370. /** @hidden */ lodTextureLow: Nullable<BaseTexture>;
  6371. /** @hidden */ isRGBD: boolean;
  6372. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6373. /** @hidden */ references: number;
  6374. private _engine;
  6375. /**
  6376. * Gets the Engine the texture belongs to.
  6377. * @returns The babylon engine
  6378. */
  6379. getEngine(): Engine;
  6380. /**
  6381. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6382. */
  6383. readonly dataSource: number;
  6384. /**
  6385. * Creates a new InternalTexture
  6386. * @param engine defines the engine to use
  6387. * @param dataSource defines the type of data that will be used
  6388. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6389. */
  6390. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6391. /**
  6392. * Increments the number of references (ie. the number of Texture that point to it)
  6393. */
  6394. incrementReferences(): void;
  6395. /**
  6396. * Change the size of the texture (not the size of the content)
  6397. * @param width defines the new width
  6398. * @param height defines the new height
  6399. * @param depth defines the new depth (1 by default)
  6400. */
  6401. updateSize(width: int, height: int, depth?: int): void;
  6402. /** @hidden */ rebuild(): void;
  6403. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6404. /**
  6405. * Dispose the current allocated resources
  6406. */
  6407. dispose(): void;
  6408. }
  6409. }
  6410. declare module BABYLON {
  6411. /**
  6412. * This represents the main contract an easing function should follow.
  6413. * Easing functions are used throughout the animation system.
  6414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6415. */
  6416. export interface IEasingFunction {
  6417. /**
  6418. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6419. * of the easing function.
  6420. * The link below provides some of the most common examples of easing functions.
  6421. * @see https://easings.net/
  6422. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6423. * @returns the corresponding value on the curve defined by the easing function
  6424. */
  6425. ease(gradient: number): number;
  6426. }
  6427. /**
  6428. * Base class used for every default easing function.
  6429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6430. */
  6431. export class EasingFunction implements IEasingFunction {
  6432. /**
  6433. * Interpolation follows the mathematical formula associated with the easing function.
  6434. */
  6435. static readonly EASINGMODE_EASEIN: number;
  6436. /**
  6437. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6438. */
  6439. static readonly EASINGMODE_EASEOUT: number;
  6440. /**
  6441. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6442. */
  6443. static readonly EASINGMODE_EASEINOUT: number;
  6444. private _easingMode;
  6445. /**
  6446. * Sets the easing mode of the current function.
  6447. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6448. */
  6449. setEasingMode(easingMode: number): void;
  6450. /**
  6451. * Gets the current easing mode.
  6452. * @returns the easing mode
  6453. */
  6454. getEasingMode(): number;
  6455. /**
  6456. * @hidden
  6457. */
  6458. easeInCore(gradient: number): number;
  6459. /**
  6460. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6461. * of the easing function.
  6462. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6463. * @returns the corresponding value on the curve defined by the easing function
  6464. */
  6465. ease(gradient: number): number;
  6466. }
  6467. /**
  6468. * Easing function with a circle shape (see link below).
  6469. * @see https://easings.net/#easeInCirc
  6470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6471. */
  6472. export class CircleEase extends EasingFunction implements IEasingFunction {
  6473. /** @hidden */
  6474. easeInCore(gradient: number): number;
  6475. }
  6476. /**
  6477. * Easing function with a ease back shape (see link below).
  6478. * @see https://easings.net/#easeInBack
  6479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6480. */
  6481. export class BackEase extends EasingFunction implements IEasingFunction {
  6482. /** Defines the amplitude of the function */
  6483. amplitude: number;
  6484. /**
  6485. * Instantiates a back ease easing
  6486. * @see https://easings.net/#easeInBack
  6487. * @param amplitude Defines the amplitude of the function
  6488. */
  6489. constructor(
  6490. /** Defines the amplitude of the function */
  6491. amplitude?: number);
  6492. /** @hidden */
  6493. easeInCore(gradient: number): number;
  6494. }
  6495. /**
  6496. * Easing function with a bouncing shape (see link below).
  6497. * @see https://easings.net/#easeInBounce
  6498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6499. */
  6500. export class BounceEase extends EasingFunction implements IEasingFunction {
  6501. /** Defines the number of bounces */
  6502. bounces: number;
  6503. /** Defines the amplitude of the bounce */
  6504. bounciness: number;
  6505. /**
  6506. * Instantiates a bounce easing
  6507. * @see https://easings.net/#easeInBounce
  6508. * @param bounces Defines the number of bounces
  6509. * @param bounciness Defines the amplitude of the bounce
  6510. */
  6511. constructor(
  6512. /** Defines the number of bounces */
  6513. bounces?: number,
  6514. /** Defines the amplitude of the bounce */
  6515. bounciness?: number);
  6516. /** @hidden */
  6517. easeInCore(gradient: number): number;
  6518. }
  6519. /**
  6520. * Easing function with a power of 3 shape (see link below).
  6521. * @see https://easings.net/#easeInCubic
  6522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6523. */
  6524. export class CubicEase extends EasingFunction implements IEasingFunction {
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with an elastic shape (see link below).
  6530. * @see https://easings.net/#easeInElastic
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6534. /** Defines the number of oscillations*/
  6535. oscillations: number;
  6536. /** Defines the amplitude of the oscillations*/
  6537. springiness: number;
  6538. /**
  6539. * Instantiates an elastic easing function
  6540. * @see https://easings.net/#easeInElastic
  6541. * @param oscillations Defines the number of oscillations
  6542. * @param springiness Defines the amplitude of the oscillations
  6543. */
  6544. constructor(
  6545. /** Defines the number of oscillations*/
  6546. oscillations?: number,
  6547. /** Defines the amplitude of the oscillations*/
  6548. springiness?: number);
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with an exponential shape (see link below).
  6554. * @see https://easings.net/#easeInExpo
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6558. /** Defines the exponent of the function */
  6559. exponent: number;
  6560. /**
  6561. * Instantiates an exponential easing function
  6562. * @see https://easings.net/#easeInExpo
  6563. * @param exponent Defines the exponent of the function
  6564. */
  6565. constructor(
  6566. /** Defines the exponent of the function */
  6567. exponent?: number);
  6568. /** @hidden */
  6569. easeInCore(gradient: number): number;
  6570. }
  6571. /**
  6572. * Easing function with a power shape (see link below).
  6573. * @see https://easings.net/#easeInQuad
  6574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6575. */
  6576. export class PowerEase extends EasingFunction implements IEasingFunction {
  6577. /** Defines the power of the function */
  6578. power: number;
  6579. /**
  6580. * Instantiates an power base easing function
  6581. * @see https://easings.net/#easeInQuad
  6582. * @param power Defines the power of the function
  6583. */
  6584. constructor(
  6585. /** Defines the power of the function */
  6586. power?: number);
  6587. /** @hidden */
  6588. easeInCore(gradient: number): number;
  6589. }
  6590. /**
  6591. * Easing function with a power of 2 shape (see link below).
  6592. * @see https://easings.net/#easeInQuad
  6593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6594. */
  6595. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6596. /** @hidden */
  6597. easeInCore(gradient: number): number;
  6598. }
  6599. /**
  6600. * Easing function with a power of 4 shape (see link below).
  6601. * @see https://easings.net/#easeInQuart
  6602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6603. */
  6604. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6605. /** @hidden */
  6606. easeInCore(gradient: number): number;
  6607. }
  6608. /**
  6609. * Easing function with a power of 5 shape (see link below).
  6610. * @see https://easings.net/#easeInQuint
  6611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6612. */
  6613. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6614. /** @hidden */
  6615. easeInCore(gradient: number): number;
  6616. }
  6617. /**
  6618. * Easing function with a sin shape (see link below).
  6619. * @see https://easings.net/#easeInSine
  6620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6621. */
  6622. export class SineEase extends EasingFunction implements IEasingFunction {
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a bezier shape (see link below).
  6628. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6632. /** Defines the x component of the start tangent in the bezier curve */
  6633. x1: number;
  6634. /** Defines the y component of the start tangent in the bezier curve */
  6635. y1: number;
  6636. /** Defines the x component of the end tangent in the bezier curve */
  6637. x2: number;
  6638. /** Defines the y component of the end tangent in the bezier curve */
  6639. y2: number;
  6640. /**
  6641. * Instantiates a bezier function
  6642. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6643. * @param x1 Defines the x component of the start tangent in the bezier curve
  6644. * @param y1 Defines the y component of the start tangent in the bezier curve
  6645. * @param x2 Defines the x component of the end tangent in the bezier curve
  6646. * @param y2 Defines the y component of the end tangent in the bezier curve
  6647. */
  6648. constructor(
  6649. /** Defines the x component of the start tangent in the bezier curve */
  6650. x1?: number,
  6651. /** Defines the y component of the start tangent in the bezier curve */
  6652. y1?: number,
  6653. /** Defines the x component of the end tangent in the bezier curve */
  6654. x2?: number,
  6655. /** Defines the y component of the end tangent in the bezier curve */
  6656. y2?: number);
  6657. /** @hidden */
  6658. easeInCore(gradient: number): number;
  6659. }
  6660. }
  6661. declare module BABYLON {
  6662. /**
  6663. * Defines an interface which represents an animation key frame
  6664. */
  6665. export interface IAnimationKey {
  6666. /**
  6667. * Frame of the key frame
  6668. */
  6669. frame: number;
  6670. /**
  6671. * Value at the specifies key frame
  6672. */
  6673. value: any;
  6674. /**
  6675. * The input tangent for the cubic hermite spline
  6676. */
  6677. inTangent?: any;
  6678. /**
  6679. * The output tangent for the cubic hermite spline
  6680. */
  6681. outTangent?: any;
  6682. /**
  6683. * The animation interpolation type
  6684. */
  6685. interpolation?: AnimationKeyInterpolation;
  6686. }
  6687. /**
  6688. * Enum for the animation key frame interpolation type
  6689. */
  6690. export enum AnimationKeyInterpolation {
  6691. /**
  6692. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6693. */
  6694. STEP = 1
  6695. }
  6696. }
  6697. declare module BABYLON {
  6698. /**
  6699. * Represents the range of an animation
  6700. */
  6701. export class AnimationRange {
  6702. /**The name of the animation range**/
  6703. name: string;
  6704. /**The starting frame of the animation */
  6705. from: number;
  6706. /**The ending frame of the animation*/
  6707. to: number;
  6708. /**
  6709. * Initializes the range of an animation
  6710. * @param name The name of the animation range
  6711. * @param from The starting frame of the animation
  6712. * @param to The ending frame of the animation
  6713. */
  6714. constructor(
  6715. /**The name of the animation range**/
  6716. name: string,
  6717. /**The starting frame of the animation */
  6718. from: number,
  6719. /**The ending frame of the animation*/
  6720. to: number);
  6721. /**
  6722. * Makes a copy of the animation range
  6723. * @returns A copy of the animation range
  6724. */
  6725. clone(): AnimationRange;
  6726. }
  6727. }
  6728. declare module BABYLON {
  6729. /**
  6730. * Composed of a frame, and an action function
  6731. */
  6732. export class AnimationEvent {
  6733. /** The frame for which the event is triggered **/
  6734. frame: number;
  6735. /** The event to perform when triggered **/
  6736. action: (currentFrame: number) => void;
  6737. /** Specifies if the event should be triggered only once**/
  6738. onlyOnce?: boolean | undefined;
  6739. /**
  6740. * Specifies if the animation event is done
  6741. */
  6742. isDone: boolean;
  6743. /**
  6744. * Initializes the animation event
  6745. * @param frame The frame for which the event is triggered
  6746. * @param action The event to perform when triggered
  6747. * @param onlyOnce Specifies if the event should be triggered only once
  6748. */
  6749. constructor(
  6750. /** The frame for which the event is triggered **/
  6751. frame: number,
  6752. /** The event to perform when triggered **/
  6753. action: (currentFrame: number) => void,
  6754. /** Specifies if the event should be triggered only once**/
  6755. onlyOnce?: boolean | undefined);
  6756. /** @hidden */ clone(): AnimationEvent;
  6757. }
  6758. }
  6759. declare module BABYLON {
  6760. /**
  6761. * Interface used to define a behavior
  6762. */
  6763. export interface Behavior<T> {
  6764. /** gets or sets behavior's name */
  6765. name: string;
  6766. /**
  6767. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6768. */
  6769. init(): void;
  6770. /**
  6771. * Called when the behavior is attached to a target
  6772. * @param target defines the target where the behavior is attached to
  6773. */
  6774. attach(target: T): void;
  6775. /**
  6776. * Called when the behavior is detached from its target
  6777. */
  6778. detach(): void;
  6779. }
  6780. /**
  6781. * Interface implemented by classes supporting behaviors
  6782. */
  6783. export interface IBehaviorAware<T> {
  6784. /**
  6785. * Attach a behavior
  6786. * @param behavior defines the behavior to attach
  6787. * @returns the current host
  6788. */
  6789. addBehavior(behavior: Behavior<T>): T;
  6790. /**
  6791. * Remove a behavior from the current object
  6792. * @param behavior defines the behavior to detach
  6793. * @returns the current host
  6794. */
  6795. removeBehavior(behavior: Behavior<T>): T;
  6796. /**
  6797. * Gets a behavior using its name to search
  6798. * @param name defines the name to search
  6799. * @returns the behavior or null if not found
  6800. */
  6801. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /**
  6806. * @hidden
  6807. */
  6808. export class IntersectionInfo {
  6809. bu: Nullable<number>;
  6810. bv: Nullable<number>;
  6811. distance: number;
  6812. faceId: number;
  6813. subMeshId: number;
  6814. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * Class used to store bounding sphere information
  6820. */
  6821. export class BoundingSphere {
  6822. /**
  6823. * Gets the center of the bounding sphere in local space
  6824. */
  6825. readonly center: Vector3;
  6826. /**
  6827. * Radius of the bounding sphere in local space
  6828. */
  6829. radius: number;
  6830. /**
  6831. * Gets the center of the bounding sphere in world space
  6832. */
  6833. readonly centerWorld: Vector3;
  6834. /**
  6835. * Radius of the bounding sphere in world space
  6836. */
  6837. radiusWorld: number;
  6838. /**
  6839. * Gets the minimum vector in local space
  6840. */
  6841. readonly minimum: Vector3;
  6842. /**
  6843. * Gets the maximum vector in local space
  6844. */
  6845. readonly maximum: Vector3;
  6846. private _worldMatrix;
  6847. private static readonly TmpVector3;
  6848. /**
  6849. * Creates a new bounding sphere
  6850. * @param min defines the minimum vector (in local space)
  6851. * @param max defines the maximum vector (in local space)
  6852. * @param worldMatrix defines the new world matrix
  6853. */
  6854. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6855. /**
  6856. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6857. * @param min defines the new minimum vector (in local space)
  6858. * @param max defines the new maximum vector (in local space)
  6859. * @param worldMatrix defines the new world matrix
  6860. */
  6861. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Scale the current bounding sphere by applying a scale factor
  6864. * @param factor defines the scale factor to apply
  6865. * @returns the current bounding box
  6866. */
  6867. scale(factor: number): BoundingSphere;
  6868. /**
  6869. * Gets the world matrix of the bounding box
  6870. * @returns a matrix
  6871. */
  6872. getWorldMatrix(): DeepImmutable<Matrix>;
  6873. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6874. /**
  6875. * Tests if the bounding sphere is intersecting the frustum planes
  6876. * @param frustumPlanes defines the frustum planes to test
  6877. * @returns true if there is an intersection
  6878. */
  6879. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6880. /**
  6881. * Tests if the bounding sphere center is in between the frustum planes.
  6882. * Used for optimistic fast inclusion.
  6883. * @param frustumPlanes defines the frustum planes to test
  6884. * @returns true if the sphere center is in between the frustum planes
  6885. */
  6886. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6887. /**
  6888. * Tests if a point is inside the bounding sphere
  6889. * @param point defines the point to test
  6890. * @returns true if the point is inside the bounding sphere
  6891. */
  6892. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Checks if two sphere intersct
  6895. * @param sphere0 sphere 0
  6896. * @param sphere1 sphere 1
  6897. * @returns true if the speres intersect
  6898. */
  6899. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /**
  6904. * Class used to store bounding box information
  6905. */
  6906. export class BoundingBox implements ICullable {
  6907. /**
  6908. * Gets the 8 vectors representing the bounding box in local space
  6909. */
  6910. readonly vectors: Vector3[];
  6911. /**
  6912. * Gets the center of the bounding box in local space
  6913. */
  6914. readonly center: Vector3;
  6915. /**
  6916. * Gets the center of the bounding box in world space
  6917. */
  6918. readonly centerWorld: Vector3;
  6919. /**
  6920. * Gets the extend size in local space
  6921. */
  6922. readonly extendSize: Vector3;
  6923. /**
  6924. * Gets the extend size in world space
  6925. */
  6926. readonly extendSizeWorld: Vector3;
  6927. /**
  6928. * Gets the OBB (object bounding box) directions
  6929. */
  6930. readonly directions: Vector3[];
  6931. /**
  6932. * Gets the 8 vectors representing the bounding box in world space
  6933. */
  6934. readonly vectorsWorld: Vector3[];
  6935. /**
  6936. * Gets the minimum vector in world space
  6937. */
  6938. readonly minimumWorld: Vector3;
  6939. /**
  6940. * Gets the maximum vector in world space
  6941. */
  6942. readonly maximumWorld: Vector3;
  6943. /**
  6944. * Gets the minimum vector in local space
  6945. */
  6946. readonly minimum: Vector3;
  6947. /**
  6948. * Gets the maximum vector in local space
  6949. */
  6950. readonly maximum: Vector3;
  6951. private _worldMatrix;
  6952. private static readonly TmpVector3;
  6953. /**
  6954. * @hidden
  6955. */ tag: number;
  6956. /**
  6957. * Creates a new bounding box
  6958. * @param min defines the minimum vector (in local space)
  6959. * @param max defines the maximum vector (in local space)
  6960. * @param worldMatrix defines the new world matrix
  6961. */
  6962. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6963. /**
  6964. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6965. * @param min defines the new minimum vector (in local space)
  6966. * @param max defines the new maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6970. /**
  6971. * Scale the current bounding box by applying a scale factor
  6972. * @param factor defines the scale factor to apply
  6973. * @returns the current bounding box
  6974. */
  6975. scale(factor: number): BoundingBox;
  6976. /**
  6977. * Gets the world matrix of the bounding box
  6978. * @returns a matrix
  6979. */
  6980. getWorldMatrix(): DeepImmutable<Matrix>;
  6981. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6982. /**
  6983. * Tests if the bounding box is intersecting the frustum planes
  6984. * @param frustumPlanes defines the frustum planes to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6988. /**
  6989. * Tests if the bounding box is entirely inside the frustum planes
  6990. * @param frustumPlanes defines the frustum planes to test
  6991. * @returns true if there is an inclusion
  6992. */
  6993. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6994. /**
  6995. * Tests if a point is inside the bounding box
  6996. * @param point defines the point to test
  6997. * @returns true if the point is inside the bounding box
  6998. */
  6999. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7000. /**
  7001. * Tests if the bounding box intersects with a bounding sphere
  7002. * @param sphere defines the sphere to test
  7003. * @returns true if there is an intersection
  7004. */
  7005. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7006. /**
  7007. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7008. * @param min defines the min vector to use
  7009. * @param max defines the max vector to use
  7010. * @returns true if there is an intersection
  7011. */
  7012. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7013. /**
  7014. * Tests if two bounding boxes are intersections
  7015. * @param box0 defines the first box to test
  7016. * @param box1 defines the second box to test
  7017. * @returns true if there is an intersection
  7018. */
  7019. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7020. /**
  7021. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7022. * @param minPoint defines the minimum vector of the bounding box
  7023. * @param maxPoint defines the maximum vector of the bounding box
  7024. * @param sphereCenter defines the sphere center
  7025. * @param sphereRadius defines the sphere radius
  7026. * @returns true if there is an intersection
  7027. */
  7028. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7029. /**
  7030. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7031. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @return true if there is an inclusion
  7034. */
  7035. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7038. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7039. * @param frustumPlanes defines the frustum planes to test
  7040. * @return true if there is an intersection
  7041. */
  7042. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7043. }
  7044. }
  7045. declare module BABYLON {
  7046. /** @hidden */
  7047. export class Collider {
  7048. /** Define if a collision was found */
  7049. collisionFound: boolean;
  7050. /**
  7051. * Define last intersection point in local space
  7052. */
  7053. intersectionPoint: Vector3;
  7054. /**
  7055. * Define last collided mesh
  7056. */
  7057. collidedMesh: Nullable<AbstractMesh>;
  7058. private _collisionPoint;
  7059. private _planeIntersectionPoint;
  7060. private _tempVector;
  7061. private _tempVector2;
  7062. private _tempVector3;
  7063. private _tempVector4;
  7064. private _edge;
  7065. private _baseToVertex;
  7066. private _destinationPoint;
  7067. private _slidePlaneNormal;
  7068. private _displacementVector;
  7069. /** @hidden */ radius: Vector3;
  7070. /** @hidden */ retry: number;
  7071. private _velocity;
  7072. private _basePoint;
  7073. private _epsilon;
  7074. /** @hidden */ velocityWorldLength: number;
  7075. /** @hidden */ basePointWorld: Vector3;
  7076. private _velocityWorld;
  7077. private _normalizedVelocity;
  7078. /** @hidden */ initialVelocity: Vector3;
  7079. /** @hidden */ initialPosition: Vector3;
  7080. private _nearestDistance;
  7081. private _collisionMask;
  7082. collisionMask: number;
  7083. /**
  7084. * Gets the plane normal used to compute the sliding response (in local space)
  7085. */
  7086. readonly slidePlaneNormal: Vector3;
  7087. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7088. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7089. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7090. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7091. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7092. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7093. }
  7094. }
  7095. declare module BABYLON {
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. readonly minimum: Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. readonly maximum: Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. isLocked: boolean;
  7155. /**
  7156. * Updates the bounding sphere and box
  7157. * @param world world matrix to be used to update
  7158. */
  7159. update(world: DeepImmutable<Matrix>): void;
  7160. /**
  7161. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7162. * @param center New center of the bounding info
  7163. * @param extend New extend of the bounding info
  7164. * @returns the current bounding info
  7165. */
  7166. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7167. /**
  7168. * Scale the current bounding info by applying a scale factor
  7169. * @param factor defines the scale factor to apply
  7170. * @returns the current bounding info
  7171. */
  7172. scale(factor: number): BoundingInfo;
  7173. /**
  7174. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7175. * @param frustumPlanes defines the frustum to test
  7176. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7177. * @returns true if the bounding info is in the frustum planes
  7178. */
  7179. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7180. /**
  7181. * Gets the world distance between the min and max points of the bounding box
  7182. */
  7183. readonly diagonalLength: number;
  7184. /**
  7185. * Checks if a cullable object (mesh...) is in the camera frustum
  7186. * Unlike isInFrustum this cheks the full bounding box
  7187. * @param frustumPlanes Camera near/planes
  7188. * @returns true if the object is in frustum otherwise false
  7189. */
  7190. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7191. /** @hidden */ checkCollision(collider: Collider): boolean;
  7192. /**
  7193. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7194. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7195. * @param point the point to check intersection with
  7196. * @returns if the point intersects
  7197. */
  7198. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7199. /**
  7200. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7201. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7202. * @param boundingInfo the bounding info to check intersection with
  7203. * @param precise if the intersection should be done using OBB
  7204. * @returns if the bounding info intersects
  7205. */
  7206. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7207. }
  7208. }
  7209. declare module BABYLON {
  7210. /**
  7211. * Defines an array and its length.
  7212. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7213. */
  7214. export interface ISmartArrayLike<T> {
  7215. /**
  7216. * The data of the array.
  7217. */
  7218. data: Array<T>;
  7219. /**
  7220. * The active length of the array.
  7221. */
  7222. length: number;
  7223. }
  7224. /**
  7225. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7226. */
  7227. export class SmartArray<T> implements ISmartArrayLike<T> {
  7228. /**
  7229. * The full set of data from the array.
  7230. */
  7231. data: Array<T>;
  7232. /**
  7233. * The active length of the array.
  7234. */
  7235. length: number;
  7236. protected _id: number;
  7237. /**
  7238. * Instantiates a Smart Array.
  7239. * @param capacity defines the default capacity of the array.
  7240. */
  7241. constructor(capacity: number);
  7242. /**
  7243. * Pushes a value at the end of the active data.
  7244. * @param value defines the object to push in the array.
  7245. */
  7246. push(value: T): void;
  7247. /**
  7248. * Iterates over the active data and apply the lambda to them.
  7249. * @param func defines the action to apply on each value.
  7250. */
  7251. forEach(func: (content: T) => void): void;
  7252. /**
  7253. * Sorts the full sets of data.
  7254. * @param compareFn defines the comparison function to apply.
  7255. */
  7256. sort(compareFn: (a: T, b: T) => number): void;
  7257. /**
  7258. * Resets the active data to an empty array.
  7259. */
  7260. reset(): void;
  7261. /**
  7262. * Releases all the data from the array as well as the array.
  7263. */
  7264. dispose(): void;
  7265. /**
  7266. * Concats the active data with a given array.
  7267. * @param array defines the data to concatenate with.
  7268. */
  7269. concat(array: any): void;
  7270. /**
  7271. * Returns the position of a value in the active data.
  7272. * @param value defines the value to find the index for
  7273. * @returns the index if found in the active data otherwise -1
  7274. */
  7275. indexOf(value: T): number;
  7276. /**
  7277. * Returns whether an element is part of the active data.
  7278. * @param value defines the value to look for
  7279. * @returns true if found in the active data otherwise false
  7280. */
  7281. contains(value: T): boolean;
  7282. private static _GlobalId;
  7283. }
  7284. /**
  7285. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7286. * The data in this array can only be present once
  7287. */
  7288. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7289. private _duplicateId;
  7290. /**
  7291. * Pushes a value at the end of the active data.
  7292. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7293. * @param value defines the object to push in the array.
  7294. */
  7295. push(value: T): void;
  7296. /**
  7297. * Pushes a value at the end of the active data.
  7298. * If the data is already present, it won t be added again
  7299. * @param value defines the object to push in the array.
  7300. * @returns true if added false if it was already present
  7301. */
  7302. pushNoDuplicate(value: T): boolean;
  7303. /**
  7304. * Resets the active data to an empty array.
  7305. */
  7306. reset(): void;
  7307. /**
  7308. * Concats the active data with a given array.
  7309. * This ensures no dupplicate will be present in the result.
  7310. * @param array defines the data to concatenate with.
  7311. */
  7312. concatWithNoDuplicate(array: any): void;
  7313. }
  7314. }
  7315. declare module BABYLON {
  7316. /**
  7317. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7318. * separate meshes. This can be use to improve performances.
  7319. * @see http://doc.babylonjs.com/how_to/multi_materials
  7320. */
  7321. export class MultiMaterial extends Material {
  7322. private _subMaterials;
  7323. /**
  7324. * Gets or Sets the list of Materials used within the multi material.
  7325. * They need to be ordered according to the submeshes order in the associated mesh
  7326. */
  7327. subMaterials: Nullable<Material>[];
  7328. /**
  7329. * Function used to align with Node.getChildren()
  7330. * @returns the list of Materials used within the multi material
  7331. */
  7332. getChildren(): Nullable<Material>[];
  7333. /**
  7334. * Instantiates a new Multi Material
  7335. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7336. * separate meshes. This can be use to improve performances.
  7337. * @see http://doc.babylonjs.com/how_to/multi_materials
  7338. * @param name Define the name in the scene
  7339. * @param scene Define the scene the material belongs to
  7340. */
  7341. constructor(name: string, scene: Scene);
  7342. private _hookArray;
  7343. /**
  7344. * Get one of the submaterial by its index in the submaterials array
  7345. * @param index The index to look the sub material at
  7346. * @returns The Material if the index has been defined
  7347. */
  7348. getSubMaterial(index: number): Nullable<Material>;
  7349. /**
  7350. * Get the list of active textures for the whole sub materials list.
  7351. * @returns All the textures that will be used during the rendering
  7352. */
  7353. getActiveTextures(): BaseTexture[];
  7354. /**
  7355. * Gets the current class name of the material e.g. "MultiMaterial"
  7356. * Mainly use in serialization.
  7357. * @returns the class name
  7358. */
  7359. getClassName(): string;
  7360. /**
  7361. * Checks if the material is ready to render the requested sub mesh
  7362. * @param mesh Define the mesh the submesh belongs to
  7363. * @param subMesh Define the sub mesh to look readyness for
  7364. * @param useInstances Define whether or not the material is used with instances
  7365. * @returns true if ready, otherwise false
  7366. */
  7367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7368. /**
  7369. * Clones the current material and its related sub materials
  7370. * @param name Define the name of the newly cloned material
  7371. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7372. * @returns the cloned material
  7373. */
  7374. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7375. /**
  7376. * Serializes the materials into a JSON representation.
  7377. * @returns the JSON representation
  7378. */
  7379. serialize(): any;
  7380. /**
  7381. * Dispose the material and release its associated resources
  7382. * @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)
  7383. * @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)
  7384. * @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)
  7385. */
  7386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7387. /**
  7388. * Creates a MultiMaterial from parsed MultiMaterial data.
  7389. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7390. * @param scene defines the hosting scene
  7391. * @returns a new MultiMaterial
  7392. */
  7393. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7394. }
  7395. }
  7396. declare module BABYLON {
  7397. /**
  7398. * Class used to represent data loading progression
  7399. */
  7400. export class SceneLoaderFlags {
  7401. private static _ForceFullSceneLoadingForIncremental;
  7402. private static _ShowLoadingScreen;
  7403. private static _CleanBoneMatrixWeights;
  7404. private static _loggingLevel;
  7405. /**
  7406. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7407. */
  7408. static ForceFullSceneLoadingForIncremental: boolean;
  7409. /**
  7410. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7411. */
  7412. static ShowLoadingScreen: boolean;
  7413. /**
  7414. * Defines the current logging level (while loading the scene)
  7415. * @ignorenaming
  7416. */
  7417. static loggingLevel: number;
  7418. /**
  7419. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7420. */
  7421. static CleanBoneMatrixWeights: boolean;
  7422. }
  7423. }
  7424. declare module BABYLON {
  7425. /**
  7426. * 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.
  7427. * @see https://doc.babylonjs.com/how_to/transformnode
  7428. */
  7429. export class TransformNode extends Node {
  7430. /**
  7431. * Object will not rotate to face the camera
  7432. */
  7433. static BILLBOARDMODE_NONE: number;
  7434. /**
  7435. * Object will rotate to face the camera but only on the x axis
  7436. */
  7437. static BILLBOARDMODE_X: number;
  7438. /**
  7439. * Object will rotate to face the camera but only on the y axis
  7440. */
  7441. static BILLBOARDMODE_Y: number;
  7442. /**
  7443. * Object will rotate to face the camera but only on the z axis
  7444. */
  7445. static BILLBOARDMODE_Z: number;
  7446. /**
  7447. * Object will rotate to face the camera
  7448. */
  7449. static BILLBOARDMODE_ALL: number;
  7450. private _forward;
  7451. private _forwardInverted;
  7452. private _up;
  7453. private _right;
  7454. private _rightInverted;
  7455. private _position;
  7456. private _rotation;
  7457. private _rotationQuaternion;
  7458. protected _scaling: Vector3;
  7459. protected _isDirty: boolean;
  7460. private _transformToBoneReferal;
  7461. private _billboardMode;
  7462. /**
  7463. * Gets or sets the billboard mode. Default is 0.
  7464. *
  7465. * | Value | Type | Description |
  7466. * | --- | --- | --- |
  7467. * | 0 | BILLBOARDMODE_NONE | |
  7468. * | 1 | BILLBOARDMODE_X | |
  7469. * | 2 | BILLBOARDMODE_Y | |
  7470. * | 4 | BILLBOARDMODE_Z | |
  7471. * | 7 | BILLBOARDMODE_ALL | |
  7472. *
  7473. */
  7474. billboardMode: number;
  7475. private _preserveParentRotationForBillboard;
  7476. /**
  7477. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7478. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7479. */
  7480. preserveParentRotationForBillboard: boolean;
  7481. /**
  7482. * 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
  7483. */
  7484. scalingDeterminant: number;
  7485. private _infiniteDistance;
  7486. /**
  7487. * Gets or sets the distance of the object to max, often used by skybox
  7488. */
  7489. infiniteDistance: boolean;
  7490. /**
  7491. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7492. * By default the system will update normals to compensate
  7493. */
  7494. ignoreNonUniformScaling: boolean;
  7495. /**
  7496. * 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
  7497. */
  7498. reIntegrateRotationIntoRotationQuaternion: boolean;
  7499. /** @hidden */ poseMatrix: Nullable<Matrix>;
  7500. /** @hidden */ localMatrix: Matrix;
  7501. private _usePivotMatrix;
  7502. private _absolutePosition;
  7503. private _pivotMatrix;
  7504. private _pivotMatrixInverse;
  7505. protected _postMultiplyPivotMatrix: boolean;
  7506. protected _isWorldMatrixFrozen: boolean;
  7507. /** @hidden */ indexInSceneTransformNodesArray: number;
  7508. /**
  7509. * An event triggered after the world matrix is updated
  7510. */
  7511. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7512. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7513. /**
  7514. * Gets a string identifying the name of the class
  7515. * @returns "TransformNode" string
  7516. */
  7517. getClassName(): string;
  7518. /**
  7519. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7520. */
  7521. position: Vector3;
  7522. /**
  7523. * 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)).
  7524. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7525. */
  7526. rotation: Vector3;
  7527. /**
  7528. * 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)).
  7529. */
  7530. scaling: Vector3;
  7531. /**
  7532. * 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).
  7533. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7534. */
  7535. rotationQuaternion: Nullable<Quaternion>;
  7536. /**
  7537. * The forward direction of that transform in world space.
  7538. */
  7539. readonly forward: Vector3;
  7540. /**
  7541. * The up direction of that transform in world space.
  7542. */
  7543. readonly up: Vector3;
  7544. /**
  7545. * The right direction of that transform in world space.
  7546. */
  7547. readonly right: Vector3;
  7548. /**
  7549. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7550. * @param matrix the matrix to copy the pose from
  7551. * @returns this TransformNode.
  7552. */
  7553. updatePoseMatrix(matrix: Matrix): TransformNode;
  7554. /**
  7555. * Returns the mesh Pose matrix.
  7556. * @returns the pose matrix
  7557. */
  7558. getPoseMatrix(): Matrix;
  7559. /** @hidden */ isSynchronized(): boolean;
  7560. /** @hidden */ initCache(): void;
  7561. /**
  7562. * Flag the transform node as dirty (Forcing it to update everything)
  7563. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7564. * @returns this transform node
  7565. */
  7566. markAsDirty(property: string): TransformNode;
  7567. /**
  7568. * Returns the current mesh absolute position.
  7569. * Returns a Vector3.
  7570. */
  7571. readonly absolutePosition: Vector3;
  7572. /**
  7573. * Sets a new matrix to apply before all other transformation
  7574. * @param matrix defines the transform matrix
  7575. * @returns the current TransformNode
  7576. */
  7577. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7578. /**
  7579. * Sets a new pivot matrix to the current node
  7580. * @param matrix defines the new pivot matrix to use
  7581. * @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
  7582. * @returns the current TransformNode
  7583. */
  7584. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7585. /**
  7586. * Returns the mesh pivot matrix.
  7587. * Default : Identity.
  7588. * @returns the matrix
  7589. */
  7590. getPivotMatrix(): Matrix;
  7591. /**
  7592. * Prevents the World matrix to be computed any longer.
  7593. * @returns the TransformNode.
  7594. */
  7595. freezeWorldMatrix(): TransformNode;
  7596. /**
  7597. * Allows back the World matrix computation.
  7598. * @returns the TransformNode.
  7599. */
  7600. unfreezeWorldMatrix(): this;
  7601. /**
  7602. * True if the World matrix has been frozen.
  7603. */
  7604. readonly isWorldMatrixFrozen: boolean;
  7605. /**
  7606. * Retuns the mesh absolute position in the World.
  7607. * @returns a Vector3.
  7608. */
  7609. getAbsolutePosition(): Vector3;
  7610. /**
  7611. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7612. * @param absolutePosition the absolute position to set
  7613. * @returns the TransformNode.
  7614. */
  7615. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7616. /**
  7617. * Sets the mesh position in its local space.
  7618. * @param vector3 the position to set in localspace
  7619. * @returns the TransformNode.
  7620. */
  7621. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7622. /**
  7623. * Returns the mesh position in the local space from the current World matrix values.
  7624. * @returns a new Vector3.
  7625. */
  7626. getPositionExpressedInLocalSpace(): Vector3;
  7627. /**
  7628. * Translates the mesh along the passed Vector3 in its local space.
  7629. * @param vector3 the distance to translate in localspace
  7630. * @returns the TransformNode.
  7631. */
  7632. locallyTranslate(vector3: Vector3): TransformNode;
  7633. private static _lookAtVectorCache;
  7634. /**
  7635. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7636. * @param targetPoint the position (must be in same space as current mesh) to look at
  7637. * @param yawCor optional yaw (y-axis) correction in radians
  7638. * @param pitchCor optional pitch (x-axis) correction in radians
  7639. * @param rollCor optional roll (z-axis) correction in radians
  7640. * @param space the choosen space of the target
  7641. * @returns the TransformNode.
  7642. */
  7643. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7644. /**
  7645. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7646. * This Vector3 is expressed in the World space.
  7647. * @param localAxis axis to rotate
  7648. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7649. */
  7650. getDirection(localAxis: Vector3): Vector3;
  7651. /**
  7652. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7653. * localAxis is expressed in the mesh local space.
  7654. * result is computed in the Wordl space from the mesh World matrix.
  7655. * @param localAxis axis to rotate
  7656. * @param result the resulting transformnode
  7657. * @returns this TransformNode.
  7658. */
  7659. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7660. /**
  7661. * Sets this transform node rotation to the given local axis.
  7662. * @param localAxis the axis in local space
  7663. * @param yawCor optional yaw (y-axis) correction in radians
  7664. * @param pitchCor optional pitch (x-axis) correction in radians
  7665. * @param rollCor optional roll (z-axis) correction in radians
  7666. * @returns this TransformNode
  7667. */
  7668. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7669. /**
  7670. * Sets a new pivot point to the current node
  7671. * @param point defines the new pivot point to use
  7672. * @param space defines if the point is in world or local space (local by default)
  7673. * @returns the current TransformNode
  7674. */
  7675. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7676. /**
  7677. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7678. * @returns the pivot point
  7679. */
  7680. getPivotPoint(): Vector3;
  7681. /**
  7682. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7683. * @param result the vector3 to store the result
  7684. * @returns this TransformNode.
  7685. */
  7686. getPivotPointToRef(result: Vector3): TransformNode;
  7687. /**
  7688. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7689. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7690. */
  7691. getAbsolutePivotPoint(): Vector3;
  7692. /**
  7693. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7694. * @param result vector3 to store the result
  7695. * @returns this TransformNode.
  7696. */
  7697. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7698. /**
  7699. * Defines the passed node as the parent of the current node.
  7700. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7701. * @see https://doc.babylonjs.com/how_to/parenting
  7702. * @param node the node ot set as the parent
  7703. * @returns this TransformNode.
  7704. */
  7705. setParent(node: Nullable<Node>): TransformNode;
  7706. private _nonUniformScaling;
  7707. /**
  7708. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7709. */
  7710. readonly nonUniformScaling: boolean;
  7711. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7712. /**
  7713. * Attach the current TransformNode to another TransformNode associated with a bone
  7714. * @param bone Bone affecting the TransformNode
  7715. * @param affectedTransformNode TransformNode associated with the bone
  7716. * @returns this object
  7717. */
  7718. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7719. /**
  7720. * Detach the transform node if its associated with a bone
  7721. * @returns this object
  7722. */
  7723. detachFromBone(): TransformNode;
  7724. private static _rotationAxisCache;
  7725. /**
  7726. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7727. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7728. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7729. * The passed axis is also normalized.
  7730. * @param axis the axis to rotate around
  7731. * @param amount the amount to rotate in radians
  7732. * @param space Space to rotate in (Default: local)
  7733. * @returns the TransformNode.
  7734. */
  7735. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7736. /**
  7737. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7738. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7739. * The passed axis is also normalized. .
  7740. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7741. * @param point the point to rotate around
  7742. * @param axis the axis to rotate around
  7743. * @param amount the amount to rotate in radians
  7744. * @returns the TransformNode
  7745. */
  7746. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7747. /**
  7748. * Translates the mesh along the axis vector for the passed distance in the given space.
  7749. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7750. * @param axis the axis to translate in
  7751. * @param distance the distance to translate
  7752. * @param space Space to rotate in (Default: local)
  7753. * @returns the TransformNode.
  7754. */
  7755. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7756. /**
  7757. * Adds a rotation step to the mesh current rotation.
  7758. * x, y, z are Euler angles expressed in radians.
  7759. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7760. * This means this rotation is made in the mesh local space only.
  7761. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7762. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7763. * ```javascript
  7764. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7765. * ```
  7766. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7767. * 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.
  7768. * @param x Rotation to add
  7769. * @param y Rotation to add
  7770. * @param z Rotation to add
  7771. * @returns the TransformNode.
  7772. */
  7773. addRotation(x: number, y: number, z: number): TransformNode;
  7774. /**
  7775. * @hidden
  7776. */
  7777. protected _getEffectiveParent(): Nullable<Node>;
  7778. /**
  7779. * Computes the world matrix of the node
  7780. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7781. * @returns the world matrix
  7782. */
  7783. computeWorldMatrix(force?: boolean): Matrix;
  7784. protected _afterComputeWorldMatrix(): void;
  7785. /**
  7786. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7787. * @param func callback function to add
  7788. *
  7789. * @returns the TransformNode.
  7790. */
  7791. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7792. /**
  7793. * Removes a registered callback function.
  7794. * @param func callback function to remove
  7795. * @returns the TransformNode.
  7796. */
  7797. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7798. /**
  7799. * Gets the position of the current mesh in camera space
  7800. * @param camera defines the camera to use
  7801. * @returns a position
  7802. */
  7803. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7804. /**
  7805. * Returns the distance from the mesh to the active camera
  7806. * @param camera defines the camera to use
  7807. * @returns the distance
  7808. */
  7809. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7810. /**
  7811. * Clone the current transform node
  7812. * @param name Name of the new clone
  7813. * @param newParent New parent for the clone
  7814. * @param doNotCloneChildren Do not clone children hierarchy
  7815. * @returns the new transform node
  7816. */
  7817. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7818. /**
  7819. * Serializes the objects information.
  7820. * @param currentSerializationObject defines the object to serialize in
  7821. * @returns the serialized object
  7822. */
  7823. serialize(currentSerializationObject?: any): any;
  7824. /**
  7825. * Returns a new TransformNode object parsed from the source provided.
  7826. * @param parsedTransformNode is the source.
  7827. * @param scene the scne the object belongs to
  7828. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7829. * @returns a new TransformNode object parsed from the source provided.
  7830. */
  7831. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7832. /**
  7833. * Get all child-transformNodes of this node
  7834. * @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
  7835. * @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
  7836. * @returns an array of TransformNode
  7837. */
  7838. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7839. /**
  7840. * Releases resources associated with this transform node.
  7841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7843. */
  7844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7845. }
  7846. }
  7847. declare module BABYLON {
  7848. /**
  7849. * Class used to override all child animations of a given target
  7850. */
  7851. export class AnimationPropertiesOverride {
  7852. /**
  7853. * Gets or sets a value indicating if animation blending must be used
  7854. */
  7855. enableBlending: boolean;
  7856. /**
  7857. * Gets or sets the blending speed to use when enableBlending is true
  7858. */
  7859. blendingSpeed: number;
  7860. /**
  7861. * Gets or sets the default loop mode to use
  7862. */
  7863. loopMode: number;
  7864. }
  7865. }
  7866. declare module BABYLON {
  7867. /**
  7868. * Class used to store bone information
  7869. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7870. */
  7871. export class Bone extends Node {
  7872. /**
  7873. * defines the bone name
  7874. */
  7875. name: string;
  7876. private static _tmpVecs;
  7877. private static _tmpQuat;
  7878. private static _tmpMats;
  7879. /**
  7880. * Gets the list of child bones
  7881. */
  7882. children: Bone[];
  7883. /** Gets the animations associated with this bone */
  7884. animations: Animation[];
  7885. /**
  7886. * Gets or sets bone length
  7887. */
  7888. length: number;
  7889. /**
  7890. * @hidden Internal only
  7891. * Set this value to map this bone to a different index in the transform matrices
  7892. * Set this value to -1 to exclude the bone from the transform matrices
  7893. */ index: Nullable<number>;
  7894. private _skeleton;
  7895. private _localMatrix;
  7896. private _restPose;
  7897. private _baseMatrix;
  7898. private _absoluteTransform;
  7899. private _invertedAbsoluteTransform;
  7900. private _parent;
  7901. private _scalingDeterminant;
  7902. private _worldTransform;
  7903. private _localScaling;
  7904. private _localRotation;
  7905. private _localPosition;
  7906. private _needToDecompose;
  7907. private _needToCompose;
  7908. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7909. /** @hidden */
  7910. /** @hidden */ matrix: Matrix;
  7911. /**
  7912. * Create a new bone
  7913. * @param name defines the bone name
  7914. * @param skeleton defines the parent skeleton
  7915. * @param parentBone defines the parent (can be null if the bone is the root)
  7916. * @param localMatrix defines the local matrix
  7917. * @param restPose defines the rest pose matrix
  7918. * @param baseMatrix defines the base matrix
  7919. * @param index defines index of the bone in the hiearchy
  7920. */
  7921. constructor(
  7922. /**
  7923. * defines the bone name
  7924. */
  7925. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7926. /**
  7927. * Gets the current object class name.
  7928. * @return the class name
  7929. */
  7930. getClassName(): string;
  7931. /**
  7932. * Gets the parent skeleton
  7933. * @returns a skeleton
  7934. */
  7935. getSkeleton(): Skeleton;
  7936. /**
  7937. * Gets parent bone
  7938. * @returns a bone or null if the bone is the root of the bone hierarchy
  7939. */
  7940. getParent(): Nullable<Bone>;
  7941. /**
  7942. * Returns an array containing the root bones
  7943. * @returns an array containing the root bones
  7944. */
  7945. getChildren(): Array<Bone>;
  7946. /**
  7947. * Sets the parent bone
  7948. * @param parent defines the parent (can be null if the bone is the root)
  7949. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7950. */
  7951. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7952. /**
  7953. * Gets the local matrix
  7954. * @returns a matrix
  7955. */
  7956. getLocalMatrix(): Matrix;
  7957. /**
  7958. * Gets the base matrix (initial matrix which remains unchanged)
  7959. * @returns a matrix
  7960. */
  7961. getBaseMatrix(): Matrix;
  7962. /**
  7963. * Gets the rest pose matrix
  7964. * @returns a matrix
  7965. */
  7966. getRestPose(): Matrix;
  7967. /**
  7968. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7969. */
  7970. getWorldMatrix(): Matrix;
  7971. /**
  7972. * Sets the local matrix to rest pose matrix
  7973. */
  7974. returnToRest(): void;
  7975. /**
  7976. * Gets the inverse of the absolute transform matrix.
  7977. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7978. * @returns a matrix
  7979. */
  7980. getInvertedAbsoluteTransform(): Matrix;
  7981. /**
  7982. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7983. * @returns a matrix
  7984. */
  7985. getAbsoluteTransform(): Matrix;
  7986. /**
  7987. * Links with the given transform node.
  7988. * The local matrix of this bone is copied from the transform node every frame.
  7989. * @param transformNode defines the transform node to link to
  7990. */
  7991. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7992. /** Gets or sets current position (in local space) */
  7993. position: Vector3;
  7994. /** Gets or sets current rotation (in local space) */
  7995. rotation: Vector3;
  7996. /** Gets or sets current rotation quaternion (in local space) */
  7997. rotationQuaternion: Quaternion;
  7998. /** Gets or sets current scaling (in local space) */
  7999. scaling: Vector3;
  8000. /**
  8001. * Gets the animation properties override
  8002. */
  8003. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8004. private _decompose;
  8005. private _compose;
  8006. /**
  8007. * Update the base and local matrices
  8008. * @param matrix defines the new base or local matrix
  8009. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8010. * @param updateLocalMatrix defines if the local matrix should be updated
  8011. */
  8012. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8013. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8014. /**
  8015. * Flag the bone as dirty (Forcing it to update everything)
  8016. */
  8017. markAsDirty(): void;
  8018. private _markAsDirtyAndCompose;
  8019. private _markAsDirtyAndDecompose;
  8020. /**
  8021. * Translate the bone in local or world space
  8022. * @param vec The amount to translate the bone
  8023. * @param space The space that the translation is in
  8024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8025. */
  8026. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8027. /**
  8028. * Set the postion of the bone in local or world space
  8029. * @param position The position to set the bone
  8030. * @param space The space that the position is in
  8031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8032. */
  8033. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8034. /**
  8035. * Set the absolute position of the bone (world space)
  8036. * @param position The position to set the bone
  8037. * @param mesh The mesh that this bone is attached to
  8038. */
  8039. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8040. /**
  8041. * Scale the bone on the x, y and z axes (in local space)
  8042. * @param x The amount to scale the bone on the x axis
  8043. * @param y The amount to scale the bone on the y axis
  8044. * @param z The amount to scale the bone on the z axis
  8045. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8046. */
  8047. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8048. /**
  8049. * Set the bone scaling in local space
  8050. * @param scale defines the scaling vector
  8051. */
  8052. setScale(scale: Vector3): void;
  8053. /**
  8054. * Gets the current scaling in local space
  8055. * @returns the current scaling vector
  8056. */
  8057. getScale(): Vector3;
  8058. /**
  8059. * Gets the current scaling in local space and stores it in a target vector
  8060. * @param result defines the target vector
  8061. */
  8062. getScaleToRef(result: Vector3): void;
  8063. /**
  8064. * Set the yaw, pitch, and roll of the bone in local or world space
  8065. * @param yaw The rotation of the bone on the y axis
  8066. * @param pitch The rotation of the bone on the x axis
  8067. * @param roll The rotation of the bone on the z axis
  8068. * @param space The space that the axes of rotation are in
  8069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8070. */
  8071. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8072. /**
  8073. * Add a rotation to the bone on an axis in local or world space
  8074. * @param axis The axis to rotate the bone on
  8075. * @param amount The amount to rotate the bone
  8076. * @param space The space that the axis is in
  8077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8078. */
  8079. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8080. /**
  8081. * Set the rotation of the bone to a particular axis angle in local or world space
  8082. * @param axis The axis to rotate the bone on
  8083. * @param angle The angle that the bone should be rotated to
  8084. * @param space The space that the axis is in
  8085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8086. */
  8087. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8088. /**
  8089. * Set the euler rotation of the bone in local of world space
  8090. * @param rotation The euler rotation that the bone should be set to
  8091. * @param space The space that the rotation is in
  8092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8093. */
  8094. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8095. /**
  8096. * Set the quaternion rotation of the bone in local of world space
  8097. * @param quat The quaternion rotation that the bone should be set to
  8098. * @param space The space that the rotation is in
  8099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8100. */
  8101. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8102. /**
  8103. * Set the rotation matrix of the bone in local of world space
  8104. * @param rotMat The rotation matrix that the bone should be set to
  8105. * @param space The space that the rotation is in
  8106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8107. */
  8108. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8109. private _rotateWithMatrix;
  8110. private _getNegativeRotationToRef;
  8111. /**
  8112. * Get the position of the bone in local or world space
  8113. * @param space The space that the returned position is in
  8114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8115. * @returns The position of the bone
  8116. */
  8117. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8118. /**
  8119. * Copy the position of the bone to a vector3 in local or world space
  8120. * @param space The space that the returned position is in
  8121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8122. * @param result The vector3 to copy the position to
  8123. */
  8124. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8125. /**
  8126. * Get the absolute position of the bone (world space)
  8127. * @param mesh The mesh that this bone is attached to
  8128. * @returns The absolute position of the bone
  8129. */
  8130. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8131. /**
  8132. * Copy the absolute position of the bone (world space) to the result param
  8133. * @param mesh The mesh that this bone is attached to
  8134. * @param result The vector3 to copy the absolute position to
  8135. */
  8136. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8137. /**
  8138. * Compute the absolute transforms of this bone and its children
  8139. */
  8140. computeAbsoluteTransforms(): void;
  8141. /**
  8142. * Get the world direction from an axis that is in the local space of the bone
  8143. * @param localAxis The local direction that is used to compute the world direction
  8144. * @param mesh The mesh that this bone is attached to
  8145. * @returns The world direction
  8146. */
  8147. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8148. /**
  8149. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8150. * @param localAxis The local direction that is used to compute the world direction
  8151. * @param mesh The mesh that this bone is attached to
  8152. * @param result The vector3 that the world direction will be copied to
  8153. */
  8154. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8155. /**
  8156. * Get the euler rotation of the bone in local or world space
  8157. * @param space The space that the rotation should be in
  8158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8159. * @returns The euler rotation
  8160. */
  8161. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8162. /**
  8163. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8164. * @param space The space that the rotation should be in
  8165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8166. * @param result The vector3 that the rotation should be copied to
  8167. */
  8168. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8169. /**
  8170. * Get the quaternion rotation of the bone in either local or world space
  8171. * @param space The space that the rotation should be in
  8172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8173. * @returns The quaternion rotation
  8174. */
  8175. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8176. /**
  8177. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8178. * @param space The space that the rotation should be in
  8179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8180. * @param result The quaternion that the rotation should be copied to
  8181. */
  8182. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8183. /**
  8184. * Get the rotation matrix of the bone in local or world space
  8185. * @param space The space that the rotation should be in
  8186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8187. * @returns The rotation matrix
  8188. */
  8189. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8190. /**
  8191. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8192. * @param space The space that the rotation should be in
  8193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8194. * @param result The quaternion that the rotation should be copied to
  8195. */
  8196. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8197. /**
  8198. * Get the world position of a point that is in the local space of the bone
  8199. * @param position The local position
  8200. * @param mesh The mesh that this bone is attached to
  8201. * @returns The world position
  8202. */
  8203. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8204. /**
  8205. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8206. * @param position The local position
  8207. * @param mesh The mesh that this bone is attached to
  8208. * @param result The vector3 that the world position should be copied to
  8209. */
  8210. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8211. /**
  8212. * Get the local position of a point that is in world space
  8213. * @param position The world position
  8214. * @param mesh The mesh that this bone is attached to
  8215. * @returns The local position
  8216. */
  8217. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8218. /**
  8219. * Get the local position of a point that is in world space and copy it to the result param
  8220. * @param position The world position
  8221. * @param mesh The mesh that this bone is attached to
  8222. * @param result The vector3 that the local position should be copied to
  8223. */
  8224. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8225. }
  8226. }
  8227. declare module BABYLON {
  8228. /**
  8229. * Enum that determines the text-wrapping mode to use.
  8230. */
  8231. export enum InspectableType {
  8232. /**
  8233. * Checkbox for booleans
  8234. */
  8235. Checkbox = 0,
  8236. /**
  8237. * Sliders for numbers
  8238. */
  8239. Slider = 1,
  8240. /**
  8241. * Vector3
  8242. */
  8243. Vector3 = 2,
  8244. /**
  8245. * Quaternions
  8246. */
  8247. Quaternion = 3,
  8248. /**
  8249. * Color3
  8250. */
  8251. Color3 = 4
  8252. }
  8253. /**
  8254. * Interface used to define custom inspectable properties.
  8255. * This interface is used by the inspector to display custom property grids
  8256. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8257. */
  8258. export interface IInspectable {
  8259. /**
  8260. * Gets the label to display
  8261. */
  8262. label: string;
  8263. /**
  8264. * Gets the name of the property to edit
  8265. */
  8266. propertyName: string;
  8267. /**
  8268. * Gets the type of the editor to use
  8269. */
  8270. type: InspectableType;
  8271. /**
  8272. * Gets the minimum value of the property when using in "slider" mode
  8273. */
  8274. min?: number;
  8275. /**
  8276. * Gets the maximum value of the property when using in "slider" mode
  8277. */
  8278. max?: number;
  8279. /**
  8280. * Gets the setp to use when using in "slider" mode
  8281. */
  8282. step?: number;
  8283. }
  8284. }
  8285. declare module BABYLON {
  8286. /**
  8287. * This represents the required contract to create a new type of texture loader.
  8288. */
  8289. export interface IInternalTextureLoader {
  8290. /**
  8291. * Defines wether the loader supports cascade loading the different faces.
  8292. */
  8293. supportCascades: boolean;
  8294. /**
  8295. * This returns if the loader support the current file information.
  8296. * @param extension defines the file extension of the file being loaded
  8297. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8298. * @param fallback defines the fallback internal texture if any
  8299. * @param isBase64 defines whether the texture is encoded as a base64
  8300. * @param isBuffer defines whether the texture data are stored as a buffer
  8301. * @returns true if the loader can load the specified file
  8302. */
  8303. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8304. /**
  8305. * Transform the url before loading if required.
  8306. * @param rootUrl the url of the texture
  8307. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8308. * @returns the transformed texture
  8309. */
  8310. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8311. /**
  8312. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8313. * @param rootUrl the url of the texture
  8314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8315. * @returns the fallback texture
  8316. */
  8317. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8318. /**
  8319. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8320. * @param data contains the texture data
  8321. * @param texture defines the BabylonJS internal texture
  8322. * @param createPolynomials will be true if polynomials have been requested
  8323. * @param onLoad defines the callback to trigger once the texture is ready
  8324. * @param onError defines the callback to trigger in case of error
  8325. */
  8326. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8327. /**
  8328. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8329. * @param data contains the texture data
  8330. * @param texture defines the BabylonJS internal texture
  8331. * @param callback defines the method to call once ready to upload
  8332. */
  8333. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8334. }
  8335. }
  8336. declare module BABYLON {
  8337. interface Engine {
  8338. /**
  8339. * Creates a depth stencil cube texture.
  8340. * This is only available in WebGL 2.
  8341. * @param size The size of face edge in the cube texture.
  8342. * @param options The options defining the cube texture.
  8343. * @returns The cube texture
  8344. */ createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8345. /**
  8346. * Creates a cube texture
  8347. * @param rootUrl defines the url where the files to load is located
  8348. * @param scene defines the current scene
  8349. * @param files defines the list of files to load (1 per face)
  8350. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8351. * @param onLoad defines an optional callback raised when the texture is loaded
  8352. * @param onError defines an optional callback raised if there is an issue to load the texture
  8353. * @param format defines the format of the data
  8354. * @param forcedExtension defines the extension to use to pick the right loader
  8355. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8356. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8357. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8358. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8359. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8360. * @returns the cube texture as an InternalTexture
  8361. */
  8362. 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;
  8363. /**
  8364. * Creates a cube texture
  8365. * @param rootUrl defines the url where the files to load is located
  8366. * @param scene defines the current scene
  8367. * @param files defines the list of files to load (1 per face)
  8368. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8369. * @param onLoad defines an optional callback raised when the texture is loaded
  8370. * @param onError defines an optional callback raised if there is an issue to load the texture
  8371. * @param format defines the format of the data
  8372. * @param forcedExtension defines the extension to use to pick the right loader
  8373. * @returns the cube texture as an InternalTexture
  8374. */
  8375. 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;
  8376. /**
  8377. * Creates a cube texture
  8378. * @param rootUrl defines the url where the files to load is located
  8379. * @param scene defines the current scene
  8380. * @param files defines the list of files to load (1 per face)
  8381. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8382. * @param onLoad defines an optional callback raised when the texture is loaded
  8383. * @param onError defines an optional callback raised if there is an issue to load the texture
  8384. * @param format defines the format of the data
  8385. * @param forcedExtension defines the extension to use to pick the right loader
  8386. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8387. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8388. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8389. * @returns the cube texture as an InternalTexture
  8390. */
  8391. 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;
  8392. /** @hidden */ partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8393. /** @hidden */ cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8394. /** @hidden */ cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8395. /** @hidden */ partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8396. }
  8397. }
  8398. declare module BABYLON {
  8399. /**
  8400. * Class for creating a cube texture
  8401. */
  8402. export class CubeTexture extends BaseTexture {
  8403. private _delayedOnLoad;
  8404. /**
  8405. * The url of the texture
  8406. */
  8407. url: string;
  8408. /**
  8409. * Gets or sets the center of the bounding box associated with the cube texture.
  8410. * It must define where the camera used to render the texture was set
  8411. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8412. */
  8413. boundingBoxPosition: Vector3;
  8414. private _boundingBoxSize;
  8415. /**
  8416. * Gets or sets the size of the bounding box associated with the cube texture
  8417. * When defined, the cubemap will switch to local mode
  8418. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8419. * @example https://www.babylonjs-playground.com/#RNASML
  8420. */
  8421. /**
  8422. * Returns the bounding box size
  8423. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8424. */
  8425. boundingBoxSize: Vector3;
  8426. protected _rotationY: number;
  8427. /**
  8428. * Sets texture matrix rotation angle around Y axis in radians.
  8429. */
  8430. /**
  8431. * Gets texture matrix rotation angle around Y axis radians.
  8432. */
  8433. rotationY: number;
  8434. /**
  8435. * Are mip maps generated for this texture or not.
  8436. */
  8437. readonly noMipmap: boolean;
  8438. private _noMipmap;
  8439. private _files;
  8440. private _extensions;
  8441. private _textureMatrix;
  8442. private _format;
  8443. private _createPolynomials;
  8444. /** @hidden */ prefiltered: boolean;
  8445. /**
  8446. * Creates a cube texture from an array of image urls
  8447. * @param files defines an array of image urls
  8448. * @param scene defines the hosting scene
  8449. * @param noMipmap specifies if mip maps are not used
  8450. * @returns a cube texture
  8451. */
  8452. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8453. /**
  8454. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8455. * @param url defines the url of the prefiltered texture
  8456. * @param scene defines the scene the texture is attached to
  8457. * @param forcedExtension defines the extension of the file if different from the url
  8458. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8459. * @return the prefiltered texture
  8460. */
  8461. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8462. /**
  8463. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8464. * as prefiltered data.
  8465. * @param rootUrl defines the url of the texture or the root name of the six images
  8466. * @param scene defines the scene the texture is attached to
  8467. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8468. * @param noMipmap defines if mipmaps should be created or not
  8469. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8470. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8471. * @param onError defines a callback triggered in case of error during load
  8472. * @param format defines the internal format to use for the texture once loaded
  8473. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8474. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8475. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8478. * @return the cube texture
  8479. */
  8480. 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);
  8481. /**
  8482. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8483. */
  8484. readonly isPrefiltered: boolean;
  8485. /**
  8486. * Get the current class name of the texture useful for serialization or dynamic coding.
  8487. * @returns "CubeTexture"
  8488. */
  8489. getClassName(): string;
  8490. /**
  8491. * Update the url (and optional buffer) of this texture if url was null during construction.
  8492. * @param url the url of the texture
  8493. * @param forcedExtension defines the extension to use
  8494. * @param onLoad callback called when the texture is loaded (defaults to null)
  8495. */
  8496. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8497. /**
  8498. * Delays loading of the cube texture
  8499. * @param forcedExtension defines the extension to use
  8500. */
  8501. delayLoad(forcedExtension?: string): void;
  8502. /**
  8503. * Returns the reflection texture matrix
  8504. * @returns the reflection texture matrix
  8505. */
  8506. getReflectionTextureMatrix(): Matrix;
  8507. /**
  8508. * Sets the reflection texture matrix
  8509. * @param value Reflection texture matrix
  8510. */
  8511. setReflectionTextureMatrix(value: Matrix): void;
  8512. /**
  8513. * Parses text to create a cube texture
  8514. * @param parsedTexture define the serialized text to read from
  8515. * @param scene defines the hosting scene
  8516. * @param rootUrl defines the root url of the cube texture
  8517. * @returns a cube texture
  8518. */
  8519. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8520. /**
  8521. * Makes a clone, or deep copy, of the cube texture
  8522. * @returns a new cube texture
  8523. */
  8524. clone(): CubeTexture;
  8525. }
  8526. }
  8527. declare module BABYLON {
  8528. /** @hidden */
  8529. export var postprocessVertexShader: {
  8530. name: string;
  8531. shader: string;
  8532. };
  8533. }
  8534. declare module BABYLON {
  8535. /**
  8536. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8537. * This is the base of the follow, arc rotate cameras and Free camera
  8538. * @see http://doc.babylonjs.com/features/cameras
  8539. */
  8540. export class TargetCamera extends Camera {
  8541. private static _RigCamTransformMatrix;
  8542. private static _TargetTransformMatrix;
  8543. private static _TargetFocalPoint;
  8544. /**
  8545. * Define the current direction the camera is moving to
  8546. */
  8547. cameraDirection: Vector3;
  8548. /**
  8549. * Define the current rotation the camera is rotating to
  8550. */
  8551. cameraRotation: Vector2;
  8552. /**
  8553. * When set, the up vector of the camera will be updated by the rotation of the camera
  8554. */
  8555. updateUpVectorFromRotation: boolean;
  8556. private _tmpQuaternion;
  8557. /**
  8558. * Define the current rotation of the camera
  8559. */
  8560. rotation: Vector3;
  8561. /**
  8562. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8563. */
  8564. rotationQuaternion: Quaternion;
  8565. /**
  8566. * Define the current speed of the camera
  8567. */
  8568. speed: number;
  8569. /**
  8570. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8571. * around all axis.
  8572. */
  8573. noRotationConstraint: boolean;
  8574. /**
  8575. * Define the current target of the camera as an object or a position.
  8576. */
  8577. lockedTarget: any;
  8578. /** @hidden */ currentTarget: Vector3;
  8579. /** @hidden */ initialFocalDistance: number;
  8580. /** @hidden */ viewMatrix: Matrix;
  8581. /** @hidden */ camMatrix: Matrix;
  8582. /** @hidden */ cameraTransformMatrix: Matrix;
  8583. /** @hidden */ cameraRotationMatrix: Matrix;
  8584. /** @hidden */ referencePoint: Vector3;
  8585. /** @hidden */ transformedReferencePoint: Vector3;
  8586. protected _globalCurrentTarget: Vector3;
  8587. protected _globalCurrentUpVector: Vector3;
  8588. /** @hidden */ reset: () => void;
  8589. private _defaultUp;
  8590. /**
  8591. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8592. * This is the base of the follow, arc rotate cameras and Free camera
  8593. * @see http://doc.babylonjs.com/features/cameras
  8594. * @param name Defines the name of the camera in the scene
  8595. * @param position Defines the start position of the camera in the scene
  8596. * @param scene Defines the scene the camera belongs to
  8597. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8598. */
  8599. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8600. /**
  8601. * Gets the position in front of the camera at a given distance.
  8602. * @param distance The distance from the camera we want the position to be
  8603. * @returns the position
  8604. */
  8605. getFrontPosition(distance: number): Vector3;
  8606. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8607. private _storedPosition;
  8608. private _storedRotation;
  8609. private _storedRotationQuaternion;
  8610. /**
  8611. * Store current camera state of the camera (fov, position, rotation, etc..)
  8612. * @returns the camera
  8613. */
  8614. storeState(): Camera;
  8615. /**
  8616. * Restored camera state. You must call storeState() first
  8617. * @returns whether it was successful or not
  8618. * @hidden
  8619. */ restoreStateValues(): boolean;
  8620. /** @hidden */ initCache(): void;
  8621. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8622. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8623. /** @hidden */ computeLocalCameraSpeed(): number;
  8624. /**
  8625. * Defines the target the camera should look at.
  8626. * This will automatically adapt alpha beta and radius to fit within the new target.
  8627. * @param target Defines the new target as a Vector or a mesh
  8628. */
  8629. setTarget(target: Vector3): void;
  8630. /**
  8631. * Return the current target position of the camera. This value is expressed in local space.
  8632. * @returns the target position
  8633. */
  8634. getTarget(): Vector3;
  8635. /** @hidden */ decideIfNeedsToMove(): boolean;
  8636. /** @hidden */ updatePosition(): void;
  8637. /** @hidden */ checkInputs(): void;
  8638. protected _updateCameraRotationMatrix(): void;
  8639. /**
  8640. * 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)
  8641. * @returns the current camera
  8642. */
  8643. private _rotateUpVectorWithCameraRotationMatrix;
  8644. private _cachedRotationZ;
  8645. private _cachedQuaternionRotationZ;
  8646. /** @hidden */ getViewMatrix(): Matrix;
  8647. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8648. /**
  8649. * @hidden
  8650. */
  8651. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8652. /**
  8653. * @hidden
  8654. */ updateRigCameras(): void;
  8655. private _getRigCamPositionAndTarget;
  8656. /**
  8657. * Gets the current object class name.
  8658. * @return the class name
  8659. */
  8660. getClassName(): string;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /**
  8665. * @ignore
  8666. * This is a list of all the different input types that are available in the application.
  8667. * Fo instance: ArcRotateCameraGamepadInput...
  8668. */
  8669. export var CameraInputTypes: {};
  8670. /**
  8671. * This is the contract to implement in order to create a new input class.
  8672. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8673. */
  8674. export interface ICameraInput<TCamera extends Camera> {
  8675. /**
  8676. * Defines the camera the input is attached to.
  8677. */
  8678. camera: Nullable<TCamera>;
  8679. /**
  8680. * Gets the class name of the current intput.
  8681. * @returns the class name
  8682. */
  8683. getClassName(): string;
  8684. /**
  8685. * Get the friendly name associated with the input class.
  8686. * @returns the input friendly name
  8687. */
  8688. getSimpleName(): string;
  8689. /**
  8690. * Attach the input controls to a specific dom element to get the input from.
  8691. * @param element Defines the element the controls should be listened from
  8692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8693. */
  8694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8695. /**
  8696. * Detach the current controls from the specified dom element.
  8697. * @param element Defines the element to stop listening the inputs from
  8698. */
  8699. detachControl(element: Nullable<HTMLElement>): void;
  8700. /**
  8701. * Update the current camera state depending on the inputs that have been used this frame.
  8702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8703. */
  8704. checkInputs?: () => void;
  8705. }
  8706. /**
  8707. * Represents a map of input types to input instance or input index to input instance.
  8708. */
  8709. export interface CameraInputsMap<TCamera extends Camera> {
  8710. /**
  8711. * Accessor to the input by input type.
  8712. */
  8713. [name: string]: ICameraInput<TCamera>;
  8714. /**
  8715. * Accessor to the input by input index.
  8716. */
  8717. [idx: number]: ICameraInput<TCamera>;
  8718. }
  8719. /**
  8720. * This represents the input manager used within a camera.
  8721. * It helps dealing with all the different kind of input attached to a camera.
  8722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8723. */
  8724. export class CameraInputsManager<TCamera extends Camera> {
  8725. /**
  8726. * Defines the list of inputs attahed to the camera.
  8727. */
  8728. attached: CameraInputsMap<TCamera>;
  8729. /**
  8730. * Defines the dom element the camera is collecting inputs from.
  8731. * This is null if the controls have not been attached.
  8732. */
  8733. attachedElement: Nullable<HTMLElement>;
  8734. /**
  8735. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8736. */
  8737. noPreventDefault: boolean;
  8738. /**
  8739. * Defined the camera the input manager belongs to.
  8740. */
  8741. camera: TCamera;
  8742. /**
  8743. * Update the current camera state depending on the inputs that have been used this frame.
  8744. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8745. */
  8746. checkInputs: () => void;
  8747. /**
  8748. * Instantiate a new Camera Input Manager.
  8749. * @param camera Defines the camera the input manager blongs to
  8750. */
  8751. constructor(camera: TCamera);
  8752. /**
  8753. * Add an input method to a camera
  8754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8755. * @param input camera input method
  8756. */
  8757. add(input: ICameraInput<TCamera>): void;
  8758. /**
  8759. * Remove a specific input method from a camera
  8760. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8761. * @param inputToRemove camera input method
  8762. */
  8763. remove(inputToRemove: ICameraInput<TCamera>): void;
  8764. /**
  8765. * Remove a specific input type from a camera
  8766. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8767. * @param inputType the type of the input to remove
  8768. */
  8769. removeByType(inputType: string): void;
  8770. private _addCheckInputs;
  8771. /**
  8772. * Attach the input controls to the currently attached dom element to listen the events from.
  8773. * @param input Defines the input to attach
  8774. */
  8775. attachInput(input: ICameraInput<TCamera>): void;
  8776. /**
  8777. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8778. * @param element Defines the dom element to collect the events from
  8779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8780. */
  8781. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8782. /**
  8783. * Detach the current manager inputs controls from a specific dom element.
  8784. * @param element Defines the dom element to collect the events from
  8785. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8786. */
  8787. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8788. /**
  8789. * Rebuild the dynamic inputCheck function from the current list of
  8790. * defined inputs in the manager.
  8791. */
  8792. rebuildInputCheck(): void;
  8793. /**
  8794. * Remove all attached input methods from a camera
  8795. */
  8796. clear(): void;
  8797. /**
  8798. * Serialize the current input manager attached to a camera.
  8799. * This ensures than once parsed,
  8800. * the input associated to the camera will be identical to the current ones
  8801. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8802. */
  8803. serialize(serializedCamera: any): void;
  8804. /**
  8805. * Parses an input manager serialized JSON to restore the previous list of inputs
  8806. * and states associated to a camera.
  8807. * @param parsedCamera Defines the JSON to parse
  8808. */
  8809. parse(parsedCamera: any): void;
  8810. }
  8811. }
  8812. declare module BABYLON {
  8813. /**
  8814. * Gather the list of keyboard event types as constants.
  8815. */
  8816. export class KeyboardEventTypes {
  8817. /**
  8818. * The keydown event is fired when a key becomes active (pressed).
  8819. */
  8820. static readonly KEYDOWN: number;
  8821. /**
  8822. * The keyup event is fired when a key has been released.
  8823. */
  8824. static readonly KEYUP: number;
  8825. }
  8826. /**
  8827. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8828. */
  8829. export class KeyboardInfo {
  8830. /**
  8831. * Defines the type of event (KeyboardEventTypes)
  8832. */
  8833. type: number;
  8834. /**
  8835. * Defines the related dom event
  8836. */
  8837. event: KeyboardEvent;
  8838. /**
  8839. * Instantiates a new keyboard info.
  8840. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8841. * @param type Defines the type of event (KeyboardEventTypes)
  8842. * @param event Defines the related dom event
  8843. */
  8844. constructor(
  8845. /**
  8846. * Defines the type of event (KeyboardEventTypes)
  8847. */
  8848. type: number,
  8849. /**
  8850. * Defines the related dom event
  8851. */
  8852. event: KeyboardEvent);
  8853. }
  8854. /**
  8855. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8856. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8857. */
  8858. export class KeyboardInfoPre extends KeyboardInfo {
  8859. /**
  8860. * Defines the type of event (KeyboardEventTypes)
  8861. */
  8862. type: number;
  8863. /**
  8864. * Defines the related dom event
  8865. */
  8866. event: KeyboardEvent;
  8867. /**
  8868. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8869. */
  8870. skipOnPointerObservable: boolean;
  8871. /**
  8872. * Instantiates a new keyboard pre info.
  8873. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8874. * @param type Defines the type of event (KeyboardEventTypes)
  8875. * @param event Defines the related dom event
  8876. */
  8877. constructor(
  8878. /**
  8879. * Defines the type of event (KeyboardEventTypes)
  8880. */
  8881. type: number,
  8882. /**
  8883. * Defines the related dom event
  8884. */
  8885. event: KeyboardEvent);
  8886. }
  8887. }
  8888. declare module BABYLON {
  8889. /**
  8890. * Manage the keyboard inputs to control the movement of a free camera.
  8891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8892. */
  8893. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8894. /**
  8895. * Defines the camera the input is attached to.
  8896. */
  8897. camera: FreeCamera;
  8898. /**
  8899. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8900. */
  8901. keysUp: number[];
  8902. /**
  8903. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8904. */
  8905. keysDown: number[];
  8906. /**
  8907. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8908. */
  8909. keysLeft: number[];
  8910. /**
  8911. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8912. */
  8913. keysRight: number[];
  8914. private _keys;
  8915. private _onCanvasBlurObserver;
  8916. private _onKeyboardObserver;
  8917. private _engine;
  8918. private _scene;
  8919. /**
  8920. * Attach the input controls to a specific dom element to get the input from.
  8921. * @param element Defines the element the controls should be listened from
  8922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8923. */
  8924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8925. /**
  8926. * Detach the current controls from the specified dom element.
  8927. * @param element Defines the element to stop listening the inputs from
  8928. */
  8929. detachControl(element: Nullable<HTMLElement>): void;
  8930. /**
  8931. * Update the current camera state depending on the inputs that have been used this frame.
  8932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8933. */
  8934. checkInputs(): void;
  8935. /**
  8936. * Gets the class name of the current intput.
  8937. * @returns the class name
  8938. */
  8939. getClassName(): string;
  8940. /** @hidden */ onLostFocus(): void;
  8941. /**
  8942. * Get the friendly name associated with the input class.
  8943. * @returns the input friendly name
  8944. */
  8945. getSimpleName(): string;
  8946. }
  8947. }
  8948. declare module BABYLON {
  8949. /**
  8950. * Interface describing all the common properties and methods a shadow light needs to implement.
  8951. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8952. * as well as binding the different shadow properties to the effects.
  8953. */
  8954. export interface IShadowLight extends Light {
  8955. /**
  8956. * The light id in the scene (used in scene.findLighById for instance)
  8957. */
  8958. id: string;
  8959. /**
  8960. * The position the shdow will be casted from.
  8961. */
  8962. position: Vector3;
  8963. /**
  8964. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8965. */
  8966. direction: Vector3;
  8967. /**
  8968. * The transformed position. Position of the light in world space taking parenting in account.
  8969. */
  8970. transformedPosition: Vector3;
  8971. /**
  8972. * The transformed direction. Direction of the light in world space taking parenting in account.
  8973. */
  8974. transformedDirection: Vector3;
  8975. /**
  8976. * The friendly name of the light in the scene.
  8977. */
  8978. name: string;
  8979. /**
  8980. * Defines the shadow projection clipping minimum z value.
  8981. */
  8982. shadowMinZ: number;
  8983. /**
  8984. * Defines the shadow projection clipping maximum z value.
  8985. */
  8986. shadowMaxZ: number;
  8987. /**
  8988. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8989. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8990. */
  8991. computeTransformedInformation(): boolean;
  8992. /**
  8993. * Gets the scene the light belongs to.
  8994. * @returns The scene
  8995. */
  8996. getScene(): Scene;
  8997. /**
  8998. * Callback defining a custom Projection Matrix Builder.
  8999. * This can be used to override the default projection matrix computation.
  9000. */
  9001. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9002. /**
  9003. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9004. * @param matrix The materix to updated with the projection information
  9005. * @param viewMatrix The transform matrix of the light
  9006. * @param renderList The list of mesh to render in the map
  9007. * @returns The current light
  9008. */
  9009. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9010. /**
  9011. * Gets the current depth scale used in ESM.
  9012. * @returns The scale
  9013. */
  9014. getDepthScale(): number;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Gets the minZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the min for
  9038. * @returns the depth min z
  9039. */
  9040. getDepthMinZ(activeCamera: Camera): number;
  9041. /**
  9042. * Gets the maxZ used for shadow according to both the scene and the light.
  9043. * @param activeCamera The camera we are returning the max for
  9044. * @returns the depth max z
  9045. */
  9046. getDepthMaxZ(activeCamera: Camera): number;
  9047. }
  9048. /**
  9049. * Base implementation IShadowLight
  9050. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9051. */
  9052. export abstract class ShadowLight extends Light implements IShadowLight {
  9053. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9054. protected _position: Vector3;
  9055. protected _setPosition(value: Vector3): void;
  9056. /**
  9057. * Sets the position the shadow will be casted from. Also use as the light position for both
  9058. * point and spot lights.
  9059. */
  9060. /**
  9061. * Sets the position the shadow will be casted from. Also use as the light position for both
  9062. * point and spot lights.
  9063. */
  9064. position: Vector3;
  9065. protected _direction: Vector3;
  9066. protected _setDirection(value: Vector3): void;
  9067. /**
  9068. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9069. * Also use as the light direction on spot and directional lights.
  9070. */
  9071. /**
  9072. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9073. * Also use as the light direction on spot and directional lights.
  9074. */
  9075. direction: Vector3;
  9076. private _shadowMinZ;
  9077. /**
  9078. * Gets the shadow projection clipping minimum z value.
  9079. */
  9080. /**
  9081. * Sets the shadow projection clipping minimum z value.
  9082. */
  9083. shadowMinZ: number;
  9084. private _shadowMaxZ;
  9085. /**
  9086. * Sets the shadow projection clipping maximum z value.
  9087. */
  9088. /**
  9089. * Gets the shadow projection clipping maximum z value.
  9090. */
  9091. shadowMaxZ: number;
  9092. /**
  9093. * Callback defining a custom Projection Matrix Builder.
  9094. * This can be used to override the default projection matrix computation.
  9095. */
  9096. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9097. /**
  9098. * The transformed position. Position of the light in world space taking parenting in account.
  9099. */
  9100. transformedPosition: Vector3;
  9101. /**
  9102. * The transformed direction. Direction of the light in world space taking parenting in account.
  9103. */
  9104. transformedDirection: Vector3;
  9105. private _needProjectionMatrixCompute;
  9106. /**
  9107. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9108. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9109. */
  9110. computeTransformedInformation(): boolean;
  9111. /**
  9112. * Return the depth scale used for the shadow map.
  9113. * @returns the depth scale.
  9114. */
  9115. getDepthScale(): number;
  9116. /**
  9117. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9118. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9119. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9120. */
  9121. getShadowDirection(faceIndex?: number): Vector3;
  9122. /**
  9123. * Returns the ShadowLight absolute position in the World.
  9124. * @returns the position vector in world space
  9125. */
  9126. getAbsolutePosition(): Vector3;
  9127. /**
  9128. * Sets the ShadowLight direction toward the passed target.
  9129. * @param target The point to target in local space
  9130. * @returns the updated ShadowLight direction
  9131. */
  9132. setDirectionToTarget(target: Vector3): Vector3;
  9133. /**
  9134. * Returns the light rotation in euler definition.
  9135. * @returns the x y z rotation in local space.
  9136. */
  9137. getRotation(): Vector3;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /** @hidden */ initCache(): void;
  9153. /** @hidden */ isSynchronized(): boolean;
  9154. /**
  9155. * Computes the world matrix of the node
  9156. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9157. * @returns the world matrix
  9158. */
  9159. computeWorldMatrix(force?: boolean): Matrix;
  9160. /**
  9161. * Gets the minZ used for shadow according to both the scene and the light.
  9162. * @param activeCamera The camera we are returning the min for
  9163. * @returns the depth min z
  9164. */
  9165. getDepthMinZ(activeCamera: Camera): number;
  9166. /**
  9167. * Gets the maxZ used for shadow according to both the scene and the light.
  9168. * @param activeCamera The camera we are returning the max for
  9169. * @returns the depth max z
  9170. */
  9171. getDepthMaxZ(activeCamera: Camera): number;
  9172. /**
  9173. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9174. * @param matrix The materix to updated with the projection information
  9175. * @param viewMatrix The transform matrix of the light
  9176. * @param renderList The list of mesh to render in the map
  9177. * @returns The current light
  9178. */
  9179. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9180. }
  9181. }
  9182. declare module BABYLON {
  9183. /**
  9184. * "Static Class" containing the most commonly used helper while dealing with material for
  9185. * rendering purpose.
  9186. *
  9187. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9188. *
  9189. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9190. */
  9191. export class MaterialHelper {
  9192. /**
  9193. * Bind the current view position to an effect.
  9194. * @param effect The effect to be bound
  9195. * @param scene The scene the eyes position is used from
  9196. */
  9197. static BindEyePosition(effect: Effect, scene: Scene): void;
  9198. /**
  9199. * Helps preparing the defines values about the UVs in used in the effect.
  9200. * UVs are shared as much as we can accross channels in the shaders.
  9201. * @param texture The texture we are preparing the UVs for
  9202. * @param defines The defines to update
  9203. * @param key The channel key "diffuse", "specular"... used in the shader
  9204. */
  9205. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9206. /**
  9207. * Binds a texture matrix value to its corrsponding uniform
  9208. * @param texture The texture to bind the matrix for
  9209. * @param uniformBuffer The uniform buffer receivin the data
  9210. * @param key The channel key "diffuse", "specular"... used in the shader
  9211. */
  9212. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9213. /**
  9214. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9215. * @param mesh defines the current mesh
  9216. * @param scene defines the current scene
  9217. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9218. * @param pointsCloud defines if point cloud rendering has to be turned on
  9219. * @param fogEnabled defines if fog has to be turned on
  9220. * @param alphaTest defines if alpha testing has to be turned on
  9221. * @param defines defines the current list of defines
  9222. */
  9223. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9224. /**
  9225. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9226. * @param scene defines the current scene
  9227. * @param engine defines the current engine
  9228. * @param defines specifies the list of active defines
  9229. * @param useInstances defines if instances have to be turned on
  9230. * @param useClipPlane defines if clip plane have to be turned on
  9231. */
  9232. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9233. /**
  9234. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9235. * @param mesh The mesh containing the geometry data we will draw
  9236. * @param defines The defines to update
  9237. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9238. * @param useBones Precise whether bones should be used or not (override mesh info)
  9239. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9240. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9241. * @returns false if defines are considered not dirty and have not been checked
  9242. */
  9243. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9244. /**
  9245. * Prepares the defines related to multiview
  9246. * @param scene The scene we are intending to draw
  9247. * @param defines The defines to update
  9248. */
  9249. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9250. /**
  9251. * Prepares the defines related to the light information passed in parameter
  9252. * @param scene The scene we are intending to draw
  9253. * @param mesh The mesh the effect is compiling for
  9254. * @param defines The defines to update
  9255. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9256. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9257. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9258. * @returns true if normals will be required for the rest of the effect
  9259. */
  9260. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9261. /**
  9262. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9263. * that won t be acctive due to defines being turned off.
  9264. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9265. * @param samplersList The samplers list
  9266. * @param defines The defines helping in the list generation
  9267. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9268. */
  9269. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9270. /**
  9271. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9272. * @param defines The defines to update while falling back
  9273. * @param fallbacks The authorized effect fallbacks
  9274. * @param maxSimultaneousLights The maximum number of lights allowed
  9275. * @param rank the current rank of the Effect
  9276. * @returns The newly affected rank
  9277. */
  9278. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9279. /**
  9280. * Prepares the list of attributes required for morph targets according to the effect defines.
  9281. * @param attribs The current list of supported attribs
  9282. * @param mesh The mesh to prepare the morph targets attributes for
  9283. * @param defines The current Defines of the effect
  9284. */
  9285. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9286. /**
  9287. * Prepares the list of attributes required for bones according to the effect defines.
  9288. * @param attribs The current list of supported attribs
  9289. * @param mesh The mesh to prepare the bones attributes for
  9290. * @param defines The current Defines of the effect
  9291. * @param fallbacks The current efffect fallback strategy
  9292. */
  9293. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9294. /**
  9295. * Prepares the list of attributes required for instances according to the effect defines.
  9296. * @param attribs The current list of supported attribs
  9297. * @param defines The current Defines of the effect
  9298. */
  9299. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9300. /**
  9301. * Binds the light shadow information to the effect for the given mesh.
  9302. * @param light The light containing the generator
  9303. * @param scene The scene the lights belongs to
  9304. * @param mesh The mesh we are binding the information to render
  9305. * @param lightIndex The light index in the effect used to render the mesh
  9306. * @param effect The effect we are binding the data to
  9307. */
  9308. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9309. /**
  9310. * Binds the light information to the effect.
  9311. * @param light The light containing the generator
  9312. * @param effect The effect we are binding the data to
  9313. * @param lightIndex The light index in the effect used to render
  9314. */
  9315. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9316. /**
  9317. * Binds the lights information from the scene to the effect for the given mesh.
  9318. * @param scene The scene the lights belongs to
  9319. * @param mesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. * @param defines The generated defines for the effect
  9322. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9323. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9324. */
  9325. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9326. private static _tempFogColor;
  9327. /**
  9328. * Binds the fog information from the scene to the effect for the given mesh.
  9329. * @param scene The scene the lights belongs to
  9330. * @param mesh The mesh we are binding the information to render
  9331. * @param effect The effect we are binding the data to
  9332. * @param linearSpace Defines if the fog effect is applied in linear space
  9333. */
  9334. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9335. /**
  9336. * Binds the bones information from the mesh to the effect.
  9337. * @param mesh The mesh we are binding the information to render
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9341. /**
  9342. * Binds the morph targets information from the mesh to the effect.
  9343. * @param abstractMesh The mesh we are binding the information to render
  9344. * @param effect The effect we are binding the data to
  9345. */
  9346. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9347. /**
  9348. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9349. * @param defines The generated defines used in the effect
  9350. * @param effect The effect we are binding the data to
  9351. * @param scene The scene we are willing to render with logarithmic scale for
  9352. */
  9353. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9354. /**
  9355. * Binds the clip plane information from the scene to the effect.
  9356. * @param scene The scene the clip plane information are extracted from
  9357. * @param effect The effect we are binding the data to
  9358. */
  9359. static BindClipPlane(effect: Effect, scene: Scene): void;
  9360. }
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var kernelBlurVaryingDeclaration: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var kernelBlurFragment: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var kernelBlurFragment2: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var kernelBlurPixelShader: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var kernelBlurVertex: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /** @hidden */
  9399. export var kernelBlurVertexShader: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module BABYLON {
  9405. /**
  9406. * The Blur Post Process which blurs an image based on a kernel and direction.
  9407. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9408. */
  9409. export class BlurPostProcess extends PostProcess {
  9410. /** The direction in which to blur the image. */
  9411. direction: Vector2;
  9412. private blockCompilation;
  9413. protected _kernel: number;
  9414. protected _idealKernel: number;
  9415. protected _packedFloat: boolean;
  9416. private _staticDefines;
  9417. /**
  9418. * Sets the length in pixels of the blur sample region
  9419. */
  9420. /**
  9421. * Gets the length in pixels of the blur sample region
  9422. */
  9423. kernel: number;
  9424. /**
  9425. * Sets wether or not the blur needs to unpack/repack floats
  9426. */
  9427. /**
  9428. * Gets wether or not the blur is unpacking/repacking floats
  9429. */
  9430. packedFloat: boolean;
  9431. /**
  9432. * Creates a new instance BlurPostProcess
  9433. * @param name The name of the effect.
  9434. * @param direction The direction in which to blur the image.
  9435. * @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.
  9436. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9437. * @param camera The camera to apply the render pass to.
  9438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9439. * @param engine The engine which the post process will be applied. (default: current engine)
  9440. * @param reusable If the post process can be reused on the same frame. (default: false)
  9441. * @param textureType Type of textures used when performing the post process. (default: 0)
  9442. * @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)
  9443. */
  9444. constructor(name: string,
  9445. /** The direction in which to blur the image. */
  9446. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9447. /**
  9448. * Updates the effect with the current post process compile time values and recompiles the shader.
  9449. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9450. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9451. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9452. * @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
  9453. * @param onCompiled Called when the shader has been compiled.
  9454. * @param onError Called if there is an error when compiling a shader.
  9455. */
  9456. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9457. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9458. /**
  9459. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9460. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9461. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9462. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9463. * The gaps between physical kernels are compensated for in the weighting of the samples
  9464. * @param idealKernel Ideal blur kernel.
  9465. * @return Nearest best kernel.
  9466. */
  9467. protected _nearestBestKernel(idealKernel: number): number;
  9468. /**
  9469. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9470. * @param x The point on the Gaussian distribution to sample.
  9471. * @return the value of the Gaussian function at x.
  9472. */
  9473. protected _gaussianWeight(x: number): number;
  9474. /**
  9475. * Generates a string that can be used as a floating point number in GLSL.
  9476. * @param x Value to print.
  9477. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9478. * @return GLSL float string.
  9479. */
  9480. protected _glslFloat(x: number, decimalFigures?: number): string;
  9481. }
  9482. }
  9483. declare module BABYLON {
  9484. /** @hidden */
  9485. export var shadowMapPixelShader: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module BABYLON {
  9491. /** @hidden */
  9492. export var bonesDeclaration: {
  9493. name: string;
  9494. shader: string;
  9495. };
  9496. }
  9497. declare module BABYLON {
  9498. /** @hidden */
  9499. export var morphTargetsVertexGlobalDeclaration: {
  9500. name: string;
  9501. shader: string;
  9502. };
  9503. }
  9504. declare module BABYLON {
  9505. /** @hidden */
  9506. export var morphTargetsVertexDeclaration: {
  9507. name: string;
  9508. shader: string;
  9509. };
  9510. }
  9511. declare module BABYLON {
  9512. /** @hidden */
  9513. export var instancesDeclaration: {
  9514. name: string;
  9515. shader: string;
  9516. };
  9517. }
  9518. declare module BABYLON {
  9519. /** @hidden */
  9520. export var helperFunctions: {
  9521. name: string;
  9522. shader: string;
  9523. };
  9524. }
  9525. declare module BABYLON {
  9526. /** @hidden */
  9527. export var morphTargetsVertex: {
  9528. name: string;
  9529. shader: string;
  9530. };
  9531. }
  9532. declare module BABYLON {
  9533. /** @hidden */
  9534. export var instancesVertex: {
  9535. name: string;
  9536. shader: string;
  9537. };
  9538. }
  9539. declare module BABYLON {
  9540. /** @hidden */
  9541. export var bonesVertex: {
  9542. name: string;
  9543. shader: string;
  9544. };
  9545. }
  9546. declare module BABYLON {
  9547. /** @hidden */
  9548. export var shadowMapVertexShader: {
  9549. name: string;
  9550. shader: string;
  9551. };
  9552. }
  9553. declare module BABYLON {
  9554. /** @hidden */
  9555. export var depthBoxBlurPixelShader: {
  9556. name: string;
  9557. shader: string;
  9558. };
  9559. }
  9560. declare module BABYLON {
  9561. /**
  9562. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9563. */
  9564. export interface ICustomShaderOptions {
  9565. /**
  9566. * Gets or sets the custom shader name to use
  9567. */
  9568. shaderName: string;
  9569. /**
  9570. * The list of attribute names used in the shader
  9571. */
  9572. attributes?: string[];
  9573. /**
  9574. * The list of unifrom names used in the shader
  9575. */
  9576. uniforms?: string[];
  9577. /**
  9578. * The list of sampler names used in the shader
  9579. */
  9580. samplers?: string[];
  9581. /**
  9582. * The list of defines used in the shader
  9583. */
  9584. defines?: string[];
  9585. }
  9586. /**
  9587. * Interface to implement to create a shadow generator compatible with BJS.
  9588. */
  9589. export interface IShadowGenerator {
  9590. /**
  9591. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9592. * @returns The render target texture if present otherwise, null
  9593. */
  9594. getShadowMap(): Nullable<RenderTargetTexture>;
  9595. /**
  9596. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9597. * @returns The render target texture if the shadow map is present otherwise, null
  9598. */
  9599. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9600. /**
  9601. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9602. * @param subMesh The submesh we want to render in the shadow map
  9603. * @param useInstances Defines wether will draw in the map using instances
  9604. * @returns true if ready otherwise, false
  9605. */
  9606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9607. /**
  9608. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9609. * @param defines Defines of the material we want to update
  9610. * @param lightIndex Index of the light in the enabled light list of the material
  9611. */
  9612. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9613. /**
  9614. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9615. * defined in the generator but impacting the effect).
  9616. * It implies the unifroms available on the materials are the standard BJS ones.
  9617. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9618. * @param effect The effect we are binfing the information for
  9619. */
  9620. bindShadowLight(lightIndex: string, effect: Effect): void;
  9621. /**
  9622. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9623. * (eq to shadow prjection matrix * light transform matrix)
  9624. * @returns The transform matrix used to create the shadow map
  9625. */
  9626. getTransformMatrix(): Matrix;
  9627. /**
  9628. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9629. * Cube and 2D textures for instance.
  9630. */
  9631. recreateShadowMap(): void;
  9632. /**
  9633. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9634. * @param onCompiled Callback triggered at the and of the effects compilation
  9635. * @param options Sets of optional options forcing the compilation with different modes
  9636. */
  9637. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9638. useInstances: boolean;
  9639. }>): void;
  9640. /**
  9641. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9642. * @param options Sets of optional options forcing the compilation with different modes
  9643. * @returns A promise that resolves when the compilation completes
  9644. */
  9645. forceCompilationAsync(options?: Partial<{
  9646. useInstances: boolean;
  9647. }>): Promise<void>;
  9648. /**
  9649. * Serializes the shadow generator setup to a json object.
  9650. * @returns The serialized JSON object
  9651. */
  9652. serialize(): any;
  9653. /**
  9654. * Disposes the Shadow map and related Textures and effects.
  9655. */
  9656. dispose(): void;
  9657. }
  9658. /**
  9659. * Default implementation IShadowGenerator.
  9660. * This is the main object responsible of generating shadows in the framework.
  9661. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9662. */
  9663. export class ShadowGenerator implements IShadowGenerator {
  9664. /**
  9665. * Shadow generator mode None: no filtering applied.
  9666. */
  9667. static readonly FILTER_NONE: number;
  9668. /**
  9669. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9670. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9671. */
  9672. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9673. /**
  9674. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9675. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9676. */
  9677. static readonly FILTER_POISSONSAMPLING: number;
  9678. /**
  9679. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9680. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9681. */
  9682. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9683. /**
  9684. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9685. * edge artifacts on steep falloff.
  9686. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9687. */
  9688. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9689. /**
  9690. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9691. * edge artifacts on steep falloff.
  9692. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9693. */
  9694. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9695. /**
  9696. * Shadow generator mode PCF: Percentage Closer Filtering
  9697. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9698. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9699. */
  9700. static readonly FILTER_PCF: number;
  9701. /**
  9702. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9703. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9704. * Contact Hardening
  9705. */
  9706. static readonly FILTER_PCSS: number;
  9707. /**
  9708. * Reserved for PCF and PCSS
  9709. * Highest Quality.
  9710. *
  9711. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9712. *
  9713. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9714. */
  9715. static readonly QUALITY_HIGH: number;
  9716. /**
  9717. * Reserved for PCF and PCSS
  9718. * Good tradeoff for quality/perf cross devices
  9719. *
  9720. * Execute PCF on a 3*3 kernel.
  9721. *
  9722. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9723. */
  9724. static readonly QUALITY_MEDIUM: number;
  9725. /**
  9726. * Reserved for PCF and PCSS
  9727. * The lowest quality but the fastest.
  9728. *
  9729. * Execute PCF on a 1*1 kernel.
  9730. *
  9731. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9732. */
  9733. static readonly QUALITY_LOW: number;
  9734. /** Gets or sets the custom shader name to use */
  9735. customShaderOptions: ICustomShaderOptions;
  9736. /**
  9737. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9738. */
  9739. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9740. /**
  9741. * Observable triggered before a mesh is rendered in the shadow map.
  9742. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9743. */
  9744. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9745. private _bias;
  9746. /**
  9747. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9748. */
  9749. /**
  9750. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9751. */
  9752. bias: number;
  9753. private _normalBias;
  9754. /**
  9755. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9756. */
  9757. /**
  9758. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9759. */
  9760. normalBias: number;
  9761. private _blurBoxOffset;
  9762. /**
  9763. * Gets the blur box offset: offset applied during the blur pass.
  9764. * Only useful if useKernelBlur = false
  9765. */
  9766. /**
  9767. * Sets the blur box offset: offset applied during the blur pass.
  9768. * Only useful if useKernelBlur = false
  9769. */
  9770. blurBoxOffset: number;
  9771. private _blurScale;
  9772. /**
  9773. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9774. * 2 means half of the size.
  9775. */
  9776. /**
  9777. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9778. * 2 means half of the size.
  9779. */
  9780. blurScale: number;
  9781. private _blurKernel;
  9782. /**
  9783. * Gets the blur kernel: kernel size of the blur pass.
  9784. * Only useful if useKernelBlur = true
  9785. */
  9786. /**
  9787. * Sets the blur kernel: kernel size of the blur pass.
  9788. * Only useful if useKernelBlur = true
  9789. */
  9790. blurKernel: number;
  9791. private _useKernelBlur;
  9792. /**
  9793. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9794. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9795. */
  9796. /**
  9797. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9798. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9799. */
  9800. useKernelBlur: boolean;
  9801. private _depthScale;
  9802. /**
  9803. * Gets the depth scale used in ESM mode.
  9804. */
  9805. /**
  9806. * Sets the depth scale used in ESM mode.
  9807. * This can override the scale stored on the light.
  9808. */
  9809. depthScale: number;
  9810. private _filter;
  9811. /**
  9812. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9813. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9814. */
  9815. /**
  9816. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9817. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9818. */
  9819. filter: number;
  9820. /**
  9821. * Gets if the current filter is set to Poisson Sampling.
  9822. */
  9823. /**
  9824. * Sets the current filter to Poisson Sampling.
  9825. */
  9826. usePoissonSampling: boolean;
  9827. /**
  9828. * Gets if the current filter is set to ESM.
  9829. */
  9830. /**
  9831. * Sets the current filter is to ESM.
  9832. */
  9833. useExponentialShadowMap: boolean;
  9834. /**
  9835. * Gets if the current filter is set to filtered ESM.
  9836. */
  9837. /**
  9838. * Gets if the current filter is set to filtered ESM.
  9839. */
  9840. useBlurExponentialShadowMap: boolean;
  9841. /**
  9842. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9843. * exponential to prevent steep falloff artifacts).
  9844. */
  9845. /**
  9846. * Sets the current filter to "close ESM" (using the inverse of the
  9847. * exponential to prevent steep falloff artifacts).
  9848. */
  9849. useCloseExponentialShadowMap: boolean;
  9850. /**
  9851. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9852. * exponential to prevent steep falloff artifacts).
  9853. */
  9854. /**
  9855. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9856. * exponential to prevent steep falloff artifacts).
  9857. */
  9858. useBlurCloseExponentialShadowMap: boolean;
  9859. /**
  9860. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9861. */
  9862. /**
  9863. * Sets the current filter to "PCF" (percentage closer filtering).
  9864. */
  9865. usePercentageCloserFiltering: boolean;
  9866. private _filteringQuality;
  9867. /**
  9868. * Gets the PCF or PCSS Quality.
  9869. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9870. */
  9871. /**
  9872. * Sets the PCF or PCSS Quality.
  9873. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9874. */
  9875. filteringQuality: number;
  9876. /**
  9877. * Gets if the current filter is set to "PCSS" (contact hardening).
  9878. */
  9879. /**
  9880. * Sets the current filter to "PCSS" (contact hardening).
  9881. */
  9882. useContactHardeningShadow: boolean;
  9883. private _contactHardeningLightSizeUVRatio;
  9884. /**
  9885. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9886. * Using a ratio helps keeping shape stability independently of the map size.
  9887. *
  9888. * It does not account for the light projection as it was having too much
  9889. * instability during the light setup or during light position changes.
  9890. *
  9891. * Only valid if useContactHardeningShadow is true.
  9892. */
  9893. /**
  9894. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9895. * Using a ratio helps keeping shape stability independently of the map size.
  9896. *
  9897. * It does not account for the light projection as it was having too much
  9898. * instability during the light setup or during light position changes.
  9899. *
  9900. * Only valid if useContactHardeningShadow is true.
  9901. */
  9902. contactHardeningLightSizeUVRatio: number;
  9903. private _darkness;
  9904. /**
  9905. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9906. * 0 means strongest and 1 would means no shadow.
  9907. * @returns the darkness.
  9908. */
  9909. getDarkness(): number;
  9910. /**
  9911. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9912. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9913. * @returns the shadow generator allowing fluent coding.
  9914. */
  9915. setDarkness(darkness: number): ShadowGenerator;
  9916. private _transparencyShadow;
  9917. /**
  9918. * Sets the ability to have transparent shadow (boolean).
  9919. * @param transparent True if transparent else False
  9920. * @returns the shadow generator allowing fluent coding
  9921. */
  9922. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9923. private _shadowMap;
  9924. private _shadowMap2;
  9925. /**
  9926. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9927. * @returns The render target texture if present otherwise, null
  9928. */
  9929. getShadowMap(): Nullable<RenderTargetTexture>;
  9930. /**
  9931. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9932. * @returns The render target texture if the shadow map is present otherwise, null
  9933. */
  9934. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9935. /**
  9936. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9937. * @param mesh Mesh to add
  9938. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9939. * @returns the Shadow Generator itself
  9940. */
  9941. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9942. /**
  9943. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9944. * @param mesh Mesh to remove
  9945. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9946. * @returns the Shadow Generator itself
  9947. */
  9948. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9949. /**
  9950. * Controls the extent to which the shadows fade out at the edge of the frustum
  9951. * Used only by directionals and spots
  9952. */
  9953. frustumEdgeFalloff: number;
  9954. private _light;
  9955. /**
  9956. * Returns the associated light object.
  9957. * @returns the light generating the shadow
  9958. */
  9959. getLight(): IShadowLight;
  9960. /**
  9961. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9962. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9963. * It might on the other hand introduce peter panning.
  9964. */
  9965. forceBackFacesOnly: boolean;
  9966. private _scene;
  9967. private _lightDirection;
  9968. private _effect;
  9969. private _viewMatrix;
  9970. private _projectionMatrix;
  9971. private _transformMatrix;
  9972. private _cachedPosition;
  9973. private _cachedDirection;
  9974. private _cachedDefines;
  9975. private _currentRenderID;
  9976. private _boxBlurPostprocess;
  9977. private _kernelBlurXPostprocess;
  9978. private _kernelBlurYPostprocess;
  9979. private _blurPostProcesses;
  9980. private _mapSize;
  9981. private _currentFaceIndex;
  9982. private _currentFaceIndexCache;
  9983. private _textureType;
  9984. private _defaultTextureMatrix;
  9985. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9986. /**
  9987. * Creates a ShadowGenerator object.
  9988. * A ShadowGenerator is the required tool to use the shadows.
  9989. * Each light casting shadows needs to use its own ShadowGenerator.
  9990. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9991. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9992. * @param light The light object generating the shadows.
  9993. * @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.
  9994. */
  9995. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9996. private _initializeGenerator;
  9997. private _initializeShadowMap;
  9998. private _initializeBlurRTTAndPostProcesses;
  9999. private _renderForShadowMap;
  10000. private _renderSubMeshForShadowMap;
  10001. private _applyFilterValues;
  10002. /**
  10003. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10004. * @param onCompiled Callback triggered at the and of the effects compilation
  10005. * @param options Sets of optional options forcing the compilation with different modes
  10006. */
  10007. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10008. useInstances: boolean;
  10009. }>): void;
  10010. /**
  10011. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10012. * @param options Sets of optional options forcing the compilation with different modes
  10013. * @returns A promise that resolves when the compilation completes
  10014. */
  10015. forceCompilationAsync(options?: Partial<{
  10016. useInstances: boolean;
  10017. }>): Promise<void>;
  10018. /**
  10019. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10020. * @param subMesh The submesh we want to render in the shadow map
  10021. * @param useInstances Defines wether will draw in the map using instances
  10022. * @returns true if ready otherwise, false
  10023. */
  10024. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10025. /**
  10026. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10027. * @param defines Defines of the material we want to update
  10028. * @param lightIndex Index of the light in the enabled light list of the material
  10029. */
  10030. prepareDefines(defines: any, lightIndex: number): void;
  10031. /**
  10032. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10033. * defined in the generator but impacting the effect).
  10034. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10035. * @param effect The effect we are binfing the information for
  10036. */
  10037. bindShadowLight(lightIndex: string, effect: Effect): void;
  10038. /**
  10039. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10040. * (eq to shadow prjection matrix * light transform matrix)
  10041. * @returns The transform matrix used to create the shadow map
  10042. */
  10043. getTransformMatrix(): Matrix;
  10044. /**
  10045. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10046. * Cube and 2D textures for instance.
  10047. */
  10048. recreateShadowMap(): void;
  10049. private _disposeBlurPostProcesses;
  10050. private _disposeRTTandPostProcesses;
  10051. /**
  10052. * Disposes the ShadowGenerator.
  10053. * Returns nothing.
  10054. */
  10055. dispose(): void;
  10056. /**
  10057. * Serializes the shadow generator setup to a json object.
  10058. * @returns The serialized JSON object
  10059. */
  10060. serialize(): any;
  10061. /**
  10062. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10063. * @param parsedShadowGenerator The JSON object to parse
  10064. * @param scene The scene to create the shadow map for
  10065. * @returns The parsed shadow generator
  10066. */
  10067. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10068. }
  10069. }
  10070. declare module BABYLON {
  10071. /**
  10072. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10073. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10074. * 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.
  10075. */
  10076. export abstract class Light extends Node {
  10077. /**
  10078. * Falloff Default: light is falling off following the material specification:
  10079. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10080. */
  10081. static readonly FALLOFF_DEFAULT: number;
  10082. /**
  10083. * Falloff Physical: light is falling off following the inverse squared distance law.
  10084. */
  10085. static readonly FALLOFF_PHYSICAL: number;
  10086. /**
  10087. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10088. * to enhance interoperability with other engines.
  10089. */
  10090. static readonly FALLOFF_GLTF: number;
  10091. /**
  10092. * Falloff Standard: light is falling off like in the standard material
  10093. * to enhance interoperability with other materials.
  10094. */
  10095. static readonly FALLOFF_STANDARD: number;
  10096. /**
  10097. * If every light affecting the material is in this lightmapMode,
  10098. * material.lightmapTexture adds or multiplies
  10099. * (depends on material.useLightmapAsShadowmap)
  10100. * after every other light calculations.
  10101. */
  10102. static readonly LIGHTMAP_DEFAULT: number;
  10103. /**
  10104. * material.lightmapTexture as only diffuse lighting from this light
  10105. * adds only specular lighting from this light
  10106. * adds dynamic shadows
  10107. */
  10108. static readonly LIGHTMAP_SPECULAR: number;
  10109. /**
  10110. * material.lightmapTexture as only lighting
  10111. * no light calculation from this light
  10112. * only adds dynamic shadows from this light
  10113. */
  10114. static readonly LIGHTMAP_SHADOWSONLY: number;
  10115. /**
  10116. * Each light type uses the default quantity according to its type:
  10117. * point/spot lights use luminous intensity
  10118. * directional lights use illuminance
  10119. */
  10120. static readonly INTENSITYMODE_AUTOMATIC: number;
  10121. /**
  10122. * lumen (lm)
  10123. */
  10124. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10125. /**
  10126. * candela (lm/sr)
  10127. */
  10128. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10129. /**
  10130. * lux (lm/m^2)
  10131. */
  10132. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10133. /**
  10134. * nit (cd/m^2)
  10135. */
  10136. static readonly INTENSITYMODE_LUMINANCE: number;
  10137. /**
  10138. * Light type const id of the point light.
  10139. */
  10140. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10141. /**
  10142. * Light type const id of the directional light.
  10143. */
  10144. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10145. /**
  10146. * Light type const id of the spot light.
  10147. */
  10148. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10149. /**
  10150. * Light type const id of the hemispheric light.
  10151. */
  10152. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10153. /**
  10154. * Diffuse gives the basic color to an object.
  10155. */
  10156. diffuse: Color3;
  10157. /**
  10158. * Specular produces a highlight color on an object.
  10159. * Note: This is note affecting PBR materials.
  10160. */
  10161. specular: Color3;
  10162. /**
  10163. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10164. * falling off base on range or angle.
  10165. * This can be set to any values in Light.FALLOFF_x.
  10166. *
  10167. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10168. * other types of materials.
  10169. */
  10170. falloffType: number;
  10171. /**
  10172. * Strength of the light.
  10173. * Note: By default it is define in the framework own unit.
  10174. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10175. */
  10176. intensity: number;
  10177. private _range;
  10178. protected _inverseSquaredRange: number;
  10179. /**
  10180. * Defines how far from the source the light is impacting in scene units.
  10181. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10182. */
  10183. /**
  10184. * Defines how far from the source the light is impacting in scene units.
  10185. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10186. */
  10187. range: number;
  10188. /**
  10189. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10190. * of light.
  10191. */
  10192. private _photometricScale;
  10193. private _intensityMode;
  10194. /**
  10195. * Gets the photometric scale used to interpret the intensity.
  10196. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10197. */
  10198. /**
  10199. * Sets the photometric scale used to interpret the intensity.
  10200. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10201. */
  10202. intensityMode: number;
  10203. private _radius;
  10204. /**
  10205. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10206. */
  10207. /**
  10208. * sets the light radius used by PBR Materials to simulate soft area lights.
  10209. */
  10210. radius: number;
  10211. private _renderPriority;
  10212. /**
  10213. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10214. * exceeding the number allowed of the materials.
  10215. */
  10216. renderPriority: number;
  10217. private _shadowEnabled;
  10218. /**
  10219. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10220. * the current shadow generator.
  10221. */
  10222. /**
  10223. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10224. * the current shadow generator.
  10225. */
  10226. shadowEnabled: boolean;
  10227. private _includedOnlyMeshes;
  10228. /**
  10229. * Gets the only meshes impacted by this light.
  10230. */
  10231. /**
  10232. * Sets the only meshes impacted by this light.
  10233. */
  10234. includedOnlyMeshes: AbstractMesh[];
  10235. private _excludedMeshes;
  10236. /**
  10237. * Gets the meshes not impacted by this light.
  10238. */
  10239. /**
  10240. * Sets the meshes not impacted by this light.
  10241. */
  10242. excludedMeshes: AbstractMesh[];
  10243. private _excludeWithLayerMask;
  10244. /**
  10245. * Gets the layer id use to find what meshes are not impacted by the light.
  10246. * Inactive if 0
  10247. */
  10248. /**
  10249. * Sets the layer id use to find what meshes are not impacted by the light.
  10250. * Inactive if 0
  10251. */
  10252. excludeWithLayerMask: number;
  10253. private _includeOnlyWithLayerMask;
  10254. /**
  10255. * Gets the layer id use to find what meshes are impacted by the light.
  10256. * Inactive if 0
  10257. */
  10258. /**
  10259. * Sets the layer id use to find what meshes are impacted by the light.
  10260. * Inactive if 0
  10261. */
  10262. includeOnlyWithLayerMask: number;
  10263. private _lightmapMode;
  10264. /**
  10265. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10266. */
  10267. /**
  10268. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10269. */
  10270. lightmapMode: number;
  10271. /**
  10272. * Shadow generator associted to the light.
  10273. * @hidden Internal use only.
  10274. */ shadowGenerator: Nullable<IShadowGenerator>;
  10275. /**
  10276. * @hidden Internal use only.
  10277. */ excludedMeshesIds: string[];
  10278. /**
  10279. * @hidden Internal use only.
  10280. */ includedOnlyMeshesIds: string[];
  10281. /**
  10282. * The current light unifom buffer.
  10283. * @hidden Internal use only.
  10284. */ uniformBuffer: UniformBuffer;
  10285. /**
  10286. * Creates a Light object in the scene.
  10287. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10288. * @param name The firendly name of the light
  10289. * @param scene The scene the light belongs too
  10290. */
  10291. constructor(name: string, scene: Scene);
  10292. protected abstract _buildUniformLayout(): void;
  10293. /**
  10294. * Sets the passed Effect "effect" with the Light information.
  10295. * @param effect The effect to update
  10296. * @param lightIndex The index of the light in the effect to update
  10297. * @returns The light
  10298. */
  10299. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10300. /**
  10301. * Returns the string "Light".
  10302. * @returns the class name
  10303. */
  10304. getClassName(): string;
  10305. /** @hidden */ protected readonly _isLight: boolean;
  10306. /**
  10307. * Converts the light information to a readable string for debug purpose.
  10308. * @param fullDetails Supports for multiple levels of logging within scene loading
  10309. * @returns the human readable light info
  10310. */
  10311. toString(fullDetails?: boolean): string;
  10312. /** @hidden */
  10313. protected _syncParentEnabledState(): void;
  10314. /**
  10315. * Set the enabled state of this node.
  10316. * @param value - the new enabled state
  10317. */
  10318. setEnabled(value: boolean): void;
  10319. /**
  10320. * Returns the Light associated shadow generator if any.
  10321. * @return the associated shadow generator.
  10322. */
  10323. getShadowGenerator(): Nullable<IShadowGenerator>;
  10324. /**
  10325. * Returns a Vector3, the absolute light position in the World.
  10326. * @returns the world space position of the light
  10327. */
  10328. getAbsolutePosition(): Vector3;
  10329. /**
  10330. * Specifies if the light will affect the passed mesh.
  10331. * @param mesh The mesh to test against the light
  10332. * @return true the mesh is affected otherwise, false.
  10333. */
  10334. canAffectMesh(mesh: AbstractMesh): boolean;
  10335. /**
  10336. * Sort function to order lights for rendering.
  10337. * @param a First Light object to compare to second.
  10338. * @param b Second Light object to compare first.
  10339. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10340. */
  10341. static CompareLightsPriority(a: Light, b: Light): number;
  10342. /**
  10343. * Releases resources associated with this node.
  10344. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10345. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10346. */
  10347. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10348. /**
  10349. * Returns the light type ID (integer).
  10350. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10351. */
  10352. getTypeID(): number;
  10353. /**
  10354. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10355. * @returns the scaled intensity in intensity mode unit
  10356. */
  10357. getScaledIntensity(): number;
  10358. /**
  10359. * Returns a new Light object, named "name", from the current one.
  10360. * @param name The name of the cloned light
  10361. * @returns the new created light
  10362. */
  10363. clone(name: string): Nullable<Light>;
  10364. /**
  10365. * Serializes the current light into a Serialization object.
  10366. * @returns the serialized object.
  10367. */
  10368. serialize(): any;
  10369. /**
  10370. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10371. * This new light is named "name" and added to the passed scene.
  10372. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10373. * @param name The friendly name of the light
  10374. * @param scene The scene the new light will belong to
  10375. * @returns the constructor function
  10376. */
  10377. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10378. /**
  10379. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10380. * @param parsedLight The JSON representation of the light
  10381. * @param scene The scene to create the parsed light in
  10382. * @returns the created light after parsing
  10383. */
  10384. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10385. private _hookArrayForExcluded;
  10386. private _hookArrayForIncludedOnly;
  10387. private _resyncMeshes;
  10388. /**
  10389. * Forces the meshes to update their light related information in their rendering used effects
  10390. * @hidden Internal Use Only
  10391. */ markMeshesAsLightDirty(): void;
  10392. /**
  10393. * Recomputes the cached photometric scale if needed.
  10394. */
  10395. private _computePhotometricScale;
  10396. /**
  10397. * Returns the Photometric Scale according to the light type and intensity mode.
  10398. */
  10399. private _getPhotometricScale;
  10400. /**
  10401. * Reorder the light in the scene according to their defined priority.
  10402. * @hidden Internal Use Only
  10403. */ reorderLightsInScene(): void;
  10404. /**
  10405. * Prepares the list of defines specific to the light type.
  10406. * @param defines the list of defines
  10407. * @param lightIndex defines the index of the light for the effect
  10408. */
  10409. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10410. }
  10411. }
  10412. declare module BABYLON {
  10413. /**
  10414. * Interface used to define Action
  10415. */
  10416. export interface IAction {
  10417. /**
  10418. * Trigger for the action
  10419. */
  10420. trigger: number;
  10421. /** Options of the trigger */
  10422. triggerOptions: any;
  10423. /**
  10424. * Gets the trigger parameters
  10425. * @returns the trigger parameters
  10426. */
  10427. getTriggerParameter(): any;
  10428. /**
  10429. * Internal only - executes current action event
  10430. * @hidden
  10431. */ executeCurrent(evt?: ActionEvent): void;
  10432. /**
  10433. * Serialize placeholder for child classes
  10434. * @param parent of child
  10435. * @returns the serialized object
  10436. */
  10437. serialize(parent: any): any;
  10438. /**
  10439. * Internal only
  10440. * @hidden
  10441. */ prepare(): void;
  10442. /**
  10443. * Internal only - manager for action
  10444. * @hidden
  10445. */ actionManager: AbstractActionManager;
  10446. }
  10447. /**
  10448. * The action to be carried out following a trigger
  10449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10450. */
  10451. export class Action implements IAction {
  10452. /** the trigger, with or without parameters, for the action */
  10453. triggerOptions: any;
  10454. /**
  10455. * Trigger for the action
  10456. */
  10457. trigger: number;
  10458. /**
  10459. * Internal only - manager for action
  10460. * @hidden
  10461. */ actionManager: ActionManager;
  10462. private _nextActiveAction;
  10463. private _child;
  10464. private _condition?;
  10465. private _triggerParameter;
  10466. /**
  10467. * An event triggered prior to action being executed.
  10468. */
  10469. onBeforeExecuteObservable: Observable<Action>;
  10470. /**
  10471. * Creates a new Action
  10472. * @param triggerOptions the trigger, with or without parameters, for the action
  10473. * @param condition an optional determinant of action
  10474. */
  10475. constructor(
  10476. /** the trigger, with or without parameters, for the action */
  10477. triggerOptions: any, condition?: Condition);
  10478. /**
  10479. * Internal only
  10480. * @hidden
  10481. */ prepare(): void;
  10482. /**
  10483. * Gets the trigger parameters
  10484. * @returns the trigger parameters
  10485. */
  10486. getTriggerParameter(): any;
  10487. /**
  10488. * Internal only - executes current action event
  10489. * @hidden
  10490. */ executeCurrent(evt?: ActionEvent): void;
  10491. /**
  10492. * Execute placeholder for child classes
  10493. * @param evt optional action event
  10494. */
  10495. execute(evt?: ActionEvent): void;
  10496. /**
  10497. * Skips to next active action
  10498. */
  10499. skipToNextActiveAction(): void;
  10500. /**
  10501. * Adds action to chain of actions, may be a DoNothingAction
  10502. * @param action defines the next action to execute
  10503. * @returns The action passed in
  10504. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10505. */
  10506. then(action: Action): Action;
  10507. /**
  10508. * Internal only
  10509. * @hidden
  10510. */ getProperty(propertyPath: string): string;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10515. /**
  10516. * Serialize placeholder for child classes
  10517. * @param parent of child
  10518. * @returns the serialized object
  10519. */
  10520. serialize(parent: any): any;
  10521. /**
  10522. * Internal only called by serialize
  10523. * @hidden
  10524. */
  10525. protected _serialize(serializedAction: any, parent?: any): any;
  10526. /**
  10527. * Internal only
  10528. * @hidden
  10529. */ private static _SerializeValueAsString: (value: any) => string;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10534. name: string;
  10535. targetType: string;
  10536. value: string;
  10537. };
  10538. }
  10539. }
  10540. declare module BABYLON {
  10541. /**
  10542. * A Condition applied to an Action
  10543. */
  10544. export class Condition {
  10545. /**
  10546. * Internal only - manager for action
  10547. * @hidden
  10548. */ actionManager: ActionManager;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */ evaluationId: number;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */ currentResult: boolean;
  10557. /**
  10558. * Creates a new Condition
  10559. * @param actionManager the manager of the action the condition is applied to
  10560. */
  10561. constructor(actionManager: ActionManager);
  10562. /**
  10563. * Check if the current condition is valid
  10564. * @returns a boolean
  10565. */
  10566. isValid(): boolean;
  10567. /**
  10568. * Internal only
  10569. * @hidden
  10570. */ getProperty(propertyPath: string): string;
  10571. /**
  10572. * Internal only
  10573. * @hidden
  10574. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10575. /**
  10576. * Serialize placeholder for child classes
  10577. * @returns the serialized object
  10578. */
  10579. serialize(): any;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. protected _serialize(serializedCondition: any): any;
  10585. }
  10586. /**
  10587. * Defines specific conditional operators as extensions of Condition
  10588. */
  10589. export class ValueCondition extends Condition {
  10590. /** path to specify the property of the target the conditional operator uses */
  10591. propertyPath: string;
  10592. /** the value compared by the conditional operator against the current value of the property */
  10593. value: any;
  10594. /** the conditional operator, default ValueCondition.IsEqual */
  10595. operator: number;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. private static _IsEqual;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */
  10605. private static _IsDifferent;
  10606. /**
  10607. * Internal only
  10608. * @hidden
  10609. */
  10610. private static _IsGreater;
  10611. /**
  10612. * Internal only
  10613. * @hidden
  10614. */
  10615. private static _IsLesser;
  10616. /**
  10617. * returns the number for IsEqual
  10618. */
  10619. static readonly IsEqual: number;
  10620. /**
  10621. * Returns the number for IsDifferent
  10622. */
  10623. static readonly IsDifferent: number;
  10624. /**
  10625. * Returns the number for IsGreater
  10626. */
  10627. static readonly IsGreater: number;
  10628. /**
  10629. * Returns the number for IsLesser
  10630. */
  10631. static readonly IsLesser: number;
  10632. /**
  10633. * Internal only The action manager for the condition
  10634. * @hidden
  10635. */ actionManager: ActionManager;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. private _target;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. private _effectiveTarget;
  10646. /**
  10647. * Internal only
  10648. * @hidden
  10649. */
  10650. private _property;
  10651. /**
  10652. * Creates a new ValueCondition
  10653. * @param actionManager manager for the action the condition applies to
  10654. * @param target for the action
  10655. * @param propertyPath path to specify the property of the target the conditional operator uses
  10656. * @param value the value compared by the conditional operator against the current value of the property
  10657. * @param operator the conditional operator, default ValueCondition.IsEqual
  10658. */
  10659. constructor(actionManager: ActionManager, target: any,
  10660. /** path to specify the property of the target the conditional operator uses */
  10661. propertyPath: string,
  10662. /** the value compared by the conditional operator against the current value of the property */
  10663. value: any,
  10664. /** the conditional operator, default ValueCondition.IsEqual */
  10665. operator?: number);
  10666. /**
  10667. * Compares the given value with the property value for the specified conditional operator
  10668. * @returns the result of the comparison
  10669. */
  10670. isValid(): boolean;
  10671. /**
  10672. * Serialize the ValueCondition into a JSON compatible object
  10673. * @returns serialization object
  10674. */
  10675. serialize(): any;
  10676. /**
  10677. * Gets the name of the conditional operator for the ValueCondition
  10678. * @param operator the conditional operator
  10679. * @returns the name
  10680. */
  10681. static GetOperatorName(operator: number): string;
  10682. }
  10683. /**
  10684. * Defines a predicate condition as an extension of Condition
  10685. */
  10686. export class PredicateCondition extends Condition {
  10687. /** defines the predicate function used to validate the condition */
  10688. predicate: () => boolean;
  10689. /**
  10690. * Internal only - manager for action
  10691. * @hidden
  10692. */ actionManager: ActionManager;
  10693. /**
  10694. * Creates a new PredicateCondition
  10695. * @param actionManager manager for the action the condition applies to
  10696. * @param predicate defines the predicate function used to validate the condition
  10697. */
  10698. constructor(actionManager: ActionManager,
  10699. /** defines the predicate function used to validate the condition */
  10700. predicate: () => boolean);
  10701. /**
  10702. * @returns the validity of the predicate condition
  10703. */
  10704. isValid(): boolean;
  10705. }
  10706. /**
  10707. * Defines a state condition as an extension of Condition
  10708. */
  10709. export class StateCondition extends Condition {
  10710. /** Value to compare with target state */
  10711. value: string;
  10712. /**
  10713. * Internal only - manager for action
  10714. * @hidden
  10715. */ actionManager: ActionManager;
  10716. /**
  10717. * Internal only
  10718. * @hidden
  10719. */
  10720. private _target;
  10721. /**
  10722. * Creates a new StateCondition
  10723. * @param actionManager manager for the action the condition applies to
  10724. * @param target of the condition
  10725. * @param value to compare with target state
  10726. */
  10727. constructor(actionManager: ActionManager, target: any,
  10728. /** Value to compare with target state */
  10729. value: string);
  10730. /**
  10731. * Gets a boolean indicating if the current condition is met
  10732. * @returns the validity of the state
  10733. */
  10734. isValid(): boolean;
  10735. /**
  10736. * Serialize the StateCondition into a JSON compatible object
  10737. * @returns serialization object
  10738. */
  10739. serialize(): any;
  10740. }
  10741. }
  10742. declare module BABYLON {
  10743. /**
  10744. * This defines an action responsible to toggle a boolean once triggered.
  10745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10746. */
  10747. export class SwitchBooleanAction extends Action {
  10748. /**
  10749. * The path to the boolean property in the target object
  10750. */
  10751. propertyPath: string;
  10752. private _target;
  10753. private _effectiveTarget;
  10754. private _property;
  10755. /**
  10756. * Instantiate the action
  10757. * @param triggerOptions defines the trigger options
  10758. * @param target defines the object containing the boolean
  10759. * @param propertyPath defines the path to the boolean property in the target object
  10760. * @param condition defines the trigger related conditions
  10761. */
  10762. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10763. /** @hidden */ prepare(): void;
  10764. /**
  10765. * Execute the action toggle the boolean value.
  10766. */
  10767. execute(): void;
  10768. /**
  10769. * Serializes the actions and its related information.
  10770. * @param parent defines the object to serialize in
  10771. * @returns the serialized object
  10772. */
  10773. serialize(parent: any): any;
  10774. }
  10775. /**
  10776. * This defines an action responsible to set a the state field of the target
  10777. * to a desired value once triggered.
  10778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10779. */
  10780. export class SetStateAction extends Action {
  10781. /**
  10782. * The value to store in the state field.
  10783. */
  10784. value: string;
  10785. private _target;
  10786. /**
  10787. * Instantiate the action
  10788. * @param triggerOptions defines the trigger options
  10789. * @param target defines the object containing the state property
  10790. * @param value defines the value to store in the state field
  10791. * @param condition defines the trigger related conditions
  10792. */
  10793. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10794. /**
  10795. * Execute the action and store the value on the target state property.
  10796. */
  10797. execute(): void;
  10798. /**
  10799. * Serializes the actions and its related information.
  10800. * @param parent defines the object to serialize in
  10801. * @returns the serialized object
  10802. */
  10803. serialize(parent: any): any;
  10804. }
  10805. /**
  10806. * This defines an action responsible to set a property of the target
  10807. * to a desired value once triggered.
  10808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10809. */
  10810. export class SetValueAction extends Action {
  10811. /**
  10812. * The path of the property to set in the target.
  10813. */
  10814. propertyPath: string;
  10815. /**
  10816. * The value to set in the property
  10817. */
  10818. value: any;
  10819. private _target;
  10820. private _effectiveTarget;
  10821. private _property;
  10822. /**
  10823. * Instantiate the action
  10824. * @param triggerOptions defines the trigger options
  10825. * @param target defines the object containing the property
  10826. * @param propertyPath defines the path of the property to set in the target
  10827. * @param value defines the value to set in the property
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10831. /** @hidden */ prepare(): void;
  10832. /**
  10833. * Execute the action and set the targetted property to the desired value.
  10834. */
  10835. execute(): void;
  10836. /**
  10837. * Serializes the actions and its related information.
  10838. * @param parent defines the object to serialize in
  10839. * @returns the serialized object
  10840. */
  10841. serialize(parent: any): any;
  10842. }
  10843. /**
  10844. * This defines an action responsible to increment the target value
  10845. * to a desired value once triggered.
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10847. */
  10848. export class IncrementValueAction extends Action {
  10849. /**
  10850. * The path of the property to increment in the target.
  10851. */
  10852. propertyPath: string;
  10853. /**
  10854. * The value we should increment the property by.
  10855. */
  10856. value: any;
  10857. private _target;
  10858. private _effectiveTarget;
  10859. private _property;
  10860. /**
  10861. * Instantiate the action
  10862. * @param triggerOptions defines the trigger options
  10863. * @param target defines the object containing the property
  10864. * @param propertyPath defines the path of the property to increment in the target
  10865. * @param value defines the value value we should increment the property by
  10866. * @param condition defines the trigger related conditions
  10867. */
  10868. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10869. /** @hidden */ prepare(): void;
  10870. /**
  10871. * Execute the action and increment the target of the value amount.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to start an animation once triggered.
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10884. */
  10885. export class PlayAnimationAction extends Action {
  10886. /**
  10887. * Where the animation should start (animation frame)
  10888. */
  10889. from: number;
  10890. /**
  10891. * Where the animation should stop (animation frame)
  10892. */
  10893. to: number;
  10894. /**
  10895. * Define if the animation should loop or stop after the first play.
  10896. */
  10897. loop?: boolean;
  10898. private _target;
  10899. /**
  10900. * Instantiate the action
  10901. * @param triggerOptions defines the trigger options
  10902. * @param target defines the target animation or animation name
  10903. * @param from defines from where the animation should start (animation frame)
  10904. * @param end defines where the animation should stop (animation frame)
  10905. * @param loop defines if the animation should loop or stop after the first play
  10906. * @param condition defines the trigger related conditions
  10907. */
  10908. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10909. /** @hidden */ prepare(): void;
  10910. /**
  10911. * Execute the action and play the animation.
  10912. */
  10913. execute(): void;
  10914. /**
  10915. * Serializes the actions and its related information.
  10916. * @param parent defines the object to serialize in
  10917. * @returns the serialized object
  10918. */
  10919. serialize(parent: any): any;
  10920. }
  10921. /**
  10922. * This defines an action responsible to stop an animation once triggered.
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10924. */
  10925. export class StopAnimationAction extends Action {
  10926. private _target;
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param target defines the target animation or animation name
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, target: any, condition?: Condition);
  10934. /** @hidden */ prepare(): void;
  10935. /**
  10936. * Execute the action and stop the animation.
  10937. */
  10938. execute(): void;
  10939. /**
  10940. * Serializes the actions and its related information.
  10941. * @param parent defines the object to serialize in
  10942. * @returns the serialized object
  10943. */
  10944. serialize(parent: any): any;
  10945. }
  10946. /**
  10947. * This defines an action responsible that does nothing once triggered.
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10949. */
  10950. export class DoNothingAction extends Action {
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param condition defines the trigger related conditions
  10955. */
  10956. constructor(triggerOptions?: any, condition?: Condition);
  10957. /**
  10958. * Execute the action and do nothing.
  10959. */
  10960. execute(): void;
  10961. /**
  10962. * Serializes the actions and its related information.
  10963. * @param parent defines the object to serialize in
  10964. * @returns the serialized object
  10965. */
  10966. serialize(parent: any): any;
  10967. }
  10968. /**
  10969. * This defines an action responsible to trigger several actions once triggered.
  10970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10971. */
  10972. export class CombineAction extends Action {
  10973. /**
  10974. * The list of aggregated animations to run.
  10975. */
  10976. children: Action[];
  10977. /**
  10978. * Instantiate the action
  10979. * @param triggerOptions defines the trigger options
  10980. * @param children defines the list of aggregated animations to run
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10984. /** @hidden */ prepare(): void;
  10985. /**
  10986. * Execute the action and executes all the aggregated actions.
  10987. */
  10988. execute(evt: ActionEvent): void;
  10989. /**
  10990. * Serializes the actions and its related information.
  10991. * @param parent defines the object to serialize in
  10992. * @returns the serialized object
  10993. */
  10994. serialize(parent: any): any;
  10995. }
  10996. /**
  10997. * This defines an action responsible to run code (external event) once triggered.
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10999. */
  11000. export class ExecuteCodeAction extends Action {
  11001. /**
  11002. * The callback function to run.
  11003. */
  11004. func: (evt: ActionEvent) => void;
  11005. /**
  11006. * Instantiate the action
  11007. * @param triggerOptions defines the trigger options
  11008. * @param func defines the callback function to run
  11009. * @param condition defines the trigger related conditions
  11010. */
  11011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11012. /**
  11013. * Execute the action and run the attached code.
  11014. */
  11015. execute(evt: ActionEvent): void;
  11016. }
  11017. /**
  11018. * This defines an action responsible to set the parent property of the target once triggered.
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11020. */
  11021. export class SetParentAction extends Action {
  11022. private _parent;
  11023. private _target;
  11024. /**
  11025. * Instantiate the action
  11026. * @param triggerOptions defines the trigger options
  11027. * @param target defines the target containing the parent property
  11028. * @param parent defines from where the animation should start (animation frame)
  11029. * @param condition defines the trigger related conditions
  11030. */
  11031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11032. /** @hidden */ prepare(): void;
  11033. /**
  11034. * Execute the action and set the parent property.
  11035. */
  11036. execute(): void;
  11037. /**
  11038. * Serializes the actions and its related information.
  11039. * @param parent defines the object to serialize in
  11040. * @returns the serialized object
  11041. */
  11042. serialize(parent: any): any;
  11043. }
  11044. }
  11045. declare module BABYLON {
  11046. /**
  11047. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11048. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11050. */
  11051. export class ActionManager extends AbstractActionManager {
  11052. /**
  11053. * Nothing
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly NothingTrigger: number;
  11057. /**
  11058. * On pick
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnPickTrigger: number;
  11062. /**
  11063. * On left pick
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnLeftPickTrigger: number;
  11067. /**
  11068. * On right pick
  11069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11070. */
  11071. static readonly OnRightPickTrigger: number;
  11072. /**
  11073. * On center pick
  11074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11075. */
  11076. static readonly OnCenterPickTrigger: number;
  11077. /**
  11078. * On pick down
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11080. */
  11081. static readonly OnPickDownTrigger: number;
  11082. /**
  11083. * On double pick
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11085. */
  11086. static readonly OnDoublePickTrigger: number;
  11087. /**
  11088. * On pick up
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnPickUpTrigger: number;
  11092. /**
  11093. * On pick out.
  11094. * This trigger will only be raised if you also declared a OnPickDown
  11095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11096. */
  11097. static readonly OnPickOutTrigger: number;
  11098. /**
  11099. * On long press
  11100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11101. */
  11102. static readonly OnLongPressTrigger: number;
  11103. /**
  11104. * On pointer over
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11106. */
  11107. static readonly OnPointerOverTrigger: number;
  11108. /**
  11109. * On pointer out
  11110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11111. */
  11112. static readonly OnPointerOutTrigger: number;
  11113. /**
  11114. * On every frame
  11115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11116. */
  11117. static readonly OnEveryFrameTrigger: number;
  11118. /**
  11119. * On intersection enter
  11120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11121. */
  11122. static readonly OnIntersectionEnterTrigger: number;
  11123. /**
  11124. * On intersection exit
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11126. */
  11127. static readonly OnIntersectionExitTrigger: number;
  11128. /**
  11129. * On key down
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11131. */
  11132. static readonly OnKeyDownTrigger: number;
  11133. /**
  11134. * On key up
  11135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11136. */
  11137. static readonly OnKeyUpTrigger: number;
  11138. private _scene;
  11139. /**
  11140. * Creates a new action manager
  11141. * @param scene defines the hosting scene
  11142. */
  11143. constructor(scene: Scene);
  11144. /**
  11145. * Releases all associated resources
  11146. */
  11147. dispose(): void;
  11148. /**
  11149. * Gets hosting scene
  11150. * @returns the hosting scene
  11151. */
  11152. getScene(): Scene;
  11153. /**
  11154. * Does this action manager handles actions of any of the given triggers
  11155. * @param triggers defines the triggers to be tested
  11156. * @return a boolean indicating whether one (or more) of the triggers is handled
  11157. */
  11158. hasSpecificTriggers(triggers: number[]): boolean;
  11159. /**
  11160. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11161. * speed.
  11162. * @param triggerA defines the trigger to be tested
  11163. * @param triggerB defines the trigger to be tested
  11164. * @return a boolean indicating whether one (or more) of the triggers is handled
  11165. */
  11166. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11167. /**
  11168. * Does this action manager handles actions of a given trigger
  11169. * @param trigger defines the trigger to be tested
  11170. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11171. * @return whether the trigger is handled
  11172. */
  11173. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11174. /**
  11175. * Does this action manager has pointer triggers
  11176. */
  11177. readonly hasPointerTriggers: boolean;
  11178. /**
  11179. * Does this action manager has pick triggers
  11180. */
  11181. readonly hasPickTriggers: boolean;
  11182. /**
  11183. * Registers an action to this action manager
  11184. * @param action defines the action to be registered
  11185. * @return the action amended (prepared) after registration
  11186. */
  11187. registerAction(action: IAction): Nullable<IAction>;
  11188. /**
  11189. * Unregisters an action to this action manager
  11190. * @param action defines the action to be unregistered
  11191. * @return a boolean indicating whether the action has been unregistered
  11192. */
  11193. unregisterAction(action: IAction): Boolean;
  11194. /**
  11195. * Process a specific trigger
  11196. * @param trigger defines the trigger to process
  11197. * @param evt defines the event details to be processed
  11198. */
  11199. processTrigger(trigger: number, evt?: IActionEvent): void;
  11200. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11201. /** @hidden */ getProperty(propertyPath: string): string;
  11202. /**
  11203. * Serialize this manager to a JSON object
  11204. * @param name defines the property name to store this manager
  11205. * @returns a JSON representation of this manager
  11206. */
  11207. serialize(name: string): any;
  11208. /**
  11209. * Creates a new ActionManager from a JSON data
  11210. * @param parsedActions defines the JSON data to read from
  11211. * @param object defines the hosting mesh
  11212. * @param scene defines the hosting scene
  11213. */
  11214. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11215. /**
  11216. * Get a trigger name by index
  11217. * @param trigger defines the trigger index
  11218. * @returns a trigger name
  11219. */
  11220. static GetTriggerName(trigger: number): string;
  11221. }
  11222. }
  11223. declare module BABYLON {
  11224. /**
  11225. * Class representing a ray with position and direction
  11226. */
  11227. export class Ray {
  11228. /** origin point */
  11229. origin: Vector3;
  11230. /** direction */
  11231. direction: Vector3;
  11232. /** length of the ray */
  11233. length: number;
  11234. private static readonly TmpVector3;
  11235. private _tmpRay;
  11236. /**
  11237. * Creates a new ray
  11238. * @param origin origin point
  11239. * @param direction direction
  11240. * @param length length of the ray
  11241. */
  11242. constructor(
  11243. /** origin point */
  11244. origin: Vector3,
  11245. /** direction */
  11246. direction: Vector3,
  11247. /** length of the ray */
  11248. length?: number);
  11249. /**
  11250. * Checks if the ray intersects a box
  11251. * @param minimum bound of the box
  11252. * @param maximum bound of the box
  11253. * @param intersectionTreshold extra extend to be added to the box in all direction
  11254. * @returns if the box was hit
  11255. */
  11256. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11257. /**
  11258. * Checks if the ray intersects a box
  11259. * @param box the bounding box to check
  11260. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11261. * @returns if the box was hit
  11262. */
  11263. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11264. /**
  11265. * If the ray hits a sphere
  11266. * @param sphere the bounding sphere to check
  11267. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11268. * @returns true if it hits the sphere
  11269. */
  11270. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11271. /**
  11272. * If the ray hits a triange
  11273. * @param vertex0 triangle vertex
  11274. * @param vertex1 triangle vertex
  11275. * @param vertex2 triangle vertex
  11276. * @returns intersection information if hit
  11277. */
  11278. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11279. /**
  11280. * Checks if ray intersects a plane
  11281. * @param plane the plane to check
  11282. * @returns the distance away it was hit
  11283. */
  11284. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11285. /**
  11286. * Checks if ray intersects a mesh
  11287. * @param mesh the mesh to check
  11288. * @param fastCheck if only the bounding box should checked
  11289. * @returns picking info of the intersecton
  11290. */
  11291. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11292. /**
  11293. * Checks if ray intersects a mesh
  11294. * @param meshes the meshes to check
  11295. * @param fastCheck if only the bounding box should checked
  11296. * @param results array to store result in
  11297. * @returns Array of picking infos
  11298. */
  11299. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11300. private _comparePickingInfo;
  11301. private static smallnum;
  11302. private static rayl;
  11303. /**
  11304. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11305. * @param sega the first point of the segment to test the intersection against
  11306. * @param segb the second point of the segment to test the intersection against
  11307. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11308. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11309. */
  11310. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11311. /**
  11312. * Update the ray from viewport position
  11313. * @param x position
  11314. * @param y y position
  11315. * @param viewportWidth viewport width
  11316. * @param viewportHeight viewport height
  11317. * @param world world matrix
  11318. * @param view view matrix
  11319. * @param projection projection matrix
  11320. * @returns this ray updated
  11321. */
  11322. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11323. /**
  11324. * Creates a ray with origin and direction of 0,0,0
  11325. * @returns the new ray
  11326. */
  11327. static Zero(): Ray;
  11328. /**
  11329. * Creates a new ray from screen space and viewport
  11330. * @param x position
  11331. * @param y y position
  11332. * @param viewportWidth viewport width
  11333. * @param viewportHeight viewport height
  11334. * @param world world matrix
  11335. * @param view view matrix
  11336. * @param projection projection matrix
  11337. * @returns new ray
  11338. */
  11339. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11340. /**
  11341. * 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
  11342. * transformed to the given world matrix.
  11343. * @param origin The origin point
  11344. * @param end The end point
  11345. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11346. * @returns the new ray
  11347. */
  11348. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11349. /**
  11350. * Transforms a ray by a matrix
  11351. * @param ray ray to transform
  11352. * @param matrix matrix to apply
  11353. * @returns the resulting new ray
  11354. */
  11355. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11356. /**
  11357. * Transforms a ray by a matrix
  11358. * @param ray ray to transform
  11359. * @param matrix matrix to apply
  11360. * @param result ray to store result in
  11361. */
  11362. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11363. /**
  11364. * Unproject a ray from screen space to object space
  11365. * @param sourceX defines the screen space x coordinate to use
  11366. * @param sourceY defines the screen space y coordinate to use
  11367. * @param viewportWidth defines the current width of the viewport
  11368. * @param viewportHeight defines the current height of the viewport
  11369. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11370. * @param view defines the view matrix to use
  11371. * @param projection defines the projection matrix to use
  11372. */
  11373. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11374. }
  11375. /**
  11376. * Type used to define predicate used to select faces when a mesh intersection is detected
  11377. */
  11378. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11379. interface Scene {
  11380. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11381. /** @hidden */ cachedRayForTransform: Ray;
  11382. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11383. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11384. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11385. }
  11386. }
  11387. declare module BABYLON {
  11388. /**
  11389. * Groups all the scene component constants in one place to ease maintenance.
  11390. * @hidden
  11391. */
  11392. export class SceneComponentConstants {
  11393. static readonly NAME_EFFECTLAYER: string;
  11394. static readonly NAME_LAYER: string;
  11395. static readonly NAME_LENSFLARESYSTEM: string;
  11396. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11397. static readonly NAME_PARTICLESYSTEM: string;
  11398. static readonly NAME_GAMEPAD: string;
  11399. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11400. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11401. static readonly NAME_DEPTHRENDERER: string;
  11402. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11403. static readonly NAME_SPRITE: string;
  11404. static readonly NAME_OUTLINERENDERER: string;
  11405. static readonly NAME_PROCEDURALTEXTURE: string;
  11406. static readonly NAME_SHADOWGENERATOR: string;
  11407. static readonly NAME_OCTREE: string;
  11408. static readonly NAME_PHYSICSENGINE: string;
  11409. static readonly NAME_AUDIO: string;
  11410. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11411. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11412. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11413. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11414. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11415. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11416. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11417. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11418. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11419. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11420. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11421. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11422. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11423. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11424. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11425. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11426. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11427. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11428. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11429. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11430. static readonly STEP_AFTERRENDER_AUDIO: number;
  11431. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11432. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11433. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11435. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11436. static readonly STEP_POINTERMOVE_SPRITE: number;
  11437. static readonly STEP_POINTERDOWN_SPRITE: number;
  11438. static readonly STEP_POINTERUP_SPRITE: number;
  11439. }
  11440. /**
  11441. * This represents a scene component.
  11442. *
  11443. * This is used to decouple the dependency the scene is having on the different workloads like
  11444. * layers, post processes...
  11445. */
  11446. export interface ISceneComponent {
  11447. /**
  11448. * The name of the component. Each component must have a unique name.
  11449. */
  11450. name: string;
  11451. /**
  11452. * The scene the component belongs to.
  11453. */
  11454. scene: Scene;
  11455. /**
  11456. * Register the component to one instance of a scene.
  11457. */
  11458. register(): void;
  11459. /**
  11460. * Rebuilds the elements related to this component in case of
  11461. * context lost for instance.
  11462. */
  11463. rebuild(): void;
  11464. /**
  11465. * Disposes the component and the associated ressources.
  11466. */
  11467. dispose(): void;
  11468. }
  11469. /**
  11470. * This represents a SERIALIZABLE scene component.
  11471. *
  11472. * This extends Scene Component to add Serialization methods on top.
  11473. */
  11474. export interface ISceneSerializableComponent extends ISceneComponent {
  11475. /**
  11476. * Adds all the element from the container to the scene
  11477. * @param container the container holding the elements
  11478. */
  11479. addFromContainer(container: AbstractScene): void;
  11480. /**
  11481. * Removes all the elements in the container from the scene
  11482. * @param container contains the elements to remove
  11483. * @param dispose if the removed element should be disposed (default: false)
  11484. */
  11485. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11486. /**
  11487. * Serializes the component data to the specified json object
  11488. * @param serializationObject The object to serialize to
  11489. */
  11490. serialize(serializationObject: any): void;
  11491. }
  11492. /**
  11493. * Strong typing of a Mesh related stage step action
  11494. */
  11495. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11496. /**
  11497. * Strong typing of a Evaluate Sub Mesh related stage step action
  11498. */
  11499. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11500. /**
  11501. * Strong typing of a Active Mesh related stage step action
  11502. */
  11503. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11504. /**
  11505. * Strong typing of a Camera related stage step action
  11506. */
  11507. export type CameraStageAction = (camera: Camera) => void;
  11508. /**
  11509. * Strong typing of a Camera Frame buffer related stage step action
  11510. */
  11511. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11512. /**
  11513. * Strong typing of a Render Target related stage step action
  11514. */
  11515. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11516. /**
  11517. * Strong typing of a RenderingGroup related stage step action
  11518. */
  11519. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11520. /**
  11521. * Strong typing of a Mesh Render related stage step action
  11522. */
  11523. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11524. /**
  11525. * Strong typing of a simple stage step action
  11526. */
  11527. export type SimpleStageAction = () => void;
  11528. /**
  11529. * Strong typing of a render target action.
  11530. */
  11531. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11532. /**
  11533. * Strong typing of a pointer move action.
  11534. */
  11535. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11536. /**
  11537. * Strong typing of a pointer up/down action.
  11538. */
  11539. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11540. /**
  11541. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11542. * @hidden
  11543. */
  11544. export class Stage<T extends Function> extends Array<{
  11545. index: number;
  11546. component: ISceneComponent;
  11547. action: T;
  11548. }> {
  11549. /**
  11550. * Hide ctor from the rest of the world.
  11551. * @param items The items to add.
  11552. */
  11553. private constructor();
  11554. /**
  11555. * Creates a new Stage.
  11556. * @returns A new instance of a Stage
  11557. */
  11558. static Create<T extends Function>(): Stage<T>;
  11559. /**
  11560. * Registers a step in an ordered way in the targeted stage.
  11561. * @param index Defines the position to register the step in
  11562. * @param component Defines the component attached to the step
  11563. * @param action Defines the action to launch during the step
  11564. */
  11565. registerStep(index: number, component: ISceneComponent, action: T): void;
  11566. /**
  11567. * Clears all the steps from the stage.
  11568. */
  11569. clear(): void;
  11570. }
  11571. }
  11572. declare module BABYLON {
  11573. interface Scene {
  11574. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11575. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11576. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11577. /**
  11578. * All of the sprite managers added to this scene
  11579. * @see http://doc.babylonjs.com/babylon101/sprites
  11580. */
  11581. spriteManagers: Array<ISpriteManager>;
  11582. /**
  11583. * An event triggered when sprites rendering is about to start
  11584. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11585. */
  11586. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11587. /**
  11588. * An event triggered when sprites rendering is done
  11589. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11590. */
  11591. onAfterSpritesRenderingObservable: Observable<Scene>;
  11592. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11593. /** Launch a ray to try to pick a sprite in the scene
  11594. * @param x position on screen
  11595. * @param y position on screen
  11596. * @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
  11597. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11598. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11599. * @returns a PickingInfo
  11600. */
  11601. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11602. /** Use the given ray to pick a sprite in the scene
  11603. * @param ray The ray (in world space) to use to pick meshes
  11604. * @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
  11605. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11606. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11607. * @returns a PickingInfo
  11608. */
  11609. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11610. /**
  11611. * Force the sprite under the pointer
  11612. * @param sprite defines the sprite to use
  11613. */
  11614. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11615. /**
  11616. * Gets the sprite under the pointer
  11617. * @returns a Sprite or null if no sprite is under the pointer
  11618. */
  11619. getPointerOverSprite(): Nullable<Sprite>;
  11620. }
  11621. /**
  11622. * Defines the sprite scene component responsible to manage sprites
  11623. * in a given scene.
  11624. */
  11625. export class SpriteSceneComponent implements ISceneComponent {
  11626. /**
  11627. * The component name helpfull to identify the component in the list of scene components.
  11628. */
  11629. readonly name: string;
  11630. /**
  11631. * The scene the component belongs to.
  11632. */
  11633. scene: Scene;
  11634. /** @hidden */
  11635. private _spritePredicate;
  11636. /**
  11637. * Creates a new instance of the component for the given scene
  11638. * @param scene Defines the scene to register the component in
  11639. */
  11640. constructor(scene: Scene);
  11641. /**
  11642. * Registers the component in a given scene
  11643. */
  11644. register(): void;
  11645. /**
  11646. * Rebuilds the elements related to this component in case of
  11647. * context lost for instance.
  11648. */
  11649. rebuild(): void;
  11650. /**
  11651. * Disposes the component and the associated ressources.
  11652. */
  11653. dispose(): void;
  11654. private _pickSpriteButKeepRay;
  11655. private _pointerMove;
  11656. private _pointerDown;
  11657. private _pointerUp;
  11658. }
  11659. }
  11660. declare module BABYLON {
  11661. /** @hidden */
  11662. export var fogFragmentDeclaration: {
  11663. name: string;
  11664. shader: string;
  11665. };
  11666. }
  11667. declare module BABYLON {
  11668. /** @hidden */
  11669. export var fogFragment: {
  11670. name: string;
  11671. shader: string;
  11672. };
  11673. }
  11674. declare module BABYLON {
  11675. /** @hidden */
  11676. export var spritesPixelShader: {
  11677. name: string;
  11678. shader: string;
  11679. };
  11680. }
  11681. declare module BABYLON {
  11682. /** @hidden */
  11683. export var fogVertexDeclaration: {
  11684. name: string;
  11685. shader: string;
  11686. };
  11687. }
  11688. declare module BABYLON {
  11689. /** @hidden */
  11690. export var spritesVertexShader: {
  11691. name: string;
  11692. shader: string;
  11693. };
  11694. }
  11695. declare module BABYLON {
  11696. /**
  11697. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11698. */
  11699. export interface ISpriteManager extends IDisposable {
  11700. /**
  11701. * Restricts the camera to viewing objects with the same layerMask.
  11702. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11703. */
  11704. layerMask: number;
  11705. /**
  11706. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11707. */
  11708. isPickable: boolean;
  11709. /**
  11710. * Specifies the rendering group id for this mesh (0 by default)
  11711. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11712. */
  11713. renderingGroupId: number;
  11714. /**
  11715. * Defines the list of sprites managed by the manager.
  11716. */
  11717. sprites: Array<Sprite>;
  11718. /**
  11719. * Tests the intersection of a sprite with a specific ray.
  11720. * @param ray The ray we are sending to test the collision
  11721. * @param camera The camera space we are sending rays in
  11722. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11723. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11724. * @returns picking info or null.
  11725. */
  11726. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11727. /**
  11728. * Renders the list of sprites on screen.
  11729. */
  11730. render(): void;
  11731. }
  11732. /**
  11733. * Class used to manage multiple sprites on the same spritesheet
  11734. * @see http://doc.babylonjs.com/babylon101/sprites
  11735. */
  11736. export class SpriteManager implements ISpriteManager {
  11737. /** defines the manager's name */
  11738. name: string;
  11739. /** Gets the list of sprites */
  11740. sprites: Sprite[];
  11741. /** Gets or sets the rendering group id (0 by default) */
  11742. renderingGroupId: number;
  11743. /** Gets or sets camera layer mask */
  11744. layerMask: number;
  11745. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11746. fogEnabled: boolean;
  11747. /** Gets or sets a boolean indicating if the sprites are pickable */
  11748. isPickable: boolean;
  11749. /** Defines the default width of a cell in the spritesheet */
  11750. cellWidth: number;
  11751. /** Defines the default height of a cell in the spritesheet */
  11752. cellHeight: number;
  11753. /**
  11754. * An event triggered when the manager is disposed.
  11755. */
  11756. onDisposeObservable: Observable<SpriteManager>;
  11757. private _onDisposeObserver;
  11758. /**
  11759. * Callback called when the manager is disposed
  11760. */
  11761. onDispose: () => void;
  11762. private _capacity;
  11763. private _spriteTexture;
  11764. private _epsilon;
  11765. private _scene;
  11766. private _vertexData;
  11767. private _buffer;
  11768. private _vertexBuffers;
  11769. private _indexBuffer;
  11770. private _effectBase;
  11771. private _effectFog;
  11772. /**
  11773. * Gets or sets the spritesheet texture
  11774. */
  11775. texture: Texture;
  11776. /**
  11777. * Creates a new sprite manager
  11778. * @param name defines the manager's name
  11779. * @param imgUrl defines the sprite sheet url
  11780. * @param capacity defines the maximum allowed number of sprites
  11781. * @param cellSize defines the size of a sprite cell
  11782. * @param scene defines the hosting scene
  11783. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11784. * @param samplingMode defines the smapling mode to use with spritesheet
  11785. */
  11786. constructor(
  11787. /** defines the manager's name */
  11788. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11789. private _appendSpriteVertex;
  11790. /**
  11791. * Intersects the sprites with a ray
  11792. * @param ray defines the ray to intersect with
  11793. * @param camera defines the current active camera
  11794. * @param predicate defines a predicate used to select candidate sprites
  11795. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11796. * @returns null if no hit or a PickingInfo
  11797. */
  11798. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11799. /**
  11800. * Render all child sprites
  11801. */
  11802. render(): void;
  11803. /**
  11804. * Release associated resources
  11805. */
  11806. dispose(): void;
  11807. }
  11808. }
  11809. declare module BABYLON {
  11810. /**
  11811. * Class used to represent a sprite
  11812. * @see http://doc.babylonjs.com/babylon101/sprites
  11813. */
  11814. export class Sprite {
  11815. /** defines the name */
  11816. name: string;
  11817. /** Gets or sets the current world position */
  11818. position: Vector3;
  11819. /** Gets or sets the main color */
  11820. color: Color4;
  11821. /** Gets or sets the width */
  11822. width: number;
  11823. /** Gets or sets the height */
  11824. height: number;
  11825. /** Gets or sets rotation angle */
  11826. angle: number;
  11827. /** Gets or sets the cell index in the sprite sheet */
  11828. cellIndex: number;
  11829. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11830. invertU: number;
  11831. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11832. invertV: number;
  11833. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11834. disposeWhenFinishedAnimating: boolean;
  11835. /** Gets the list of attached animations */
  11836. animations: Animation[];
  11837. /** Gets or sets a boolean indicating if the sprite can be picked */
  11838. isPickable: boolean;
  11839. /**
  11840. * Gets or sets the associated action manager
  11841. */
  11842. actionManager: Nullable<ActionManager>;
  11843. private _animationStarted;
  11844. private _loopAnimation;
  11845. private _fromIndex;
  11846. private _toIndex;
  11847. private _delay;
  11848. private _direction;
  11849. private _manager;
  11850. private _time;
  11851. private _onAnimationEnd;
  11852. /**
  11853. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11854. */
  11855. isVisible: boolean;
  11856. /**
  11857. * Gets or sets the sprite size
  11858. */
  11859. size: number;
  11860. /**
  11861. * Creates a new Sprite
  11862. * @param name defines the name
  11863. * @param manager defines the manager
  11864. */
  11865. constructor(
  11866. /** defines the name */
  11867. name: string, manager: ISpriteManager);
  11868. /**
  11869. * Starts an animation
  11870. * @param from defines the initial key
  11871. * @param to defines the end key
  11872. * @param loop defines if the animation must loop
  11873. * @param delay defines the start delay (in ms)
  11874. * @param onAnimationEnd defines a callback to call when animation ends
  11875. */
  11876. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11877. /** Stops current animation (if any) */
  11878. stopAnimation(): void;
  11879. /** @hidden */ animate(deltaTime: number): void;
  11880. /** Release associated resources */
  11881. dispose(): void;
  11882. }
  11883. }
  11884. declare module BABYLON {
  11885. /**
  11886. * Information about the result of picking within a scene
  11887. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11888. */
  11889. export class PickingInfo {
  11890. /** @hidden */ pickingUnavailable: boolean;
  11891. /**
  11892. * If the pick collided with an object
  11893. */
  11894. hit: boolean;
  11895. /**
  11896. * Distance away where the pick collided
  11897. */
  11898. distance: number;
  11899. /**
  11900. * The location of pick collision
  11901. */
  11902. pickedPoint: Nullable<Vector3>;
  11903. /**
  11904. * The mesh corresponding the the pick collision
  11905. */
  11906. pickedMesh: Nullable<AbstractMesh>;
  11907. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11908. bu: number;
  11909. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11910. bv: number;
  11911. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11912. faceId: number;
  11913. /** Id of the the submesh that was picked */
  11914. subMeshId: number;
  11915. /** If a sprite was picked, this will be the sprite the pick collided with */
  11916. pickedSprite: Nullable<Sprite>;
  11917. /**
  11918. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11919. */
  11920. originMesh: Nullable<AbstractMesh>;
  11921. /**
  11922. * The ray that was used to perform the picking.
  11923. */
  11924. ray: Nullable<Ray>;
  11925. /**
  11926. * Gets the normal correspodning to the face the pick collided with
  11927. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11928. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11929. * @returns The normal correspodning to the face the pick collided with
  11930. */
  11931. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11932. /**
  11933. * Gets the texture coordinates of where the pick occured
  11934. * @returns the vector containing the coordnates of the texture
  11935. */
  11936. getTextureCoordinates(): Nullable<Vector2>;
  11937. }
  11938. }
  11939. declare module BABYLON {
  11940. /**
  11941. * Gather the list of pointer event types as constants.
  11942. */
  11943. export class PointerEventTypes {
  11944. /**
  11945. * 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.
  11946. */
  11947. static readonly POINTERDOWN: number;
  11948. /**
  11949. * The pointerup event is fired when a pointer is no longer active.
  11950. */
  11951. static readonly POINTERUP: number;
  11952. /**
  11953. * The pointermove event is fired when a pointer changes coordinates.
  11954. */
  11955. static readonly POINTERMOVE: number;
  11956. /**
  11957. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11958. */
  11959. static readonly POINTERWHEEL: number;
  11960. /**
  11961. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11962. */
  11963. static readonly POINTERPICK: number;
  11964. /**
  11965. * The pointertap event is fired when a the object has been touched and released without drag.
  11966. */
  11967. static readonly POINTERTAP: number;
  11968. /**
  11969. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11970. */
  11971. static readonly POINTERDOUBLETAP: number;
  11972. }
  11973. /**
  11974. * Base class of pointer info types.
  11975. */
  11976. export class PointerInfoBase {
  11977. /**
  11978. * Defines the type of event (PointerEventTypes)
  11979. */
  11980. type: number;
  11981. /**
  11982. * Defines the related dom event
  11983. */
  11984. event: PointerEvent | MouseWheelEvent;
  11985. /**
  11986. * Instantiates the base class of pointers info.
  11987. * @param type Defines the type of event (PointerEventTypes)
  11988. * @param event Defines the related dom event
  11989. */
  11990. constructor(
  11991. /**
  11992. * Defines the type of event (PointerEventTypes)
  11993. */
  11994. type: number,
  11995. /**
  11996. * Defines the related dom event
  11997. */
  11998. event: PointerEvent | MouseWheelEvent);
  11999. }
  12000. /**
  12001. * This class is used to store pointer related info for the onPrePointerObservable event.
  12002. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12003. */
  12004. export class PointerInfoPre extends PointerInfoBase {
  12005. /**
  12006. * Ray from a pointer if availible (eg. 6dof controller)
  12007. */
  12008. ray: Nullable<Ray>;
  12009. /**
  12010. * Defines the local position of the pointer on the canvas.
  12011. */
  12012. localPosition: Vector2;
  12013. /**
  12014. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12015. */
  12016. skipOnPointerObservable: boolean;
  12017. /**
  12018. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12019. * @param type Defines the type of event (PointerEventTypes)
  12020. * @param event Defines the related dom event
  12021. * @param localX Defines the local x coordinates of the pointer when the event occured
  12022. * @param localY Defines the local y coordinates of the pointer when the event occured
  12023. */
  12024. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12025. }
  12026. /**
  12027. * This type contains all the data related to a pointer event in Babylon.js.
  12028. * 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.
  12029. */
  12030. export class PointerInfo extends PointerInfoBase {
  12031. /**
  12032. * Defines the picking info associated to the info (if any)\
  12033. */
  12034. pickInfo: Nullable<PickingInfo>;
  12035. /**
  12036. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12037. * @param type Defines the type of event (PointerEventTypes)
  12038. * @param event Defines the related dom event
  12039. * @param pickInfo Defines the picking info associated to the info (if any)\
  12040. */
  12041. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12042. /**
  12043. * Defines the picking info associated to the info (if any)\
  12044. */
  12045. pickInfo: Nullable<PickingInfo>);
  12046. }
  12047. /**
  12048. * Data relating to a touch event on the screen.
  12049. */
  12050. export interface PointerTouch {
  12051. /**
  12052. * X coordinate of touch.
  12053. */
  12054. x: number;
  12055. /**
  12056. * Y coordinate of touch.
  12057. */
  12058. y: number;
  12059. /**
  12060. * Id of touch. Unique for each finger.
  12061. */
  12062. pointerId: number;
  12063. /**
  12064. * Event type passed from DOM.
  12065. */
  12066. type: any;
  12067. }
  12068. }
  12069. declare module BABYLON {
  12070. /**
  12071. * Manage the mouse inputs to control the movement of a free camera.
  12072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12073. */
  12074. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12075. /**
  12076. * Define if touch is enabled in the mouse input
  12077. */
  12078. touchEnabled: boolean;
  12079. /**
  12080. * Defines the camera the input is attached to.
  12081. */
  12082. camera: FreeCamera;
  12083. /**
  12084. * Defines the buttons associated with the input to handle camera move.
  12085. */
  12086. buttons: number[];
  12087. /**
  12088. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12089. */
  12090. angularSensibility: number;
  12091. private _pointerInput;
  12092. private _onMouseMove;
  12093. private _observer;
  12094. private previousPosition;
  12095. /**
  12096. * Observable for when a pointer move event occurs containing the move offset
  12097. */
  12098. onPointerMovedObservable: Observable<{
  12099. offsetX: number;
  12100. offsetY: number;
  12101. }>;
  12102. /**
  12103. * @hidden
  12104. * If the camera should be rotated automatically based on pointer movement
  12105. */ allowCameraRotation: boolean;
  12106. /**
  12107. * Manage the mouse inputs to control the movement of a free camera.
  12108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12109. * @param touchEnabled Defines if touch is enabled or not
  12110. */
  12111. constructor(
  12112. /**
  12113. * Define if touch is enabled in the mouse input
  12114. */
  12115. touchEnabled?: boolean);
  12116. /**
  12117. * Attach the input controls to a specific dom element to get the input from.
  12118. * @param element Defines the element the controls should be listened from
  12119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12120. */
  12121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12122. /**
  12123. * Called on JS contextmenu event.
  12124. * Override this method to provide functionality.
  12125. */
  12126. protected onContextMenu(evt: PointerEvent): void;
  12127. /**
  12128. * Detach the current controls from the specified dom element.
  12129. * @param element Defines the element to stop listening the inputs from
  12130. */
  12131. detachControl(element: Nullable<HTMLElement>): void;
  12132. /**
  12133. * Gets the class name of the current intput.
  12134. * @returns the class name
  12135. */
  12136. getClassName(): string;
  12137. /**
  12138. * Get the friendly name associated with the input class.
  12139. * @returns the input friendly name
  12140. */
  12141. getSimpleName(): string;
  12142. }
  12143. }
  12144. declare module BABYLON {
  12145. /**
  12146. * Manage the touch inputs to control the movement of a free camera.
  12147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12148. */
  12149. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12150. /**
  12151. * Defines the camera the input is attached to.
  12152. */
  12153. camera: FreeCamera;
  12154. /**
  12155. * Defines the touch sensibility for rotation.
  12156. * The higher the faster.
  12157. */
  12158. touchAngularSensibility: number;
  12159. /**
  12160. * Defines the touch sensibility for move.
  12161. * The higher the faster.
  12162. */
  12163. touchMoveSensibility: number;
  12164. private _offsetX;
  12165. private _offsetY;
  12166. private _pointerPressed;
  12167. private _pointerInput;
  12168. private _observer;
  12169. private _onLostFocus;
  12170. /**
  12171. * Attach the input controls to a specific dom element to get the input from.
  12172. * @param element Defines the element the controls should be listened from
  12173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12174. */
  12175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12176. /**
  12177. * Detach the current controls from the specified dom element.
  12178. * @param element Defines the element to stop listening the inputs from
  12179. */
  12180. detachControl(element: Nullable<HTMLElement>): void;
  12181. /**
  12182. * Update the current camera state depending on the inputs that have been used this frame.
  12183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12184. */
  12185. checkInputs(): void;
  12186. /**
  12187. * Gets the class name of the current intput.
  12188. * @returns the class name
  12189. */
  12190. getClassName(): string;
  12191. /**
  12192. * Get the friendly name associated with the input class.
  12193. * @returns the input friendly name
  12194. */
  12195. getSimpleName(): string;
  12196. }
  12197. }
  12198. declare module BABYLON {
  12199. /**
  12200. * Default Inputs manager for the FreeCamera.
  12201. * It groups all the default supported inputs for ease of use.
  12202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12203. */
  12204. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12205. /**
  12206. * @hidden
  12207. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12208. /**
  12209. * @hidden
  12210. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12211. /**
  12212. * Instantiates a new FreeCameraInputsManager.
  12213. * @param camera Defines the camera the inputs belong to
  12214. */
  12215. constructor(camera: FreeCamera);
  12216. /**
  12217. * Add keyboard input support to the input manager.
  12218. * @returns the current input manager
  12219. */
  12220. addKeyboard(): FreeCameraInputsManager;
  12221. /**
  12222. * Add mouse input support to the input manager.
  12223. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12224. * @returns the current input manager
  12225. */
  12226. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12227. /**
  12228. * Removes the mouse input support from the manager
  12229. * @returns the current input manager
  12230. */
  12231. removeMouse(): FreeCameraInputsManager;
  12232. /**
  12233. * Add touch input support to the input manager.
  12234. * @returns the current input manager
  12235. */
  12236. addTouch(): FreeCameraInputsManager;
  12237. }
  12238. }
  12239. declare module BABYLON {
  12240. /**
  12241. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12242. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12244. */
  12245. export class FreeCamera extends TargetCamera {
  12246. /**
  12247. * Define the collision ellipsoid of the camera.
  12248. * This is helpful to simulate a camera body like the player body around the camera
  12249. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12250. */
  12251. ellipsoid: Vector3;
  12252. /**
  12253. * Define an offset for the position of the ellipsoid around the camera.
  12254. * This can be helpful to determine the center of the body near the gravity center of the body
  12255. * instead of its head.
  12256. */
  12257. ellipsoidOffset: Vector3;
  12258. /**
  12259. * Enable or disable collisions of the camera with the rest of the scene objects.
  12260. */
  12261. checkCollisions: boolean;
  12262. /**
  12263. * Enable or disable gravity on the camera.
  12264. */
  12265. applyGravity: boolean;
  12266. /**
  12267. * Define the input manager associated to the camera.
  12268. */
  12269. inputs: FreeCameraInputsManager;
  12270. /**
  12271. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12272. * Higher values reduce sensitivity.
  12273. */
  12274. /**
  12275. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12276. * Higher values reduce sensitivity.
  12277. */
  12278. angularSensibility: number;
  12279. /**
  12280. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12281. */
  12282. keysUp: number[];
  12283. /**
  12284. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12285. */
  12286. keysDown: number[];
  12287. /**
  12288. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12289. */
  12290. keysLeft: number[];
  12291. /**
  12292. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12293. */
  12294. keysRight: number[];
  12295. /**
  12296. * Event raised when the camera collide with a mesh in the scene.
  12297. */
  12298. onCollide: (collidedMesh: AbstractMesh) => void;
  12299. private _collider;
  12300. private _needMoveForGravity;
  12301. private _oldPosition;
  12302. private _diffPosition;
  12303. private _newPosition;
  12304. /** @hidden */ localDirection: Vector3;
  12305. /** @hidden */ transformedDirection: Vector3;
  12306. /**
  12307. * Instantiates a Free Camera.
  12308. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12309. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12310. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12311. * @param name Define the name of the camera in the scene
  12312. * @param position Define the start position of the camera in the scene
  12313. * @param scene Define the scene the camera belongs to
  12314. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12315. */
  12316. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12317. /**
  12318. * Attached controls to the current camera.
  12319. * @param element Defines the element the controls should be listened from
  12320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12321. */
  12322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12323. /**
  12324. * Detach the current controls from the camera.
  12325. * The camera will stop reacting to inputs.
  12326. * @param element Defines the element to stop listening the inputs from
  12327. */
  12328. detachControl(element: HTMLElement): void;
  12329. private _collisionMask;
  12330. /**
  12331. * Define a collision mask to limit the list of object the camera can collide with
  12332. */
  12333. collisionMask: number;
  12334. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12335. private _onCollisionPositionChange;
  12336. /** @hidden */ checkInputs(): void;
  12337. /** @hidden */ decideIfNeedsToMove(): boolean;
  12338. /** @hidden */ updatePosition(): void;
  12339. /**
  12340. * Destroy the camera and release the current resources hold by it.
  12341. */
  12342. dispose(): void;
  12343. /**
  12344. * Gets the current object class name.
  12345. * @return the class name
  12346. */
  12347. getClassName(): string;
  12348. }
  12349. }
  12350. declare module BABYLON {
  12351. /**
  12352. * Represents a gamepad control stick position
  12353. */
  12354. export class StickValues {
  12355. /**
  12356. * The x component of the control stick
  12357. */
  12358. x: number;
  12359. /**
  12360. * The y component of the control stick
  12361. */
  12362. y: number;
  12363. /**
  12364. * Initializes the gamepad x and y control stick values
  12365. * @param x The x component of the gamepad control stick value
  12366. * @param y The y component of the gamepad control stick value
  12367. */
  12368. constructor(
  12369. /**
  12370. * The x component of the control stick
  12371. */
  12372. x: number,
  12373. /**
  12374. * The y component of the control stick
  12375. */
  12376. y: number);
  12377. }
  12378. /**
  12379. * An interface which manages callbacks for gamepad button changes
  12380. */
  12381. export interface GamepadButtonChanges {
  12382. /**
  12383. * Called when a gamepad has been changed
  12384. */
  12385. changed: boolean;
  12386. /**
  12387. * Called when a gamepad press event has been triggered
  12388. */
  12389. pressChanged: boolean;
  12390. /**
  12391. * Called when a touch event has been triggered
  12392. */
  12393. touchChanged: boolean;
  12394. /**
  12395. * Called when a value has changed
  12396. */
  12397. valueChanged: boolean;
  12398. }
  12399. /**
  12400. * Represents a gamepad
  12401. */
  12402. export class Gamepad {
  12403. /**
  12404. * The id of the gamepad
  12405. */
  12406. id: string;
  12407. /**
  12408. * The index of the gamepad
  12409. */
  12410. index: number;
  12411. /**
  12412. * The browser gamepad
  12413. */
  12414. browserGamepad: any;
  12415. /**
  12416. * Specifies what type of gamepad this represents
  12417. */
  12418. type: number;
  12419. private _leftStick;
  12420. private _rightStick;
  12421. /** @hidden */ isConnected: boolean;
  12422. private _leftStickAxisX;
  12423. private _leftStickAxisY;
  12424. private _rightStickAxisX;
  12425. private _rightStickAxisY;
  12426. /**
  12427. * Triggered when the left control stick has been changed
  12428. */
  12429. private _onleftstickchanged;
  12430. /**
  12431. * Triggered when the right control stick has been changed
  12432. */
  12433. private _onrightstickchanged;
  12434. /**
  12435. * Represents a gamepad controller
  12436. */
  12437. static GAMEPAD: number;
  12438. /**
  12439. * Represents a generic controller
  12440. */
  12441. static GENERIC: number;
  12442. /**
  12443. * Represents an XBox controller
  12444. */
  12445. static XBOX: number;
  12446. /**
  12447. * Represents a pose-enabled controller
  12448. */
  12449. static POSE_ENABLED: number;
  12450. /**
  12451. * Specifies whether the left control stick should be Y-inverted
  12452. */
  12453. protected _invertLeftStickY: boolean;
  12454. /**
  12455. * Specifies if the gamepad has been connected
  12456. */
  12457. readonly isConnected: boolean;
  12458. /**
  12459. * Initializes the gamepad
  12460. * @param id The id of the gamepad
  12461. * @param index The index of the gamepad
  12462. * @param browserGamepad The browser gamepad
  12463. * @param leftStickX The x component of the left joystick
  12464. * @param leftStickY The y component of the left joystick
  12465. * @param rightStickX The x component of the right joystick
  12466. * @param rightStickY The y component of the right joystick
  12467. */
  12468. constructor(
  12469. /**
  12470. * The id of the gamepad
  12471. */
  12472. id: string,
  12473. /**
  12474. * The index of the gamepad
  12475. */
  12476. index: number,
  12477. /**
  12478. * The browser gamepad
  12479. */
  12480. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12481. /**
  12482. * Callback triggered when the left joystick has changed
  12483. * @param callback
  12484. */
  12485. onleftstickchanged(callback: (values: StickValues) => void): void;
  12486. /**
  12487. * Callback triggered when the right joystick has changed
  12488. * @param callback
  12489. */
  12490. onrightstickchanged(callback: (values: StickValues) => void): void;
  12491. /**
  12492. * Gets the left joystick
  12493. */
  12494. /**
  12495. * Sets the left joystick values
  12496. */
  12497. leftStick: StickValues;
  12498. /**
  12499. * Gets the right joystick
  12500. */
  12501. /**
  12502. * Sets the right joystick value
  12503. */
  12504. rightStick: StickValues;
  12505. /**
  12506. * Updates the gamepad joystick positions
  12507. */
  12508. update(): void;
  12509. /**
  12510. * Disposes the gamepad
  12511. */
  12512. dispose(): void;
  12513. }
  12514. /**
  12515. * Represents a generic gamepad
  12516. */
  12517. export class GenericPad extends Gamepad {
  12518. private _buttons;
  12519. private _onbuttondown;
  12520. private _onbuttonup;
  12521. /**
  12522. * Observable triggered when a button has been pressed
  12523. */
  12524. onButtonDownObservable: Observable<number>;
  12525. /**
  12526. * Observable triggered when a button has been released
  12527. */
  12528. onButtonUpObservable: Observable<number>;
  12529. /**
  12530. * Callback triggered when a button has been pressed
  12531. * @param callback Called when a button has been pressed
  12532. */
  12533. onbuttondown(callback: (buttonPressed: number) => void): void;
  12534. /**
  12535. * Callback triggered when a button has been released
  12536. * @param callback Called when a button has been released
  12537. */
  12538. onbuttonup(callback: (buttonReleased: number) => void): void;
  12539. /**
  12540. * Initializes the generic gamepad
  12541. * @param id The id of the generic gamepad
  12542. * @param index The index of the generic gamepad
  12543. * @param browserGamepad The browser gamepad
  12544. */
  12545. constructor(id: string, index: number, browserGamepad: any);
  12546. private _setButtonValue;
  12547. /**
  12548. * Updates the generic gamepad
  12549. */
  12550. update(): void;
  12551. /**
  12552. * Disposes the generic gamepad
  12553. */
  12554. dispose(): void;
  12555. }
  12556. }
  12557. declare module BABYLON {
  12558. /**
  12559. * Defines the types of pose enabled controllers that are supported
  12560. */
  12561. export enum PoseEnabledControllerType {
  12562. /**
  12563. * HTC Vive
  12564. */
  12565. VIVE = 0,
  12566. /**
  12567. * Oculus Rift
  12568. */
  12569. OCULUS = 1,
  12570. /**
  12571. * Windows mixed reality
  12572. */
  12573. WINDOWS = 2,
  12574. /**
  12575. * Samsung gear VR
  12576. */
  12577. GEAR_VR = 3,
  12578. /**
  12579. * Google Daydream
  12580. */
  12581. DAYDREAM = 4,
  12582. /**
  12583. * Generic
  12584. */
  12585. GENERIC = 5
  12586. }
  12587. /**
  12588. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12589. */
  12590. export interface MutableGamepadButton {
  12591. /**
  12592. * Value of the button/trigger
  12593. */
  12594. value: number;
  12595. /**
  12596. * If the button/trigger is currently touched
  12597. */
  12598. touched: boolean;
  12599. /**
  12600. * If the button/trigger is currently pressed
  12601. */
  12602. pressed: boolean;
  12603. }
  12604. /**
  12605. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12606. * @hidden
  12607. */
  12608. export interface ExtendedGamepadButton extends GamepadButton {
  12609. /**
  12610. * If the button/trigger is currently pressed
  12611. */
  12612. readonly pressed: boolean;
  12613. /**
  12614. * If the button/trigger is currently touched
  12615. */
  12616. readonly touched: boolean;
  12617. /**
  12618. * Value of the button/trigger
  12619. */
  12620. readonly value: number;
  12621. }
  12622. /** @hidden */
  12623. export interface _GamePadFactory {
  12624. /**
  12625. * Returns wether or not the current gamepad can be created for this type of controller.
  12626. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12627. * @returns true if it can be created, otherwise false
  12628. */
  12629. canCreate(gamepadInfo: any): boolean;
  12630. /**
  12631. * Creates a new instance of the Gamepad.
  12632. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12633. * @returns the new gamepad instance
  12634. */
  12635. create(gamepadInfo: any): Gamepad;
  12636. }
  12637. /**
  12638. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12639. */
  12640. export class PoseEnabledControllerHelper {
  12641. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12642. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12643. /**
  12644. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12645. * @param vrGamepad the gamepad to initialized
  12646. * @returns a vr controller of the type the gamepad identified as
  12647. */
  12648. static InitiateController(vrGamepad: any): Gamepad;
  12649. }
  12650. /**
  12651. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12652. */
  12653. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12654. private _deviceRoomPosition;
  12655. private _deviceRoomRotationQuaternion;
  12656. /**
  12657. * The device position in babylon space
  12658. */
  12659. devicePosition: Vector3;
  12660. /**
  12661. * The device rotation in babylon space
  12662. */
  12663. deviceRotationQuaternion: Quaternion;
  12664. /**
  12665. * The scale factor of the device in babylon space
  12666. */
  12667. deviceScaleFactor: number;
  12668. /**
  12669. * (Likely devicePosition should be used instead) The device position in its room space
  12670. */
  12671. position: Vector3;
  12672. /**
  12673. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12674. */
  12675. rotationQuaternion: Quaternion;
  12676. /**
  12677. * The type of controller (Eg. Windows mixed reality)
  12678. */
  12679. controllerType: PoseEnabledControllerType;
  12680. protected _calculatedPosition: Vector3;
  12681. private _calculatedRotation;
  12682. /**
  12683. * The raw pose from the device
  12684. */
  12685. rawPose: DevicePose;
  12686. private _trackPosition;
  12687. private _maxRotationDistFromHeadset;
  12688. private _draggedRoomRotation;
  12689. /**
  12690. * @hidden
  12691. */ disableTrackPosition(fixedPosition: Vector3): void;
  12692. /**
  12693. * Internal, the mesh attached to the controller
  12694. * @hidden
  12695. */ mesh: Nullable<AbstractMesh>;
  12696. private _poseControlledCamera;
  12697. private _leftHandSystemQuaternion;
  12698. /**
  12699. * Internal, matrix used to convert room space to babylon space
  12700. * @hidden
  12701. */ deviceToWorld: Matrix;
  12702. /**
  12703. * Node to be used when casting a ray from the controller
  12704. * @hidden
  12705. */ pointingPoseNode: Nullable<TransformNode>;
  12706. /**
  12707. * Name of the child mesh that can be used to cast a ray from the controller
  12708. */
  12709. static readonly POINTING_POSE: string;
  12710. /**
  12711. * Creates a new PoseEnabledController from a gamepad
  12712. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12713. */
  12714. constructor(browserGamepad: any);
  12715. private _workingMatrix;
  12716. /**
  12717. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12718. */
  12719. update(): void;
  12720. /**
  12721. * Updates only the pose device and mesh without doing any button event checking
  12722. */
  12723. protected _updatePoseAndMesh(): void;
  12724. /**
  12725. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12726. * @param poseData raw pose fromthe device
  12727. */
  12728. updateFromDevice(poseData: DevicePose): void;
  12729. /**
  12730. * @hidden
  12731. */ meshAttachedObservable: Observable<AbstractMesh>;
  12732. /**
  12733. * Attaches a mesh to the controller
  12734. * @param mesh the mesh to be attached
  12735. */
  12736. attachToMesh(mesh: AbstractMesh): void;
  12737. /**
  12738. * Attaches the controllers mesh to a camera
  12739. * @param camera the camera the mesh should be attached to
  12740. */
  12741. attachToPoseControlledCamera(camera: TargetCamera): void;
  12742. /**
  12743. * Disposes of the controller
  12744. */
  12745. dispose(): void;
  12746. /**
  12747. * The mesh that is attached to the controller
  12748. */
  12749. readonly mesh: Nullable<AbstractMesh>;
  12750. /**
  12751. * Gets the ray of the controller in the direction the controller is pointing
  12752. * @param length the length the resulting ray should be
  12753. * @returns a ray in the direction the controller is pointing
  12754. */
  12755. getForwardRay(length?: number): Ray;
  12756. }
  12757. }
  12758. declare module BABYLON {
  12759. /**
  12760. * Defines the WebVRController object that represents controllers tracked in 3D space
  12761. */
  12762. export abstract class WebVRController extends PoseEnabledController {
  12763. /**
  12764. * Internal, the default controller model for the controller
  12765. */
  12766. protected _defaultModel: AbstractMesh;
  12767. /**
  12768. * Fired when the trigger state has changed
  12769. */
  12770. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12771. /**
  12772. * Fired when the main button state has changed
  12773. */
  12774. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12775. /**
  12776. * Fired when the secondary button state has changed
  12777. */
  12778. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12779. /**
  12780. * Fired when the pad state has changed
  12781. */
  12782. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12783. /**
  12784. * Fired when controllers stick values have changed
  12785. */
  12786. onPadValuesChangedObservable: Observable<StickValues>;
  12787. /**
  12788. * Array of button availible on the controller
  12789. */
  12790. protected _buttons: Array<MutableGamepadButton>;
  12791. private _onButtonStateChange;
  12792. /**
  12793. * Fired when a controller button's state has changed
  12794. * @param callback the callback containing the button that was modified
  12795. */
  12796. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12797. /**
  12798. * X and Y axis corrisponding to the controllers joystick
  12799. */
  12800. pad: StickValues;
  12801. /**
  12802. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12803. */
  12804. hand: string;
  12805. /**
  12806. * The default controller model for the controller
  12807. */
  12808. readonly defaultModel: AbstractMesh;
  12809. /**
  12810. * Creates a new WebVRController from a gamepad
  12811. * @param vrGamepad the gamepad that the WebVRController should be created from
  12812. */
  12813. constructor(vrGamepad: any);
  12814. /**
  12815. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12816. */
  12817. update(): void;
  12818. /**
  12819. * Function to be called when a button is modified
  12820. */
  12821. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12822. /**
  12823. * Loads a mesh and attaches it to the controller
  12824. * @param scene the scene the mesh should be added to
  12825. * @param meshLoaded callback for when the mesh has been loaded
  12826. */
  12827. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12828. private _setButtonValue;
  12829. private _changes;
  12830. private _checkChanges;
  12831. /**
  12832. * Disposes of th webVRCOntroller
  12833. */
  12834. dispose(): void;
  12835. }
  12836. }
  12837. declare module BABYLON {
  12838. /**
  12839. * The HemisphericLight simulates the ambient environment light,
  12840. * so the passed direction is the light reflection direction, not the incoming direction.
  12841. */
  12842. export class HemisphericLight extends Light {
  12843. /**
  12844. * The groundColor is the light in the opposite direction to the one specified during creation.
  12845. * 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.
  12846. */
  12847. groundColor: Color3;
  12848. /**
  12849. * The light reflection direction, not the incoming direction.
  12850. */
  12851. direction: Vector3;
  12852. /**
  12853. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12854. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12855. * The HemisphericLight can't cast shadows.
  12856. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12857. * @param name The friendly name of the light
  12858. * @param direction The direction of the light reflection
  12859. * @param scene The scene the light belongs to
  12860. */
  12861. constructor(name: string, direction: Vector3, scene: Scene);
  12862. protected _buildUniformLayout(): void;
  12863. /**
  12864. * Returns the string "HemisphericLight".
  12865. * @return The class name
  12866. */
  12867. getClassName(): string;
  12868. /**
  12869. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12870. * Returns the updated direction.
  12871. * @param target The target the direction should point to
  12872. * @return The computed direction
  12873. */
  12874. setDirectionToTarget(target: Vector3): Vector3;
  12875. /**
  12876. * Returns the shadow generator associated to the light.
  12877. * @returns Always null for hemispheric lights because it does not support shadows.
  12878. */
  12879. getShadowGenerator(): Nullable<IShadowGenerator>;
  12880. /**
  12881. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12882. * @param effect The effect to update
  12883. * @param lightIndex The index of the light in the effect to update
  12884. * @returns The hemispheric light
  12885. */
  12886. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12887. /**
  12888. * Computes the world matrix of the node
  12889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12890. * @param useWasUpdatedFlag defines a reserved property
  12891. * @returns the world matrix
  12892. */
  12893. computeWorldMatrix(): Matrix;
  12894. /**
  12895. * Returns the integer 3.
  12896. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12897. */
  12898. getTypeID(): number;
  12899. /**
  12900. * Prepares the list of defines specific to the light type.
  12901. * @param defines the list of defines
  12902. * @param lightIndex defines the index of the light for the effect
  12903. */
  12904. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12905. }
  12906. }
  12907. declare module BABYLON {
  12908. /** @hidden */
  12909. export var vrMultiviewToSingleviewPixelShader: {
  12910. name: string;
  12911. shader: string;
  12912. };
  12913. }
  12914. declare module BABYLON {
  12915. /**
  12916. * Renders to multiple views with a single draw call
  12917. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12918. */
  12919. export class MultiviewRenderTarget extends RenderTargetTexture {
  12920. /**
  12921. * Creates a multiview render target
  12922. * @param scene scene used with the render target
  12923. * @param size the size of the render target (used for each view)
  12924. */
  12925. constructor(scene: Scene, size?: number | {
  12926. width: number;
  12927. height: number;
  12928. } | {
  12929. ratio: number;
  12930. });
  12931. /**
  12932. * @hidden
  12933. * @param faceIndex the face index, if its a cube texture
  12934. */ bindFrameBuffer(faceIndex?: number): void;
  12935. /**
  12936. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12937. * @returns the view count
  12938. */
  12939. getViewCount(): number;
  12940. }
  12941. }
  12942. declare module BABYLON {
  12943. interface Engine {
  12944. /**
  12945. * Creates a new multiview render target
  12946. * @param width defines the width of the texture
  12947. * @param height defines the height of the texture
  12948. * @returns the created multiview texture
  12949. */
  12950. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12951. /**
  12952. * Binds a multiview framebuffer to be drawn to
  12953. * @param multiviewTexture texture to bind
  12954. */
  12955. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12956. }
  12957. interface Camera {
  12958. /**
  12959. * @hidden
  12960. * 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)
  12961. */ useMultiviewToSingleView: boolean;
  12962. /**
  12963. * @hidden
  12964. * 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)
  12965. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12966. /**
  12967. * @hidden
  12968. * ensures the multiview texture of the camera exists and has the specified width/height
  12969. * @param width height to set on the multiview texture
  12970. * @param height width to set on the multiview texture
  12971. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12972. }
  12973. interface Scene {
  12974. /** @hidden */ transformMatrixR: Matrix;
  12975. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12976. /** @hidden */ createMultiviewUbo(): void;
  12977. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12978. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12979. }
  12980. }
  12981. declare module BABYLON {
  12982. /**
  12983. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12984. * This will not be used for webXR as it supports displaying texture arrays directly
  12985. */
  12986. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12987. /**
  12988. * Initializes a VRMultiviewToSingleview
  12989. * @param name name of the post process
  12990. * @param camera camera to be applied to
  12991. * @param scaleFactor scaling factor to the size of the output texture
  12992. */
  12993. constructor(name: string, camera: Camera, scaleFactor: number);
  12994. }
  12995. }
  12996. declare module BABYLON {
  12997. /**
  12998. * Defines the interface used by display changed events
  12999. */
  13000. interface IDisplayChangedEventArgs {
  13001. /** Gets the vrDisplay object (if any) */
  13002. vrDisplay: Nullable<any>;
  13003. /** Gets a boolean indicating if webVR is supported */
  13004. vrSupported: boolean;
  13005. }
  13006. interface Engine {
  13007. /** @hidden */ vrDisplay: any;
  13008. /** @hidden */ vrSupported: boolean;
  13009. /** @hidden */ oldSize: Size;
  13010. /** @hidden */ oldHardwareScaleFactor: number;
  13011. /** @hidden */ vrExclusivePointerMode: boolean;
  13012. /** @hidden */ webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13013. /** @hidden */ onVRDisplayPointerRestricted: () => void;
  13014. /** @hidden */ onVRDisplayPointerUnrestricted: () => void;
  13015. /** @hidden */ onVrDisplayConnect: Nullable<(display: any) => void>;
  13016. /** @hidden */ onVrDisplayDisconnect: Nullable<() => void>;
  13017. /** @hidden */ onVrDisplayPresentChange: Nullable<() => void>;
  13018. /**
  13019. * Observable signaled when VR display mode changes
  13020. */
  13021. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13022. /**
  13023. * Observable signaled when VR request present is complete
  13024. */
  13025. onVRRequestPresentComplete: Observable<boolean>;
  13026. /**
  13027. * Observable signaled when VR request present starts
  13028. */
  13029. onVRRequestPresentStart: Observable<Engine>;
  13030. /**
  13031. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13032. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13033. */
  13034. isInVRExclusivePointerMode: boolean;
  13035. /**
  13036. * Gets a boolean indicating if a webVR device was detected
  13037. * @returns true if a webVR device was detected
  13038. */
  13039. isVRDevicePresent(): boolean;
  13040. /**
  13041. * Gets the current webVR device
  13042. * @returns the current webVR device (or null)
  13043. */
  13044. getVRDevice(): any;
  13045. /**
  13046. * Initializes a webVR display and starts listening to display change events
  13047. * The onVRDisplayChangedObservable will be notified upon these changes
  13048. * @returns A promise containing a VRDisplay and if vr is supported
  13049. */
  13050. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13051. /** @hidden */ getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13052. /**
  13053. * Call this function to switch to webVR mode
  13054. * Will do nothing if webVR is not supported or if there is no webVR device
  13055. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13056. */
  13057. enableVR(): void;
  13058. /** @hidden */ onVRFullScreenTriggered(): void;
  13059. }
  13060. }
  13061. declare module BABYLON {
  13062. /**
  13063. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13064. * IMPORTANT!! The data is right-hand data.
  13065. * @export
  13066. * @interface DevicePose
  13067. */
  13068. export interface DevicePose {
  13069. /**
  13070. * The position of the device, values in array are [x,y,z].
  13071. */
  13072. readonly position: Nullable<Float32Array>;
  13073. /**
  13074. * The linearVelocity of the device, values in array are [x,y,z].
  13075. */
  13076. readonly linearVelocity: Nullable<Float32Array>;
  13077. /**
  13078. * The linearAcceleration of the device, values in array are [x,y,z].
  13079. */
  13080. readonly linearAcceleration: Nullable<Float32Array>;
  13081. /**
  13082. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13083. */
  13084. readonly orientation: Nullable<Float32Array>;
  13085. /**
  13086. * The angularVelocity of the device, values in array are [x,y,z].
  13087. */
  13088. readonly angularVelocity: Nullable<Float32Array>;
  13089. /**
  13090. * The angularAcceleration of the device, values in array are [x,y,z].
  13091. */
  13092. readonly angularAcceleration: Nullable<Float32Array>;
  13093. }
  13094. /**
  13095. * Interface representing a pose controlled object in Babylon.
  13096. * A pose controlled object has both regular pose values as well as pose values
  13097. * from an external device such as a VR head mounted display
  13098. */
  13099. export interface PoseControlled {
  13100. /**
  13101. * The position of the object in babylon space.
  13102. */
  13103. position: Vector3;
  13104. /**
  13105. * The rotation quaternion of the object in babylon space.
  13106. */
  13107. rotationQuaternion: Quaternion;
  13108. /**
  13109. * The position of the device in babylon space.
  13110. */
  13111. devicePosition?: Vector3;
  13112. /**
  13113. * The rotation quaternion of the device in babylon space.
  13114. */
  13115. deviceRotationQuaternion: Quaternion;
  13116. /**
  13117. * The raw pose coming from the device.
  13118. */
  13119. rawPose: Nullable<DevicePose>;
  13120. /**
  13121. * The scale of the device to be used when translating from device space to babylon space.
  13122. */
  13123. deviceScaleFactor: number;
  13124. /**
  13125. * Updates the poseControlled values based on the input device pose.
  13126. * @param poseData the pose data to update the object with
  13127. */
  13128. updateFromDevice(poseData: DevicePose): void;
  13129. }
  13130. /**
  13131. * Set of options to customize the webVRCamera
  13132. */
  13133. export interface WebVROptions {
  13134. /**
  13135. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13136. */
  13137. trackPosition?: boolean;
  13138. /**
  13139. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13140. */
  13141. positionScale?: number;
  13142. /**
  13143. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13144. */
  13145. displayName?: string;
  13146. /**
  13147. * Should the native controller meshes be initialized. (default: true)
  13148. */
  13149. controllerMeshes?: boolean;
  13150. /**
  13151. * Creating a default HemiLight only on controllers. (default: true)
  13152. */
  13153. defaultLightingOnControllers?: boolean;
  13154. /**
  13155. * If you don't want to use the default VR button of the helper. (default: false)
  13156. */
  13157. useCustomVRButton?: boolean;
  13158. /**
  13159. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13160. */
  13161. customVRButton?: HTMLButtonElement;
  13162. /**
  13163. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13164. */
  13165. rayLength?: number;
  13166. /**
  13167. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13168. */
  13169. defaultHeight?: number;
  13170. /**
  13171. * If multiview should be used if availible (default: false)
  13172. */
  13173. useMultiview?: boolean;
  13174. }
  13175. /**
  13176. * This represents a WebVR camera.
  13177. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13178. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13179. */
  13180. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13181. private webVROptions;
  13182. /**
  13183. * @hidden
  13184. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13185. */ vrDevice: any;
  13186. /**
  13187. * The rawPose of the vrDevice.
  13188. */
  13189. rawPose: Nullable<DevicePose>;
  13190. private _onVREnabled;
  13191. private _specsVersion;
  13192. private _attached;
  13193. private _frameData;
  13194. protected _descendants: Array<Node>;
  13195. private _deviceRoomPosition;
  13196. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  13197. private _standingMatrix;
  13198. /**
  13199. * Represents device position in babylon space.
  13200. */
  13201. devicePosition: Vector3;
  13202. /**
  13203. * Represents device rotation in babylon space.
  13204. */
  13205. deviceRotationQuaternion: Quaternion;
  13206. /**
  13207. * The scale of the device to be used when translating from device space to babylon space.
  13208. */
  13209. deviceScaleFactor: number;
  13210. private _deviceToWorld;
  13211. private _worldToDevice;
  13212. /**
  13213. * References to the webVR controllers for the vrDevice.
  13214. */
  13215. controllers: Array<WebVRController>;
  13216. /**
  13217. * Emits an event when a controller is attached.
  13218. */
  13219. onControllersAttachedObservable: Observable<WebVRController[]>;
  13220. /**
  13221. * Emits an event when a controller's mesh has been loaded;
  13222. */
  13223. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13224. /**
  13225. * Emits an event when the HMD's pose has been updated.
  13226. */
  13227. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13228. private _poseSet;
  13229. /**
  13230. * If the rig cameras be used as parent instead of this camera.
  13231. */
  13232. rigParenting: boolean;
  13233. private _lightOnControllers;
  13234. private _defaultHeight?;
  13235. /**
  13236. * Instantiates a WebVRFreeCamera.
  13237. * @param name The name of the WebVRFreeCamera
  13238. * @param position The starting anchor position for the camera
  13239. * @param scene The scene the camera belongs to
  13240. * @param webVROptions a set of customizable options for the webVRCamera
  13241. */
  13242. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13243. /**
  13244. * Gets the device distance from the ground in meters.
  13245. * @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.
  13246. */
  13247. deviceDistanceToRoomGround(): number;
  13248. /**
  13249. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13250. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13251. */
  13252. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13253. /**
  13254. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13255. * @returns A promise with a boolean set to if the standing matrix is supported.
  13256. */
  13257. useStandingMatrixAsync(): Promise<boolean>;
  13258. /**
  13259. * Disposes the camera
  13260. */
  13261. dispose(): void;
  13262. /**
  13263. * Gets a vrController by name.
  13264. * @param name The name of the controller to retreive
  13265. * @returns the controller matching the name specified or null if not found
  13266. */
  13267. getControllerByName(name: string): Nullable<WebVRController>;
  13268. private _leftController;
  13269. /**
  13270. * The controller corrisponding to the users left hand.
  13271. */
  13272. readonly leftController: Nullable<WebVRController>;
  13273. private _rightController;
  13274. /**
  13275. * The controller corrisponding to the users right hand.
  13276. */
  13277. readonly rightController: Nullable<WebVRController>;
  13278. /**
  13279. * Casts a ray forward from the vrCamera's gaze.
  13280. * @param length Length of the ray (default: 100)
  13281. * @returns the ray corrisponding to the gaze
  13282. */
  13283. getForwardRay(length?: number): Ray;
  13284. /**
  13285. * @hidden
  13286. * Updates the camera based on device's frame data
  13287. */ checkInputs(): void;
  13288. /**
  13289. * Updates the poseControlled values based on the input device pose.
  13290. * @param poseData Pose coming from the device
  13291. */
  13292. updateFromDevice(poseData: DevicePose): void;
  13293. private _htmlElementAttached;
  13294. private _detachIfAttached;
  13295. /**
  13296. * WebVR's attach control will start broadcasting frames to the device.
  13297. * Note that in certain browsers (chrome for example) this function must be called
  13298. * within a user-interaction callback. Example:
  13299. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13300. *
  13301. * @param element html element to attach the vrDevice to
  13302. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13303. */
  13304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13305. /**
  13306. * Detaches the camera from the html element and disables VR
  13307. *
  13308. * @param element html element to detach from
  13309. */
  13310. detachControl(element: HTMLElement): void;
  13311. /**
  13312. * @returns the name of this class
  13313. */
  13314. getClassName(): string;
  13315. /**
  13316. * Calls resetPose on the vrDisplay
  13317. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13318. */
  13319. resetToCurrentRotation(): void;
  13320. /**
  13321. * @hidden
  13322. * Updates the rig cameras (left and right eye)
  13323. */ updateRigCameras(): void;
  13324. private _workingVector;
  13325. private _oneVector;
  13326. private _workingMatrix;
  13327. private updateCacheCalled;
  13328. private _correctPositionIfNotTrackPosition;
  13329. /**
  13330. * @hidden
  13331. * Updates the cached values of the camera
  13332. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13333. */ updateCache(ignoreParentClass?: boolean): void;
  13334. /**
  13335. * @hidden
  13336. * Get current device position in babylon world
  13337. */ computeDevicePosition(): void;
  13338. /**
  13339. * Updates the current device position and rotation in the babylon world
  13340. */
  13341. update(): void;
  13342. /**
  13343. * @hidden
  13344. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13345. * @returns an identity matrix
  13346. */ getViewMatrix(): Matrix;
  13347. private _tmpMatrix;
  13348. /**
  13349. * This function is called by the two RIG cameras.
  13350. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13351. * @hidden
  13352. */ getWebVRViewMatrix(): Matrix;
  13353. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13354. private _onGamepadConnectedObserver;
  13355. private _onGamepadDisconnectedObserver;
  13356. private _updateCacheWhenTrackingDisabledObserver;
  13357. /**
  13358. * Initializes the controllers and their meshes
  13359. */
  13360. initControllers(): void;
  13361. }
  13362. }
  13363. declare module BABYLON {
  13364. /**
  13365. * Size options for a post process
  13366. */
  13367. export type PostProcessOptions = {
  13368. width: number;
  13369. height: number;
  13370. };
  13371. /**
  13372. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13373. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13374. */
  13375. export class PostProcess {
  13376. /** Name of the PostProcess. */
  13377. name: string;
  13378. /**
  13379. * Gets or sets the unique id of the post process
  13380. */
  13381. uniqueId: number;
  13382. /**
  13383. * Width of the texture to apply the post process on
  13384. */
  13385. width: number;
  13386. /**
  13387. * Height of the texture to apply the post process on
  13388. */
  13389. height: number;
  13390. /**
  13391. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13392. * @hidden
  13393. */ outputTexture: Nullable<InternalTexture>;
  13394. /**
  13395. * Sampling mode used by the shader
  13396. * See https://doc.babylonjs.com/classes/3.1/texture
  13397. */
  13398. renderTargetSamplingMode: number;
  13399. /**
  13400. * Clear color to use when screen clearing
  13401. */
  13402. clearColor: Color4;
  13403. /**
  13404. * If the buffer needs to be cleared before applying the post process. (default: true)
  13405. * Should be set to false if shader will overwrite all previous pixels.
  13406. */
  13407. autoClear: boolean;
  13408. /**
  13409. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13410. */
  13411. alphaMode: number;
  13412. /**
  13413. * Sets the setAlphaBlendConstants of the babylon engine
  13414. */
  13415. alphaConstants: Color4;
  13416. /**
  13417. * Animations to be used for the post processing
  13418. */
  13419. animations: Animation[];
  13420. /**
  13421. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13422. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13423. */
  13424. enablePixelPerfectMode: boolean;
  13425. /**
  13426. * Force the postprocess to be applied without taking in account viewport
  13427. */
  13428. forceFullscreenViewport: boolean;
  13429. /**
  13430. * List of inspectable custom properties (used by the Inspector)
  13431. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13432. */
  13433. inspectableCustomProperties: IInspectable[];
  13434. /**
  13435. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13436. *
  13437. * | Value | Type | Description |
  13438. * | ----- | ----------------------------------- | ----------- |
  13439. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13440. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13441. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13442. *
  13443. */
  13444. scaleMode: number;
  13445. /**
  13446. * Force textures to be a power of two (default: false)
  13447. */
  13448. alwaysForcePOT: boolean;
  13449. private _samples;
  13450. /**
  13451. * Number of sample textures (default: 1)
  13452. */
  13453. samples: number;
  13454. /**
  13455. * Modify the scale of the post process to be the same as the viewport (default: false)
  13456. */
  13457. adaptScaleToCurrentViewport: boolean;
  13458. private _camera;
  13459. private _scene;
  13460. private _engine;
  13461. private _options;
  13462. private _reusable;
  13463. private _textureType;
  13464. /**
  13465. * Smart array of input and output textures for the post process.
  13466. * @hidden
  13467. */ textures: SmartArray<InternalTexture>;
  13468. /**
  13469. * The index in _textures that corresponds to the output texture.
  13470. * @hidden
  13471. */ currentRenderTextureInd: number;
  13472. private _effect;
  13473. private _samplers;
  13474. private _fragmentUrl;
  13475. private _vertexUrl;
  13476. private _parameters;
  13477. private _scaleRatio;
  13478. protected _indexParameters: any;
  13479. private _shareOutputWithPostProcess;
  13480. private _texelSize;
  13481. private _forcedOutputTexture;
  13482. /**
  13483. * Returns the fragment url or shader name used in the post process.
  13484. * @returns the fragment url or name in the shader store.
  13485. */
  13486. getEffectName(): string;
  13487. /**
  13488. * An event triggered when the postprocess is activated.
  13489. */
  13490. onActivateObservable: Observable<Camera>;
  13491. private _onActivateObserver;
  13492. /**
  13493. * A function that is added to the onActivateObservable
  13494. */
  13495. onActivate: Nullable<(camera: Camera) => void>;
  13496. /**
  13497. * An event triggered when the postprocess changes its size.
  13498. */
  13499. onSizeChangedObservable: Observable<PostProcess>;
  13500. private _onSizeChangedObserver;
  13501. /**
  13502. * A function that is added to the onSizeChangedObservable
  13503. */
  13504. onSizeChanged: (postProcess: PostProcess) => void;
  13505. /**
  13506. * An event triggered when the postprocess applies its effect.
  13507. */
  13508. onApplyObservable: Observable<Effect>;
  13509. private _onApplyObserver;
  13510. /**
  13511. * A function that is added to the onApplyObservable
  13512. */
  13513. onApply: (effect: Effect) => void;
  13514. /**
  13515. * An event triggered before rendering the postprocess
  13516. */
  13517. onBeforeRenderObservable: Observable<Effect>;
  13518. private _onBeforeRenderObserver;
  13519. /**
  13520. * A function that is added to the onBeforeRenderObservable
  13521. */
  13522. onBeforeRender: (effect: Effect) => void;
  13523. /**
  13524. * An event triggered after rendering the postprocess
  13525. */
  13526. onAfterRenderObservable: Observable<Effect>;
  13527. private _onAfterRenderObserver;
  13528. /**
  13529. * A function that is added to the onAfterRenderObservable
  13530. */
  13531. onAfterRender: (efect: Effect) => void;
  13532. /**
  13533. * 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
  13534. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13535. */
  13536. inputTexture: InternalTexture;
  13537. /**
  13538. * Gets the camera which post process is applied to.
  13539. * @returns The camera the post process is applied to.
  13540. */
  13541. getCamera(): Camera;
  13542. /**
  13543. * Gets the texel size of the postprocess.
  13544. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13545. */
  13546. readonly texelSize: Vector2;
  13547. /**
  13548. * Creates a new instance PostProcess
  13549. * @param name The name of the PostProcess.
  13550. * @param fragmentUrl The url of the fragment shader to be used.
  13551. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13552. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13553. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13554. * @param camera The camera to apply the render pass to.
  13555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13556. * @param engine The engine which the post process will be applied. (default: current engine)
  13557. * @param reusable If the post process can be reused on the same frame. (default: false)
  13558. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13559. * @param textureType Type of textures used when performing the post process. (default: 0)
  13560. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13561. * @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
  13562. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13563. */
  13564. constructor(
  13565. /** Name of the PostProcess. */
  13566. 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);
  13567. /**
  13568. * Gets a string idenfifying the name of the class
  13569. * @returns "PostProcess" string
  13570. */
  13571. getClassName(): string;
  13572. /**
  13573. * Gets the engine which this post process belongs to.
  13574. * @returns The engine the post process was enabled with.
  13575. */
  13576. getEngine(): Engine;
  13577. /**
  13578. * The effect that is created when initializing the post process.
  13579. * @returns The created effect corrisponding the the postprocess.
  13580. */
  13581. getEffect(): Effect;
  13582. /**
  13583. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13584. * @param postProcess The post process to share the output with.
  13585. * @returns This post process.
  13586. */
  13587. shareOutputWith(postProcess: PostProcess): PostProcess;
  13588. /**
  13589. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13590. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13591. */
  13592. useOwnOutput(): void;
  13593. /**
  13594. * Updates the effect with the current post process compile time values and recompiles the shader.
  13595. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13596. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13597. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13598. * @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
  13599. * @param onCompiled Called when the shader has been compiled.
  13600. * @param onError Called if there is an error when compiling a shader.
  13601. */
  13602. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13603. /**
  13604. * The post process is reusable if it can be used multiple times within one frame.
  13605. * @returns If the post process is reusable
  13606. */
  13607. isReusable(): boolean;
  13608. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13609. markTextureDirty(): void;
  13610. /**
  13611. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13612. * 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.
  13613. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13614. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13615. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13616. * @returns The target texture that was bound to be written to.
  13617. */
  13618. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13619. /**
  13620. * If the post process is supported.
  13621. */
  13622. readonly isSupported: boolean;
  13623. /**
  13624. * The aspect ratio of the output texture.
  13625. */
  13626. readonly aspectRatio: number;
  13627. /**
  13628. * Get a value indicating if the post-process is ready to be used
  13629. * @returns true if the post-process is ready (shader is compiled)
  13630. */
  13631. isReady(): boolean;
  13632. /**
  13633. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13634. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13635. */
  13636. apply(): Nullable<Effect>;
  13637. private _disposeTextures;
  13638. /**
  13639. * Disposes the post process.
  13640. * @param camera The camera to dispose the post process on.
  13641. */
  13642. dispose(camera?: Camera): void;
  13643. }
  13644. }
  13645. declare module BABYLON {
  13646. /**
  13647. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13648. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13649. */
  13650. export class PostProcessManager {
  13651. private _scene;
  13652. private _indexBuffer;
  13653. private _vertexBuffers;
  13654. /**
  13655. * Creates a new instance PostProcess
  13656. * @param scene The scene that the post process is associated with.
  13657. */
  13658. constructor(scene: Scene);
  13659. private _prepareBuffers;
  13660. private _buildIndexBuffer;
  13661. /**
  13662. * Rebuilds the vertex buffers of the manager.
  13663. * @hidden
  13664. */ rebuild(): void;
  13665. /**
  13666. * Prepares a frame to be run through a post process.
  13667. * @param sourceTexture The input texture to the post procesess. (default: null)
  13668. * @param postProcesses An array of post processes to be run. (default: null)
  13669. * @returns True if the post processes were able to be run.
  13670. * @hidden
  13671. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13672. /**
  13673. * Manually render a set of post processes to a texture.
  13674. * @param postProcesses An array of post processes to be run.
  13675. * @param targetTexture The target texture to render to.
  13676. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13677. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13678. * @param lodLevel defines which lod of the texture to render to
  13679. */
  13680. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13681. /**
  13682. * Finalize the result of the output of the postprocesses.
  13683. * @param doNotPresent If true the result will not be displayed to the screen.
  13684. * @param targetTexture The target texture to render to.
  13685. * @param faceIndex The index of the face to bind the target texture to.
  13686. * @param postProcesses The array of post processes to render.
  13687. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13688. * @hidden
  13689. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13690. /**
  13691. * Disposes of the post process manager.
  13692. */
  13693. dispose(): void;
  13694. }
  13695. }
  13696. declare module BABYLON {
  13697. interface AbstractScene {
  13698. /**
  13699. * The list of layers (background and foreground) of the scene
  13700. */
  13701. layers: Array<Layer>;
  13702. }
  13703. /**
  13704. * Defines the layer scene component responsible to manage any layers
  13705. * in a given scene.
  13706. */
  13707. export class LayerSceneComponent implements ISceneComponent {
  13708. /**
  13709. * The component name helpfull to identify the component in the list of scene components.
  13710. */
  13711. readonly name: string;
  13712. /**
  13713. * The scene the component belongs to.
  13714. */
  13715. scene: Scene;
  13716. private _engine;
  13717. /**
  13718. * Creates a new instance of the component for the given scene
  13719. * @param scene Defines the scene to register the component in
  13720. */
  13721. constructor(scene: Scene);
  13722. /**
  13723. * Registers the component in a given scene
  13724. */
  13725. register(): void;
  13726. /**
  13727. * Rebuilds the elements related to this component in case of
  13728. * context lost for instance.
  13729. */
  13730. rebuild(): void;
  13731. /**
  13732. * Disposes the component and the associated ressources.
  13733. */
  13734. dispose(): void;
  13735. private _draw;
  13736. private _drawCameraPredicate;
  13737. private _drawCameraBackground;
  13738. private _drawCameraForeground;
  13739. private _drawRenderTargetPredicate;
  13740. private _drawRenderTargetBackground;
  13741. private _drawRenderTargetForeground;
  13742. }
  13743. }
  13744. declare module BABYLON {
  13745. /** @hidden */
  13746. export var layerPixelShader: {
  13747. name: string;
  13748. shader: string;
  13749. };
  13750. }
  13751. declare module BABYLON {
  13752. /** @hidden */
  13753. export var layerVertexShader: {
  13754. name: string;
  13755. shader: string;
  13756. };
  13757. }
  13758. declare module BABYLON {
  13759. /**
  13760. * This represents a full screen 2d layer.
  13761. * This can be useful to display a picture in the background of your scene for instance.
  13762. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13763. */
  13764. export class Layer {
  13765. /**
  13766. * Define the name of the layer.
  13767. */
  13768. name: string;
  13769. /**
  13770. * Define the texture the layer should display.
  13771. */
  13772. texture: Nullable<Texture>;
  13773. /**
  13774. * Is the layer in background or foreground.
  13775. */
  13776. isBackground: boolean;
  13777. /**
  13778. * Define the color of the layer (instead of texture).
  13779. */
  13780. color: Color4;
  13781. /**
  13782. * Define the scale of the layer in order to zoom in out of the texture.
  13783. */
  13784. scale: Vector2;
  13785. /**
  13786. * Define an offset for the layer in order to shift the texture.
  13787. */
  13788. offset: Vector2;
  13789. /**
  13790. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13791. */
  13792. alphaBlendingMode: number;
  13793. /**
  13794. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13795. * Alpha test will not mix with the background color in case of transparency.
  13796. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13797. */
  13798. alphaTest: boolean;
  13799. /**
  13800. * Define a mask to restrict the layer to only some of the scene cameras.
  13801. */
  13802. layerMask: number;
  13803. /**
  13804. * Define the list of render target the layer is visible into.
  13805. */
  13806. renderTargetTextures: RenderTargetTexture[];
  13807. /**
  13808. * Define if the layer is only used in renderTarget or if it also
  13809. * renders in the main frame buffer of the canvas.
  13810. */
  13811. renderOnlyInRenderTargetTextures: boolean;
  13812. private _scene;
  13813. private _vertexBuffers;
  13814. private _indexBuffer;
  13815. private _effect;
  13816. private _alphaTestEffect;
  13817. /**
  13818. * An event triggered when the layer is disposed.
  13819. */
  13820. onDisposeObservable: Observable<Layer>;
  13821. private _onDisposeObserver;
  13822. /**
  13823. * Back compatibility with callback before the onDisposeObservable existed.
  13824. * The set callback will be triggered when the layer has been disposed.
  13825. */
  13826. onDispose: () => void;
  13827. /**
  13828. * An event triggered before rendering the scene
  13829. */
  13830. onBeforeRenderObservable: Observable<Layer>;
  13831. private _onBeforeRenderObserver;
  13832. /**
  13833. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13834. * The set callback will be triggered just before rendering the layer.
  13835. */
  13836. onBeforeRender: () => void;
  13837. /**
  13838. * An event triggered after rendering the scene
  13839. */
  13840. onAfterRenderObservable: Observable<Layer>;
  13841. private _onAfterRenderObserver;
  13842. /**
  13843. * Back compatibility with callback before the onAfterRenderObservable existed.
  13844. * The set callback will be triggered just after rendering the layer.
  13845. */
  13846. onAfterRender: () => void;
  13847. /**
  13848. * Instantiates a new layer.
  13849. * This represents a full screen 2d layer.
  13850. * This can be useful to display a picture in the background of your scene for instance.
  13851. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13852. * @param name Define the name of the layer in the scene
  13853. * @param imgUrl Define the url of the texture to display in the layer
  13854. * @param scene Define the scene the layer belongs to
  13855. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13856. * @param color Defines a color for the layer
  13857. */
  13858. constructor(
  13859. /**
  13860. * Define the name of the layer.
  13861. */
  13862. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13863. private _createIndexBuffer;
  13864. /** @hidden */ rebuild(): void;
  13865. /**
  13866. * Renders the layer in the scene.
  13867. */
  13868. render(): void;
  13869. /**
  13870. * Disposes and releases the associated ressources.
  13871. */
  13872. dispose(): void;
  13873. }
  13874. }
  13875. declare module BABYLON {
  13876. interface AbstractScene {
  13877. /**
  13878. * The list of procedural textures added to the scene
  13879. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13880. */
  13881. proceduralTextures: Array<ProceduralTexture>;
  13882. }
  13883. /**
  13884. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13885. * in a given scene.
  13886. */
  13887. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13888. /**
  13889. * The component name helpfull to identify the component in the list of scene components.
  13890. */
  13891. readonly name: string;
  13892. /**
  13893. * The scene the component belongs to.
  13894. */
  13895. scene: Scene;
  13896. /**
  13897. * Creates a new instance of the component for the given scene
  13898. * @param scene Defines the scene to register the component in
  13899. */
  13900. constructor(scene: Scene);
  13901. /**
  13902. * Registers the component in a given scene
  13903. */
  13904. register(): void;
  13905. /**
  13906. * Rebuilds the elements related to this component in case of
  13907. * context lost for instance.
  13908. */
  13909. rebuild(): void;
  13910. /**
  13911. * Disposes the component and the associated ressources.
  13912. */
  13913. dispose(): void;
  13914. private _beforeClear;
  13915. }
  13916. }
  13917. declare module BABYLON {
  13918. interface Engine {
  13919. /**
  13920. * Creates a new render target cube texture
  13921. * @param size defines the size of the texture
  13922. * @param options defines the options used to create the texture
  13923. * @returns a new render target cube texture stored in an InternalTexture
  13924. */
  13925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13926. }
  13927. }
  13928. declare module BABYLON {
  13929. /** @hidden */
  13930. export var proceduralVertexShader: {
  13931. name: string;
  13932. shader: string;
  13933. };
  13934. }
  13935. declare module BABYLON {
  13936. /**
  13937. * 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.
  13938. * This is the base class of any Procedural texture and contains most of the shareable code.
  13939. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13940. */
  13941. export class ProceduralTexture extends Texture {
  13942. isCube: boolean;
  13943. /**
  13944. * Define if the texture is enabled or not (disabled texture will not render)
  13945. */
  13946. isEnabled: boolean;
  13947. /**
  13948. * Define if the texture must be cleared before rendering (default is true)
  13949. */
  13950. autoClear: boolean;
  13951. /**
  13952. * Callback called when the texture is generated
  13953. */
  13954. onGenerated: () => void;
  13955. /**
  13956. * Event raised when the texture is generated
  13957. */
  13958. onGeneratedObservable: Observable<ProceduralTexture>;
  13959. /** @hidden */ generateMipMaps: boolean;
  13960. /** @hidden **/ effect: Effect;
  13961. /** @hidden */ textures: {
  13962. [key: string]: Texture;
  13963. };
  13964. private _size;
  13965. private _currentRefreshId;
  13966. private _refreshRate;
  13967. private _vertexBuffers;
  13968. private _indexBuffer;
  13969. private _uniforms;
  13970. private _samplers;
  13971. private _fragment;
  13972. private _floats;
  13973. private _ints;
  13974. private _floatsArrays;
  13975. private _colors3;
  13976. private _colors4;
  13977. private _vectors2;
  13978. private _vectors3;
  13979. private _matrices;
  13980. private _fallbackTexture;
  13981. private _fallbackTextureUsed;
  13982. private _engine;
  13983. private _cachedDefines;
  13984. private _contentUpdateId;
  13985. private _contentData;
  13986. /**
  13987. * Instantiates a new procedural texture.
  13988. * 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.
  13989. * This is the base class of any Procedural texture and contains most of the shareable code.
  13990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13991. * @param name Define the name of the texture
  13992. * @param size Define the size of the texture to create
  13993. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13994. * @param scene Define the scene the texture belongs to
  13995. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13996. * @param generateMipMaps Define if the texture should creates mip maps or not
  13997. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13998. */
  13999. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14000. /**
  14001. * The effect that is created when initializing the post process.
  14002. * @returns The created effect corrisponding the the postprocess.
  14003. */
  14004. getEffect(): Effect;
  14005. /**
  14006. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14007. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14008. */
  14009. getContent(): Nullable<ArrayBufferView>;
  14010. private _createIndexBuffer;
  14011. /** @hidden */ rebuild(): void;
  14012. /**
  14013. * Resets the texture in order to recreate its associated resources.
  14014. * This can be called in case of context loss
  14015. */
  14016. reset(): void;
  14017. protected _getDefines(): string;
  14018. /**
  14019. * Is the texture ready to be used ? (rendered at least once)
  14020. * @returns true if ready, otherwise, false.
  14021. */
  14022. isReady(): boolean;
  14023. /**
  14024. * Resets the refresh counter of the texture and start bak from scratch.
  14025. * Could be useful to regenerate the texture if it is setup to render only once.
  14026. */
  14027. resetRefreshCounter(): void;
  14028. /**
  14029. * Set the fragment shader to use in order to render the texture.
  14030. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14031. */
  14032. setFragment(fragment: any): void;
  14033. /**
  14034. * Define the refresh rate of the texture or the rendering frequency.
  14035. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14036. */
  14037. refreshRate: number;
  14038. /** @hidden */ shouldRender(): boolean;
  14039. /**
  14040. * Get the size the texture is rendering at.
  14041. * @returns the size (texture is always squared)
  14042. */
  14043. getRenderSize(): number;
  14044. /**
  14045. * Resize the texture to new value.
  14046. * @param size Define the new size the texture should have
  14047. * @param generateMipMaps Define whether the new texture should create mip maps
  14048. */
  14049. resize(size: number, generateMipMaps: boolean): void;
  14050. private _checkUniform;
  14051. /**
  14052. * Set a texture in the shader program used to render.
  14053. * @param name Define the name of the uniform samplers as defined in the shader
  14054. * @param texture Define the texture to bind to this sampler
  14055. * @return the texture itself allowing "fluent" like uniform updates
  14056. */
  14057. setTexture(name: string, texture: Texture): ProceduralTexture;
  14058. /**
  14059. * Set a float in the shader.
  14060. * @param name Define the name of the uniform as defined in the shader
  14061. * @param value Define the value to give to the uniform
  14062. * @return the texture itself allowing "fluent" like uniform updates
  14063. */
  14064. setFloat(name: string, value: number): ProceduralTexture;
  14065. /**
  14066. * Set a int in the shader.
  14067. * @param name Define the name of the uniform as defined in the shader
  14068. * @param value Define the value to give to the uniform
  14069. * @return the texture itself allowing "fluent" like uniform updates
  14070. */
  14071. setInt(name: string, value: number): ProceduralTexture;
  14072. /**
  14073. * Set an array of floats in the shader.
  14074. * @param name Define the name of the uniform as defined in the shader
  14075. * @param value Define the value to give to the uniform
  14076. * @return the texture itself allowing "fluent" like uniform updates
  14077. */
  14078. setFloats(name: string, value: number[]): ProceduralTexture;
  14079. /**
  14080. * Set a vec3 in the shader from a Color3.
  14081. * @param name Define the name of the uniform as defined in the shader
  14082. * @param value Define the value to give to the uniform
  14083. * @return the texture itself allowing "fluent" like uniform updates
  14084. */
  14085. setColor3(name: string, value: Color3): ProceduralTexture;
  14086. /**
  14087. * Set a vec4 in the shader from a Color4.
  14088. * @param name Define the name of the uniform as defined in the shader
  14089. * @param value Define the value to give to the uniform
  14090. * @return the texture itself allowing "fluent" like uniform updates
  14091. */
  14092. setColor4(name: string, value: Color4): ProceduralTexture;
  14093. /**
  14094. * Set a vec2 in the shader from a Vector2.
  14095. * @param name Define the name of the uniform as defined in the shader
  14096. * @param value Define the value to give to the uniform
  14097. * @return the texture itself allowing "fluent" like uniform updates
  14098. */
  14099. setVector2(name: string, value: Vector2): ProceduralTexture;
  14100. /**
  14101. * Set a vec3 in the shader from a Vector3.
  14102. * @param name Define the name of the uniform as defined in the shader
  14103. * @param value Define the value to give to the uniform
  14104. * @return the texture itself allowing "fluent" like uniform updates
  14105. */
  14106. setVector3(name: string, value: Vector3): ProceduralTexture;
  14107. /**
  14108. * Set a mat4 in the shader from a MAtrix.
  14109. * @param name Define the name of the uniform as defined in the shader
  14110. * @param value Define the value to give to the uniform
  14111. * @return the texture itself allowing "fluent" like uniform updates
  14112. */
  14113. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14114. /**
  14115. * Render the texture to its associated render target.
  14116. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14117. */
  14118. render(useCameraPostProcess?: boolean): void;
  14119. /**
  14120. * Clone the texture.
  14121. * @returns the cloned texture
  14122. */
  14123. clone(): ProceduralTexture;
  14124. /**
  14125. * Dispose the texture and release its asoociated resources.
  14126. */
  14127. dispose(): void;
  14128. }
  14129. }
  14130. declare module BABYLON {
  14131. /**
  14132. * This represents the base class for particle system in Babylon.
  14133. * 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.
  14134. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14135. * @example https://doc.babylonjs.com/babylon101/particles
  14136. */
  14137. export class BaseParticleSystem {
  14138. /**
  14139. * Source color is added to the destination color without alpha affecting the result
  14140. */
  14141. static BLENDMODE_ONEONE: number;
  14142. /**
  14143. * Blend current color and particle color using particle’s alpha
  14144. */
  14145. static BLENDMODE_STANDARD: number;
  14146. /**
  14147. * Add current color and particle color multiplied by particle’s alpha
  14148. */
  14149. static BLENDMODE_ADD: number;
  14150. /**
  14151. * Multiply current color with particle color
  14152. */
  14153. static BLENDMODE_MULTIPLY: number;
  14154. /**
  14155. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14156. */
  14157. static BLENDMODE_MULTIPLYADD: number;
  14158. /**
  14159. * List of animations used by the particle system.
  14160. */
  14161. animations: Animation[];
  14162. /**
  14163. * The id of the Particle system.
  14164. */
  14165. id: string;
  14166. /**
  14167. * The friendly name of the Particle system.
  14168. */
  14169. name: string;
  14170. /**
  14171. * The rendering group used by the Particle system to chose when to render.
  14172. */
  14173. renderingGroupId: number;
  14174. /**
  14175. * The emitter represents the Mesh or position we are attaching the particle system to.
  14176. */
  14177. emitter: Nullable<AbstractMesh | Vector3>;
  14178. /**
  14179. * The maximum number of particles to emit per frame
  14180. */
  14181. emitRate: number;
  14182. /**
  14183. * If you want to launch only a few particles at once, that can be done, as well.
  14184. */
  14185. manualEmitCount: number;
  14186. /**
  14187. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14188. */
  14189. updateSpeed: number;
  14190. /**
  14191. * The amount of time the particle system is running (depends of the overall update speed).
  14192. */
  14193. targetStopDuration: number;
  14194. /**
  14195. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14196. */
  14197. disposeOnStop: boolean;
  14198. /**
  14199. * Minimum power of emitting particles.
  14200. */
  14201. minEmitPower: number;
  14202. /**
  14203. * Maximum power of emitting particles.
  14204. */
  14205. maxEmitPower: number;
  14206. /**
  14207. * Minimum life time of emitting particles.
  14208. */
  14209. minLifeTime: number;
  14210. /**
  14211. * Maximum life time of emitting particles.
  14212. */
  14213. maxLifeTime: number;
  14214. /**
  14215. * Minimum Size of emitting particles.
  14216. */
  14217. minSize: number;
  14218. /**
  14219. * Maximum Size of emitting particles.
  14220. */
  14221. maxSize: number;
  14222. /**
  14223. * Minimum scale of emitting particles on X axis.
  14224. */
  14225. minScaleX: number;
  14226. /**
  14227. * Maximum scale of emitting particles on X axis.
  14228. */
  14229. maxScaleX: number;
  14230. /**
  14231. * Minimum scale of emitting particles on Y axis.
  14232. */
  14233. minScaleY: number;
  14234. /**
  14235. * Maximum scale of emitting particles on Y axis.
  14236. */
  14237. maxScaleY: number;
  14238. /**
  14239. * Gets or sets the minimal initial rotation in radians.
  14240. */
  14241. minInitialRotation: number;
  14242. /**
  14243. * Gets or sets the maximal initial rotation in radians.
  14244. */
  14245. maxInitialRotation: number;
  14246. /**
  14247. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14248. */
  14249. minAngularSpeed: number;
  14250. /**
  14251. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14252. */
  14253. maxAngularSpeed: number;
  14254. /**
  14255. * The texture used to render each particle. (this can be a spritesheet)
  14256. */
  14257. particleTexture: Nullable<Texture>;
  14258. /**
  14259. * The layer mask we are rendering the particles through.
  14260. */
  14261. layerMask: number;
  14262. /**
  14263. * This can help using your own shader to render the particle system.
  14264. * The according effect will be created
  14265. */
  14266. customShader: any;
  14267. /**
  14268. * By default particle system starts as soon as they are created. This prevents the
  14269. * automatic start to happen and let you decide when to start emitting particles.
  14270. */
  14271. preventAutoStart: boolean;
  14272. private _noiseTexture;
  14273. /**
  14274. * Gets or sets a texture used to add random noise to particle positions
  14275. */
  14276. noiseTexture: Nullable<ProceduralTexture>;
  14277. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14278. noiseStrength: Vector3;
  14279. /**
  14280. * Callback triggered when the particle animation is ending.
  14281. */
  14282. onAnimationEnd: Nullable<() => void>;
  14283. /**
  14284. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14285. */
  14286. blendMode: number;
  14287. /**
  14288. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14289. * to override the particles.
  14290. */
  14291. forceDepthWrite: boolean;
  14292. /** 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 */
  14293. preWarmCycles: number;
  14294. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14295. preWarmStepOffset: number;
  14296. /**
  14297. * 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)
  14298. */
  14299. spriteCellChangeSpeed: number;
  14300. /**
  14301. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14302. */
  14303. startSpriteCellID: number;
  14304. /**
  14305. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14306. */
  14307. endSpriteCellID: number;
  14308. /**
  14309. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14310. */
  14311. spriteCellWidth: number;
  14312. /**
  14313. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14314. */
  14315. spriteCellHeight: number;
  14316. /**
  14317. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14318. */
  14319. spriteRandomStartCell: boolean;
  14320. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14321. translationPivot: Vector2;
  14322. /** @hidden */
  14323. protected _isAnimationSheetEnabled: boolean;
  14324. /**
  14325. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14326. */
  14327. beginAnimationOnStart: boolean;
  14328. /**
  14329. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14330. */
  14331. beginAnimationFrom: number;
  14332. /**
  14333. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14334. */
  14335. beginAnimationTo: number;
  14336. /**
  14337. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14338. */
  14339. beginAnimationLoop: boolean;
  14340. /**
  14341. * Gets or sets a world offset applied to all particles
  14342. */
  14343. worldOffset: Vector3;
  14344. /**
  14345. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14346. */
  14347. isAnimationSheetEnabled: boolean;
  14348. /**
  14349. * Get hosting scene
  14350. * @returns the scene
  14351. */
  14352. getScene(): Scene;
  14353. /**
  14354. * You can use gravity if you want to give an orientation to your particles.
  14355. */
  14356. gravity: Vector3;
  14357. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14358. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14359. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14360. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14361. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14362. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14363. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14364. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14365. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14366. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14367. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14368. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14369. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14370. /**
  14371. * Defines the delay in milliseconds before starting the system (0 by default)
  14372. */
  14373. startDelay: number;
  14374. /**
  14375. * Gets the current list of drag gradients.
  14376. * You must use addDragGradient and removeDragGradient to udpate this list
  14377. * @returns the list of drag gradients
  14378. */
  14379. getDragGradients(): Nullable<Array<FactorGradient>>;
  14380. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14381. limitVelocityDamping: number;
  14382. /**
  14383. * Gets the current list of limit velocity gradients.
  14384. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14385. * @returns the list of limit velocity gradients
  14386. */
  14387. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Gets the current list of color gradients.
  14390. * You must use addColorGradient and removeColorGradient to udpate this list
  14391. * @returns the list of color gradients
  14392. */
  14393. getColorGradients(): Nullable<Array<ColorGradient>>;
  14394. /**
  14395. * Gets the current list of size gradients.
  14396. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14397. * @returns the list of size gradients
  14398. */
  14399. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14400. /**
  14401. * Gets the current list of color remap gradients.
  14402. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14403. * @returns the list of color remap gradients
  14404. */
  14405. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14406. /**
  14407. * Gets the current list of alpha remap gradients.
  14408. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14409. * @returns the list of alpha remap gradients
  14410. */
  14411. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14412. /**
  14413. * Gets the current list of life time gradients.
  14414. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14415. * @returns the list of life time gradients
  14416. */
  14417. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14418. /**
  14419. * Gets the current list of angular speed gradients.
  14420. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14421. * @returns the list of angular speed gradients
  14422. */
  14423. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14424. /**
  14425. * Gets the current list of velocity gradients.
  14426. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14427. * @returns the list of velocity gradients
  14428. */
  14429. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Gets the current list of start size gradients.
  14432. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14433. * @returns the list of start size gradients
  14434. */
  14435. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14436. /**
  14437. * Gets the current list of emit rate gradients.
  14438. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14439. * @returns the list of emit rate gradients
  14440. */
  14441. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14444. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14445. */
  14446. direction1: Vector3;
  14447. /**
  14448. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14449. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14450. */
  14451. direction2: Vector3;
  14452. /**
  14453. * 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.
  14454. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14455. */
  14456. minEmitBox: Vector3;
  14457. /**
  14458. * 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.
  14459. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14460. */
  14461. maxEmitBox: Vector3;
  14462. /**
  14463. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14464. */
  14465. color1: Color4;
  14466. /**
  14467. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14468. */
  14469. color2: Color4;
  14470. /**
  14471. * Color the particle will have at the end of its lifetime
  14472. */
  14473. colorDead: Color4;
  14474. /**
  14475. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14476. */
  14477. textureMask: Color4;
  14478. /**
  14479. * The particle emitter type defines the emitter used by the particle system.
  14480. * It can be for example box, sphere, or cone...
  14481. */
  14482. particleEmitterType: IParticleEmitterType;
  14483. /** @hidden */ isSubEmitter: boolean;
  14484. /**
  14485. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14486. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14487. */
  14488. billboardMode: number;
  14489. protected _isBillboardBased: boolean;
  14490. /**
  14491. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14492. */
  14493. isBillboardBased: boolean;
  14494. /**
  14495. * The scene the particle system belongs to.
  14496. */
  14497. protected _scene: Scene;
  14498. /**
  14499. * Local cache of defines for image processing.
  14500. */
  14501. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14502. /**
  14503. * Default configuration related to image processing available in the standard Material.
  14504. */
  14505. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14506. /**
  14507. * Gets the image processing configuration used either in this material.
  14508. */
  14509. /**
  14510. * Sets the Default image processing configuration used either in the this material.
  14511. *
  14512. * If sets to null, the scene one is in use.
  14513. */
  14514. imageProcessingConfiguration: ImageProcessingConfiguration;
  14515. /**
  14516. * Attaches a new image processing configuration to the Standard Material.
  14517. * @param configuration
  14518. */
  14519. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14520. /** @hidden */
  14521. protected _reset(): void;
  14522. /** @hidden */
  14523. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14524. /**
  14525. * Instantiates a particle system.
  14526. * 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.
  14527. * @param name The name of the particle system
  14528. */
  14529. constructor(name: string);
  14530. /**
  14531. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14532. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14533. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14534. * @returns the emitter
  14535. */
  14536. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14537. /**
  14538. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14539. * @param radius The radius of the hemisphere to emit from
  14540. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14541. * @returns the emitter
  14542. */
  14543. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14544. /**
  14545. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14546. * @param radius The radius of the sphere to emit from
  14547. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14548. * @returns the emitter
  14549. */
  14550. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14551. /**
  14552. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14553. * @param radius The radius of the sphere to emit from
  14554. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14555. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14556. * @returns the emitter
  14557. */
  14558. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14559. /**
  14560. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14561. * @param radius The radius of the emission cylinder
  14562. * @param height The height of the emission cylinder
  14563. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14564. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14565. * @returns the emitter
  14566. */
  14567. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14568. /**
  14569. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14570. * @param radius The radius of the cylinder to emit from
  14571. * @param height The height of the emission cylinder
  14572. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14573. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14574. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14575. * @returns the emitter
  14576. */
  14577. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14578. /**
  14579. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14580. * @param radius The radius of the cone to emit from
  14581. * @param angle The base angle of the cone
  14582. * @returns the emitter
  14583. */
  14584. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14585. /**
  14586. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14589. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14590. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14591. * @returns the emitter
  14592. */
  14593. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14594. }
  14595. }
  14596. declare module BABYLON {
  14597. /**
  14598. * Type of sub emitter
  14599. */
  14600. export enum SubEmitterType {
  14601. /**
  14602. * Attached to the particle over it's lifetime
  14603. */
  14604. ATTACHED = 0,
  14605. /**
  14606. * Created when the particle dies
  14607. */
  14608. END = 1
  14609. }
  14610. /**
  14611. * Sub emitter class used to emit particles from an existing particle
  14612. */
  14613. export class SubEmitter {
  14614. /**
  14615. * the particle system to be used by the sub emitter
  14616. */
  14617. particleSystem: ParticleSystem;
  14618. /**
  14619. * Type of the submitter (Default: END)
  14620. */
  14621. type: SubEmitterType;
  14622. /**
  14623. * 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)
  14624. * Note: This only is supported when using an emitter of type Mesh
  14625. */
  14626. inheritDirection: boolean;
  14627. /**
  14628. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14629. */
  14630. inheritedVelocityAmount: number;
  14631. /**
  14632. * Creates a sub emitter
  14633. * @param particleSystem the particle system to be used by the sub emitter
  14634. */
  14635. constructor(
  14636. /**
  14637. * the particle system to be used by the sub emitter
  14638. */
  14639. particleSystem: ParticleSystem);
  14640. /**
  14641. * Clones the sub emitter
  14642. * @returns the cloned sub emitter
  14643. */
  14644. clone(): SubEmitter;
  14645. /**
  14646. * Serialize current object to a JSON object
  14647. * @returns the serialized object
  14648. */
  14649. serialize(): any;
  14650. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14651. /**
  14652. * Creates a new SubEmitter from a serialized JSON version
  14653. * @param serializationObject defines the JSON object to read from
  14654. * @param scene defines the hosting scene
  14655. * @param rootUrl defines the rootUrl for data loading
  14656. * @returns a new SubEmitter
  14657. */
  14658. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14659. /** Release associated resources */
  14660. dispose(): void;
  14661. }
  14662. }
  14663. declare module BABYLON {
  14664. /** @hidden */
  14665. export var clipPlaneFragmentDeclaration: {
  14666. name: string;
  14667. shader: string;
  14668. };
  14669. }
  14670. declare module BABYLON {
  14671. /** @hidden */
  14672. export var imageProcessingDeclaration: {
  14673. name: string;
  14674. shader: string;
  14675. };
  14676. }
  14677. declare module BABYLON {
  14678. /** @hidden */
  14679. export var imageProcessingFunctions: {
  14680. name: string;
  14681. shader: string;
  14682. };
  14683. }
  14684. declare module BABYLON {
  14685. /** @hidden */
  14686. export var clipPlaneFragment: {
  14687. name: string;
  14688. shader: string;
  14689. };
  14690. }
  14691. declare module BABYLON {
  14692. /** @hidden */
  14693. export var particlesPixelShader: {
  14694. name: string;
  14695. shader: string;
  14696. };
  14697. }
  14698. declare module BABYLON {
  14699. /** @hidden */
  14700. export var clipPlaneVertexDeclaration: {
  14701. name: string;
  14702. shader: string;
  14703. };
  14704. }
  14705. declare module BABYLON {
  14706. /** @hidden */
  14707. export var clipPlaneVertex: {
  14708. name: string;
  14709. shader: string;
  14710. };
  14711. }
  14712. declare module BABYLON {
  14713. /** @hidden */
  14714. export var particlesVertexShader: {
  14715. name: string;
  14716. shader: string;
  14717. };
  14718. }
  14719. declare module BABYLON {
  14720. /**
  14721. * This represents a particle system in Babylon.
  14722. * 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.
  14723. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14724. * @example https://doc.babylonjs.com/babylon101/particles
  14725. */
  14726. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14727. /**
  14728. * Billboard mode will only apply to Y axis
  14729. */
  14730. static readonly BILLBOARDMODE_Y: number;
  14731. /**
  14732. * Billboard mode will apply to all axes
  14733. */
  14734. static readonly BILLBOARDMODE_ALL: number;
  14735. /**
  14736. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14737. */
  14738. static readonly BILLBOARDMODE_STRETCHED: number;
  14739. /**
  14740. * This function can be defined to provide custom update for active particles.
  14741. * This function will be called instead of regular update (age, position, color, etc.).
  14742. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14743. */
  14744. updateFunction: (particles: Particle[]) => void;
  14745. private _emitterWorldMatrix;
  14746. /**
  14747. * This function can be defined to specify initial direction for every new particle.
  14748. * It by default use the emitterType defined function
  14749. */
  14750. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14751. /**
  14752. * This function can be defined to specify initial position for every new particle.
  14753. * It by default use the emitterType defined function
  14754. */
  14755. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14756. /**
  14757. * @hidden
  14758. */ inheritedVelocityOffset: Vector3;
  14759. /**
  14760. * An event triggered when the system is disposed
  14761. */
  14762. onDisposeObservable: Observable<ParticleSystem>;
  14763. private _onDisposeObserver;
  14764. /**
  14765. * Sets a callback that will be triggered when the system is disposed
  14766. */
  14767. onDispose: () => void;
  14768. private _particles;
  14769. private _epsilon;
  14770. private _capacity;
  14771. private _stockParticles;
  14772. private _newPartsExcess;
  14773. private _vertexData;
  14774. private _vertexBuffer;
  14775. private _vertexBuffers;
  14776. private _spriteBuffer;
  14777. private _indexBuffer;
  14778. private _effect;
  14779. private _customEffect;
  14780. private _cachedDefines;
  14781. private _scaledColorStep;
  14782. private _colorDiff;
  14783. private _scaledDirection;
  14784. private _scaledGravity;
  14785. private _currentRenderId;
  14786. private _alive;
  14787. private _useInstancing;
  14788. private _started;
  14789. private _stopped;
  14790. private _actualFrame;
  14791. private _scaledUpdateSpeed;
  14792. private _vertexBufferSize;
  14793. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14794. /** @hidden */ currentEmitRate1: number;
  14795. /** @hidden */ currentEmitRate2: number;
  14796. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14797. /** @hidden */ currentStartSize1: number;
  14798. /** @hidden */ currentStartSize2: number;
  14799. private readonly _rawTextureWidth;
  14800. private _rampGradientsTexture;
  14801. private _useRampGradients;
  14802. /** Gets or sets a boolean indicating that ramp gradients must be used
  14803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14804. */
  14805. useRampGradients: boolean;
  14806. /**
  14807. * 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.
  14808. * 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: [])
  14809. */
  14810. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14811. private _subEmitters;
  14812. /**
  14813. * @hidden
  14814. * If the particle systems emitter should be disposed when the particle system is disposed
  14815. */ disposeEmitterOnDispose: boolean;
  14816. /**
  14817. * The current active Sub-systems, this property is used by the root particle system only.
  14818. */
  14819. activeSubSystems: Array<ParticleSystem>;
  14820. private _rootParticleSystem;
  14821. /**
  14822. * Gets the current list of active particles
  14823. */
  14824. readonly particles: Particle[];
  14825. /**
  14826. * Returns the string "ParticleSystem"
  14827. * @returns a string containing the class name
  14828. */
  14829. getClassName(): string;
  14830. /**
  14831. * Instantiates a particle system.
  14832. * 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.
  14833. * @param name The name of the particle system
  14834. * @param capacity The max number of particles alive at the same time
  14835. * @param scene The scene the particle system belongs to
  14836. * @param customEffect a custom effect used to change the way particles are rendered by default
  14837. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14838. * @param epsilon Offset used to render the particles
  14839. */
  14840. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14841. private _addFactorGradient;
  14842. private _removeFactorGradient;
  14843. /**
  14844. * Adds a new life time gradient
  14845. * @param gradient defines the gradient to use (between 0 and 1)
  14846. * @param factor defines the life time factor to affect to the specified gradient
  14847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14848. * @returns the current particle system
  14849. */
  14850. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14851. /**
  14852. * Remove a specific life time gradient
  14853. * @param gradient defines the gradient to remove
  14854. * @returns the current particle system
  14855. */
  14856. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14857. /**
  14858. * Adds a new size gradient
  14859. * @param gradient defines the gradient to use (between 0 and 1)
  14860. * @param factor defines the size factor to affect to the specified gradient
  14861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14862. * @returns the current particle system
  14863. */
  14864. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14865. /**
  14866. * Remove a specific size gradient
  14867. * @param gradient defines the gradient to remove
  14868. * @returns the current particle system
  14869. */
  14870. removeSizeGradient(gradient: number): IParticleSystem;
  14871. /**
  14872. * Adds a new color remap gradient
  14873. * @param gradient defines the gradient to use (between 0 and 1)
  14874. * @param min defines the color remap minimal range
  14875. * @param max defines the color remap maximal range
  14876. * @returns the current particle system
  14877. */
  14878. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14879. /**
  14880. * Remove a specific color remap gradient
  14881. * @param gradient defines the gradient to remove
  14882. * @returns the current particle system
  14883. */
  14884. removeColorRemapGradient(gradient: number): IParticleSystem;
  14885. /**
  14886. * Adds a new alpha remap gradient
  14887. * @param gradient defines the gradient to use (between 0 and 1)
  14888. * @param min defines the alpha remap minimal range
  14889. * @param max defines the alpha remap maximal range
  14890. * @returns the current particle system
  14891. */
  14892. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14893. /**
  14894. * Remove a specific alpha remap gradient
  14895. * @param gradient defines the gradient to remove
  14896. * @returns the current particle system
  14897. */
  14898. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14899. /**
  14900. * Adds a new angular speed gradient
  14901. * @param gradient defines the gradient to use (between 0 and 1)
  14902. * @param factor defines the angular speed to affect to the specified gradient
  14903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14904. * @returns the current particle system
  14905. */
  14906. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14907. /**
  14908. * Remove a specific angular speed gradient
  14909. * @param gradient defines the gradient to remove
  14910. * @returns the current particle system
  14911. */
  14912. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14913. /**
  14914. * Adds a new velocity gradient
  14915. * @param gradient defines the gradient to use (between 0 and 1)
  14916. * @param factor defines the velocity to affect to the specified gradient
  14917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14918. * @returns the current particle system
  14919. */
  14920. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14921. /**
  14922. * Remove a specific velocity gradient
  14923. * @param gradient defines the gradient to remove
  14924. * @returns the current particle system
  14925. */
  14926. removeVelocityGradient(gradient: number): IParticleSystem;
  14927. /**
  14928. * Adds a new limit velocity gradient
  14929. * @param gradient defines the gradient to use (between 0 and 1)
  14930. * @param factor defines the limit velocity value to affect to the specified gradient
  14931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14932. * @returns the current particle system
  14933. */
  14934. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14935. /**
  14936. * Remove a specific limit velocity gradient
  14937. * @param gradient defines the gradient to remove
  14938. * @returns the current particle system
  14939. */
  14940. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14941. /**
  14942. * Adds a new drag gradient
  14943. * @param gradient defines the gradient to use (between 0 and 1)
  14944. * @param factor defines the drag value to affect to the specified gradient
  14945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14946. * @returns the current particle system
  14947. */
  14948. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14949. /**
  14950. * Remove a specific drag gradient
  14951. * @param gradient defines the gradient to remove
  14952. * @returns the current particle system
  14953. */
  14954. removeDragGradient(gradient: number): IParticleSystem;
  14955. /**
  14956. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14957. * @param gradient defines the gradient to use (between 0 and 1)
  14958. * @param factor defines the emit rate value to affect to the specified gradient
  14959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14960. * @returns the current particle system
  14961. */
  14962. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14963. /**
  14964. * Remove a specific emit rate gradient
  14965. * @param gradient defines the gradient to remove
  14966. * @returns the current particle system
  14967. */
  14968. removeEmitRateGradient(gradient: number): IParticleSystem;
  14969. /**
  14970. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14971. * @param gradient defines the gradient to use (between 0 and 1)
  14972. * @param factor defines the start size value to affect to the specified gradient
  14973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14974. * @returns the current particle system
  14975. */
  14976. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14977. /**
  14978. * Remove a specific start size gradient
  14979. * @param gradient defines the gradient to remove
  14980. * @returns the current particle system
  14981. */
  14982. removeStartSizeGradient(gradient: number): IParticleSystem;
  14983. private _createRampGradientTexture;
  14984. /**
  14985. * Gets the current list of ramp gradients.
  14986. * You must use addRampGradient and removeRampGradient to udpate this list
  14987. * @returns the list of ramp gradients
  14988. */
  14989. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14990. /**
  14991. * Adds a new ramp gradient used to remap particle colors
  14992. * @param gradient defines the gradient to use (between 0 and 1)
  14993. * @param color defines the color to affect to the specified gradient
  14994. * @returns the current particle system
  14995. */
  14996. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14997. /**
  14998. * Remove a specific ramp gradient
  14999. * @param gradient defines the gradient to remove
  15000. * @returns the current particle system
  15001. */
  15002. removeRampGradient(gradient: number): ParticleSystem;
  15003. /**
  15004. * Adds a new color gradient
  15005. * @param gradient defines the gradient to use (between 0 and 1)
  15006. * @param color1 defines the color to affect to the specified gradient
  15007. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15008. * @returns this particle system
  15009. */
  15010. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15011. /**
  15012. * Remove a specific color gradient
  15013. * @param gradient defines the gradient to remove
  15014. * @returns this particle system
  15015. */
  15016. removeColorGradient(gradient: number): IParticleSystem;
  15017. private _fetchR;
  15018. protected _reset(): void;
  15019. private _resetEffect;
  15020. private _createVertexBuffers;
  15021. private _createIndexBuffer;
  15022. /**
  15023. * Gets the maximum number of particles active at the same time.
  15024. * @returns The max number of active particles.
  15025. */
  15026. getCapacity(): number;
  15027. /**
  15028. * Gets whether there are still active particles in the system.
  15029. * @returns True if it is alive, otherwise false.
  15030. */
  15031. isAlive(): boolean;
  15032. /**
  15033. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15034. * @returns True if it has been started, otherwise false.
  15035. */
  15036. isStarted(): boolean;
  15037. private _prepareSubEmitterInternalArray;
  15038. /**
  15039. * Starts the particle system and begins to emit
  15040. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15041. */
  15042. start(delay?: number): void;
  15043. /**
  15044. * Stops the particle system.
  15045. * @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.
  15046. */
  15047. stop(stopSubEmitters?: boolean): void;
  15048. /**
  15049. * Remove all active particles
  15050. */
  15051. reset(): void;
  15052. /**
  15053. * @hidden (for internal use only)
  15054. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15055. /**
  15056. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15057. * Its lifetime will start back at 0.
  15058. */
  15059. recycleParticle: (particle: Particle) => void;
  15060. private _stopSubEmitters;
  15061. private _createParticle;
  15062. private _removeFromRoot;
  15063. private _emitFromParticle;
  15064. private _update;
  15065. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15066. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15067. /** @hidden */
  15068. private _getEffect;
  15069. /**
  15070. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15071. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15072. */
  15073. animate(preWarmOnly?: boolean): void;
  15074. private _appendParticleVertices;
  15075. /**
  15076. * Rebuilds the particle system.
  15077. */
  15078. rebuild(): void;
  15079. /**
  15080. * Is this system ready to be used/rendered
  15081. * @return true if the system is ready
  15082. */
  15083. isReady(): boolean;
  15084. private _render;
  15085. /**
  15086. * Renders the particle system in its current state.
  15087. * @returns the current number of particles
  15088. */
  15089. render(): number;
  15090. /**
  15091. * Disposes the particle system and free the associated resources
  15092. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15093. */
  15094. dispose(disposeTexture?: boolean): void;
  15095. /**
  15096. * Clones the particle system.
  15097. * @param name The name of the cloned object
  15098. * @param newEmitter The new emitter to use
  15099. * @returns the cloned particle system
  15100. */
  15101. clone(name: string, newEmitter: any): ParticleSystem;
  15102. /**
  15103. * Serializes the particle system to a JSON object.
  15104. * @returns the JSON object
  15105. */
  15106. serialize(): any;
  15107. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15108. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15109. /**
  15110. * Parses a JSON object to create a particle system.
  15111. * @param parsedParticleSystem The JSON object to parse
  15112. * @param scene The scene to create the particle system in
  15113. * @param rootUrl The root url to use to load external dependencies like texture
  15114. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15115. * @returns the Parsed particle system
  15116. */
  15117. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15118. }
  15119. }
  15120. declare module BABYLON {
  15121. /**
  15122. * A particle represents one of the element emitted by a particle system.
  15123. * This is mainly define by its coordinates, direction, velocity and age.
  15124. */
  15125. export class Particle {
  15126. /**
  15127. * The particle system the particle belongs to.
  15128. */
  15129. particleSystem: ParticleSystem;
  15130. private static _Count;
  15131. /**
  15132. * Unique ID of the particle
  15133. */
  15134. id: number;
  15135. /**
  15136. * The world position of the particle in the scene.
  15137. */
  15138. position: Vector3;
  15139. /**
  15140. * The world direction of the particle in the scene.
  15141. */
  15142. direction: Vector3;
  15143. /**
  15144. * The color of the particle.
  15145. */
  15146. color: Color4;
  15147. /**
  15148. * The color change of the particle per step.
  15149. */
  15150. colorStep: Color4;
  15151. /**
  15152. * Defines how long will the life of the particle be.
  15153. */
  15154. lifeTime: number;
  15155. /**
  15156. * The current age of the particle.
  15157. */
  15158. age: number;
  15159. /**
  15160. * The current size of the particle.
  15161. */
  15162. size: number;
  15163. /**
  15164. * The current scale of the particle.
  15165. */
  15166. scale: Vector2;
  15167. /**
  15168. * The current angle of the particle.
  15169. */
  15170. angle: number;
  15171. /**
  15172. * Defines how fast is the angle changing.
  15173. */
  15174. angularSpeed: number;
  15175. /**
  15176. * Defines the cell index used by the particle to be rendered from a sprite.
  15177. */
  15178. cellIndex: number;
  15179. /**
  15180. * The information required to support color remapping
  15181. */
  15182. remapData: Vector4;
  15183. /** @hidden */ randomCellOffset?: number;
  15184. /** @hidden */ initialDirection: Nullable<Vector3>;
  15185. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15186. /** @hidden */ initialStartSpriteCellID: number;
  15187. /** @hidden */ initialEndSpriteCellID: number;
  15188. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15189. /** @hidden */ currentColor1: Color4;
  15190. /** @hidden */ currentColor2: Color4;
  15191. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15192. /** @hidden */ currentSize1: number;
  15193. /** @hidden */ currentSize2: number;
  15194. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15195. /** @hidden */ currentAngularSpeed1: number;
  15196. /** @hidden */ currentAngularSpeed2: number;
  15197. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15198. /** @hidden */ currentVelocity1: number;
  15199. /** @hidden */ currentVelocity2: number;
  15200. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15201. /** @hidden */ currentLimitVelocity1: number;
  15202. /** @hidden */ currentLimitVelocity2: number;
  15203. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15204. /** @hidden */ currentDrag1: number;
  15205. /** @hidden */ currentDrag2: number;
  15206. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15207. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15208. /**
  15209. * Creates a new instance Particle
  15210. * @param particleSystem the particle system the particle belongs to
  15211. */
  15212. constructor(
  15213. /**
  15214. * The particle system the particle belongs to.
  15215. */
  15216. particleSystem: ParticleSystem);
  15217. private updateCellInfoFromSystem;
  15218. /**
  15219. * Defines how the sprite cell index is updated for the particle
  15220. */
  15221. updateCellIndex(): void;
  15222. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15223. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15224. /** @hidden */ reset(): void;
  15225. /**
  15226. * Copy the properties of particle to another one.
  15227. * @param other the particle to copy the information to.
  15228. */
  15229. copyTo(other: Particle): void;
  15230. }
  15231. }
  15232. declare module BABYLON {
  15233. /**
  15234. * Particle emitter represents a volume emitting particles.
  15235. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15236. */
  15237. export interface IParticleEmitterType {
  15238. /**
  15239. * Called by the particle System when the direction is computed for the created particle.
  15240. * @param worldMatrix is the world matrix of the particle system
  15241. * @param directionToUpdate is the direction vector to update with the result
  15242. * @param particle is the particle we are computed the direction for
  15243. */
  15244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15245. /**
  15246. * Called by the particle System when the position is computed for the created particle.
  15247. * @param worldMatrix is the world matrix of the particle system
  15248. * @param positionToUpdate is the position vector to update with the result
  15249. * @param particle is the particle we are computed the position for
  15250. */
  15251. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15252. /**
  15253. * Clones the current emitter and returns a copy of it
  15254. * @returns the new emitter
  15255. */
  15256. clone(): IParticleEmitterType;
  15257. /**
  15258. * Called by the GPUParticleSystem to setup the update shader
  15259. * @param effect defines the update shader
  15260. */
  15261. applyToShader(effect: Effect): void;
  15262. /**
  15263. * Returns a string to use to update the GPU particles update shader
  15264. * @returns the effect defines string
  15265. */
  15266. getEffectDefines(): string;
  15267. /**
  15268. * Returns a string representing the class name
  15269. * @returns a string containing the class name
  15270. */
  15271. getClassName(): string;
  15272. /**
  15273. * Serializes the particle system to a JSON object.
  15274. * @returns the JSON object
  15275. */
  15276. serialize(): any;
  15277. /**
  15278. * Parse properties from a JSON object
  15279. * @param serializationObject defines the JSON object
  15280. */
  15281. parse(serializationObject: any): void;
  15282. }
  15283. }
  15284. declare module BABYLON {
  15285. /**
  15286. * Particle emitter emitting particles from the inside of a box.
  15287. * It emits the particles randomly between 2 given directions.
  15288. */
  15289. export class BoxParticleEmitter implements IParticleEmitterType {
  15290. /**
  15291. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15292. */
  15293. direction1: Vector3;
  15294. /**
  15295. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15296. */
  15297. direction2: Vector3;
  15298. /**
  15299. * 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.
  15300. */
  15301. minEmitBox: Vector3;
  15302. /**
  15303. * 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.
  15304. */
  15305. maxEmitBox: Vector3;
  15306. /**
  15307. * Creates a new instance BoxParticleEmitter
  15308. */
  15309. constructor();
  15310. /**
  15311. * Called by the particle System when the direction is computed for the created particle.
  15312. * @param worldMatrix is the world matrix of the particle system
  15313. * @param directionToUpdate is the direction vector to update with the result
  15314. * @param particle is the particle we are computed the direction for
  15315. */
  15316. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15317. /**
  15318. * Called by the particle System when the position is computed for the created particle.
  15319. * @param worldMatrix is the world matrix of the particle system
  15320. * @param positionToUpdate is the position vector to update with the result
  15321. * @param particle is the particle we are computed the position for
  15322. */
  15323. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15324. /**
  15325. * Clones the current emitter and returns a copy of it
  15326. * @returns the new emitter
  15327. */
  15328. clone(): BoxParticleEmitter;
  15329. /**
  15330. * Called by the GPUParticleSystem to setup the update shader
  15331. * @param effect defines the update shader
  15332. */
  15333. applyToShader(effect: Effect): void;
  15334. /**
  15335. * Returns a string to use to update the GPU particles update shader
  15336. * @returns a string containng the defines string
  15337. */
  15338. getEffectDefines(): string;
  15339. /**
  15340. * Returns the string "BoxParticleEmitter"
  15341. * @returns a string containing the class name
  15342. */
  15343. getClassName(): string;
  15344. /**
  15345. * Serializes the particle system to a JSON object.
  15346. * @returns the JSON object
  15347. */
  15348. serialize(): any;
  15349. /**
  15350. * Parse properties from a JSON object
  15351. * @param serializationObject defines the JSON object
  15352. */
  15353. parse(serializationObject: any): void;
  15354. }
  15355. }
  15356. declare module BABYLON {
  15357. /**
  15358. * Particle emitter emitting particles from the inside of a cone.
  15359. * It emits the particles alongside the cone volume from the base to the particle.
  15360. * The emission direction might be randomized.
  15361. */
  15362. export class ConeParticleEmitter implements IParticleEmitterType {
  15363. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15364. directionRandomizer: number;
  15365. private _radius;
  15366. private _angle;
  15367. private _height;
  15368. /**
  15369. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15370. */
  15371. radiusRange: number;
  15372. /**
  15373. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15374. */
  15375. heightRange: number;
  15376. /**
  15377. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15378. */
  15379. emitFromSpawnPointOnly: boolean;
  15380. /**
  15381. * Gets or sets the radius of the emission cone
  15382. */
  15383. radius: number;
  15384. /**
  15385. * Gets or sets the angle of the emission cone
  15386. */
  15387. angle: number;
  15388. private _buildHeight;
  15389. /**
  15390. * Creates a new instance ConeParticleEmitter
  15391. * @param radius the radius of the emission cone (1 by default)
  15392. * @param angle the cone base angle (PI by default)
  15393. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15394. */
  15395. constructor(radius?: number, angle?: number,
  15396. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15397. directionRandomizer?: number);
  15398. /**
  15399. * Called by the particle System when the direction is computed for the created particle.
  15400. * @param worldMatrix is the world matrix of the particle system
  15401. * @param directionToUpdate is the direction vector to update with the result
  15402. * @param particle is the particle we are computed the direction for
  15403. */
  15404. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15405. /**
  15406. * Called by the particle System when the position is computed for the created particle.
  15407. * @param worldMatrix is the world matrix of the particle system
  15408. * @param positionToUpdate is the position vector to update with the result
  15409. * @param particle is the particle we are computed the position for
  15410. */
  15411. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15412. /**
  15413. * Clones the current emitter and returns a copy of it
  15414. * @returns the new emitter
  15415. */
  15416. clone(): ConeParticleEmitter;
  15417. /**
  15418. * Called by the GPUParticleSystem to setup the update shader
  15419. * @param effect defines the update shader
  15420. */
  15421. applyToShader(effect: Effect): void;
  15422. /**
  15423. * Returns a string to use to update the GPU particles update shader
  15424. * @returns a string containng the defines string
  15425. */
  15426. getEffectDefines(): string;
  15427. /**
  15428. * Returns the string "ConeParticleEmitter"
  15429. * @returns a string containing the class name
  15430. */
  15431. getClassName(): string;
  15432. /**
  15433. * Serializes the particle system to a JSON object.
  15434. * @returns the JSON object
  15435. */
  15436. serialize(): any;
  15437. /**
  15438. * Parse properties from a JSON object
  15439. * @param serializationObject defines the JSON object
  15440. */
  15441. parse(serializationObject: any): void;
  15442. }
  15443. }
  15444. declare module BABYLON {
  15445. /**
  15446. * Particle emitter emitting particles from the inside of a cylinder.
  15447. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15448. */
  15449. export class CylinderParticleEmitter implements IParticleEmitterType {
  15450. /**
  15451. * The radius of the emission cylinder.
  15452. */
  15453. radius: number;
  15454. /**
  15455. * The height of the emission cylinder.
  15456. */
  15457. height: number;
  15458. /**
  15459. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15460. */
  15461. radiusRange: number;
  15462. /**
  15463. * How much to randomize the particle direction [0-1].
  15464. */
  15465. directionRandomizer: number;
  15466. /**
  15467. * Creates a new instance CylinderParticleEmitter
  15468. * @param radius the radius of the emission cylinder (1 by default)
  15469. * @param height the height of the emission cylinder (1 by default)
  15470. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15471. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15472. */
  15473. constructor(
  15474. /**
  15475. * The radius of the emission cylinder.
  15476. */
  15477. radius?: number,
  15478. /**
  15479. * The height of the emission cylinder.
  15480. */
  15481. height?: number,
  15482. /**
  15483. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15484. */
  15485. radiusRange?: number,
  15486. /**
  15487. * How much to randomize the particle direction [0-1].
  15488. */
  15489. directionRandomizer?: number);
  15490. /**
  15491. * Called by the particle System when the direction is computed for the created particle.
  15492. * @param worldMatrix is the world matrix of the particle system
  15493. * @param directionToUpdate is the direction vector to update with the result
  15494. * @param particle is the particle we are computed the direction for
  15495. */
  15496. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15497. /**
  15498. * Called by the particle System when the position is computed for the created particle.
  15499. * @param worldMatrix is the world matrix of the particle system
  15500. * @param positionToUpdate is the position vector to update with the result
  15501. * @param particle is the particle we are computed the position for
  15502. */
  15503. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15504. /**
  15505. * Clones the current emitter and returns a copy of it
  15506. * @returns the new emitter
  15507. */
  15508. clone(): CylinderParticleEmitter;
  15509. /**
  15510. * Called by the GPUParticleSystem to setup the update shader
  15511. * @param effect defines the update shader
  15512. */
  15513. applyToShader(effect: Effect): void;
  15514. /**
  15515. * Returns a string to use to update the GPU particles update shader
  15516. * @returns a string containng the defines string
  15517. */
  15518. getEffectDefines(): string;
  15519. /**
  15520. * Returns the string "CylinderParticleEmitter"
  15521. * @returns a string containing the class name
  15522. */
  15523. getClassName(): string;
  15524. /**
  15525. * Serializes the particle system to a JSON object.
  15526. * @returns the JSON object
  15527. */
  15528. serialize(): any;
  15529. /**
  15530. * Parse properties from a JSON object
  15531. * @param serializationObject defines the JSON object
  15532. */
  15533. parse(serializationObject: any): void;
  15534. }
  15535. /**
  15536. * Particle emitter emitting particles from the inside of a cylinder.
  15537. * It emits the particles randomly between two vectors.
  15538. */
  15539. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15540. /**
  15541. * The min limit of the emission direction.
  15542. */
  15543. direction1: Vector3;
  15544. /**
  15545. * The max limit of the emission direction.
  15546. */
  15547. direction2: Vector3;
  15548. /**
  15549. * Creates a new instance CylinderDirectedParticleEmitter
  15550. * @param radius the radius of the emission cylinder (1 by default)
  15551. * @param height the height of the emission cylinder (1 by default)
  15552. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15553. * @param direction1 the min limit of the emission direction (up vector by default)
  15554. * @param direction2 the max limit of the emission direction (up vector by default)
  15555. */
  15556. constructor(radius?: number, height?: number, radiusRange?: number,
  15557. /**
  15558. * The min limit of the emission direction.
  15559. */
  15560. direction1?: Vector3,
  15561. /**
  15562. * The max limit of the emission direction.
  15563. */
  15564. direction2?: Vector3);
  15565. /**
  15566. * Called by the particle System when the direction is computed for the created particle.
  15567. * @param worldMatrix is the world matrix of the particle system
  15568. * @param directionToUpdate is the direction vector to update with the result
  15569. * @param particle is the particle we are computed the direction for
  15570. */
  15571. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15572. /**
  15573. * Clones the current emitter and returns a copy of it
  15574. * @returns the new emitter
  15575. */
  15576. clone(): CylinderDirectedParticleEmitter;
  15577. /**
  15578. * Called by the GPUParticleSystem to setup the update shader
  15579. * @param effect defines the update shader
  15580. */
  15581. applyToShader(effect: Effect): void;
  15582. /**
  15583. * Returns a string to use to update the GPU particles update shader
  15584. * @returns a string containng the defines string
  15585. */
  15586. getEffectDefines(): string;
  15587. /**
  15588. * Returns the string "CylinderDirectedParticleEmitter"
  15589. * @returns a string containing the class name
  15590. */
  15591. getClassName(): string;
  15592. /**
  15593. * Serializes the particle system to a JSON object.
  15594. * @returns the JSON object
  15595. */
  15596. serialize(): any;
  15597. /**
  15598. * Parse properties from a JSON object
  15599. * @param serializationObject defines the JSON object
  15600. */
  15601. parse(serializationObject: any): void;
  15602. }
  15603. }
  15604. declare module BABYLON {
  15605. /**
  15606. * Particle emitter emitting particles from the inside of a hemisphere.
  15607. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15608. */
  15609. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15610. /**
  15611. * The radius of the emission hemisphere.
  15612. */
  15613. radius: number;
  15614. /**
  15615. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15616. */
  15617. radiusRange: number;
  15618. /**
  15619. * How much to randomize the particle direction [0-1].
  15620. */
  15621. directionRandomizer: number;
  15622. /**
  15623. * Creates a new instance HemisphericParticleEmitter
  15624. * @param radius the radius of the emission hemisphere (1 by default)
  15625. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15626. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15627. */
  15628. constructor(
  15629. /**
  15630. * The radius of the emission hemisphere.
  15631. */
  15632. radius?: number,
  15633. /**
  15634. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15635. */
  15636. radiusRange?: number,
  15637. /**
  15638. * How much to randomize the particle direction [0-1].
  15639. */
  15640. directionRandomizer?: number);
  15641. /**
  15642. * Called by the particle System when the direction is computed for the created particle.
  15643. * @param worldMatrix is the world matrix of the particle system
  15644. * @param directionToUpdate is the direction vector to update with the result
  15645. * @param particle is the particle we are computed the direction for
  15646. */
  15647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15648. /**
  15649. * Called by the particle System when the position is computed for the created particle.
  15650. * @param worldMatrix is the world matrix of the particle system
  15651. * @param positionToUpdate is the position vector to update with the result
  15652. * @param particle is the particle we are computed the position for
  15653. */
  15654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15655. /**
  15656. * Clones the current emitter and returns a copy of it
  15657. * @returns the new emitter
  15658. */
  15659. clone(): HemisphericParticleEmitter;
  15660. /**
  15661. * Called by the GPUParticleSystem to setup the update shader
  15662. * @param effect defines the update shader
  15663. */
  15664. applyToShader(effect: Effect): void;
  15665. /**
  15666. * Returns a string to use to update the GPU particles update shader
  15667. * @returns a string containng the defines string
  15668. */
  15669. getEffectDefines(): string;
  15670. /**
  15671. * Returns the string "HemisphericParticleEmitter"
  15672. * @returns a string containing the class name
  15673. */
  15674. getClassName(): string;
  15675. /**
  15676. * Serializes the particle system to a JSON object.
  15677. * @returns the JSON object
  15678. */
  15679. serialize(): any;
  15680. /**
  15681. * Parse properties from a JSON object
  15682. * @param serializationObject defines the JSON object
  15683. */
  15684. parse(serializationObject: any): void;
  15685. }
  15686. }
  15687. declare module BABYLON {
  15688. /**
  15689. * Particle emitter emitting particles from a point.
  15690. * It emits the particles randomly between 2 given directions.
  15691. */
  15692. export class PointParticleEmitter implements IParticleEmitterType {
  15693. /**
  15694. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15695. */
  15696. direction1: Vector3;
  15697. /**
  15698. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15699. */
  15700. direction2: Vector3;
  15701. /**
  15702. * Creates a new instance PointParticleEmitter
  15703. */
  15704. constructor();
  15705. /**
  15706. * Called by the particle System when the direction is computed for the created particle.
  15707. * @param worldMatrix is the world matrix of the particle system
  15708. * @param directionToUpdate is the direction vector to update with the result
  15709. * @param particle is the particle we are computed the direction for
  15710. */
  15711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15712. /**
  15713. * Called by the particle System when the position is computed for the created particle.
  15714. * @param worldMatrix is the world matrix of the particle system
  15715. * @param positionToUpdate is the position vector to update with the result
  15716. * @param particle is the particle we are computed the position for
  15717. */
  15718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15719. /**
  15720. * Clones the current emitter and returns a copy of it
  15721. * @returns the new emitter
  15722. */
  15723. clone(): PointParticleEmitter;
  15724. /**
  15725. * Called by the GPUParticleSystem to setup the update shader
  15726. * @param effect defines the update shader
  15727. */
  15728. applyToShader(effect: Effect): void;
  15729. /**
  15730. * Returns a string to use to update the GPU particles update shader
  15731. * @returns a string containng the defines string
  15732. */
  15733. getEffectDefines(): string;
  15734. /**
  15735. * Returns the string "PointParticleEmitter"
  15736. * @returns a string containing the class name
  15737. */
  15738. getClassName(): string;
  15739. /**
  15740. * Serializes the particle system to a JSON object.
  15741. * @returns the JSON object
  15742. */
  15743. serialize(): any;
  15744. /**
  15745. * Parse properties from a JSON object
  15746. * @param serializationObject defines the JSON object
  15747. */
  15748. parse(serializationObject: any): void;
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. /**
  15753. * Particle emitter emitting particles from the inside of a sphere.
  15754. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15755. */
  15756. export class SphereParticleEmitter implements IParticleEmitterType {
  15757. /**
  15758. * The radius of the emission sphere.
  15759. */
  15760. radius: number;
  15761. /**
  15762. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15763. */
  15764. radiusRange: number;
  15765. /**
  15766. * How much to randomize the particle direction [0-1].
  15767. */
  15768. directionRandomizer: number;
  15769. /**
  15770. * Creates a new instance SphereParticleEmitter
  15771. * @param radius the radius of the emission sphere (1 by default)
  15772. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15773. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15774. */
  15775. constructor(
  15776. /**
  15777. * The radius of the emission sphere.
  15778. */
  15779. radius?: number,
  15780. /**
  15781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15782. */
  15783. radiusRange?: number,
  15784. /**
  15785. * How much to randomize the particle direction [0-1].
  15786. */
  15787. directionRandomizer?: number);
  15788. /**
  15789. * Called by the particle System when the direction is computed for the created particle.
  15790. * @param worldMatrix is the world matrix of the particle system
  15791. * @param directionToUpdate is the direction vector to update with the result
  15792. * @param particle is the particle we are computed the direction for
  15793. */
  15794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15795. /**
  15796. * Called by the particle System when the position is computed for the created particle.
  15797. * @param worldMatrix is the world matrix of the particle system
  15798. * @param positionToUpdate is the position vector to update with the result
  15799. * @param particle is the particle we are computed the position for
  15800. */
  15801. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15802. /**
  15803. * Clones the current emitter and returns a copy of it
  15804. * @returns the new emitter
  15805. */
  15806. clone(): SphereParticleEmitter;
  15807. /**
  15808. * Called by the GPUParticleSystem to setup the update shader
  15809. * @param effect defines the update shader
  15810. */
  15811. applyToShader(effect: Effect): void;
  15812. /**
  15813. * Returns a string to use to update the GPU particles update shader
  15814. * @returns a string containng the defines string
  15815. */
  15816. getEffectDefines(): string;
  15817. /**
  15818. * Returns the string "SphereParticleEmitter"
  15819. * @returns a string containing the class name
  15820. */
  15821. getClassName(): string;
  15822. /**
  15823. * Serializes the particle system to a JSON object.
  15824. * @returns the JSON object
  15825. */
  15826. serialize(): any;
  15827. /**
  15828. * Parse properties from a JSON object
  15829. * @param serializationObject defines the JSON object
  15830. */
  15831. parse(serializationObject: any): void;
  15832. }
  15833. /**
  15834. * Particle emitter emitting particles from the inside of a sphere.
  15835. * It emits the particles randomly between two vectors.
  15836. */
  15837. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15838. /**
  15839. * The min limit of the emission direction.
  15840. */
  15841. direction1: Vector3;
  15842. /**
  15843. * The max limit of the emission direction.
  15844. */
  15845. direction2: Vector3;
  15846. /**
  15847. * Creates a new instance SphereDirectedParticleEmitter
  15848. * @param radius the radius of the emission sphere (1 by default)
  15849. * @param direction1 the min limit of the emission direction (up vector by default)
  15850. * @param direction2 the max limit of the emission direction (up vector by default)
  15851. */
  15852. constructor(radius?: number,
  15853. /**
  15854. * The min limit of the emission direction.
  15855. */
  15856. direction1?: Vector3,
  15857. /**
  15858. * The max limit of the emission direction.
  15859. */
  15860. direction2?: Vector3);
  15861. /**
  15862. * Called by the particle System when the direction is computed for the created particle.
  15863. * @param worldMatrix is the world matrix of the particle system
  15864. * @param directionToUpdate is the direction vector to update with the result
  15865. * @param particle is the particle we are computed the direction for
  15866. */
  15867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15868. /**
  15869. * Clones the current emitter and returns a copy of it
  15870. * @returns the new emitter
  15871. */
  15872. clone(): SphereDirectedParticleEmitter;
  15873. /**
  15874. * Called by the GPUParticleSystem to setup the update shader
  15875. * @param effect defines the update shader
  15876. */
  15877. applyToShader(effect: Effect): void;
  15878. /**
  15879. * Returns a string to use to update the GPU particles update shader
  15880. * @returns a string containng the defines string
  15881. */
  15882. getEffectDefines(): string;
  15883. /**
  15884. * Returns the string "SphereDirectedParticleEmitter"
  15885. * @returns a string containing the class name
  15886. */
  15887. getClassName(): string;
  15888. /**
  15889. * Serializes the particle system to a JSON object.
  15890. * @returns the JSON object
  15891. */
  15892. serialize(): any;
  15893. /**
  15894. * Parse properties from a JSON object
  15895. * @param serializationObject defines the JSON object
  15896. */
  15897. parse(serializationObject: any): void;
  15898. }
  15899. }
  15900. declare module BABYLON {
  15901. /**
  15902. * Interface representing a particle system in Babylon.js.
  15903. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15904. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15905. */
  15906. export interface IParticleSystem {
  15907. /**
  15908. * List of animations used by the particle system.
  15909. */
  15910. animations: Animation[];
  15911. /**
  15912. * The id of the Particle system.
  15913. */
  15914. id: string;
  15915. /**
  15916. * The name of the Particle system.
  15917. */
  15918. name: string;
  15919. /**
  15920. * The emitter represents the Mesh or position we are attaching the particle system to.
  15921. */
  15922. emitter: Nullable<AbstractMesh | Vector3>;
  15923. /**
  15924. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15925. */
  15926. isBillboardBased: boolean;
  15927. /**
  15928. * The rendering group used by the Particle system to chose when to render.
  15929. */
  15930. renderingGroupId: number;
  15931. /**
  15932. * The layer mask we are rendering the particles through.
  15933. */
  15934. layerMask: number;
  15935. /**
  15936. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15937. */
  15938. updateSpeed: number;
  15939. /**
  15940. * The amount of time the particle system is running (depends of the overall update speed).
  15941. */
  15942. targetStopDuration: number;
  15943. /**
  15944. * The texture used to render each particle. (this can be a spritesheet)
  15945. */
  15946. particleTexture: Nullable<Texture>;
  15947. /**
  15948. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15949. */
  15950. blendMode: number;
  15951. /**
  15952. * Minimum life time of emitting particles.
  15953. */
  15954. minLifeTime: number;
  15955. /**
  15956. * Maximum life time of emitting particles.
  15957. */
  15958. maxLifeTime: number;
  15959. /**
  15960. * Minimum Size of emitting particles.
  15961. */
  15962. minSize: number;
  15963. /**
  15964. * Maximum Size of emitting particles.
  15965. */
  15966. maxSize: number;
  15967. /**
  15968. * Minimum scale of emitting particles on X axis.
  15969. */
  15970. minScaleX: number;
  15971. /**
  15972. * Maximum scale of emitting particles on X axis.
  15973. */
  15974. maxScaleX: number;
  15975. /**
  15976. * Minimum scale of emitting particles on Y axis.
  15977. */
  15978. minScaleY: number;
  15979. /**
  15980. * Maximum scale of emitting particles on Y axis.
  15981. */
  15982. maxScaleY: number;
  15983. /**
  15984. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15985. */
  15986. color1: Color4;
  15987. /**
  15988. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15989. */
  15990. color2: Color4;
  15991. /**
  15992. * Color the particle will have at the end of its lifetime.
  15993. */
  15994. colorDead: Color4;
  15995. /**
  15996. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15997. */
  15998. emitRate: number;
  15999. /**
  16000. * You can use gravity if you want to give an orientation to your particles.
  16001. */
  16002. gravity: Vector3;
  16003. /**
  16004. * Minimum power of emitting particles.
  16005. */
  16006. minEmitPower: number;
  16007. /**
  16008. * Maximum power of emitting particles.
  16009. */
  16010. maxEmitPower: number;
  16011. /**
  16012. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16013. */
  16014. minAngularSpeed: number;
  16015. /**
  16016. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16017. */
  16018. maxAngularSpeed: number;
  16019. /**
  16020. * Gets or sets the minimal initial rotation in radians.
  16021. */
  16022. minInitialRotation: number;
  16023. /**
  16024. * Gets or sets the maximal initial rotation in radians.
  16025. */
  16026. maxInitialRotation: number;
  16027. /**
  16028. * The particle emitter type defines the emitter used by the particle system.
  16029. * It can be for example box, sphere, or cone...
  16030. */
  16031. particleEmitterType: Nullable<IParticleEmitterType>;
  16032. /**
  16033. * Defines the delay in milliseconds before starting the system (0 by default)
  16034. */
  16035. startDelay: number;
  16036. /**
  16037. * 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
  16038. */
  16039. preWarmCycles: number;
  16040. /**
  16041. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16042. */
  16043. preWarmStepOffset: number;
  16044. /**
  16045. * 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)
  16046. */
  16047. spriteCellChangeSpeed: number;
  16048. /**
  16049. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16050. */
  16051. startSpriteCellID: number;
  16052. /**
  16053. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16054. */
  16055. endSpriteCellID: number;
  16056. /**
  16057. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16058. */
  16059. spriteCellWidth: number;
  16060. /**
  16061. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16062. */
  16063. spriteCellHeight: number;
  16064. /**
  16065. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16066. */
  16067. spriteRandomStartCell: boolean;
  16068. /**
  16069. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16070. */
  16071. isAnimationSheetEnabled: boolean;
  16072. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16073. translationPivot: Vector2;
  16074. /**
  16075. * Gets or sets a texture used to add random noise to particle positions
  16076. */
  16077. noiseTexture: Nullable<BaseTexture>;
  16078. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16079. noiseStrength: Vector3;
  16080. /**
  16081. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16082. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16083. */
  16084. billboardMode: number;
  16085. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16086. limitVelocityDamping: number;
  16087. /**
  16088. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16089. */
  16090. beginAnimationOnStart: boolean;
  16091. /**
  16092. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16093. */
  16094. beginAnimationFrom: number;
  16095. /**
  16096. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16097. */
  16098. beginAnimationTo: number;
  16099. /**
  16100. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16101. */
  16102. beginAnimationLoop: boolean;
  16103. /**
  16104. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16105. */
  16106. disposeOnStop: boolean;
  16107. /**
  16108. * Gets the maximum number of particles active at the same time.
  16109. * @returns The max number of active particles.
  16110. */
  16111. getCapacity(): number;
  16112. /**
  16113. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16114. * @returns True if it has been started, otherwise false.
  16115. */
  16116. isStarted(): boolean;
  16117. /**
  16118. * Animates the particle system for this frame.
  16119. */
  16120. animate(): void;
  16121. /**
  16122. * Renders the particle system in its current state.
  16123. * @returns the current number of particles
  16124. */
  16125. render(): number;
  16126. /**
  16127. * Dispose the particle system and frees its associated resources.
  16128. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16129. */
  16130. dispose(disposeTexture?: boolean): void;
  16131. /**
  16132. * Clones the particle system.
  16133. * @param name The name of the cloned object
  16134. * @param newEmitter The new emitter to use
  16135. * @returns the cloned particle system
  16136. */
  16137. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16138. /**
  16139. * Serializes the particle system to a JSON object.
  16140. * @returns the JSON object
  16141. */
  16142. serialize(): any;
  16143. /**
  16144. * Rebuild the particle system
  16145. */
  16146. rebuild(): void;
  16147. /**
  16148. * Starts the particle system and begins to emit
  16149. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16150. */
  16151. start(delay?: number): void;
  16152. /**
  16153. * Stops the particle system.
  16154. */
  16155. stop(): void;
  16156. /**
  16157. * Remove all active particles
  16158. */
  16159. reset(): void;
  16160. /**
  16161. * Is this system ready to be used/rendered
  16162. * @return true if the system is ready
  16163. */
  16164. isReady(): boolean;
  16165. /**
  16166. * Adds a new color gradient
  16167. * @param gradient defines the gradient to use (between 0 and 1)
  16168. * @param color1 defines the color to affect to the specified gradient
  16169. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16170. * @returns the current particle system
  16171. */
  16172. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16173. /**
  16174. * Remove a specific color gradient
  16175. * @param gradient defines the gradient to remove
  16176. * @returns the current particle system
  16177. */
  16178. removeColorGradient(gradient: number): IParticleSystem;
  16179. /**
  16180. * Adds a new size gradient
  16181. * @param gradient defines the gradient to use (between 0 and 1)
  16182. * @param factor defines the size factor to affect to the specified gradient
  16183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16184. * @returns the current particle system
  16185. */
  16186. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16187. /**
  16188. * Remove a specific size gradient
  16189. * @param gradient defines the gradient to remove
  16190. * @returns the current particle system
  16191. */
  16192. removeSizeGradient(gradient: number): IParticleSystem;
  16193. /**
  16194. * Gets the current list of color gradients.
  16195. * You must use addColorGradient and removeColorGradient to udpate this list
  16196. * @returns the list of color gradients
  16197. */
  16198. getColorGradients(): Nullable<Array<ColorGradient>>;
  16199. /**
  16200. * Gets the current list of size gradients.
  16201. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16202. * @returns the list of size gradients
  16203. */
  16204. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16205. /**
  16206. * Gets the current list of angular speed gradients.
  16207. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16208. * @returns the list of angular speed gradients
  16209. */
  16210. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16211. /**
  16212. * Adds a new angular speed gradient
  16213. * @param gradient defines the gradient to use (between 0 and 1)
  16214. * @param factor defines the angular speed to affect to the specified gradient
  16215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16216. * @returns the current particle system
  16217. */
  16218. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16219. /**
  16220. * Remove a specific angular speed gradient
  16221. * @param gradient defines the gradient to remove
  16222. * @returns the current particle system
  16223. */
  16224. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16225. /**
  16226. * Gets the current list of velocity gradients.
  16227. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16228. * @returns the list of velocity gradients
  16229. */
  16230. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16231. /**
  16232. * Adds a new velocity gradient
  16233. * @param gradient defines the gradient to use (between 0 and 1)
  16234. * @param factor defines the velocity to affect to the specified gradient
  16235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16236. * @returns the current particle system
  16237. */
  16238. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16239. /**
  16240. * Remove a specific velocity gradient
  16241. * @param gradient defines the gradient to remove
  16242. * @returns the current particle system
  16243. */
  16244. removeVelocityGradient(gradient: number): IParticleSystem;
  16245. /**
  16246. * Gets the current list of limit velocity gradients.
  16247. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16248. * @returns the list of limit velocity gradients
  16249. */
  16250. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16251. /**
  16252. * Adds a new limit velocity gradient
  16253. * @param gradient defines the gradient to use (between 0 and 1)
  16254. * @param factor defines the limit velocity to affect to the specified gradient
  16255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16256. * @returns the current particle system
  16257. */
  16258. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16259. /**
  16260. * Remove a specific limit velocity gradient
  16261. * @param gradient defines the gradient to remove
  16262. * @returns the current particle system
  16263. */
  16264. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16265. /**
  16266. * Adds a new drag gradient
  16267. * @param gradient defines the gradient to use (between 0 and 1)
  16268. * @param factor defines the drag to affect to the specified gradient
  16269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16270. * @returns the current particle system
  16271. */
  16272. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16273. /**
  16274. * Remove a specific drag gradient
  16275. * @param gradient defines the gradient to remove
  16276. * @returns the current particle system
  16277. */
  16278. removeDragGradient(gradient: number): IParticleSystem;
  16279. /**
  16280. * Gets the current list of drag gradients.
  16281. * You must use addDragGradient and removeDragGradient to udpate this list
  16282. * @returns the list of drag gradients
  16283. */
  16284. getDragGradients(): Nullable<Array<FactorGradient>>;
  16285. /**
  16286. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16287. * @param gradient defines the gradient to use (between 0 and 1)
  16288. * @param factor defines the emit rate to affect to the specified gradient
  16289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16290. * @returns the current particle system
  16291. */
  16292. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16293. /**
  16294. * Remove a specific emit rate gradient
  16295. * @param gradient defines the gradient to remove
  16296. * @returns the current particle system
  16297. */
  16298. removeEmitRateGradient(gradient: number): IParticleSystem;
  16299. /**
  16300. * Gets the current list of emit rate gradients.
  16301. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16302. * @returns the list of emit rate gradients
  16303. */
  16304. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16305. /**
  16306. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16307. * @param gradient defines the gradient to use (between 0 and 1)
  16308. * @param factor defines the start size to affect to the specified gradient
  16309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16310. * @returns the current particle system
  16311. */
  16312. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16313. /**
  16314. * Remove a specific start size gradient
  16315. * @param gradient defines the gradient to remove
  16316. * @returns the current particle system
  16317. */
  16318. removeStartSizeGradient(gradient: number): IParticleSystem;
  16319. /**
  16320. * Gets the current list of start size gradients.
  16321. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16322. * @returns the list of start size gradients
  16323. */
  16324. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16325. /**
  16326. * Adds a new life time gradient
  16327. * @param gradient defines the gradient to use (between 0 and 1)
  16328. * @param factor defines the life time factor to affect to the specified gradient
  16329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16330. * @returns the current particle system
  16331. */
  16332. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16333. /**
  16334. * Remove a specific life time gradient
  16335. * @param gradient defines the gradient to remove
  16336. * @returns the current particle system
  16337. */
  16338. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16339. /**
  16340. * Gets the current list of life time gradients.
  16341. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16342. * @returns the list of life time gradients
  16343. */
  16344. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16345. /**
  16346. * Gets the current list of color gradients.
  16347. * You must use addColorGradient and removeColorGradient to udpate this list
  16348. * @returns the list of color gradients
  16349. */
  16350. getColorGradients(): Nullable<Array<ColorGradient>>;
  16351. /**
  16352. * Adds a new ramp gradient used to remap particle colors
  16353. * @param gradient defines the gradient to use (between 0 and 1)
  16354. * @param color defines the color to affect to the specified gradient
  16355. * @returns the current particle system
  16356. */
  16357. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16358. /**
  16359. * Gets the current list of ramp gradients.
  16360. * You must use addRampGradient and removeRampGradient to udpate this list
  16361. * @returns the list of ramp gradients
  16362. */
  16363. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16364. /** Gets or sets a boolean indicating that ramp gradients must be used
  16365. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16366. */
  16367. useRampGradients: boolean;
  16368. /**
  16369. * Adds a new color remap gradient
  16370. * @param gradient defines the gradient to use (between 0 and 1)
  16371. * @param min defines the color remap minimal range
  16372. * @param max defines the color remap maximal range
  16373. * @returns the current particle system
  16374. */
  16375. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16376. /**
  16377. * Gets the current list of color remap gradients.
  16378. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16379. * @returns the list of color remap gradients
  16380. */
  16381. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16382. /**
  16383. * Adds a new alpha remap gradient
  16384. * @param gradient defines the gradient to use (between 0 and 1)
  16385. * @param min defines the alpha remap minimal range
  16386. * @param max defines the alpha remap maximal range
  16387. * @returns the current particle system
  16388. */
  16389. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16390. /**
  16391. * Gets the current list of alpha remap gradients.
  16392. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16393. * @returns the list of alpha remap gradients
  16394. */
  16395. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16396. /**
  16397. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16398. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16399. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16400. * @returns the emitter
  16401. */
  16402. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16403. /**
  16404. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16405. * @param radius The radius of the hemisphere to emit from
  16406. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16407. * @returns the emitter
  16408. */
  16409. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16410. /**
  16411. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16412. * @param radius The radius of the sphere to emit from
  16413. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16414. * @returns the emitter
  16415. */
  16416. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16417. /**
  16418. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16419. * @param radius The radius of the sphere to emit from
  16420. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16421. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16422. * @returns the emitter
  16423. */
  16424. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16425. /**
  16426. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16427. * @param radius The radius of the emission cylinder
  16428. * @param height The height of the emission cylinder
  16429. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16430. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16431. * @returns the emitter
  16432. */
  16433. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16434. /**
  16435. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16436. * @param radius The radius of the cylinder to emit from
  16437. * @param height The height of the emission cylinder
  16438. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16439. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16440. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16441. * @returns the emitter
  16442. */
  16443. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16444. /**
  16445. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16446. * @param radius The radius of the cone to emit from
  16447. * @param angle The base angle of the cone
  16448. * @returns the emitter
  16449. */
  16450. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16451. /**
  16452. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16453. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16454. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16455. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16456. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16457. * @returns the emitter
  16458. */
  16459. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16460. /**
  16461. * Get hosting scene
  16462. * @returns the scene
  16463. */
  16464. getScene(): Scene;
  16465. }
  16466. }
  16467. declare module BABYLON {
  16468. /**
  16469. * Creates an instance based on a source mesh.
  16470. */
  16471. export class InstancedMesh extends AbstractMesh {
  16472. private _sourceMesh;
  16473. private _currentLOD;
  16474. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16475. constructor(name: string, source: Mesh);
  16476. /**
  16477. * Returns the string "InstancedMesh".
  16478. */
  16479. getClassName(): string;
  16480. /** Gets the list of lights affecting that mesh */
  16481. readonly lightSources: Light[]; resyncLightSources(): void; resyncLighSource(light: Light): void; removeLightSource(light: Light): void;
  16482. /**
  16483. * If the source mesh receives shadows
  16484. */
  16485. readonly receiveShadows: boolean;
  16486. /**
  16487. * The material of the source mesh
  16488. */
  16489. readonly material: Nullable<Material>;
  16490. /**
  16491. * Visibility of the source mesh
  16492. */
  16493. readonly visibility: number;
  16494. /**
  16495. * Skeleton of the source mesh
  16496. */
  16497. readonly skeleton: Nullable<Skeleton>;
  16498. /**
  16499. * Rendering ground id of the source mesh
  16500. */
  16501. renderingGroupId: number;
  16502. /**
  16503. * Returns the total number of vertices (integer).
  16504. */
  16505. getTotalVertices(): number;
  16506. /**
  16507. * Returns a positive integer : the total number of indices in this mesh geometry.
  16508. * @returns the numner of indices or zero if the mesh has no geometry.
  16509. */
  16510. getTotalIndices(): number;
  16511. /**
  16512. * The source mesh of the instance
  16513. */
  16514. readonly sourceMesh: Mesh;
  16515. /**
  16516. * Is this node ready to be used/rendered
  16517. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16518. * @return {boolean} is it ready
  16519. */
  16520. isReady(completeCheck?: boolean): boolean;
  16521. /**
  16522. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16523. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16524. * @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.
  16525. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16526. */
  16527. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16528. /**
  16529. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16530. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16531. * The `data` are either a numeric array either a Float32Array.
  16532. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16533. * 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).
  16534. * Note that a new underlying VertexBuffer object is created each call.
  16535. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16536. *
  16537. * Possible `kind` values :
  16538. * - VertexBuffer.PositionKind
  16539. * - VertexBuffer.UVKind
  16540. * - VertexBuffer.UV2Kind
  16541. * - VertexBuffer.UV3Kind
  16542. * - VertexBuffer.UV4Kind
  16543. * - VertexBuffer.UV5Kind
  16544. * - VertexBuffer.UV6Kind
  16545. * - VertexBuffer.ColorKind
  16546. * - VertexBuffer.MatricesIndicesKind
  16547. * - VertexBuffer.MatricesIndicesExtraKind
  16548. * - VertexBuffer.MatricesWeightsKind
  16549. * - VertexBuffer.MatricesWeightsExtraKind
  16550. *
  16551. * Returns the Mesh.
  16552. */
  16553. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16554. /**
  16555. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16556. * If the mesh has no geometry, it is simply returned as it is.
  16557. * The `data` are either a numeric array either a Float32Array.
  16558. * No new underlying VertexBuffer object is created.
  16559. * 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.
  16560. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16561. *
  16562. * Possible `kind` values :
  16563. * - VertexBuffer.PositionKind
  16564. * - VertexBuffer.UVKind
  16565. * - VertexBuffer.UV2Kind
  16566. * - VertexBuffer.UV3Kind
  16567. * - VertexBuffer.UV4Kind
  16568. * - VertexBuffer.UV5Kind
  16569. * - VertexBuffer.UV6Kind
  16570. * - VertexBuffer.ColorKind
  16571. * - VertexBuffer.MatricesIndicesKind
  16572. * - VertexBuffer.MatricesIndicesExtraKind
  16573. * - VertexBuffer.MatricesWeightsKind
  16574. * - VertexBuffer.MatricesWeightsExtraKind
  16575. *
  16576. * Returns the Mesh.
  16577. */
  16578. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16579. /**
  16580. * Sets the mesh indices.
  16581. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16583. * This method creates a new index buffer each call.
  16584. * Returns the Mesh.
  16585. */
  16586. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16587. /**
  16588. * Boolean : True if the mesh owns the requested kind of data.
  16589. */
  16590. isVerticesDataPresent(kind: string): boolean;
  16591. /**
  16592. * Returns an array of indices (IndicesArray).
  16593. */
  16594. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16595. /**
  16596. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16597. * This means the mesh underlying bounding box and sphere are recomputed.
  16598. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16599. * @returns the current mesh
  16600. */
  16601. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16602. /** @hidden */ preActivate(): InstancedMesh;
  16603. /** @hidden */ activate(renderId: number): boolean;
  16604. /** @hidden */ postActivate(): void;
  16605. getWorldMatrix(): Matrix;
  16606. readonly isAnInstance: boolean;
  16607. /**
  16608. * Returns the current associated LOD AbstractMesh.
  16609. */
  16610. getLOD(camera: Camera): AbstractMesh;
  16611. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16612. /** @hidden */ generatePointsArray(): boolean;
  16613. /**
  16614. * Creates a new InstancedMesh from the current mesh.
  16615. * - name (string) : the cloned mesh name
  16616. * - newParent (optional Node) : the optional Node to parent the clone to.
  16617. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16618. *
  16619. * Returns the clone.
  16620. */
  16621. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16622. /**
  16623. * Disposes the InstancedMesh.
  16624. * Returns nothing.
  16625. */
  16626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16627. }
  16628. }
  16629. declare module BABYLON {
  16630. /**
  16631. * Defines the options associated with the creation of a shader material.
  16632. */
  16633. export interface IShaderMaterialOptions {
  16634. /**
  16635. * Does the material work in alpha blend mode
  16636. */
  16637. needAlphaBlending: boolean;
  16638. /**
  16639. * Does the material work in alpha test mode
  16640. */
  16641. needAlphaTesting: boolean;
  16642. /**
  16643. * The list of attribute names used in the shader
  16644. */
  16645. attributes: string[];
  16646. /**
  16647. * The list of unifrom names used in the shader
  16648. */
  16649. uniforms: string[];
  16650. /**
  16651. * The list of UBO names used in the shader
  16652. */
  16653. uniformBuffers: string[];
  16654. /**
  16655. * The list of sampler names used in the shader
  16656. */
  16657. samplers: string[];
  16658. /**
  16659. * The list of defines used in the shader
  16660. */
  16661. defines: string[];
  16662. }
  16663. /**
  16664. * 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.
  16665. *
  16666. * This returned material effects how the mesh will look based on the code in the shaders.
  16667. *
  16668. * @see http://doc.babylonjs.com/how_to/shader_material
  16669. */
  16670. export class ShaderMaterial extends Material {
  16671. private _shaderPath;
  16672. private _options;
  16673. private _textures;
  16674. private _textureArrays;
  16675. private _floats;
  16676. private _ints;
  16677. private _floatsArrays;
  16678. private _colors3;
  16679. private _colors3Arrays;
  16680. private _colors4;
  16681. private _vectors2;
  16682. private _vectors3;
  16683. private _vectors4;
  16684. private _matrices;
  16685. private _matrices3x3;
  16686. private _matrices2x2;
  16687. private _vectors2Arrays;
  16688. private _vectors3Arrays;
  16689. private _cachedWorldViewMatrix;
  16690. private _renderId;
  16691. /**
  16692. * Instantiate a new shader material.
  16693. * 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.
  16694. * This returned material effects how the mesh will look based on the code in the shaders.
  16695. * @see http://doc.babylonjs.com/how_to/shader_material
  16696. * @param name Define the name of the material in the scene
  16697. * @param scene Define the scene the material belongs to
  16698. * @param shaderPath Defines the route to the shader code in one of three ways:
  16699. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16700. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16701. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16702. * @param options Define the options used to create the shader
  16703. */
  16704. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16705. /**
  16706. * Gets the options used to compile the shader.
  16707. * They can be modified to trigger a new compilation
  16708. */
  16709. readonly options: IShaderMaterialOptions;
  16710. /**
  16711. * Gets the current class name of the material e.g. "ShaderMaterial"
  16712. * Mainly use in serialization.
  16713. * @returns the class name
  16714. */
  16715. getClassName(): string;
  16716. /**
  16717. * Specifies if the material will require alpha blending
  16718. * @returns a boolean specifying if alpha blending is needed
  16719. */
  16720. needAlphaBlending(): boolean;
  16721. /**
  16722. * Specifies if this material should be rendered in alpha test mode
  16723. * @returns a boolean specifying if an alpha test is needed.
  16724. */
  16725. needAlphaTesting(): boolean;
  16726. private _checkUniform;
  16727. /**
  16728. * Set a texture in the shader.
  16729. * @param name Define the name of the uniform samplers as defined in the shader
  16730. * @param texture Define the texture to bind to this sampler
  16731. * @return the material itself allowing "fluent" like uniform updates
  16732. */
  16733. setTexture(name: string, texture: Texture): ShaderMaterial;
  16734. /**
  16735. * Set a texture array in the shader.
  16736. * @param name Define the name of the uniform sampler array as defined in the shader
  16737. * @param textures Define the list of textures to bind to this sampler
  16738. * @return the material itself allowing "fluent" like uniform updates
  16739. */
  16740. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16741. /**
  16742. * Set a float in the shader.
  16743. * @param name Define the name of the uniform as defined in the shader
  16744. * @param value Define the value to give to the uniform
  16745. * @return the material itself allowing "fluent" like uniform updates
  16746. */
  16747. setFloat(name: string, value: number): ShaderMaterial;
  16748. /**
  16749. * Set a int in the shader.
  16750. * @param name Define the name of the uniform as defined in the shader
  16751. * @param value Define the value to give to the uniform
  16752. * @return the material itself allowing "fluent" like uniform updates
  16753. */
  16754. setInt(name: string, value: number): ShaderMaterial;
  16755. /**
  16756. * Set an array of floats in the shader.
  16757. * @param name Define the name of the uniform as defined in the shader
  16758. * @param value Define the value to give to the uniform
  16759. * @return the material itself allowing "fluent" like uniform updates
  16760. */
  16761. setFloats(name: string, value: number[]): ShaderMaterial;
  16762. /**
  16763. * Set a vec3 in the shader from a Color3.
  16764. * @param name Define the name of the uniform as defined in the shader
  16765. * @param value Define the value to give to the uniform
  16766. * @return the material itself allowing "fluent" like uniform updates
  16767. */
  16768. setColor3(name: string, value: Color3): ShaderMaterial;
  16769. /**
  16770. * Set a vec3 array in the shader from a Color3 array.
  16771. * @param name Define the name of the uniform as defined in the shader
  16772. * @param value Define the value to give to the uniform
  16773. * @return the material itself allowing "fluent" like uniform updates
  16774. */
  16775. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16776. /**
  16777. * Set a vec4 in the shader from a Color4.
  16778. * @param name Define the name of the uniform as defined in the shader
  16779. * @param value Define the value to give to the uniform
  16780. * @return the material itself allowing "fluent" like uniform updates
  16781. */
  16782. setColor4(name: string, value: Color4): ShaderMaterial;
  16783. /**
  16784. * Set a vec2 in the shader from a Vector2.
  16785. * @param name Define the name of the uniform as defined in the shader
  16786. * @param value Define the value to give to the uniform
  16787. * @return the material itself allowing "fluent" like uniform updates
  16788. */
  16789. setVector2(name: string, value: Vector2): ShaderMaterial;
  16790. /**
  16791. * Set a vec3 in the shader from a Vector3.
  16792. * @param name Define the name of the uniform as defined in the shader
  16793. * @param value Define the value to give to the uniform
  16794. * @return the material itself allowing "fluent" like uniform updates
  16795. */
  16796. setVector3(name: string, value: Vector3): ShaderMaterial;
  16797. /**
  16798. * Set a vec4 in the shader from a Vector4.
  16799. * @param name Define the name of the uniform as defined in the shader
  16800. * @param value Define the value to give to the uniform
  16801. * @return the material itself allowing "fluent" like uniform updates
  16802. */
  16803. setVector4(name: string, value: Vector4): ShaderMaterial;
  16804. /**
  16805. * Set a mat4 in the shader from a Matrix.
  16806. * @param name Define the name of the uniform as defined in the shader
  16807. * @param value Define the value to give to the uniform
  16808. * @return the material itself allowing "fluent" like uniform updates
  16809. */
  16810. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16811. /**
  16812. * Set a mat3 in the shader from a Float32Array.
  16813. * @param name Define the name of the uniform as defined in the shader
  16814. * @param value Define the value to give to the uniform
  16815. * @return the material itself allowing "fluent" like uniform updates
  16816. */
  16817. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16818. /**
  16819. * Set a mat2 in the shader from a Float32Array.
  16820. * @param name Define the name of the uniform as defined in the shader
  16821. * @param value Define the value to give to the uniform
  16822. * @return the material itself allowing "fluent" like uniform updates
  16823. */
  16824. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16825. /**
  16826. * Set a vec2 array in the shader from a number array.
  16827. * @param name Define the name of the uniform as defined in the shader
  16828. * @param value Define the value to give to the uniform
  16829. * @return the material itself allowing "fluent" like uniform updates
  16830. */
  16831. setArray2(name: string, value: number[]): ShaderMaterial;
  16832. /**
  16833. * Set a vec3 array in the shader from a number array.
  16834. * @param name Define the name of the uniform as defined in the shader
  16835. * @param value Define the value to give to the uniform
  16836. * @return the material itself allowing "fluent" like uniform updates
  16837. */
  16838. setArray3(name: string, value: number[]): ShaderMaterial;
  16839. private _checkCache;
  16840. /**
  16841. * Specifies that the submesh is ready to be used
  16842. * @param mesh defines the mesh to check
  16843. * @param subMesh defines which submesh to check
  16844. * @param useInstances specifies that instances should be used
  16845. * @returns a boolean indicating that the submesh is ready or not
  16846. */
  16847. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16848. /**
  16849. * Checks if the material is ready to render the requested mesh
  16850. * @param mesh Define the mesh to render
  16851. * @param useInstances Define whether or not the material is used with instances
  16852. * @returns true if ready, otherwise false
  16853. */
  16854. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16855. /**
  16856. * Binds the world matrix to the material
  16857. * @param world defines the world transformation matrix
  16858. */
  16859. bindOnlyWorldMatrix(world: Matrix): void;
  16860. /**
  16861. * Binds the material to the mesh
  16862. * @param world defines the world transformation matrix
  16863. * @param mesh defines the mesh to bind the material to
  16864. */
  16865. bind(world: Matrix, mesh?: Mesh): void;
  16866. /**
  16867. * Gets the active textures from the material
  16868. * @returns an array of textures
  16869. */
  16870. getActiveTextures(): BaseTexture[];
  16871. /**
  16872. * Specifies if the material uses a texture
  16873. * @param texture defines the texture to check against the material
  16874. * @returns a boolean specifying if the material uses the texture
  16875. */
  16876. hasTexture(texture: BaseTexture): boolean;
  16877. /**
  16878. * Makes a duplicate of the material, and gives it a new name
  16879. * @param name defines the new name for the duplicated material
  16880. * @returns the cloned material
  16881. */
  16882. clone(name: string): ShaderMaterial;
  16883. /**
  16884. * Disposes the material
  16885. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16886. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16887. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16888. */
  16889. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16890. /**
  16891. * Serializes this material in a JSON representation
  16892. * @returns the serialized material object
  16893. */
  16894. serialize(): any;
  16895. /**
  16896. * Creates a shader material from parsed shader material data
  16897. * @param source defines the JSON represnetation of the material
  16898. * @param scene defines the hosting scene
  16899. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16900. * @returns a new material
  16901. */
  16902. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16903. }
  16904. }
  16905. declare module BABYLON {
  16906. /** @hidden */
  16907. export var colorPixelShader: {
  16908. name: string;
  16909. shader: string;
  16910. };
  16911. }
  16912. declare module BABYLON {
  16913. /** @hidden */
  16914. export var colorVertexShader: {
  16915. name: string;
  16916. shader: string;
  16917. };
  16918. }
  16919. declare module BABYLON {
  16920. /**
  16921. * Line mesh
  16922. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16923. */
  16924. export class LinesMesh extends Mesh {
  16925. /**
  16926. * If vertex color should be applied to the mesh
  16927. */
  16928. useVertexColor?: boolean | undefined;
  16929. /**
  16930. * If vertex alpha should be applied to the mesh
  16931. */
  16932. useVertexAlpha?: boolean | undefined;
  16933. /**
  16934. * Color of the line (Default: White)
  16935. */
  16936. color: Color3;
  16937. /**
  16938. * Alpha of the line (Default: 1)
  16939. */
  16940. alpha: number;
  16941. /**
  16942. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16943. * This margin is expressed in world space coordinates, so its value may vary.
  16944. * Default value is 0.1
  16945. */
  16946. intersectionThreshold: number;
  16947. private _colorShader;
  16948. /**
  16949. * Creates a new LinesMesh
  16950. * @param name defines the name
  16951. * @param scene defines the hosting scene
  16952. * @param parent defines the parent mesh if any
  16953. * @param source defines the optional source LinesMesh used to clone data from
  16954. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16955. * When false, achieved by calling a clone(), also passing False.
  16956. * This will make creation of children, recursive.
  16957. * @param useVertexColor defines if this LinesMesh supports vertex color
  16958. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16959. */
  16960. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16961. /**
  16962. * If vertex color should be applied to the mesh
  16963. */
  16964. useVertexColor?: boolean | undefined,
  16965. /**
  16966. * If vertex alpha should be applied to the mesh
  16967. */
  16968. useVertexAlpha?: boolean | undefined);
  16969. private _addClipPlaneDefine;
  16970. private _removeClipPlaneDefine;
  16971. isReady(): boolean;
  16972. /**
  16973. * Returns the string "LineMesh"
  16974. */
  16975. getClassName(): string;
  16976. /**
  16977. * @hidden
  16978. */
  16979. /**
  16980. * @hidden
  16981. */
  16982. material: Material;
  16983. /**
  16984. * @hidden
  16985. */
  16986. readonly checkCollisions: boolean;
  16987. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16988. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16989. /**
  16990. * Disposes of the line mesh
  16991. * @param doNotRecurse If children should be disposed
  16992. */
  16993. dispose(doNotRecurse?: boolean): void;
  16994. /**
  16995. * Returns a new LineMesh object cloned from the current one.
  16996. */
  16997. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16998. /**
  16999. * Creates a new InstancedLinesMesh object from the mesh model.
  17000. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17001. * @param name defines the name of the new instance
  17002. * @returns a new InstancedLinesMesh
  17003. */
  17004. createInstance(name: string): InstancedLinesMesh;
  17005. }
  17006. /**
  17007. * Creates an instance based on a source LinesMesh
  17008. */
  17009. export class InstancedLinesMesh extends InstancedMesh {
  17010. /**
  17011. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17012. * This margin is expressed in world space coordinates, so its value may vary.
  17013. * Initilized with the intersectionThreshold value of the source LinesMesh
  17014. */
  17015. intersectionThreshold: number;
  17016. constructor(name: string, source: LinesMesh);
  17017. /**
  17018. * Returns the string "InstancedLinesMesh".
  17019. */
  17020. getClassName(): string;
  17021. }
  17022. }
  17023. declare module BABYLON {
  17024. /** @hidden */
  17025. export var linePixelShader: {
  17026. name: string;
  17027. shader: string;
  17028. };
  17029. }
  17030. declare module BABYLON {
  17031. /** @hidden */
  17032. export var lineVertexShader: {
  17033. name: string;
  17034. shader: string;
  17035. };
  17036. }
  17037. declare module BABYLON {
  17038. interface AbstractMesh {
  17039. /**
  17040. * Disables the mesh edge rendering mode
  17041. * @returns the currentAbstractMesh
  17042. */
  17043. disableEdgesRendering(): AbstractMesh;
  17044. /**
  17045. * Enables the edge rendering mode on the mesh.
  17046. * This mode makes the mesh edges visible
  17047. * @param epsilon defines the maximal distance between two angles to detect a face
  17048. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17049. * @returns the currentAbstractMesh
  17050. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17051. */
  17052. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17053. /**
  17054. * Gets the edgesRenderer associated with the mesh
  17055. */
  17056. edgesRenderer: Nullable<EdgesRenderer>;
  17057. }
  17058. interface LinesMesh {
  17059. /**
  17060. * Enables the edge rendering mode on the mesh.
  17061. * This mode makes the mesh edges visible
  17062. * @param epsilon defines the maximal distance between two angles to detect a face
  17063. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17064. * @returns the currentAbstractMesh
  17065. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17066. */
  17067. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17068. }
  17069. interface InstancedLinesMesh {
  17070. /**
  17071. * Enables the edge rendering mode on the mesh.
  17072. * This mode makes the mesh edges visible
  17073. * @param epsilon defines the maximal distance between two angles to detect a face
  17074. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17075. * @returns the current InstancedLinesMesh
  17076. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17077. */
  17078. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17079. }
  17080. /**
  17081. * Defines the minimum contract an Edges renderer should follow.
  17082. */
  17083. export interface IEdgesRenderer extends IDisposable {
  17084. /**
  17085. * Gets or sets a boolean indicating if the edgesRenderer is active
  17086. */
  17087. isEnabled: boolean;
  17088. /**
  17089. * Renders the edges of the attached mesh,
  17090. */
  17091. render(): void;
  17092. /**
  17093. * Checks wether or not the edges renderer is ready to render.
  17094. * @return true if ready, otherwise false.
  17095. */
  17096. isReady(): boolean;
  17097. }
  17098. /**
  17099. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17100. */
  17101. export class EdgesRenderer implements IEdgesRenderer {
  17102. /**
  17103. * Define the size of the edges with an orthographic camera
  17104. */
  17105. edgesWidthScalerForOrthographic: number;
  17106. /**
  17107. * Define the size of the edges with a perspective camera
  17108. */
  17109. edgesWidthScalerForPerspective: number;
  17110. protected _source: AbstractMesh;
  17111. protected _linesPositions: number[];
  17112. protected _linesNormals: number[];
  17113. protected _linesIndices: number[];
  17114. protected _epsilon: number;
  17115. protected _indicesCount: number;
  17116. protected _lineShader: ShaderMaterial;
  17117. protected _ib: DataBuffer;
  17118. protected _buffers: {
  17119. [key: string]: Nullable<VertexBuffer>;
  17120. };
  17121. protected _checkVerticesInsteadOfIndices: boolean;
  17122. private _meshRebuildObserver;
  17123. private _meshDisposeObserver;
  17124. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17125. isEnabled: boolean;
  17126. /**
  17127. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17128. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17129. * @param source Mesh used to create edges
  17130. * @param epsilon sum of angles in adjacency to check for edge
  17131. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17132. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17133. */
  17134. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17135. protected _prepareRessources(): void;
  17136. /** @hidden */ rebuild(): void;
  17137. /**
  17138. * Releases the required resources for the edges renderer
  17139. */
  17140. dispose(): void;
  17141. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17142. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17143. /**
  17144. * Checks if the pair of p0 and p1 is en edge
  17145. * @param faceIndex
  17146. * @param edge
  17147. * @param faceNormals
  17148. * @param p0
  17149. * @param p1
  17150. * @private
  17151. */
  17152. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17153. /**
  17154. * push line into the position, normal and index buffer
  17155. * @protected
  17156. */
  17157. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17158. /**
  17159. * Generates lines edges from adjacencjes
  17160. * @private
  17161. */ generateEdgesLines(): void;
  17162. /**
  17163. * Checks wether or not the edges renderer is ready to render.
  17164. * @return true if ready, otherwise false.
  17165. */
  17166. isReady(): boolean;
  17167. /**
  17168. * Renders the edges of the attached mesh,
  17169. */
  17170. render(): void;
  17171. }
  17172. /**
  17173. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17174. */
  17175. export class LineEdgesRenderer extends EdgesRenderer {
  17176. /**
  17177. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17178. * @param source LineMesh used to generate edges
  17179. * @param epsilon not important (specified angle for edge detection)
  17180. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17181. */
  17182. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17183. /**
  17184. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17185. */ generateEdgesLines(): void;
  17186. }
  17187. }
  17188. declare module BABYLON {
  17189. /**
  17190. * This represents the object necessary to create a rendering group.
  17191. * This is exclusively used and created by the rendering manager.
  17192. * To modify the behavior, you use the available helpers in your scene or meshes.
  17193. * @hidden
  17194. */
  17195. export class RenderingGroup {
  17196. index: number;
  17197. private _scene;
  17198. private _opaqueSubMeshes;
  17199. private _transparentSubMeshes;
  17200. private _alphaTestSubMeshes;
  17201. private _depthOnlySubMeshes;
  17202. private _particleSystems;
  17203. private _spriteManagers;
  17204. private _opaqueSortCompareFn;
  17205. private _alphaTestSortCompareFn;
  17206. private _transparentSortCompareFn;
  17207. private _renderOpaque;
  17208. private _renderAlphaTest;
  17209. private _renderTransparent;
  17210. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  17211. onBeforeTransparentRendering: () => void;
  17212. /**
  17213. * Set the opaque sort comparison function.
  17214. * If null the sub meshes will be render in the order they were created
  17215. */
  17216. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17217. /**
  17218. * Set the alpha test sort comparison function.
  17219. * If null the sub meshes will be render in the order they were created
  17220. */
  17221. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17222. /**
  17223. * Set the transparent sort comparison function.
  17224. * If null the sub meshes will be render in the order they were created
  17225. */
  17226. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17227. /**
  17228. * Creates a new rendering group.
  17229. * @param index The rendering group index
  17230. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17231. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17232. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17233. */
  17234. 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>);
  17235. /**
  17236. * Render all the sub meshes contained in the group.
  17237. * @param customRenderFunction Used to override the default render behaviour of the group.
  17238. * @returns true if rendered some submeshes.
  17239. */
  17240. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17241. /**
  17242. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17243. * @param subMeshes The submeshes to render
  17244. */
  17245. private renderOpaqueSorted;
  17246. /**
  17247. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17248. * @param subMeshes The submeshes to render
  17249. */
  17250. private renderAlphaTestSorted;
  17251. /**
  17252. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17253. * @param subMeshes The submeshes to render
  17254. */
  17255. private renderTransparentSorted;
  17256. /**
  17257. * Renders the submeshes in a specified order.
  17258. * @param subMeshes The submeshes to sort before render
  17259. * @param sortCompareFn The comparison function use to sort
  17260. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17261. * @param transparent Specifies to activate blending if true
  17262. */
  17263. private static renderSorted;
  17264. /**
  17265. * Renders the submeshes in the order they were dispatched (no sort applied).
  17266. * @param subMeshes The submeshes to render
  17267. */
  17268. private static renderUnsorted;
  17269. /**
  17270. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17271. * are rendered back to front if in the same alpha index.
  17272. *
  17273. * @param a The first submesh
  17274. * @param b The second submesh
  17275. * @returns The result of the comparison
  17276. */
  17277. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17278. /**
  17279. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17280. * are rendered back to front.
  17281. *
  17282. * @param a The first submesh
  17283. * @param b The second submesh
  17284. * @returns The result of the comparison
  17285. */
  17286. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17287. /**
  17288. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17289. * are rendered front to back (prevent overdraw).
  17290. *
  17291. * @param a The first submesh
  17292. * @param b The second submesh
  17293. * @returns The result of the comparison
  17294. */
  17295. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17296. /**
  17297. * Resets the different lists of submeshes to prepare a new frame.
  17298. */
  17299. prepare(): void;
  17300. dispose(): void;
  17301. /**
  17302. * Inserts the submesh in its correct queue depending on its material.
  17303. * @param subMesh The submesh to dispatch
  17304. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17305. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17306. */
  17307. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17308. dispatchSprites(spriteManager: ISpriteManager): void;
  17309. dispatchParticles(particleSystem: IParticleSystem): void;
  17310. private _renderParticles;
  17311. private _renderSprites;
  17312. }
  17313. }
  17314. declare module BABYLON {
  17315. /**
  17316. * Interface describing the different options available in the rendering manager
  17317. * regarding Auto Clear between groups.
  17318. */
  17319. export interface IRenderingManagerAutoClearSetup {
  17320. /**
  17321. * Defines whether or not autoclear is enable.
  17322. */
  17323. autoClear: boolean;
  17324. /**
  17325. * Defines whether or not to autoclear the depth buffer.
  17326. */
  17327. depth: boolean;
  17328. /**
  17329. * Defines whether or not to autoclear the stencil buffer.
  17330. */
  17331. stencil: boolean;
  17332. }
  17333. /**
  17334. * This class is used by the onRenderingGroupObservable
  17335. */
  17336. export class RenderingGroupInfo {
  17337. /**
  17338. * The Scene that being rendered
  17339. */
  17340. scene: Scene;
  17341. /**
  17342. * The camera currently used for the rendering pass
  17343. */
  17344. camera: Nullable<Camera>;
  17345. /**
  17346. * The ID of the renderingGroup being processed
  17347. */
  17348. renderingGroupId: number;
  17349. }
  17350. /**
  17351. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17352. * It is enable to manage the different groups as well as the different necessary sort functions.
  17353. * This should not be used directly aside of the few static configurations
  17354. */
  17355. export class RenderingManager {
  17356. /**
  17357. * The max id used for rendering groups (not included)
  17358. */
  17359. static MAX_RENDERINGGROUPS: number;
  17360. /**
  17361. * The min id used for rendering groups (included)
  17362. */
  17363. static MIN_RENDERINGGROUPS: number;
  17364. /**
  17365. * Used to globally prevent autoclearing scenes.
  17366. */
  17367. static AUTOCLEAR: boolean;
  17368. /**
  17369. * @hidden
  17370. */ useSceneAutoClearSetup: boolean;
  17371. private _scene;
  17372. private _renderingGroups;
  17373. private _depthStencilBufferAlreadyCleaned;
  17374. private _autoClearDepthStencil;
  17375. private _customOpaqueSortCompareFn;
  17376. private _customAlphaTestSortCompareFn;
  17377. private _customTransparentSortCompareFn;
  17378. private _renderingGroupInfo;
  17379. /**
  17380. * Instantiates a new rendering group for a particular scene
  17381. * @param scene Defines the scene the groups belongs to
  17382. */
  17383. constructor(scene: Scene);
  17384. private _clearDepthStencilBuffer;
  17385. /**
  17386. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17387. * @hidden
  17388. */
  17389. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17390. /**
  17391. * Resets the different information of the group to prepare a new frame
  17392. * @hidden
  17393. */
  17394. reset(): void;
  17395. /**
  17396. * Dispose and release the group and its associated resources.
  17397. * @hidden
  17398. */
  17399. dispose(): void;
  17400. /**
  17401. * Clear the info related to rendering groups preventing retention points during dispose.
  17402. */
  17403. freeRenderingGroups(): void;
  17404. private _prepareRenderingGroup;
  17405. /**
  17406. * Add a sprite manager to the rendering manager in order to render it this frame.
  17407. * @param spriteManager Define the sprite manager to render
  17408. */
  17409. dispatchSprites(spriteManager: ISpriteManager): void;
  17410. /**
  17411. * Add a particle system to the rendering manager in order to render it this frame.
  17412. * @param particleSystem Define the particle system to render
  17413. */
  17414. dispatchParticles(particleSystem: IParticleSystem): void;
  17415. /**
  17416. * Add a submesh to the manager in order to render it this frame
  17417. * @param subMesh The submesh to dispatch
  17418. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17419. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17420. */
  17421. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17422. /**
  17423. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17424. * This allowed control for front to back rendering or reversly depending of the special needs.
  17425. *
  17426. * @param renderingGroupId The rendering group id corresponding to its index
  17427. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17428. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17429. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17430. */
  17431. 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;
  17432. /**
  17433. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17434. *
  17435. * @param renderingGroupId The rendering group id corresponding to its index
  17436. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17437. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17438. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17439. */
  17440. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17441. /**
  17442. * Gets the current auto clear configuration for one rendering group of the rendering
  17443. * manager.
  17444. * @param index the rendering group index to get the information for
  17445. * @returns The auto clear setup for the requested rendering group
  17446. */
  17447. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17448. }
  17449. }
  17450. declare module BABYLON {
  17451. /**
  17452. * This Helps creating a texture that will be created from a camera in your scene.
  17453. * It is basically a dynamic texture that could be used to create special effects for instance.
  17454. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17455. */
  17456. export class RenderTargetTexture extends Texture {
  17457. isCube: boolean;
  17458. /**
  17459. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17460. */
  17461. static readonly REFRESHRATE_RENDER_ONCE: number;
  17462. /**
  17463. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17464. */
  17465. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17466. /**
  17467. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17468. * the central point of your effect and can save a lot of performances.
  17469. */
  17470. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17471. /**
  17472. * Use this predicate to dynamically define the list of mesh you want to render.
  17473. * If set, the renderList property will be overwritten.
  17474. */
  17475. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17476. private _renderList;
  17477. /**
  17478. * Use this list to define the list of mesh you want to render.
  17479. */
  17480. renderList: Nullable<Array<AbstractMesh>>;
  17481. private _hookArray;
  17482. /**
  17483. * Define if particles should be rendered in your texture.
  17484. */
  17485. renderParticles: boolean;
  17486. /**
  17487. * Define if sprites should be rendered in your texture.
  17488. */
  17489. renderSprites: boolean;
  17490. /**
  17491. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17492. */
  17493. coordinatesMode: number;
  17494. /**
  17495. * Define the camera used to render the texture.
  17496. */
  17497. activeCamera: Nullable<Camera>;
  17498. /**
  17499. * Override the render function of the texture with your own one.
  17500. */
  17501. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17502. /**
  17503. * Define if camera post processes should be use while rendering the texture.
  17504. */
  17505. useCameraPostProcesses: boolean;
  17506. /**
  17507. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17508. */
  17509. ignoreCameraViewport: boolean;
  17510. private _postProcessManager;
  17511. private _postProcesses;
  17512. private _resizeObserver;
  17513. /**
  17514. * An event triggered when the texture is unbind.
  17515. */
  17516. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17517. /**
  17518. * An event triggered when the texture is unbind.
  17519. */
  17520. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17521. private _onAfterUnbindObserver;
  17522. /**
  17523. * Set a after unbind callback in the texture.
  17524. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17525. */
  17526. onAfterUnbind: () => void;
  17527. /**
  17528. * An event triggered before rendering the texture
  17529. */
  17530. onBeforeRenderObservable: Observable<number>;
  17531. private _onBeforeRenderObserver;
  17532. /**
  17533. * Set a before render callback in the texture.
  17534. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17535. */
  17536. onBeforeRender: (faceIndex: number) => void;
  17537. /**
  17538. * An event triggered after rendering the texture
  17539. */
  17540. onAfterRenderObservable: Observable<number>;
  17541. private _onAfterRenderObserver;
  17542. /**
  17543. * Set a after render callback in the texture.
  17544. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17545. */
  17546. onAfterRender: (faceIndex: number) => void;
  17547. /**
  17548. * An event triggered after the texture clear
  17549. */
  17550. onClearObservable: Observable<Engine>;
  17551. private _onClearObserver;
  17552. /**
  17553. * Set a clear callback in the texture.
  17554. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17555. */
  17556. onClear: (Engine: Engine) => void;
  17557. /**
  17558. * Define the clear color of the Render Target if it should be different from the scene.
  17559. */
  17560. clearColor: Color4;
  17561. protected _size: number | {
  17562. width: number;
  17563. height: number;
  17564. };
  17565. protected _initialSizeParameter: number | {
  17566. width: number;
  17567. height: number;
  17568. } | {
  17569. ratio: number;
  17570. };
  17571. protected _sizeRatio: Nullable<number>;
  17572. /** @hidden */ generateMipMaps: boolean;
  17573. protected _renderingManager: RenderingManager;
  17574. /** @hidden */ waitingRenderList: string[];
  17575. protected _doNotChangeAspectRatio: boolean;
  17576. protected _currentRefreshId: number;
  17577. protected _refreshRate: number;
  17578. protected _textureMatrix: Matrix;
  17579. protected _samples: number;
  17580. protected _renderTargetOptions: RenderTargetCreationOptions;
  17581. /**
  17582. * Gets render target creation options that were used.
  17583. */
  17584. readonly renderTargetOptions: RenderTargetCreationOptions;
  17585. protected _engine: Engine;
  17586. protected _onRatioRescale(): void;
  17587. /**
  17588. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17589. * It must define where the camera used to render the texture is set
  17590. */
  17591. boundingBoxPosition: Vector3;
  17592. private _boundingBoxSize;
  17593. /**
  17594. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17595. * When defined, the cubemap will switch to local mode
  17596. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17597. * @example https://www.babylonjs-playground.com/#RNASML
  17598. */
  17599. boundingBoxSize: Vector3;
  17600. /**
  17601. * In case the RTT has been created with a depth texture, get the associated
  17602. * depth texture.
  17603. * Otherwise, return null.
  17604. */
  17605. depthStencilTexture: Nullable<InternalTexture>;
  17606. /**
  17607. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17608. * or used a shadow, depth texture...
  17609. * @param name The friendly name of the texture
  17610. * @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)
  17611. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17612. * @param generateMipMaps True if mip maps need to be generated after render.
  17613. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17614. * @param type The type of the buffer in the RTT (int, half float, float...)
  17615. * @param isCube True if a cube texture needs to be created
  17616. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17617. * @param generateDepthBuffer True to generate a depth buffer
  17618. * @param generateStencilBuffer True to generate a stencil buffer
  17619. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17620. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17621. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17622. */
  17623. constructor(name: string, size: number | {
  17624. width: number;
  17625. height: number;
  17626. } | {
  17627. ratio: number;
  17628. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17629. /**
  17630. * Creates a depth stencil texture.
  17631. * This is only available in WebGL 2 or with the depth texture extension available.
  17632. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17633. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17634. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17635. */
  17636. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17637. private _processSizeParameter;
  17638. /**
  17639. * Define the number of samples to use in case of MSAA.
  17640. * It defaults to one meaning no MSAA has been enabled.
  17641. */
  17642. samples: number;
  17643. /**
  17644. * Resets the refresh counter of the texture and start bak from scratch.
  17645. * Could be useful to regenerate the texture if it is setup to render only once.
  17646. */
  17647. resetRefreshCounter(): void;
  17648. /**
  17649. * Define the refresh rate of the texture or the rendering frequency.
  17650. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17651. */
  17652. refreshRate: number;
  17653. /**
  17654. * Adds a post process to the render target rendering passes.
  17655. * @param postProcess define the post process to add
  17656. */
  17657. addPostProcess(postProcess: PostProcess): void;
  17658. /**
  17659. * Clear all the post processes attached to the render target
  17660. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17661. */
  17662. clearPostProcesses(dispose?: boolean): void;
  17663. /**
  17664. * Remove one of the post process from the list of attached post processes to the texture
  17665. * @param postProcess define the post process to remove from the list
  17666. */
  17667. removePostProcess(postProcess: PostProcess): void;
  17668. /** @hidden */ shouldRender(): boolean;
  17669. /**
  17670. * Gets the actual render size of the texture.
  17671. * @returns the width of the render size
  17672. */
  17673. getRenderSize(): number;
  17674. /**
  17675. * Gets the actual render width of the texture.
  17676. * @returns the width of the render size
  17677. */
  17678. getRenderWidth(): number;
  17679. /**
  17680. * Gets the actual render height of the texture.
  17681. * @returns the height of the render size
  17682. */
  17683. getRenderHeight(): number;
  17684. /**
  17685. * Get if the texture can be rescaled or not.
  17686. */
  17687. readonly canRescale: boolean;
  17688. /**
  17689. * Resize the texture using a ratio.
  17690. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17691. */
  17692. scale(ratio: number): void;
  17693. /**
  17694. * Get the texture reflection matrix used to rotate/transform the reflection.
  17695. * @returns the reflection matrix
  17696. */
  17697. getReflectionTextureMatrix(): Matrix;
  17698. /**
  17699. * Resize the texture to a new desired size.
  17700. * Be carrefull as it will recreate all the data in the new texture.
  17701. * @param size Define the new size. It can be:
  17702. * - a number for squared texture,
  17703. * - an object containing { width: number, height: number }
  17704. * - or an object containing a ratio { ratio: number }
  17705. */
  17706. resize(size: number | {
  17707. width: number;
  17708. height: number;
  17709. } | {
  17710. ratio: number;
  17711. }): void;
  17712. /**
  17713. * Renders all the objects from the render list into the texture.
  17714. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17715. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17716. */
  17717. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17718. private _bestReflectionRenderTargetDimension;
  17719. /**
  17720. * @hidden
  17721. * @param faceIndex face index to bind to if this is a cubetexture
  17722. */ bindFrameBuffer(faceIndex?: number): void;
  17723. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17724. private renderToTarget;
  17725. /**
  17726. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17727. * This allowed control for front to back rendering or reversly depending of the special needs.
  17728. *
  17729. * @param renderingGroupId The rendering group id corresponding to its index
  17730. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17731. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17732. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17733. */
  17734. 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;
  17735. /**
  17736. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17737. *
  17738. * @param renderingGroupId The rendering group id corresponding to its index
  17739. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17740. */
  17741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17742. /**
  17743. * Clones the texture.
  17744. * @returns the cloned texture
  17745. */
  17746. clone(): RenderTargetTexture;
  17747. /**
  17748. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17749. * @returns The JSON representation of the texture
  17750. */
  17751. serialize(): any;
  17752. /**
  17753. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17754. */
  17755. disposeFramebufferObjects(): void;
  17756. /**
  17757. * Dispose the texture and release its associated resources.
  17758. */
  17759. dispose(): void;
  17760. /** @hidden */ rebuild(): void;
  17761. /**
  17762. * Clear the info related to rendering groups preventing retention point in material dispose.
  17763. */
  17764. freeRenderingGroups(): void;
  17765. /**
  17766. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17767. * @returns the view count
  17768. */
  17769. getViewCount(): number;
  17770. }
  17771. }
  17772. declare module BABYLON {
  17773. /**
  17774. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17775. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17776. * You can then easily use it as a reflectionTexture on a flat surface.
  17777. * In case the surface is not a plane, please consider relying on reflection probes.
  17778. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17779. */
  17780. export class MirrorTexture extends RenderTargetTexture {
  17781. private scene;
  17782. /**
  17783. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17784. * 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.
  17785. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17786. */
  17787. mirrorPlane: Plane;
  17788. /**
  17789. * Define the blur ratio used to blur the reflection if needed.
  17790. */
  17791. blurRatio: number;
  17792. /**
  17793. * Define the adaptive blur kernel used to blur the reflection if needed.
  17794. * This will autocompute the closest best match for the `blurKernel`
  17795. */
  17796. adaptiveBlurKernel: number;
  17797. /**
  17798. * Define the blur kernel used to blur the reflection if needed.
  17799. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17800. */
  17801. blurKernel: number;
  17802. /**
  17803. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17804. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17805. */
  17806. blurKernelX: number;
  17807. /**
  17808. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17809. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17810. */
  17811. blurKernelY: number;
  17812. private _autoComputeBlurKernel;
  17813. protected _onRatioRescale(): void;
  17814. private _updateGammaSpace;
  17815. private _imageProcessingConfigChangeObserver;
  17816. private _transformMatrix;
  17817. private _mirrorMatrix;
  17818. private _savedViewMatrix;
  17819. private _blurX;
  17820. private _blurY;
  17821. private _adaptiveBlurKernel;
  17822. private _blurKernelX;
  17823. private _blurKernelY;
  17824. private _blurRatio;
  17825. /**
  17826. * Instantiates a Mirror Texture.
  17827. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17828. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17829. * You can then easily use it as a reflectionTexture on a flat surface.
  17830. * In case the surface is not a plane, please consider relying on reflection probes.
  17831. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17832. * @param name
  17833. * @param size
  17834. * @param scene
  17835. * @param generateMipMaps
  17836. * @param type
  17837. * @param samplingMode
  17838. * @param generateDepthBuffer
  17839. */
  17840. constructor(name: string, size: number | {
  17841. width: number;
  17842. height: number;
  17843. } | {
  17844. ratio: number;
  17845. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17846. private _preparePostProcesses;
  17847. /**
  17848. * Clone the mirror texture.
  17849. * @returns the cloned texture
  17850. */
  17851. clone(): MirrorTexture;
  17852. /**
  17853. * Serialize the texture to a JSON representation you could use in Parse later on
  17854. * @returns the serialized JSON representation
  17855. */
  17856. serialize(): any;
  17857. /**
  17858. * Dispose the texture and release its associated resources.
  17859. */
  17860. dispose(): void;
  17861. }
  17862. }
  17863. declare module BABYLON {
  17864. /**
  17865. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17866. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17867. */
  17868. export class Texture extends BaseTexture {
  17869. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17870. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17871. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17872. /** nearest is mag = nearest and min = nearest and mip = linear */
  17873. static readonly NEAREST_SAMPLINGMODE: number;
  17874. /** nearest is mag = nearest and min = nearest and mip = linear */
  17875. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17876. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17877. static readonly BILINEAR_SAMPLINGMODE: number;
  17878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17879. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17880. /** Trilinear is mag = linear and min = linear and mip = linear */
  17881. static readonly TRILINEAR_SAMPLINGMODE: number;
  17882. /** Trilinear is mag = linear and min = linear and mip = linear */
  17883. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17884. /** mag = nearest and min = nearest and mip = nearest */
  17885. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17886. /** mag = nearest and min = linear and mip = nearest */
  17887. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17888. /** mag = nearest and min = linear and mip = linear */
  17889. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17890. /** mag = nearest and min = linear and mip = none */
  17891. static readonly NEAREST_LINEAR: number;
  17892. /** mag = nearest and min = nearest and mip = none */
  17893. static readonly NEAREST_NEAREST: number;
  17894. /** mag = linear and min = nearest and mip = nearest */
  17895. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17896. /** mag = linear and min = nearest and mip = linear */
  17897. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17898. /** mag = linear and min = linear and mip = none */
  17899. static readonly LINEAR_LINEAR: number;
  17900. /** mag = linear and min = nearest and mip = none */
  17901. static readonly LINEAR_NEAREST: number;
  17902. /** Explicit coordinates mode */
  17903. static readonly EXPLICIT_MODE: number;
  17904. /** Spherical coordinates mode */
  17905. static readonly SPHERICAL_MODE: number;
  17906. /** Planar coordinates mode */
  17907. static readonly PLANAR_MODE: number;
  17908. /** Cubic coordinates mode */
  17909. static readonly CUBIC_MODE: number;
  17910. /** Projection coordinates mode */
  17911. static readonly PROJECTION_MODE: number;
  17912. /** Inverse Cubic coordinates mode */
  17913. static readonly SKYBOX_MODE: number;
  17914. /** Inverse Cubic coordinates mode */
  17915. static readonly INVCUBIC_MODE: number;
  17916. /** Equirectangular coordinates mode */
  17917. static readonly EQUIRECTANGULAR_MODE: number;
  17918. /** Equirectangular Fixed coordinates mode */
  17919. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17920. /** Equirectangular Fixed Mirrored coordinates mode */
  17921. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17922. /** Texture is not repeating outside of 0..1 UVs */
  17923. static readonly CLAMP_ADDRESSMODE: number;
  17924. /** Texture is repeating outside of 0..1 UVs */
  17925. static readonly WRAP_ADDRESSMODE: number;
  17926. /** Texture is repeating and mirrored */
  17927. static readonly MIRROR_ADDRESSMODE: number;
  17928. /**
  17929. * 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
  17930. */
  17931. static UseSerializedUrlIfAny: boolean;
  17932. /**
  17933. * Define the url of the texture.
  17934. */
  17935. url: Nullable<string>;
  17936. /**
  17937. * Define an offset on the texture to offset the u coordinates of the UVs
  17938. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17939. */
  17940. uOffset: number;
  17941. /**
  17942. * Define an offset on the texture to offset the v coordinates of the UVs
  17943. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17944. */
  17945. vOffset: number;
  17946. /**
  17947. * Define an offset on the texture to scale the u coordinates of the UVs
  17948. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17949. */
  17950. uScale: number;
  17951. /**
  17952. * Define an offset on the texture to scale the v coordinates of the UVs
  17953. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17954. */
  17955. vScale: number;
  17956. /**
  17957. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17958. * @see http://doc.babylonjs.com/how_to/more_materials
  17959. */
  17960. uAng: number;
  17961. /**
  17962. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17963. * @see http://doc.babylonjs.com/how_to/more_materials
  17964. */
  17965. vAng: number;
  17966. /**
  17967. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17968. * @see http://doc.babylonjs.com/how_to/more_materials
  17969. */
  17970. wAng: number;
  17971. /**
  17972. * Defines the center of rotation (U)
  17973. */
  17974. uRotationCenter: number;
  17975. /**
  17976. * Defines the center of rotation (V)
  17977. */
  17978. vRotationCenter: number;
  17979. /**
  17980. * Defines the center of rotation (W)
  17981. */
  17982. wRotationCenter: number;
  17983. /**
  17984. * Are mip maps generated for this texture or not.
  17985. */
  17986. readonly noMipmap: boolean;
  17987. /**
  17988. * List of inspectable custom properties (used by the Inspector)
  17989. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17990. */
  17991. inspectableCustomProperties: Nullable<IInspectable[]>;
  17992. private _noMipmap;
  17993. /** @hidden */ invertY: boolean;
  17994. private _rowGenerationMatrix;
  17995. private _cachedTextureMatrix;
  17996. private _projectionModeMatrix;
  17997. private _t0;
  17998. private _t1;
  17999. private _t2;
  18000. private _cachedUOffset;
  18001. private _cachedVOffset;
  18002. private _cachedUScale;
  18003. private _cachedVScale;
  18004. private _cachedUAng;
  18005. private _cachedVAng;
  18006. private _cachedWAng;
  18007. private _cachedProjectionMatrixId;
  18008. private _cachedCoordinatesMode;
  18009. /** @hidden */
  18010. protected _initialSamplingMode: number;
  18011. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18012. private _deleteBuffer;
  18013. protected _format: Nullable<number>;
  18014. private _delayedOnLoad;
  18015. private _delayedOnError;
  18016. /**
  18017. * Observable triggered once the texture has been loaded.
  18018. */
  18019. onLoadObservable: Observable<Texture>;
  18020. protected _isBlocking: boolean;
  18021. /**
  18022. * Is the texture preventing material to render while loading.
  18023. * If false, a default texture will be used instead of the loading one during the preparation step.
  18024. */
  18025. isBlocking: boolean;
  18026. /**
  18027. * Get the current sampling mode associated with the texture.
  18028. */
  18029. readonly samplingMode: number;
  18030. /**
  18031. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18032. */
  18033. readonly invertY: boolean;
  18034. /**
  18035. * Instantiates a new texture.
  18036. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18037. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18038. * @param url define the url of the picture to load as a texture
  18039. * @param scene define the scene the texture will belong to
  18040. * @param noMipmap define if the texture will require mip maps or not
  18041. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18042. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18043. * @param onLoad define a callback triggered when the texture has been loaded
  18044. * @param onError define a callback triggered when an error occurred during the loading session
  18045. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18046. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18047. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18048. */
  18049. constructor(url: Nullable<string>, scene: Nullable<Scene>, 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);
  18050. /**
  18051. * Update the url (and optional buffer) of this texture if url was null during construction.
  18052. * @param url the url of the texture
  18053. * @param buffer the buffer of the texture (defaults to null)
  18054. * @param onLoad callback called when the texture is loaded (defaults to null)
  18055. */
  18056. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18057. /**
  18058. * Finish the loading sequence of a texture flagged as delayed load.
  18059. * @hidden
  18060. */
  18061. delayLoad(): void;
  18062. private _prepareRowForTextureGeneration;
  18063. /**
  18064. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18065. * @returns the transform matrix of the texture.
  18066. */
  18067. getTextureMatrix(): Matrix;
  18068. /**
  18069. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18070. * @returns The reflection texture transform
  18071. */
  18072. getReflectionTextureMatrix(): Matrix;
  18073. /**
  18074. * Clones the texture.
  18075. * @returns the cloned texture
  18076. */
  18077. clone(): Texture;
  18078. /**
  18079. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18080. * @returns The JSON representation of the texture
  18081. */
  18082. serialize(): any;
  18083. /**
  18084. * Get the current class name of the texture useful for serialization or dynamic coding.
  18085. * @returns "Texture"
  18086. */
  18087. getClassName(): string;
  18088. /**
  18089. * Dispose the texture and release its associated resources.
  18090. */
  18091. dispose(): void;
  18092. /**
  18093. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18094. * @param parsedTexture Define the JSON representation of the texture
  18095. * @param scene Define the scene the parsed texture should be instantiated in
  18096. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18097. * @returns The parsed texture if successful
  18098. */
  18099. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18100. /**
  18101. * Creates a texture from its base 64 representation.
  18102. * @param data Define the base64 payload without the data: prefix
  18103. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18104. * @param scene Define the scene the texture should belong to
  18105. * @param noMipmap Forces the texture to not create mip map information if true
  18106. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18107. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18108. * @param onLoad define a callback triggered when the texture has been loaded
  18109. * @param onError define a callback triggered when an error occurred during the loading session
  18110. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18111. * @returns the created texture
  18112. */
  18113. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18114. /**
  18115. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18116. * @param data Define the base64 payload without the data: prefix
  18117. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18118. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18119. * @param scene Define the scene the texture should belong to
  18120. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18121. * @param noMipmap Forces the texture to not create mip map information if true
  18122. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18123. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18124. * @param onLoad define a callback triggered when the texture has been loaded
  18125. * @param onError define a callback triggered when an error occurred during the loading session
  18126. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18127. * @returns the created texture
  18128. */
  18129. 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;
  18130. }
  18131. }
  18132. declare module BABYLON {
  18133. interface Engine {
  18134. /**
  18135. * Creates a raw texture
  18136. * @param data defines the data to store in the texture
  18137. * @param width defines the width of the texture
  18138. * @param height defines the height of the texture
  18139. * @param format defines the format of the data
  18140. * @param generateMipMaps defines if the engine should generate the mip levels
  18141. * @param invertY defines if data must be stored with Y axis inverted
  18142. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18143. * @param compression defines the compression used (null by default)
  18144. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18145. * @returns the raw texture inside an InternalTexture
  18146. */
  18147. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18148. /**
  18149. * Update a raw texture
  18150. * @param texture defines the texture to update
  18151. * @param data defines the data to store in the texture
  18152. * @param format defines the format of the data
  18153. * @param invertY defines if data must be stored with Y axis inverted
  18154. */
  18155. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18156. /**
  18157. * Update a raw texture
  18158. * @param texture defines the texture to update
  18159. * @param data defines the data to store in the texture
  18160. * @param format defines the format of the data
  18161. * @param invertY defines if data must be stored with Y axis inverted
  18162. * @param compression defines the compression used (null by default)
  18163. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18164. */
  18165. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18166. /**
  18167. * Creates a new raw cube texture
  18168. * @param data defines the array of data to use to create each face
  18169. * @param size defines the size of the textures
  18170. * @param format defines the format of the data
  18171. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18172. * @param generateMipMaps defines if the engine should generate the mip levels
  18173. * @param invertY defines if data must be stored with Y axis inverted
  18174. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18175. * @param compression defines the compression used (null by default)
  18176. * @returns the cube texture as an InternalTexture
  18177. */
  18178. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18179. /**
  18180. * Update a raw cube texture
  18181. * @param texture defines the texture to udpdate
  18182. * @param data defines the data to store
  18183. * @param format defines the data format
  18184. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18185. * @param invertY defines if data must be stored with Y axis inverted
  18186. */
  18187. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18188. /**
  18189. * Update a raw cube texture
  18190. * @param texture defines the texture to udpdate
  18191. * @param data defines the data to store
  18192. * @param format defines the data format
  18193. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18194. * @param invertY defines if data must be stored with Y axis inverted
  18195. * @param compression defines the compression used (null by default)
  18196. */
  18197. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18198. /**
  18199. * Update a raw cube texture
  18200. * @param texture defines the texture to udpdate
  18201. * @param data defines the data to store
  18202. * @param format defines the data format
  18203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18204. * @param invertY defines if data must be stored with Y axis inverted
  18205. * @param compression defines the compression used (null by default)
  18206. * @param level defines which level of the texture to update
  18207. */
  18208. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18209. /**
  18210. * Creates a new raw cube texture from a specified url
  18211. * @param url defines the url where the data is located
  18212. * @param scene defines the current scene
  18213. * @param size defines the size of the textures
  18214. * @param format defines the format of the data
  18215. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18216. * @param noMipmap defines if the engine should avoid generating the mip levels
  18217. * @param callback defines a callback used to extract texture data from loaded data
  18218. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18219. * @param onLoad defines a callback called when texture is loaded
  18220. * @param onError defines a callback called if there is an error
  18221. * @returns the cube texture as an InternalTexture
  18222. */
  18223. 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;
  18224. /**
  18225. * Creates a new raw cube texture from a specified url
  18226. * @param url defines the url where the data is located
  18227. * @param scene defines the current scene
  18228. * @param size defines the size of the textures
  18229. * @param format defines the format of the data
  18230. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18231. * @param noMipmap defines if the engine should avoid generating the mip levels
  18232. * @param callback defines a callback used to extract texture data from loaded data
  18233. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18234. * @param onLoad defines a callback called when texture is loaded
  18235. * @param onError defines a callback called if there is an error
  18236. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18237. * @param invertY defines if data must be stored with Y axis inverted
  18238. * @returns the cube texture as an InternalTexture
  18239. */
  18240. 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;
  18241. /**
  18242. * Creates a new raw 3D texture
  18243. * @param data defines the data used to create the texture
  18244. * @param width defines the width of the texture
  18245. * @param height defines the height of the texture
  18246. * @param depth defines the depth of the texture
  18247. * @param format defines the format of the texture
  18248. * @param generateMipMaps defines if the engine must generate mip levels
  18249. * @param invertY defines if data must be stored with Y axis inverted
  18250. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18251. * @param compression defines the compressed used (can be null)
  18252. * @param textureType defines the compressed used (can be null)
  18253. * @returns a new raw 3D texture (stored in an InternalTexture)
  18254. */
  18255. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18256. /**
  18257. * Update a raw 3D texture
  18258. * @param texture defines the texture to update
  18259. * @param data defines the data to store
  18260. * @param format defines the data format
  18261. * @param invertY defines if data must be stored with Y axis inverted
  18262. */
  18263. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18264. /**
  18265. * Update a raw 3D texture
  18266. * @param texture defines the texture to update
  18267. * @param data defines the data to store
  18268. * @param format defines the data format
  18269. * @param invertY defines if data must be stored with Y axis inverted
  18270. * @param compression defines the used compression (can be null)
  18271. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18272. */
  18273. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18274. }
  18275. }
  18276. declare module BABYLON {
  18277. /**
  18278. * Raw texture can help creating a texture directly from an array of data.
  18279. * This can be super useful if you either get the data from an uncompressed source or
  18280. * if you wish to create your texture pixel by pixel.
  18281. */
  18282. export class RawTexture extends Texture {
  18283. /**
  18284. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18285. */
  18286. format: number;
  18287. private _engine;
  18288. /**
  18289. * Instantiates a new RawTexture.
  18290. * Raw texture can help creating a texture directly from an array of data.
  18291. * This can be super useful if you either get the data from an uncompressed source or
  18292. * if you wish to create your texture pixel by pixel.
  18293. * @param data define the array of data to use to create the texture
  18294. * @param width define the width of the texture
  18295. * @param height define the height of the texture
  18296. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18297. * @param scene define the scene the texture belongs to
  18298. * @param generateMipMaps define whether mip maps should be generated or not
  18299. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18300. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18301. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18302. */
  18303. constructor(data: ArrayBufferView, width: number, height: number,
  18304. /**
  18305. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18306. */
  18307. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18308. /**
  18309. * Updates the texture underlying data.
  18310. * @param data Define the new data of the texture
  18311. */
  18312. update(data: ArrayBufferView): void;
  18313. /**
  18314. * Creates a luminance texture from some data.
  18315. * @param data Define the texture data
  18316. * @param width Define the width of the texture
  18317. * @param height Define the height of the texture
  18318. * @param scene Define the scene the texture belongs to
  18319. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18320. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18321. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18322. * @returns the luminance texture
  18323. */
  18324. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18325. /**
  18326. * Creates a luminance alpha texture from some data.
  18327. * @param data Define the texture data
  18328. * @param width Define the width of the texture
  18329. * @param height Define the height of the texture
  18330. * @param scene Define the scene the texture belongs to
  18331. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18332. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18333. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18334. * @returns the luminance alpha texture
  18335. */
  18336. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18337. /**
  18338. * Creates an alpha texture from some data.
  18339. * @param data Define the texture data
  18340. * @param width Define the width of the texture
  18341. * @param height Define the height of the texture
  18342. * @param scene Define the scene the texture belongs to
  18343. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18344. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18345. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18346. * @returns the alpha texture
  18347. */
  18348. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18349. /**
  18350. * Creates a RGB texture from some data.
  18351. * @param data Define the texture data
  18352. * @param width Define the width of the texture
  18353. * @param height Define the height of the texture
  18354. * @param scene Define the scene the texture belongs to
  18355. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18356. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18357. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18358. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18359. * @returns the RGB alpha texture
  18360. */
  18361. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18362. /**
  18363. * Creates a RGBA texture from some data.
  18364. * @param data Define the texture data
  18365. * @param width Define the width of the texture
  18366. * @param height Define the height of the texture
  18367. * @param scene Define the scene the texture belongs to
  18368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18371. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18372. * @returns the RGBA texture
  18373. */
  18374. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18375. /**
  18376. * Creates a R texture from some data.
  18377. * @param data Define the texture data
  18378. * @param width Define the width of the texture
  18379. * @param height Define the height of the texture
  18380. * @param scene Define the scene the texture belongs to
  18381. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18382. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18383. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18384. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18385. * @returns the R texture
  18386. */
  18387. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18388. }
  18389. }
  18390. declare module BABYLON {
  18391. /**
  18392. * Defines a runtime animation
  18393. */
  18394. export class RuntimeAnimation {
  18395. private _events;
  18396. /**
  18397. * The current frame of the runtime animation
  18398. */
  18399. private _currentFrame;
  18400. /**
  18401. * The animation used by the runtime animation
  18402. */
  18403. private _animation;
  18404. /**
  18405. * The target of the runtime animation
  18406. */
  18407. private _target;
  18408. /**
  18409. * The initiating animatable
  18410. */
  18411. private _host;
  18412. /**
  18413. * The original value of the runtime animation
  18414. */
  18415. private _originalValue;
  18416. /**
  18417. * The original blend value of the runtime animation
  18418. */
  18419. private _originalBlendValue;
  18420. /**
  18421. * The offsets cache of the runtime animation
  18422. */
  18423. private _offsetsCache;
  18424. /**
  18425. * The high limits cache of the runtime animation
  18426. */
  18427. private _highLimitsCache;
  18428. /**
  18429. * Specifies if the runtime animation has been stopped
  18430. */
  18431. private _stopped;
  18432. /**
  18433. * The blending factor of the runtime animation
  18434. */
  18435. private _blendingFactor;
  18436. /**
  18437. * The BabylonJS scene
  18438. */
  18439. private _scene;
  18440. /**
  18441. * The current value of the runtime animation
  18442. */
  18443. private _currentValue;
  18444. /** @hidden */ animationState: _IAnimationState;
  18445. /**
  18446. * The active target of the runtime animation
  18447. */
  18448. private _activeTargets;
  18449. private _currentActiveTarget;
  18450. private _directTarget;
  18451. /**
  18452. * The target path of the runtime animation
  18453. */
  18454. private _targetPath;
  18455. /**
  18456. * The weight of the runtime animation
  18457. */
  18458. private _weight;
  18459. /**
  18460. * The ratio offset of the runtime animation
  18461. */
  18462. private _ratioOffset;
  18463. /**
  18464. * The previous delay of the runtime animation
  18465. */
  18466. private _previousDelay;
  18467. /**
  18468. * The previous ratio of the runtime animation
  18469. */
  18470. private _previousRatio;
  18471. private _enableBlending;
  18472. private _keys;
  18473. private _minFrame;
  18474. private _maxFrame;
  18475. private _minValue;
  18476. private _maxValue;
  18477. private _targetIsArray;
  18478. /**
  18479. * Gets the current frame of the runtime animation
  18480. */
  18481. readonly currentFrame: number;
  18482. /**
  18483. * Gets the weight of the runtime animation
  18484. */
  18485. readonly weight: number;
  18486. /**
  18487. * Gets the current value of the runtime animation
  18488. */
  18489. readonly currentValue: any;
  18490. /**
  18491. * Gets the target path of the runtime animation
  18492. */
  18493. readonly targetPath: string;
  18494. /**
  18495. * Gets the actual target of the runtime animation
  18496. */
  18497. readonly target: any;
  18498. /** @hidden */ onLoop: () => void;
  18499. /**
  18500. * Create a new RuntimeAnimation object
  18501. * @param target defines the target of the animation
  18502. * @param animation defines the source animation object
  18503. * @param scene defines the hosting scene
  18504. * @param host defines the initiating Animatable
  18505. */
  18506. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18507. private _preparePath;
  18508. /**
  18509. * Gets the animation from the runtime animation
  18510. */
  18511. readonly animation: Animation;
  18512. /**
  18513. * Resets the runtime animation to the beginning
  18514. * @param restoreOriginal defines whether to restore the target property to the original value
  18515. */
  18516. reset(restoreOriginal?: boolean): void;
  18517. /**
  18518. * Specifies if the runtime animation is stopped
  18519. * @returns Boolean specifying if the runtime animation is stopped
  18520. */
  18521. isStopped(): boolean;
  18522. /**
  18523. * Disposes of the runtime animation
  18524. */
  18525. dispose(): void;
  18526. /**
  18527. * Apply the interpolated value to the target
  18528. * @param currentValue defines the value computed by the animation
  18529. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18530. */
  18531. setValue(currentValue: any, weight: number): void;
  18532. private _getOriginalValues;
  18533. private _setValue;
  18534. /**
  18535. * Gets the loop pmode of the runtime animation
  18536. * @returns Loop Mode
  18537. */
  18538. private _getCorrectLoopMode;
  18539. /**
  18540. * Move the current animation to a given frame
  18541. * @param frame defines the frame to move to
  18542. */
  18543. goToFrame(frame: number): void;
  18544. /**
  18545. * @hidden Internal use only
  18546. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18547. /**
  18548. * Execute the current animation
  18549. * @param delay defines the delay to add to the current frame
  18550. * @param from defines the lower bound of the animation range
  18551. * @param to defines the upper bound of the animation range
  18552. * @param loop defines if the current animation must loop
  18553. * @param speedRatio defines the current speed ratio
  18554. * @param weight defines the weight of the animation (default is -1 so no weight)
  18555. * @param onLoop optional callback called when animation loops
  18556. * @returns a boolean indicating if the animation is running
  18557. */
  18558. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18559. }
  18560. }
  18561. declare module BABYLON {
  18562. /**
  18563. * Class used to store an actual running animation
  18564. */
  18565. export class Animatable {
  18566. /** defines the target object */
  18567. target: any;
  18568. /** defines the starting frame number (default is 0) */
  18569. fromFrame: number;
  18570. /** defines the ending frame number (default is 100) */
  18571. toFrame: number;
  18572. /** defines if the animation must loop (default is false) */
  18573. loopAnimation: boolean;
  18574. /** defines a callback to call when animation ends if it is not looping */
  18575. onAnimationEnd?: (() => void) | null | undefined;
  18576. /** defines a callback to call when animation loops */
  18577. onAnimationLoop?: (() => void) | null | undefined;
  18578. private _localDelayOffset;
  18579. private _pausedDelay;
  18580. private _runtimeAnimations;
  18581. private _paused;
  18582. private _scene;
  18583. private _speedRatio;
  18584. private _weight;
  18585. private _syncRoot;
  18586. /**
  18587. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18588. * This will only apply for non looping animation (default is true)
  18589. */
  18590. disposeOnEnd: boolean;
  18591. /**
  18592. * Gets a boolean indicating if the animation has started
  18593. */
  18594. animationStarted: boolean;
  18595. /**
  18596. * Observer raised when the animation ends
  18597. */
  18598. onAnimationEndObservable: Observable<Animatable>;
  18599. /**
  18600. * Observer raised when the animation loops
  18601. */
  18602. onAnimationLoopObservable: Observable<Animatable>;
  18603. /**
  18604. * Gets the root Animatable used to synchronize and normalize animations
  18605. */
  18606. readonly syncRoot: Nullable<Animatable>;
  18607. /**
  18608. * Gets the current frame of the first RuntimeAnimation
  18609. * Used to synchronize Animatables
  18610. */
  18611. readonly masterFrame: number;
  18612. /**
  18613. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18614. */
  18615. weight: number;
  18616. /**
  18617. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18618. */
  18619. speedRatio: number;
  18620. /**
  18621. * Creates a new Animatable
  18622. * @param scene defines the hosting scene
  18623. * @param target defines the target object
  18624. * @param fromFrame defines the starting frame number (default is 0)
  18625. * @param toFrame defines the ending frame number (default is 100)
  18626. * @param loopAnimation defines if the animation must loop (default is false)
  18627. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18628. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18629. * @param animations defines a group of animation to add to the new Animatable
  18630. * @param onAnimationLoop defines a callback to call when animation loops
  18631. */
  18632. constructor(scene: Scene,
  18633. /** defines the target object */
  18634. target: any,
  18635. /** defines the starting frame number (default is 0) */
  18636. fromFrame?: number,
  18637. /** defines the ending frame number (default is 100) */
  18638. toFrame?: number,
  18639. /** defines if the animation must loop (default is false) */
  18640. loopAnimation?: boolean, speedRatio?: number,
  18641. /** defines a callback to call when animation ends if it is not looping */
  18642. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18643. /** defines a callback to call when animation loops */
  18644. onAnimationLoop?: (() => void) | null | undefined);
  18645. /**
  18646. * Synchronize and normalize current Animatable with a source Animatable
  18647. * This is useful when using animation weights and when animations are not of the same length
  18648. * @param root defines the root Animatable to synchronize with
  18649. * @returns the current Animatable
  18650. */
  18651. syncWith(root: Animatable): Animatable;
  18652. /**
  18653. * Gets the list of runtime animations
  18654. * @returns an array of RuntimeAnimation
  18655. */
  18656. getAnimations(): RuntimeAnimation[];
  18657. /**
  18658. * Adds more animations to the current animatable
  18659. * @param target defines the target of the animations
  18660. * @param animations defines the new animations to add
  18661. */
  18662. appendAnimations(target: any, animations: Animation[]): void;
  18663. /**
  18664. * Gets the source animation for a specific property
  18665. * @param property defines the propertyu to look for
  18666. * @returns null or the source animation for the given property
  18667. */
  18668. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18669. /**
  18670. * Gets the runtime animation for a specific property
  18671. * @param property defines the propertyu to look for
  18672. * @returns null or the runtime animation for the given property
  18673. */
  18674. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18675. /**
  18676. * Resets the animatable to its original state
  18677. */
  18678. reset(): void;
  18679. /**
  18680. * Allows the animatable to blend with current running animations
  18681. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18682. * @param blendingSpeed defines the blending speed to use
  18683. */
  18684. enableBlending(blendingSpeed: number): void;
  18685. /**
  18686. * Disable animation blending
  18687. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18688. */
  18689. disableBlending(): void;
  18690. /**
  18691. * Jump directly to a given frame
  18692. * @param frame defines the frame to jump to
  18693. */
  18694. goToFrame(frame: number): void;
  18695. /**
  18696. * Pause the animation
  18697. */
  18698. pause(): void;
  18699. /**
  18700. * Restart the animation
  18701. */
  18702. restart(): void;
  18703. private _raiseOnAnimationEnd;
  18704. /**
  18705. * Stop and delete the current animation
  18706. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18707. * @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)
  18708. */
  18709. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18710. /**
  18711. * Wait asynchronously for the animation to end
  18712. * @returns a promise which will be fullfilled when the animation ends
  18713. */
  18714. waitAsync(): Promise<Animatable>;
  18715. /** @hidden */ animate(delay: number): boolean;
  18716. }
  18717. interface Scene {
  18718. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18719. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18720. totalWeight: number;
  18721. animations: RuntimeAnimation[];
  18722. originalValue: Matrix;
  18723. }): any;
  18724. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18725. totalWeight: number;
  18726. animations: RuntimeAnimation[];
  18727. originalValue: Quaternion;
  18728. }, refQuaternion: Quaternion): Quaternion;
  18729. /** @hidden */ processLateAnimationBindings(): void;
  18730. /**
  18731. * Will start the animation sequence of a given target
  18732. * @param target defines the target
  18733. * @param from defines from which frame should animation start
  18734. * @param to defines until which frame should animation run.
  18735. * @param weight defines the weight to apply to the animation (1.0 by default)
  18736. * @param loop defines if the animation loops
  18737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18738. * @param onAnimationEnd defines the function to be executed when the animation ends
  18739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18740. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18741. * @param onAnimationLoop defines the callback to call when an animation loops
  18742. * @returns the animatable object created for this animation
  18743. */
  18744. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18745. /**
  18746. * Will start the animation sequence of a given target
  18747. * @param target defines the target
  18748. * @param from defines from which frame should animation start
  18749. * @param to defines until which frame should animation run.
  18750. * @param loop defines if the animation loops
  18751. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18752. * @param onAnimationEnd defines the function to be executed when the animation ends
  18753. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18754. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18755. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18756. * @param onAnimationLoop defines the callback to call when an animation loops
  18757. * @returns the animatable object created for this animation
  18758. */
  18759. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18760. /**
  18761. * Will start the animation sequence of a given target and its hierarchy
  18762. * @param target defines the target
  18763. * @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.
  18764. * @param from defines from which frame should animation start
  18765. * @param to defines until which frame should animation run.
  18766. * @param loop defines if the animation loops
  18767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18768. * @param onAnimationEnd defines the function to be executed when the animation ends
  18769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18770. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18772. * @param onAnimationLoop defines the callback to call when an animation loops
  18773. * @returns the list of created animatables
  18774. */
  18775. 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[];
  18776. /**
  18777. * Begin a new animation on a given node
  18778. * @param target defines the target where the animation will take place
  18779. * @param animations defines the list of animations to start
  18780. * @param from defines the initial value
  18781. * @param to defines the final value
  18782. * @param loop defines if you want animation to loop (off by default)
  18783. * @param speedRatio defines the speed ratio to apply to all animations
  18784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18785. * @param onAnimationLoop defines the callback to call when an animation loops
  18786. * @returns the list of created animatables
  18787. */
  18788. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18789. /**
  18790. * Begin a new animation on a given node and its hierarchy
  18791. * @param target defines the root node where the animation will take place
  18792. * @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.
  18793. * @param animations defines the list of animations to start
  18794. * @param from defines the initial value
  18795. * @param to defines the final value
  18796. * @param loop defines if you want animation to loop (off by default)
  18797. * @param speedRatio defines the speed ratio to apply to all animations
  18798. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18799. * @param onAnimationLoop defines the callback to call when an animation loops
  18800. * @returns the list of animatables created for all nodes
  18801. */
  18802. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18803. /**
  18804. * Gets the animatable associated with a specific target
  18805. * @param target defines the target of the animatable
  18806. * @returns the required animatable if found
  18807. */
  18808. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18809. /**
  18810. * Gets all animatables associated with a given target
  18811. * @param target defines the target to look animatables for
  18812. * @returns an array of Animatables
  18813. */
  18814. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18815. /**
  18816. * Stops and removes all animations that have been applied to the scene
  18817. */
  18818. stopAllAnimations(): void;
  18819. }
  18820. interface Bone {
  18821. /**
  18822. * Copy an animation range from another bone
  18823. * @param source defines the source bone
  18824. * @param rangeName defines the range name to copy
  18825. * @param frameOffset defines the frame offset
  18826. * @param rescaleAsRequired defines if rescaling must be applied if required
  18827. * @param skelDimensionsRatio defines the scaling ratio
  18828. * @returns true if operation was successful
  18829. */
  18830. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18831. }
  18832. }
  18833. declare module BABYLON {
  18834. /**
  18835. * Class used to handle skinning animations
  18836. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18837. */
  18838. export class Skeleton implements IAnimatable {
  18839. /** defines the skeleton name */
  18840. name: string;
  18841. /** defines the skeleton Id */
  18842. id: string;
  18843. /**
  18844. * Defines the list of child bones
  18845. */
  18846. bones: Bone[];
  18847. /**
  18848. * Defines an estimate of the dimension of the skeleton at rest
  18849. */
  18850. dimensionsAtRest: Vector3;
  18851. /**
  18852. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18853. */
  18854. needInitialSkinMatrix: boolean;
  18855. /**
  18856. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18857. */
  18858. overrideMesh: Nullable<AbstractMesh>;
  18859. /**
  18860. * Gets the list of animations attached to this skeleton
  18861. */
  18862. animations: Array<Animation>;
  18863. private _scene;
  18864. private _isDirty;
  18865. private _transformMatrices;
  18866. private _transformMatrixTexture;
  18867. private _meshesWithPoseMatrix;
  18868. private _animatables;
  18869. private _identity;
  18870. private _synchronizedWithMesh;
  18871. private _ranges;
  18872. private _lastAbsoluteTransformsUpdateId;
  18873. private _canUseTextureForBones;
  18874. private _uniqueId;
  18875. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18876. /**
  18877. * Specifies if the skeleton should be serialized
  18878. */
  18879. doNotSerialize: boolean;
  18880. private _useTextureToStoreBoneMatrices;
  18881. /**
  18882. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18883. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18884. */
  18885. useTextureToStoreBoneMatrices: boolean;
  18886. private _animationPropertiesOverride;
  18887. /**
  18888. * Gets or sets the animation properties override
  18889. */
  18890. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18891. /**
  18892. * List of inspectable custom properties (used by the Inspector)
  18893. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18894. */
  18895. inspectableCustomProperties: IInspectable[];
  18896. /**
  18897. * An observable triggered before computing the skeleton's matrices
  18898. */
  18899. onBeforeComputeObservable: Observable<Skeleton>;
  18900. /**
  18901. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18902. */
  18903. readonly isUsingTextureForMatrices: boolean;
  18904. /**
  18905. * Gets the unique ID of this skeleton
  18906. */
  18907. readonly uniqueId: number;
  18908. /**
  18909. * Creates a new skeleton
  18910. * @param name defines the skeleton name
  18911. * @param id defines the skeleton Id
  18912. * @param scene defines the hosting scene
  18913. */
  18914. constructor(
  18915. /** defines the skeleton name */
  18916. name: string,
  18917. /** defines the skeleton Id */
  18918. id: string, scene: Scene);
  18919. /**
  18920. * Gets the current object class name.
  18921. * @return the class name
  18922. */
  18923. getClassName(): string;
  18924. /**
  18925. * Returns an array containing the root bones
  18926. * @returns an array containing the root bones
  18927. */
  18928. getChildren(): Array<Bone>;
  18929. /**
  18930. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18931. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18932. * @returns a Float32Array containing matrices data
  18933. */
  18934. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18935. /**
  18936. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18937. * @returns a raw texture containing the data
  18938. */
  18939. getTransformMatrixTexture(): Nullable<RawTexture>;
  18940. /**
  18941. * Gets the current hosting scene
  18942. * @returns a scene object
  18943. */
  18944. getScene(): Scene;
  18945. /**
  18946. * Gets a string representing the current skeleton data
  18947. * @param fullDetails defines a boolean indicating if we want a verbose version
  18948. * @returns a string representing the current skeleton data
  18949. */
  18950. toString(fullDetails?: boolean): string;
  18951. /**
  18952. * Get bone's index searching by name
  18953. * @param name defines bone's name to search for
  18954. * @return the indice of the bone. Returns -1 if not found
  18955. */
  18956. getBoneIndexByName(name: string): number;
  18957. /**
  18958. * Creater a new animation range
  18959. * @param name defines the name of the range
  18960. * @param from defines the start key
  18961. * @param to defines the end key
  18962. */
  18963. createAnimationRange(name: string, from: number, to: number): void;
  18964. /**
  18965. * Delete a specific animation range
  18966. * @param name defines the name of the range
  18967. * @param deleteFrames defines if frames must be removed as well
  18968. */
  18969. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18970. /**
  18971. * Gets a specific animation range
  18972. * @param name defines the name of the range to look for
  18973. * @returns the requested animation range or null if not found
  18974. */
  18975. getAnimationRange(name: string): Nullable<AnimationRange>;
  18976. /**
  18977. * Gets the list of all animation ranges defined on this skeleton
  18978. * @returns an array
  18979. */
  18980. getAnimationRanges(): Nullable<AnimationRange>[];
  18981. /**
  18982. * Copy animation range from a source skeleton.
  18983. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18984. * @param source defines the source skeleton
  18985. * @param name defines the name of the range to copy
  18986. * @param rescaleAsRequired defines if rescaling must be applied if required
  18987. * @returns true if operation was successful
  18988. */
  18989. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18990. /**
  18991. * Forces the skeleton to go to rest pose
  18992. */
  18993. returnToRest(): void;
  18994. private _getHighestAnimationFrame;
  18995. /**
  18996. * Begin a specific animation range
  18997. * @param name defines the name of the range to start
  18998. * @param loop defines if looping must be turned on (false by default)
  18999. * @param speedRatio defines the speed ratio to apply (1 by default)
  19000. * @param onAnimationEnd defines a callback which will be called when animation will end
  19001. * @returns a new animatable
  19002. */
  19003. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19004. /** @hidden */ markAsDirty(): void;
  19005. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19006. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19007. private _computeTransformMatrices;
  19008. /**
  19009. * Build all resources required to render a skeleton
  19010. */
  19011. prepare(): void;
  19012. /**
  19013. * Gets the list of animatables currently running for this skeleton
  19014. * @returns an array of animatables
  19015. */
  19016. getAnimatables(): IAnimatable[];
  19017. /**
  19018. * Clone the current skeleton
  19019. * @param name defines the name of the new skeleton
  19020. * @param id defines the id of the new skeleton
  19021. * @returns the new skeleton
  19022. */
  19023. clone(name: string, id: string): Skeleton;
  19024. /**
  19025. * Enable animation blending for this skeleton
  19026. * @param blendingSpeed defines the blending speed to apply
  19027. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19028. */
  19029. enableBlending(blendingSpeed?: number): void;
  19030. /**
  19031. * Releases all resources associated with the current skeleton
  19032. */
  19033. dispose(): void;
  19034. /**
  19035. * Serialize the skeleton in a JSON object
  19036. * @returns a JSON object
  19037. */
  19038. serialize(): any;
  19039. /**
  19040. * Creates a new skeleton from serialized data
  19041. * @param parsedSkeleton defines the serialized data
  19042. * @param scene defines the hosting scene
  19043. * @returns a new skeleton
  19044. */
  19045. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19046. /**
  19047. * Compute all node absolute transforms
  19048. * @param forceUpdate defines if computation must be done even if cache is up to date
  19049. */
  19050. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19051. /**
  19052. * Gets the root pose matrix
  19053. * @returns a matrix
  19054. */
  19055. getPoseMatrix(): Nullable<Matrix>;
  19056. /**
  19057. * Sorts bones per internal index
  19058. */
  19059. sortBones(): void;
  19060. private _sortBones;
  19061. }
  19062. }
  19063. declare module BABYLON {
  19064. /**
  19065. * Defines a target to use with MorphTargetManager
  19066. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19067. */
  19068. export class MorphTarget implements IAnimatable {
  19069. /** defines the name of the target */
  19070. name: string;
  19071. /**
  19072. * Gets or sets the list of animations
  19073. */
  19074. animations: Animation[];
  19075. private _scene;
  19076. private _positions;
  19077. private _normals;
  19078. private _tangents;
  19079. private _influence;
  19080. /**
  19081. * Observable raised when the influence changes
  19082. */
  19083. onInfluenceChanged: Observable<boolean>;
  19084. /** @hidden */ onDataLayoutChanged: Observable<void>;
  19085. /**
  19086. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19087. */
  19088. influence: number;
  19089. /**
  19090. * Gets or sets the id of the morph Target
  19091. */
  19092. id: string;
  19093. private _animationPropertiesOverride;
  19094. /**
  19095. * Gets or sets the animation properties override
  19096. */
  19097. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19098. /**
  19099. * Creates a new MorphTarget
  19100. * @param name defines the name of the target
  19101. * @param influence defines the influence to use
  19102. * @param scene defines the scene the morphtarget belongs to
  19103. */
  19104. constructor(
  19105. /** defines the name of the target */
  19106. name: string, influence?: number, scene?: Nullable<Scene>);
  19107. /**
  19108. * Gets a boolean defining if the target contains position data
  19109. */
  19110. readonly hasPositions: boolean;
  19111. /**
  19112. * Gets a boolean defining if the target contains normal data
  19113. */
  19114. readonly hasNormals: boolean;
  19115. /**
  19116. * Gets a boolean defining if the target contains tangent data
  19117. */
  19118. readonly hasTangents: boolean;
  19119. /**
  19120. * Affects position data to this target
  19121. * @param data defines the position data to use
  19122. */
  19123. setPositions(data: Nullable<FloatArray>): void;
  19124. /**
  19125. * Gets the position data stored in this target
  19126. * @returns a FloatArray containing the position data (or null if not present)
  19127. */
  19128. getPositions(): Nullable<FloatArray>;
  19129. /**
  19130. * Affects normal data to this target
  19131. * @param data defines the normal data to use
  19132. */
  19133. setNormals(data: Nullable<FloatArray>): void;
  19134. /**
  19135. * Gets the normal data stored in this target
  19136. * @returns a FloatArray containing the normal data (or null if not present)
  19137. */
  19138. getNormals(): Nullable<FloatArray>;
  19139. /**
  19140. * Affects tangent data to this target
  19141. * @param data defines the tangent data to use
  19142. */
  19143. setTangents(data: Nullable<FloatArray>): void;
  19144. /**
  19145. * Gets the tangent data stored in this target
  19146. * @returns a FloatArray containing the tangent data (or null if not present)
  19147. */
  19148. getTangents(): Nullable<FloatArray>;
  19149. /**
  19150. * Serializes the current target into a Serialization object
  19151. * @returns the serialized object
  19152. */
  19153. serialize(): any;
  19154. /**
  19155. * Returns the string "MorphTarget"
  19156. * @returns "MorphTarget"
  19157. */
  19158. getClassName(): string;
  19159. /**
  19160. * Creates a new target from serialized data
  19161. * @param serializationObject defines the serialized data to use
  19162. * @returns a new MorphTarget
  19163. */
  19164. static Parse(serializationObject: any): MorphTarget;
  19165. /**
  19166. * Creates a MorphTarget from mesh data
  19167. * @param mesh defines the source mesh
  19168. * @param name defines the name to use for the new target
  19169. * @param influence defines the influence to attach to the target
  19170. * @returns a new MorphTarget
  19171. */
  19172. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19173. }
  19174. }
  19175. declare module BABYLON {
  19176. /**
  19177. * This class is used to deform meshes using morphing between different targets
  19178. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19179. */
  19180. export class MorphTargetManager {
  19181. private _targets;
  19182. private _targetInfluenceChangedObservers;
  19183. private _targetDataLayoutChangedObservers;
  19184. private _activeTargets;
  19185. private _scene;
  19186. private _influences;
  19187. private _supportsNormals;
  19188. private _supportsTangents;
  19189. private _vertexCount;
  19190. private _uniqueId;
  19191. private _tempInfluences;
  19192. /**
  19193. * Creates a new MorphTargetManager
  19194. * @param scene defines the current scene
  19195. */
  19196. constructor(scene?: Nullable<Scene>);
  19197. /**
  19198. * Gets the unique ID of this manager
  19199. */
  19200. readonly uniqueId: number;
  19201. /**
  19202. * Gets the number of vertices handled by this manager
  19203. */
  19204. readonly vertexCount: number;
  19205. /**
  19206. * Gets a boolean indicating if this manager supports morphing of normals
  19207. */
  19208. readonly supportsNormals: boolean;
  19209. /**
  19210. * Gets a boolean indicating if this manager supports morphing of tangents
  19211. */
  19212. readonly supportsTangents: boolean;
  19213. /**
  19214. * Gets the number of targets stored in this manager
  19215. */
  19216. readonly numTargets: number;
  19217. /**
  19218. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19219. */
  19220. readonly numInfluencers: number;
  19221. /**
  19222. * Gets the list of influences (one per target)
  19223. */
  19224. readonly influences: Float32Array;
  19225. /**
  19226. * Gets the active target at specified index. An active target is a target with an influence > 0
  19227. * @param index defines the index to check
  19228. * @returns the requested target
  19229. */
  19230. getActiveTarget(index: number): MorphTarget;
  19231. /**
  19232. * Gets the target at specified index
  19233. * @param index defines the index to check
  19234. * @returns the requested target
  19235. */
  19236. getTarget(index: number): MorphTarget;
  19237. /**
  19238. * Add a new target to this manager
  19239. * @param target defines the target to add
  19240. */
  19241. addTarget(target: MorphTarget): void;
  19242. /**
  19243. * Removes a target from the manager
  19244. * @param target defines the target to remove
  19245. */
  19246. removeTarget(target: MorphTarget): void;
  19247. /**
  19248. * Serializes the current manager into a Serialization object
  19249. * @returns the serialized object
  19250. */
  19251. serialize(): any;
  19252. private _syncActiveTargets;
  19253. /**
  19254. * Syncrhonize the targets with all the meshes using this morph target manager
  19255. */
  19256. synchronize(): void;
  19257. /**
  19258. * Creates a new MorphTargetManager from serialized data
  19259. * @param serializationObject defines the serialized data
  19260. * @param scene defines the hosting scene
  19261. * @returns the new MorphTargetManager
  19262. */
  19263. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19264. }
  19265. }
  19266. declare module BABYLON {
  19267. /**
  19268. * Class used to represent a specific level of detail of a mesh
  19269. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19270. */
  19271. export class MeshLODLevel {
  19272. /** Defines the distance where this level should star being displayed */
  19273. distance: number;
  19274. /** Defines the mesh to use to render this level */
  19275. mesh: Nullable<Mesh>;
  19276. /**
  19277. * Creates a new LOD level
  19278. * @param distance defines the distance where this level should star being displayed
  19279. * @param mesh defines the mesh to use to render this level
  19280. */
  19281. constructor(
  19282. /** Defines the distance where this level should star being displayed */
  19283. distance: number,
  19284. /** Defines the mesh to use to render this level */
  19285. mesh: Nullable<Mesh>);
  19286. }
  19287. }
  19288. declare module BABYLON {
  19289. /**
  19290. * Mesh representing the gorund
  19291. */
  19292. export class GroundMesh extends Mesh {
  19293. /** If octree should be generated */
  19294. generateOctree: boolean;
  19295. private _heightQuads;
  19296. /** @hidden */ subdivisionsX: number;
  19297. /** @hidden */ subdivisionsY: number;
  19298. /** @hidden */ width: number;
  19299. /** @hidden */ height: number;
  19300. /** @hidden */ minX: number;
  19301. /** @hidden */ maxX: number;
  19302. /** @hidden */ minZ: number;
  19303. /** @hidden */ maxZ: number;
  19304. constructor(name: string, scene: Scene);
  19305. /**
  19306. * "GroundMesh"
  19307. * @returns "GroundMesh"
  19308. */
  19309. getClassName(): string;
  19310. /**
  19311. * The minimum of x and y subdivisions
  19312. */
  19313. readonly subdivisions: number;
  19314. /**
  19315. * X subdivisions
  19316. */
  19317. readonly subdivisionsX: number;
  19318. /**
  19319. * Y subdivisions
  19320. */
  19321. readonly subdivisionsY: number;
  19322. /**
  19323. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19324. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19325. * @param chunksCount the number of subdivisions for x and y
  19326. * @param octreeBlocksSize (Default: 32)
  19327. */
  19328. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19329. /**
  19330. * Returns a height (y) value in the Worl system :
  19331. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19332. * @param x x coordinate
  19333. * @param z z coordinate
  19334. * @returns the ground y position if (x, z) are outside the ground surface.
  19335. */
  19336. getHeightAtCoordinates(x: number, z: number): number;
  19337. /**
  19338. * Returns a normalized vector (Vector3) orthogonal to the ground
  19339. * at the ground coordinates (x, z) expressed in the World system.
  19340. * @param x x coordinate
  19341. * @param z z coordinate
  19342. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19343. */
  19344. getNormalAtCoordinates(x: number, z: number): Vector3;
  19345. /**
  19346. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19347. * at the ground coordinates (x, z) expressed in the World system.
  19348. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19349. * @param x x coordinate
  19350. * @param z z coordinate
  19351. * @param ref vector to store the result
  19352. * @returns the GroundMesh.
  19353. */
  19354. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19355. /**
  19356. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19357. * if the ground has been updated.
  19358. * This can be used in the render loop.
  19359. * @returns the GroundMesh.
  19360. */
  19361. updateCoordinateHeights(): GroundMesh;
  19362. private _getFacetAt;
  19363. private _initHeightQuads;
  19364. private _computeHeightQuads;
  19365. /**
  19366. * Serializes this ground mesh
  19367. * @param serializationObject object to write serialization to
  19368. */
  19369. serialize(serializationObject: any): void;
  19370. /**
  19371. * Parses a serialized ground mesh
  19372. * @param parsedMesh the serialized mesh
  19373. * @param scene the scene to create the ground mesh in
  19374. * @returns the created ground mesh
  19375. */
  19376. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19377. }
  19378. }
  19379. declare module BABYLON {
  19380. /**
  19381. * Interface for Physics-Joint data
  19382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19383. */
  19384. export interface PhysicsJointData {
  19385. /**
  19386. * The main pivot of the joint
  19387. */
  19388. mainPivot?: Vector3;
  19389. /**
  19390. * The connected pivot of the joint
  19391. */
  19392. connectedPivot?: Vector3;
  19393. /**
  19394. * The main axis of the joint
  19395. */
  19396. mainAxis?: Vector3;
  19397. /**
  19398. * The connected axis of the joint
  19399. */
  19400. connectedAxis?: Vector3;
  19401. /**
  19402. * The collision of the joint
  19403. */
  19404. collision?: boolean;
  19405. /**
  19406. * Native Oimo/Cannon/Energy data
  19407. */
  19408. nativeParams?: any;
  19409. }
  19410. /**
  19411. * This is a holder class for the physics joint created by the physics plugin
  19412. * It holds a set of functions to control the underlying joint
  19413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19414. */
  19415. export class PhysicsJoint {
  19416. /**
  19417. * The type of the physics joint
  19418. */
  19419. type: number;
  19420. /**
  19421. * The data for the physics joint
  19422. */
  19423. jointData: PhysicsJointData;
  19424. private _physicsJoint;
  19425. protected _physicsPlugin: IPhysicsEnginePlugin;
  19426. /**
  19427. * Initializes the physics joint
  19428. * @param type The type of the physics joint
  19429. * @param jointData The data for the physics joint
  19430. */
  19431. constructor(
  19432. /**
  19433. * The type of the physics joint
  19434. */
  19435. type: number,
  19436. /**
  19437. * The data for the physics joint
  19438. */
  19439. jointData: PhysicsJointData);
  19440. /**
  19441. * Gets the physics joint
  19442. */
  19443. /**
  19444. * Sets the physics joint
  19445. */
  19446. physicsJoint: any;
  19447. /**
  19448. * Sets the physics plugin
  19449. */
  19450. physicsPlugin: IPhysicsEnginePlugin;
  19451. /**
  19452. * Execute a function that is physics-plugin specific.
  19453. * @param {Function} func the function that will be executed.
  19454. * It accepts two parameters: the physics world and the physics joint
  19455. */
  19456. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19457. /**
  19458. * Distance-Joint type
  19459. */
  19460. static DistanceJoint: number;
  19461. /**
  19462. * Hinge-Joint type
  19463. */
  19464. static HingeJoint: number;
  19465. /**
  19466. * Ball-and-Socket joint type
  19467. */
  19468. static BallAndSocketJoint: number;
  19469. /**
  19470. * Wheel-Joint type
  19471. */
  19472. static WheelJoint: number;
  19473. /**
  19474. * Slider-Joint type
  19475. */
  19476. static SliderJoint: number;
  19477. /**
  19478. * Prismatic-Joint type
  19479. */
  19480. static PrismaticJoint: number;
  19481. /**
  19482. * Universal-Joint type
  19483. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19484. */
  19485. static UniversalJoint: number;
  19486. /**
  19487. * Hinge-Joint 2 type
  19488. */
  19489. static Hinge2Joint: number;
  19490. /**
  19491. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19492. */
  19493. static PointToPointJoint: number;
  19494. /**
  19495. * Spring-Joint type
  19496. */
  19497. static SpringJoint: number;
  19498. /**
  19499. * Lock-Joint type
  19500. */
  19501. static LockJoint: number;
  19502. }
  19503. /**
  19504. * A class representing a physics distance joint
  19505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19506. */
  19507. export class DistanceJoint extends PhysicsJoint {
  19508. /**
  19509. *
  19510. * @param jointData The data for the Distance-Joint
  19511. */
  19512. constructor(jointData: DistanceJointData);
  19513. /**
  19514. * Update the predefined distance.
  19515. * @param maxDistance The maximum preferred distance
  19516. * @param minDistance The minimum preferred distance
  19517. */
  19518. updateDistance(maxDistance: number, minDistance?: number): void;
  19519. }
  19520. /**
  19521. * Represents a Motor-Enabled Joint
  19522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19523. */
  19524. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19525. /**
  19526. * Initializes the Motor-Enabled Joint
  19527. * @param type The type of the joint
  19528. * @param jointData The physica joint data for the joint
  19529. */
  19530. constructor(type: number, jointData: PhysicsJointData);
  19531. /**
  19532. * Set the motor values.
  19533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19534. * @param force the force to apply
  19535. * @param maxForce max force for this motor.
  19536. */
  19537. setMotor(force?: number, maxForce?: number): void;
  19538. /**
  19539. * Set the motor's limits.
  19540. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19541. * @param upperLimit The upper limit of the motor
  19542. * @param lowerLimit The lower limit of the motor
  19543. */
  19544. setLimit(upperLimit: number, lowerLimit?: number): void;
  19545. }
  19546. /**
  19547. * This class represents a single physics Hinge-Joint
  19548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19549. */
  19550. export class HingeJoint extends MotorEnabledJoint {
  19551. /**
  19552. * Initializes the Hinge-Joint
  19553. * @param jointData The joint data for the Hinge-Joint
  19554. */
  19555. constructor(jointData: PhysicsJointData);
  19556. /**
  19557. * Set the motor values.
  19558. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19559. * @param {number} force the force to apply
  19560. * @param {number} maxForce max force for this motor.
  19561. */
  19562. setMotor(force?: number, maxForce?: number): void;
  19563. /**
  19564. * Set the motor's limits.
  19565. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19566. * @param upperLimit The upper limit of the motor
  19567. * @param lowerLimit The lower limit of the motor
  19568. */
  19569. setLimit(upperLimit: number, lowerLimit?: number): void;
  19570. }
  19571. /**
  19572. * This class represents a dual hinge physics joint (same as wheel joint)
  19573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19574. */
  19575. export class Hinge2Joint extends MotorEnabledJoint {
  19576. /**
  19577. * Initializes the Hinge2-Joint
  19578. * @param jointData The joint data for the Hinge2-Joint
  19579. */
  19580. constructor(jointData: PhysicsJointData);
  19581. /**
  19582. * Set the motor values.
  19583. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19584. * @param {number} targetSpeed the speed the motor is to reach
  19585. * @param {number} maxForce max force for this motor.
  19586. * @param {motorIndex} the motor's index, 0 or 1.
  19587. */
  19588. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19589. /**
  19590. * Set the motor limits.
  19591. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19592. * @param {number} upperLimit the upper limit
  19593. * @param {number} lowerLimit lower limit
  19594. * @param {motorIndex} the motor's index, 0 or 1.
  19595. */
  19596. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19597. }
  19598. /**
  19599. * Interface for a motor enabled joint
  19600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19601. */
  19602. export interface IMotorEnabledJoint {
  19603. /**
  19604. * Physics joint
  19605. */
  19606. physicsJoint: any;
  19607. /**
  19608. * Sets the motor of the motor-enabled joint
  19609. * @param force The force of the motor
  19610. * @param maxForce The maximum force of the motor
  19611. * @param motorIndex The index of the motor
  19612. */
  19613. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19614. /**
  19615. * Sets the limit of the motor
  19616. * @param upperLimit The upper limit of the motor
  19617. * @param lowerLimit The lower limit of the motor
  19618. * @param motorIndex The index of the motor
  19619. */
  19620. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19621. }
  19622. /**
  19623. * Joint data for a Distance-Joint
  19624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19625. */
  19626. export interface DistanceJointData extends PhysicsJointData {
  19627. /**
  19628. * Max distance the 2 joint objects can be apart
  19629. */
  19630. maxDistance: number;
  19631. }
  19632. /**
  19633. * Joint data from a spring joint
  19634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19635. */
  19636. export interface SpringJointData extends PhysicsJointData {
  19637. /**
  19638. * Length of the spring
  19639. */
  19640. length: number;
  19641. /**
  19642. * Stiffness of the spring
  19643. */
  19644. stiffness: number;
  19645. /**
  19646. * Damping of the spring
  19647. */
  19648. damping: number;
  19649. /** this callback will be called when applying the force to the impostors. */
  19650. forceApplicationCallback: () => void;
  19651. }
  19652. }
  19653. declare module BABYLON {
  19654. /**
  19655. * Holds the data for the raycast result
  19656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19657. */
  19658. export class PhysicsRaycastResult {
  19659. private _hasHit;
  19660. private _hitDistance;
  19661. private _hitNormalWorld;
  19662. private _hitPointWorld;
  19663. private _rayFromWorld;
  19664. private _rayToWorld;
  19665. /**
  19666. * Gets if there was a hit
  19667. */
  19668. readonly hasHit: boolean;
  19669. /**
  19670. * Gets the distance from the hit
  19671. */
  19672. readonly hitDistance: number;
  19673. /**
  19674. * Gets the hit normal/direction in the world
  19675. */
  19676. readonly hitNormalWorld: Vector3;
  19677. /**
  19678. * Gets the hit point in the world
  19679. */
  19680. readonly hitPointWorld: Vector3;
  19681. /**
  19682. * Gets the ray "start point" of the ray in the world
  19683. */
  19684. readonly rayFromWorld: Vector3;
  19685. /**
  19686. * Gets the ray "end point" of the ray in the world
  19687. */
  19688. readonly rayToWorld: Vector3;
  19689. /**
  19690. * Sets the hit data (normal & point in world space)
  19691. * @param hitNormalWorld defines the normal in world space
  19692. * @param hitPointWorld defines the point in world space
  19693. */
  19694. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19695. /**
  19696. * Sets the distance from the start point to the hit point
  19697. * @param distance
  19698. */
  19699. setHitDistance(distance: number): void;
  19700. /**
  19701. * Calculates the distance manually
  19702. */
  19703. calculateHitDistance(): void;
  19704. /**
  19705. * Resets all the values to default
  19706. * @param from The from point on world space
  19707. * @param to The to point on world space
  19708. */
  19709. reset(from?: Vector3, to?: Vector3): void;
  19710. }
  19711. /**
  19712. * Interface for the size containing width and height
  19713. */
  19714. interface IXYZ {
  19715. /**
  19716. * X
  19717. */
  19718. x: number;
  19719. /**
  19720. * Y
  19721. */
  19722. y: number;
  19723. /**
  19724. * Z
  19725. */
  19726. z: number;
  19727. }
  19728. }
  19729. declare module BABYLON {
  19730. /**
  19731. * Interface used to describe a physics joint
  19732. */
  19733. export interface PhysicsImpostorJoint {
  19734. /** Defines the main impostor to which the joint is linked */
  19735. mainImpostor: PhysicsImpostor;
  19736. /** Defines the impostor that is connected to the main impostor using this joint */
  19737. connectedImpostor: PhysicsImpostor;
  19738. /** Defines the joint itself */
  19739. joint: PhysicsJoint;
  19740. }
  19741. /** @hidden */
  19742. export interface IPhysicsEnginePlugin {
  19743. world: any;
  19744. name: string;
  19745. setGravity(gravity: Vector3): void;
  19746. setTimeStep(timeStep: number): void;
  19747. getTimeStep(): number;
  19748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19749. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19750. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19751. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19752. removePhysicsBody(impostor: PhysicsImpostor): void;
  19753. generateJoint(joint: PhysicsImpostorJoint): void;
  19754. removeJoint(joint: PhysicsImpostorJoint): void;
  19755. isSupported(): boolean;
  19756. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19757. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19758. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19759. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19760. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19761. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19762. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19763. getBodyMass(impostor: PhysicsImpostor): number;
  19764. getBodyFriction(impostor: PhysicsImpostor): number;
  19765. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19766. getBodyRestitution(impostor: PhysicsImpostor): number;
  19767. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19768. getBodyPressure?(impostor: PhysicsImpostor): number;
  19769. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19770. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19771. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19772. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19773. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19774. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19775. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19776. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19777. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19778. sleepBody(impostor: PhysicsImpostor): void;
  19779. wakeUpBody(impostor: PhysicsImpostor): void;
  19780. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19782. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19783. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19784. getRadius(impostor: PhysicsImpostor): number;
  19785. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19786. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19787. dispose(): void;
  19788. }
  19789. /**
  19790. * Interface used to define a physics engine
  19791. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19792. */
  19793. export interface IPhysicsEngine {
  19794. /**
  19795. * Gets the gravity vector used by the simulation
  19796. */
  19797. gravity: Vector3;
  19798. /**
  19799. * Sets the gravity vector used by the simulation
  19800. * @param gravity defines the gravity vector to use
  19801. */
  19802. setGravity(gravity: Vector3): void;
  19803. /**
  19804. * Set the time step of the physics engine.
  19805. * Default is 1/60.
  19806. * To slow it down, enter 1/600 for example.
  19807. * To speed it up, 1/30
  19808. * @param newTimeStep the new timestep to apply to this world.
  19809. */
  19810. setTimeStep(newTimeStep: number): void;
  19811. /**
  19812. * Get the time step of the physics engine.
  19813. * @returns the current time step
  19814. */
  19815. getTimeStep(): number;
  19816. /**
  19817. * Release all resources
  19818. */
  19819. dispose(): void;
  19820. /**
  19821. * Gets the name of the current physics plugin
  19822. * @returns the name of the plugin
  19823. */
  19824. getPhysicsPluginName(): string;
  19825. /**
  19826. * Adding a new impostor for the impostor tracking.
  19827. * This will be done by the impostor itself.
  19828. * @param impostor the impostor to add
  19829. */
  19830. addImpostor(impostor: PhysicsImpostor): void;
  19831. /**
  19832. * Remove an impostor from the engine.
  19833. * This impostor and its mesh will not longer be updated by the physics engine.
  19834. * @param impostor the impostor to remove
  19835. */
  19836. removeImpostor(impostor: PhysicsImpostor): void;
  19837. /**
  19838. * Add a joint to the physics engine
  19839. * @param mainImpostor defines the main impostor to which the joint is added.
  19840. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19841. * @param joint defines the joint that will connect both impostors.
  19842. */
  19843. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19844. /**
  19845. * Removes a joint from the simulation
  19846. * @param mainImpostor defines the impostor used with the joint
  19847. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19848. * @param joint defines the joint to remove
  19849. */
  19850. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19851. /**
  19852. * Gets the current plugin used to run the simulation
  19853. * @returns current plugin
  19854. */
  19855. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19856. /**
  19857. * Gets the list of physic impostors
  19858. * @returns an array of PhysicsImpostor
  19859. */
  19860. getImpostors(): Array<PhysicsImpostor>;
  19861. /**
  19862. * Gets the impostor for a physics enabled object
  19863. * @param object defines the object impersonated by the impostor
  19864. * @returns the PhysicsImpostor or null if not found
  19865. */
  19866. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19867. /**
  19868. * Gets the impostor for a physics body object
  19869. * @param body defines physics body used by the impostor
  19870. * @returns the PhysicsImpostor or null if not found
  19871. */
  19872. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19873. /**
  19874. * Does a raycast in the physics world
  19875. * @param from when should the ray start?
  19876. * @param to when should the ray end?
  19877. * @returns PhysicsRaycastResult
  19878. */
  19879. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19880. /**
  19881. * Called by the scene. No need to call it.
  19882. * @param delta defines the timespam between frames
  19883. */ step(delta: number): void;
  19884. }
  19885. }
  19886. declare module BABYLON {
  19887. /**
  19888. * The interface for the physics imposter parameters
  19889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19890. */
  19891. export interface PhysicsImpostorParameters {
  19892. /**
  19893. * The mass of the physics imposter
  19894. */
  19895. mass: number;
  19896. /**
  19897. * The friction of the physics imposter
  19898. */
  19899. friction?: number;
  19900. /**
  19901. * The coefficient of restitution of the physics imposter
  19902. */
  19903. restitution?: number;
  19904. /**
  19905. * The native options of the physics imposter
  19906. */
  19907. nativeOptions?: any;
  19908. /**
  19909. * Specifies if the parent should be ignored
  19910. */
  19911. ignoreParent?: boolean;
  19912. /**
  19913. * Specifies if bi-directional transformations should be disabled
  19914. */
  19915. disableBidirectionalTransformation?: boolean;
  19916. /**
  19917. * The pressure inside the physics imposter, soft object only
  19918. */
  19919. pressure?: number;
  19920. /**
  19921. * The stiffness the physics imposter, soft object only
  19922. */
  19923. stiffness?: number;
  19924. /**
  19925. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19926. */
  19927. velocityIterations?: number;
  19928. /**
  19929. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19930. */
  19931. positionIterations?: number;
  19932. /**
  19933. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19934. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19935. * Add to fix multiple points
  19936. */
  19937. fixedPoints?: number;
  19938. /**
  19939. * The collision margin around a soft object
  19940. */
  19941. margin?: number;
  19942. /**
  19943. * The collision margin around a soft object
  19944. */
  19945. damping?: number;
  19946. /**
  19947. * The path for a rope based on an extrusion
  19948. */
  19949. path?: any;
  19950. /**
  19951. * The shape of an extrusion used for a rope based on an extrusion
  19952. */
  19953. shape?: any;
  19954. }
  19955. /**
  19956. * Interface for a physics-enabled object
  19957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19958. */
  19959. export interface IPhysicsEnabledObject {
  19960. /**
  19961. * The position of the physics-enabled object
  19962. */
  19963. position: Vector3;
  19964. /**
  19965. * The rotation of the physics-enabled object
  19966. */
  19967. rotationQuaternion: Nullable<Quaternion>;
  19968. /**
  19969. * The scale of the physics-enabled object
  19970. */
  19971. scaling: Vector3;
  19972. /**
  19973. * The rotation of the physics-enabled object
  19974. */
  19975. rotation?: Vector3;
  19976. /**
  19977. * The parent of the physics-enabled object
  19978. */
  19979. parent?: any;
  19980. /**
  19981. * The bounding info of the physics-enabled object
  19982. * @returns The bounding info of the physics-enabled object
  19983. */
  19984. getBoundingInfo(): BoundingInfo;
  19985. /**
  19986. * Computes the world matrix
  19987. * @param force Specifies if the world matrix should be computed by force
  19988. * @returns A world matrix
  19989. */
  19990. computeWorldMatrix(force: boolean): Matrix;
  19991. /**
  19992. * Gets the world matrix
  19993. * @returns A world matrix
  19994. */
  19995. getWorldMatrix?(): Matrix;
  19996. /**
  19997. * Gets the child meshes
  19998. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19999. * @returns An array of abstract meshes
  20000. */
  20001. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20002. /**
  20003. * Gets the vertex data
  20004. * @param kind The type of vertex data
  20005. * @returns A nullable array of numbers, or a float32 array
  20006. */
  20007. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20008. /**
  20009. * Gets the indices from the mesh
  20010. * @returns A nullable array of index arrays
  20011. */
  20012. getIndices?(): Nullable<IndicesArray>;
  20013. /**
  20014. * Gets the scene from the mesh
  20015. * @returns the indices array or null
  20016. */
  20017. getScene?(): Scene;
  20018. /**
  20019. * Gets the absolute position from the mesh
  20020. * @returns the absolute position
  20021. */
  20022. getAbsolutePosition(): Vector3;
  20023. /**
  20024. * Gets the absolute pivot point from the mesh
  20025. * @returns the absolute pivot point
  20026. */
  20027. getAbsolutePivotPoint(): Vector3;
  20028. /**
  20029. * Rotates the mesh
  20030. * @param axis The axis of rotation
  20031. * @param amount The amount of rotation
  20032. * @param space The space of the rotation
  20033. * @returns The rotation transform node
  20034. */
  20035. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20036. /**
  20037. * Translates the mesh
  20038. * @param axis The axis of translation
  20039. * @param distance The distance of translation
  20040. * @param space The space of the translation
  20041. * @returns The transform node
  20042. */
  20043. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20044. /**
  20045. * Sets the absolute position of the mesh
  20046. * @param absolutePosition The absolute position of the mesh
  20047. * @returns The transform node
  20048. */
  20049. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20050. /**
  20051. * Gets the class name of the mesh
  20052. * @returns The class name
  20053. */
  20054. getClassName(): string;
  20055. }
  20056. /**
  20057. * Represents a physics imposter
  20058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20059. */
  20060. export class PhysicsImpostor {
  20061. /**
  20062. * The physics-enabled object used as the physics imposter
  20063. */
  20064. object: IPhysicsEnabledObject;
  20065. /**
  20066. * The type of the physics imposter
  20067. */
  20068. type: number;
  20069. private _options;
  20070. private _scene?;
  20071. /**
  20072. * The default object size of the imposter
  20073. */
  20074. static DEFAULT_OBJECT_SIZE: Vector3;
  20075. /**
  20076. * The identity quaternion of the imposter
  20077. */
  20078. static IDENTITY_QUATERNION: Quaternion;
  20079. /** @hidden */ pluginData: any;
  20080. private _physicsEngine;
  20081. private _physicsBody;
  20082. private _bodyUpdateRequired;
  20083. private _onBeforePhysicsStepCallbacks;
  20084. private _onAfterPhysicsStepCallbacks;
  20085. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  20086. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20087. otherImpostors: Array<PhysicsImpostor>;
  20088. }>;
  20089. private _deltaPosition;
  20090. private _deltaRotation;
  20091. private _deltaRotationConjugated;
  20092. /** hidden */ isFromLine: boolean;
  20093. private _parent;
  20094. private _isDisposed;
  20095. private static _tmpVecs;
  20096. private static _tmpQuat;
  20097. /**
  20098. * Specifies if the physics imposter is disposed
  20099. */
  20100. readonly isDisposed: boolean;
  20101. /**
  20102. * Gets the mass of the physics imposter
  20103. */
  20104. mass: number;
  20105. /**
  20106. * Gets the coefficient of friction
  20107. */
  20108. /**
  20109. * Sets the coefficient of friction
  20110. */
  20111. friction: number;
  20112. /**
  20113. * Gets the coefficient of restitution
  20114. */
  20115. /**
  20116. * Sets the coefficient of restitution
  20117. */
  20118. restitution: number;
  20119. /**
  20120. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20121. */
  20122. /**
  20123. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20124. */
  20125. pressure: number;
  20126. /**
  20127. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20128. */
  20129. /**
  20130. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20131. */
  20132. stiffness: number;
  20133. /**
  20134. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20135. */
  20136. /**
  20137. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20138. */
  20139. velocityIterations: number;
  20140. /**
  20141. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20142. */
  20143. /**
  20144. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20145. */
  20146. positionIterations: number;
  20147. /**
  20148. * The unique id of the physics imposter
  20149. * set by the physics engine when adding this impostor to the array
  20150. */
  20151. uniqueId: number;
  20152. /**
  20153. * @hidden
  20154. */
  20155. soft: boolean;
  20156. /**
  20157. * @hidden
  20158. */
  20159. segments: number;
  20160. private _joints;
  20161. /**
  20162. * Initializes the physics imposter
  20163. * @param object The physics-enabled object used as the physics imposter
  20164. * @param type The type of the physics imposter
  20165. * @param _options The options for the physics imposter
  20166. * @param _scene The Babylon scene
  20167. */
  20168. constructor(
  20169. /**
  20170. * The physics-enabled object used as the physics imposter
  20171. */
  20172. object: IPhysicsEnabledObject,
  20173. /**
  20174. * The type of the physics imposter
  20175. */
  20176. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20177. /**
  20178. * This function will completly initialize this impostor.
  20179. * It will create a new body - but only if this mesh has no parent.
  20180. * If it has, this impostor will not be used other than to define the impostor
  20181. * of the child mesh.
  20182. * @hidden
  20183. */ init(): void;
  20184. private _getPhysicsParent;
  20185. /**
  20186. * Should a new body be generated.
  20187. * @returns boolean specifying if body initialization is required
  20188. */
  20189. isBodyInitRequired(): boolean;
  20190. /**
  20191. * Sets the updated scaling
  20192. * @param updated Specifies if the scaling is updated
  20193. */
  20194. setScalingUpdated(): void;
  20195. /**
  20196. * Force a regeneration of this or the parent's impostor's body.
  20197. * Use under cautious - This will remove all joints already implemented.
  20198. */
  20199. forceUpdate(): void;
  20200. /**
  20201. * Gets the body that holds this impostor. Either its own, or its parent.
  20202. */
  20203. /**
  20204. * Set the physics body. Used mainly by the physics engine/plugin
  20205. */
  20206. physicsBody: any;
  20207. /**
  20208. * Get the parent of the physics imposter
  20209. * @returns Physics imposter or null
  20210. */
  20211. /**
  20212. * Sets the parent of the physics imposter
  20213. */
  20214. parent: Nullable<PhysicsImpostor>;
  20215. /**
  20216. * Resets the update flags
  20217. */
  20218. resetUpdateFlags(): void;
  20219. /**
  20220. * Gets the object extend size
  20221. * @returns the object extend size
  20222. */
  20223. getObjectExtendSize(): Vector3;
  20224. /**
  20225. * Gets the object center
  20226. * @returns The object center
  20227. */
  20228. getObjectCenter(): Vector3;
  20229. /**
  20230. * Get a specific parametes from the options parameter
  20231. * @param paramName The object parameter name
  20232. * @returns The object parameter
  20233. */
  20234. getParam(paramName: string): any;
  20235. /**
  20236. * Sets a specific parameter in the options given to the physics plugin
  20237. * @param paramName The parameter name
  20238. * @param value The value of the parameter
  20239. */
  20240. setParam(paramName: string, value: number): void;
  20241. /**
  20242. * Specifically change the body's mass option. Won't recreate the physics body object
  20243. * @param mass The mass of the physics imposter
  20244. */
  20245. setMass(mass: number): void;
  20246. /**
  20247. * Gets the linear velocity
  20248. * @returns linear velocity or null
  20249. */
  20250. getLinearVelocity(): Nullable<Vector3>;
  20251. /**
  20252. * Sets the linear velocity
  20253. * @param velocity linear velocity or null
  20254. */
  20255. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20256. /**
  20257. * Gets the angular velocity
  20258. * @returns angular velocity or null
  20259. */
  20260. getAngularVelocity(): Nullable<Vector3>;
  20261. /**
  20262. * Sets the angular velocity
  20263. * @param velocity The velocity or null
  20264. */
  20265. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20266. /**
  20267. * Execute a function with the physics plugin native code
  20268. * Provide a function the will have two variables - the world object and the physics body object
  20269. * @param func The function to execute with the physics plugin native code
  20270. */
  20271. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20272. /**
  20273. * Register a function that will be executed before the physics world is stepping forward
  20274. * @param func The function to execute before the physics world is stepped forward
  20275. */
  20276. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20277. /**
  20278. * Unregister a function that will be executed before the physics world is stepping forward
  20279. * @param func The function to execute before the physics world is stepped forward
  20280. */
  20281. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20282. /**
  20283. * Register a function that will be executed after the physics step
  20284. * @param func The function to execute after physics step
  20285. */
  20286. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20287. /**
  20288. * Unregisters a function that will be executed after the physics step
  20289. * @param func The function to execute after physics step
  20290. */
  20291. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20292. /**
  20293. * register a function that will be executed when this impostor collides against a different body
  20294. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20295. * @param func Callback that is executed on collision
  20296. */
  20297. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20298. /**
  20299. * Unregisters the physics imposter on contact
  20300. * @param collideAgainst The physics object to collide against
  20301. * @param func Callback to execute on collision
  20302. */
  20303. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20304. private _tmpQuat;
  20305. private _tmpQuat2;
  20306. /**
  20307. * Get the parent rotation
  20308. * @returns The parent rotation
  20309. */
  20310. getParentsRotation(): Quaternion;
  20311. /**
  20312. * this function is executed by the physics engine.
  20313. */
  20314. beforeStep: () => void;
  20315. /**
  20316. * this function is executed by the physics engine
  20317. */
  20318. afterStep: () => void;
  20319. /**
  20320. * Legacy collision detection event support
  20321. */
  20322. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20323. /**
  20324. * event and body object due to cannon's event-based architecture.
  20325. */
  20326. onCollide: (e: {
  20327. body: any;
  20328. }) => void;
  20329. /**
  20330. * Apply a force
  20331. * @param force The force to apply
  20332. * @param contactPoint The contact point for the force
  20333. * @returns The physics imposter
  20334. */
  20335. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20336. /**
  20337. * Apply an impulse
  20338. * @param force The impulse force
  20339. * @param contactPoint The contact point for the impulse force
  20340. * @returns The physics imposter
  20341. */
  20342. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20343. /**
  20344. * A help function to create a joint
  20345. * @param otherImpostor A physics imposter used to create a joint
  20346. * @param jointType The type of joint
  20347. * @param jointData The data for the joint
  20348. * @returns The physics imposter
  20349. */
  20350. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20351. /**
  20352. * Add a joint to this impostor with a different impostor
  20353. * @param otherImpostor A physics imposter used to add a joint
  20354. * @param joint The joint to add
  20355. * @returns The physics imposter
  20356. */
  20357. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20358. /**
  20359. * Add an anchor to a cloth impostor
  20360. * @param otherImpostor rigid impostor to anchor to
  20361. * @param width ratio across width from 0 to 1
  20362. * @param height ratio up height from 0 to 1
  20363. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20364. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20365. * @returns impostor the soft imposter
  20366. */
  20367. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20368. /**
  20369. * Add a hook to a rope impostor
  20370. * @param otherImpostor rigid impostor to anchor to
  20371. * @param length ratio across rope from 0 to 1
  20372. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20373. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20374. * @returns impostor the rope imposter
  20375. */
  20376. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20377. /**
  20378. * Will keep this body still, in a sleep mode.
  20379. * @returns the physics imposter
  20380. */
  20381. sleep(): PhysicsImpostor;
  20382. /**
  20383. * Wake the body up.
  20384. * @returns The physics imposter
  20385. */
  20386. wakeUp(): PhysicsImpostor;
  20387. /**
  20388. * Clones the physics imposter
  20389. * @param newObject The physics imposter clones to this physics-enabled object
  20390. * @returns A nullable physics imposter
  20391. */
  20392. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20393. /**
  20394. * Disposes the physics imposter
  20395. */
  20396. dispose(): void;
  20397. /**
  20398. * Sets the delta position
  20399. * @param position The delta position amount
  20400. */
  20401. setDeltaPosition(position: Vector3): void;
  20402. /**
  20403. * Sets the delta rotation
  20404. * @param rotation The delta rotation amount
  20405. */
  20406. setDeltaRotation(rotation: Quaternion): void;
  20407. /**
  20408. * Gets the box size of the physics imposter and stores the result in the input parameter
  20409. * @param result Stores the box size
  20410. * @returns The physics imposter
  20411. */
  20412. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20413. /**
  20414. * Gets the radius of the physics imposter
  20415. * @returns Radius of the physics imposter
  20416. */
  20417. getRadius(): number;
  20418. /**
  20419. * Sync a bone with this impostor
  20420. * @param bone The bone to sync to the impostor.
  20421. * @param boneMesh The mesh that the bone is influencing.
  20422. * @param jointPivot The pivot of the joint / bone in local space.
  20423. * @param distToJoint Optional distance from the impostor to the joint.
  20424. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20425. */
  20426. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20427. /**
  20428. * Sync impostor to a bone
  20429. * @param bone The bone that the impostor will be synced to.
  20430. * @param boneMesh The mesh that the bone is influencing.
  20431. * @param jointPivot The pivot of the joint / bone in local space.
  20432. * @param distToJoint Optional distance from the impostor to the joint.
  20433. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20434. * @param boneAxis Optional vector3 axis the bone is aligned with
  20435. */
  20436. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20437. /**
  20438. * No-Imposter type
  20439. */
  20440. static NoImpostor: number;
  20441. /**
  20442. * Sphere-Imposter type
  20443. */
  20444. static SphereImpostor: number;
  20445. /**
  20446. * Box-Imposter type
  20447. */
  20448. static BoxImpostor: number;
  20449. /**
  20450. * Plane-Imposter type
  20451. */
  20452. static PlaneImpostor: number;
  20453. /**
  20454. * Mesh-imposter type
  20455. */
  20456. static MeshImpostor: number;
  20457. /**
  20458. * Cylinder-Imposter type
  20459. */
  20460. static CylinderImpostor: number;
  20461. /**
  20462. * Particle-Imposter type
  20463. */
  20464. static ParticleImpostor: number;
  20465. /**
  20466. * Heightmap-Imposter type
  20467. */
  20468. static HeightmapImpostor: number;
  20469. /**
  20470. * ConvexHull-Impostor type (Ammo.js plugin only)
  20471. */
  20472. static ConvexHullImpostor: number;
  20473. /**
  20474. * Rope-Imposter type
  20475. */
  20476. static RopeImpostor: number;
  20477. /**
  20478. * Cloth-Imposter type
  20479. */
  20480. static ClothImpostor: number;
  20481. /**
  20482. * Softbody-Imposter type
  20483. */
  20484. static SoftbodyImpostor: number;
  20485. }
  20486. }
  20487. declare module BABYLON {
  20488. /**
  20489. * @hidden
  20490. **/
  20491. export class _CreationDataStorage {
  20492. closePath?: boolean;
  20493. closeArray?: boolean;
  20494. idx: number[];
  20495. dashSize: number;
  20496. gapSize: number;
  20497. path3D: Path3D;
  20498. pathArray: Vector3[][];
  20499. arc: number;
  20500. radius: number;
  20501. cap: number;
  20502. tessellation: number;
  20503. }
  20504. /**
  20505. * @hidden
  20506. **/ private class _InstanceDataStorage {
  20507. visibleInstances: any;
  20508. batchCache: _InstancesBatch;
  20509. instancesBufferSize: number;
  20510. instancesBuffer: Nullable<Buffer>;
  20511. instancesData: Float32Array;
  20512. overridenInstanceCount: number;
  20513. isFrozen: boolean;
  20514. previousBatch: _InstancesBatch;
  20515. hardwareInstancedRendering: boolean;
  20516. sideOrientation: number;
  20517. }
  20518. /**
  20519. * @hidden
  20520. **/
  20521. export class _InstancesBatch {
  20522. mustReturn: boolean;
  20523. visibleInstances: Nullable<InstancedMesh[]>[];
  20524. renderSelf: boolean[];
  20525. hardwareInstancedRendering: boolean[];
  20526. }
  20527. /**
  20528. * Class used to represent renderable models
  20529. */
  20530. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20531. /**
  20532. * Mesh side orientation : usually the external or front surface
  20533. */
  20534. static readonly FRONTSIDE: number;
  20535. /**
  20536. * Mesh side orientation : usually the internal or back surface
  20537. */
  20538. static readonly BACKSIDE: number;
  20539. /**
  20540. * Mesh side orientation : both internal and external or front and back surfaces
  20541. */
  20542. static readonly DOUBLESIDE: number;
  20543. /**
  20544. * Mesh side orientation : by default, `FRONTSIDE`
  20545. */
  20546. static readonly DEFAULTSIDE: number;
  20547. /**
  20548. * Mesh cap setting : no cap
  20549. */
  20550. static readonly NO_CAP: number;
  20551. /**
  20552. * Mesh cap setting : one cap at the beginning of the mesh
  20553. */
  20554. static readonly CAP_START: number;
  20555. /**
  20556. * Mesh cap setting : one cap at the end of the mesh
  20557. */
  20558. static readonly CAP_END: number;
  20559. /**
  20560. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20561. */
  20562. static readonly CAP_ALL: number;
  20563. /**
  20564. * Gets the default side orientation.
  20565. * @param orientation the orientation to value to attempt to get
  20566. * @returns the default orientation
  20567. * @hidden
  20568. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20569. private _onBeforeRenderObservable;
  20570. private _onBeforeBindObservable;
  20571. private _onAfterRenderObservable;
  20572. private _onBeforeDrawObservable;
  20573. /**
  20574. * An event triggered before rendering the mesh
  20575. */
  20576. readonly onBeforeRenderObservable: Observable<Mesh>;
  20577. /**
  20578. * An event triggered before binding the mesh
  20579. */
  20580. readonly onBeforeBindObservable: Observable<Mesh>;
  20581. /**
  20582. * An event triggered after rendering the mesh
  20583. */
  20584. readonly onAfterRenderObservable: Observable<Mesh>;
  20585. /**
  20586. * An event triggered before drawing the mesh
  20587. */
  20588. readonly onBeforeDrawObservable: Observable<Mesh>;
  20589. private _onBeforeDrawObserver;
  20590. /**
  20591. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20592. */
  20593. onBeforeDraw: () => void;
  20594. /**
  20595. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20596. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20597. */
  20598. delayLoadState: number;
  20599. /**
  20600. * Gets the list of instances created from this mesh
  20601. * it is not supposed to be modified manually.
  20602. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20603. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20604. */
  20605. instances: InstancedMesh[];
  20606. /**
  20607. * Gets the file containing delay loading data for this mesh
  20608. */
  20609. delayLoadingFile: string;
  20610. /** @hidden */ binaryInfo: any;
  20611. private _LODLevels;
  20612. /**
  20613. * User defined function used to change how LOD level selection is done
  20614. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20615. */
  20616. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20617. private _morphTargetManager;
  20618. /**
  20619. * Gets or sets the morph target manager
  20620. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20621. */
  20622. morphTargetManager: Nullable<MorphTargetManager>;
  20623. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20624. /** @hidden */ geometry: Nullable<Geometry>;
  20625. /** @hidden */ delayInfo: Array<string>;
  20626. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20627. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20628. private _effectiveMaterial;
  20629. /** @hidden */ shouldGenerateFlatShading: boolean;
  20630. private _preActivateId;
  20631. /** @hidden */ originalBuilderSideOrientation: number;
  20632. /**
  20633. * Use this property to change the original side orientation defined at construction time
  20634. */
  20635. overrideMaterialSideOrientation: Nullable<number>;
  20636. private _areNormalsFrozen;
  20637. private _sourcePositions;
  20638. private _sourceNormals;
  20639. private _source;
  20640. private meshMap;
  20641. /**
  20642. * Gets the source mesh (the one used to clone this one from)
  20643. */
  20644. readonly source: Nullable<Mesh>;
  20645. /**
  20646. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20647. */
  20648. isUnIndexed: boolean;
  20649. /**
  20650. * @constructor
  20651. * @param name The value used by scene.getMeshByName() to do a lookup.
  20652. * @param scene The scene to add this mesh to.
  20653. * @param parent The parent of this mesh, if it has one
  20654. * @param source An optional Mesh from which geometry is shared, cloned.
  20655. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20656. * When false, achieved by calling a clone(), also passing False.
  20657. * This will make creation of children, recursive.
  20658. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20659. */
  20660. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20661. /**
  20662. * Gets the class name
  20663. * @returns the string "Mesh".
  20664. */
  20665. getClassName(): string;
  20666. /** @hidden */ protected readonly _isMesh: boolean;
  20667. /**
  20668. * Returns a description of this mesh
  20669. * @param fullDetails define if full details about this mesh must be used
  20670. * @returns a descriptive string representing this mesh
  20671. */
  20672. toString(fullDetails?: boolean): string;
  20673. /** @hidden */ unBindEffect(): void;
  20674. /**
  20675. * Gets a boolean indicating if this mesh has LOD
  20676. */
  20677. readonly hasLODLevels: boolean;
  20678. /**
  20679. * Gets the list of MeshLODLevel associated with the current mesh
  20680. * @returns an array of MeshLODLevel
  20681. */
  20682. getLODLevels(): MeshLODLevel[];
  20683. private _sortLODLevels;
  20684. /**
  20685. * Add a mesh as LOD level triggered at the given distance.
  20686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20687. * @param distance The distance from the center of the object to show this level
  20688. * @param mesh The mesh to be added as LOD level (can be null)
  20689. * @return This mesh (for chaining)
  20690. */
  20691. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20692. /**
  20693. * Returns the LOD level mesh at the passed distance or null if not found.
  20694. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20695. * @param distance The distance from the center of the object to show this level
  20696. * @returns a Mesh or `null`
  20697. */
  20698. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20699. /**
  20700. * Remove a mesh from the LOD array
  20701. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20702. * @param mesh defines the mesh to be removed
  20703. * @return This mesh (for chaining)
  20704. */
  20705. removeLODLevel(mesh: Mesh): Mesh;
  20706. /**
  20707. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20708. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20709. * @param camera defines the camera to use to compute distance
  20710. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20711. * @return This mesh (for chaining)
  20712. */
  20713. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20714. /**
  20715. * Gets the mesh internal Geometry object
  20716. */
  20717. readonly geometry: Nullable<Geometry>;
  20718. /**
  20719. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20720. * @returns the total number of vertices
  20721. */
  20722. getTotalVertices(): number;
  20723. /**
  20724. * Returns the content of an associated vertex buffer
  20725. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20726. * - VertexBuffer.PositionKind
  20727. * - VertexBuffer.UVKind
  20728. * - VertexBuffer.UV2Kind
  20729. * - VertexBuffer.UV3Kind
  20730. * - VertexBuffer.UV4Kind
  20731. * - VertexBuffer.UV5Kind
  20732. * - VertexBuffer.UV6Kind
  20733. * - VertexBuffer.ColorKind
  20734. * - VertexBuffer.MatricesIndicesKind
  20735. * - VertexBuffer.MatricesIndicesExtraKind
  20736. * - VertexBuffer.MatricesWeightsKind
  20737. * - VertexBuffer.MatricesWeightsExtraKind
  20738. * @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
  20739. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20740. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20741. */
  20742. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20743. /**
  20744. * Returns the mesh VertexBuffer object from the requested `kind`
  20745. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20746. * - VertexBuffer.PositionKind
  20747. * - VertexBuffer.UVKind
  20748. * - VertexBuffer.UV2Kind
  20749. * - VertexBuffer.UV3Kind
  20750. * - VertexBuffer.UV4Kind
  20751. * - VertexBuffer.UV5Kind
  20752. * - VertexBuffer.UV6Kind
  20753. * - VertexBuffer.ColorKind
  20754. * - VertexBuffer.MatricesIndicesKind
  20755. * - VertexBuffer.MatricesIndicesExtraKind
  20756. * - VertexBuffer.MatricesWeightsKind
  20757. * - VertexBuffer.MatricesWeightsExtraKind
  20758. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20759. */
  20760. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20761. /**
  20762. * Tests if a specific vertex buffer is associated with this mesh
  20763. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20764. * - VertexBuffer.PositionKind
  20765. * - VertexBuffer.UVKind
  20766. * - VertexBuffer.UV2Kind
  20767. * - VertexBuffer.UV3Kind
  20768. * - VertexBuffer.UV4Kind
  20769. * - VertexBuffer.UV5Kind
  20770. * - VertexBuffer.UV6Kind
  20771. * - VertexBuffer.ColorKind
  20772. * - VertexBuffer.MatricesIndicesKind
  20773. * - VertexBuffer.MatricesIndicesExtraKind
  20774. * - VertexBuffer.MatricesWeightsKind
  20775. * - VertexBuffer.MatricesWeightsExtraKind
  20776. * @returns a boolean
  20777. */
  20778. isVerticesDataPresent(kind: string): boolean;
  20779. /**
  20780. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20781. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20782. * - VertexBuffer.PositionKind
  20783. * - VertexBuffer.UVKind
  20784. * - VertexBuffer.UV2Kind
  20785. * - VertexBuffer.UV3Kind
  20786. * - VertexBuffer.UV4Kind
  20787. * - VertexBuffer.UV5Kind
  20788. * - VertexBuffer.UV6Kind
  20789. * - VertexBuffer.ColorKind
  20790. * - VertexBuffer.MatricesIndicesKind
  20791. * - VertexBuffer.MatricesIndicesExtraKind
  20792. * - VertexBuffer.MatricesWeightsKind
  20793. * - VertexBuffer.MatricesWeightsExtraKind
  20794. * @returns a boolean
  20795. */
  20796. isVertexBufferUpdatable(kind: string): boolean;
  20797. /**
  20798. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20799. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20800. * - VertexBuffer.PositionKind
  20801. * - VertexBuffer.UVKind
  20802. * - VertexBuffer.UV2Kind
  20803. * - VertexBuffer.UV3Kind
  20804. * - VertexBuffer.UV4Kind
  20805. * - VertexBuffer.UV5Kind
  20806. * - VertexBuffer.UV6Kind
  20807. * - VertexBuffer.ColorKind
  20808. * - VertexBuffer.MatricesIndicesKind
  20809. * - VertexBuffer.MatricesIndicesExtraKind
  20810. * - VertexBuffer.MatricesWeightsKind
  20811. * - VertexBuffer.MatricesWeightsExtraKind
  20812. * @returns an array of strings
  20813. */
  20814. getVerticesDataKinds(): string[];
  20815. /**
  20816. * Returns a positive integer : the total number of indices in this mesh geometry.
  20817. * @returns the numner of indices or zero if the mesh has no geometry.
  20818. */
  20819. getTotalIndices(): number;
  20820. /**
  20821. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20822. * @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.
  20823. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20824. * @returns the indices array or an empty array if the mesh has no geometry
  20825. */
  20826. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20827. readonly isBlocked: boolean;
  20828. /**
  20829. * Determine if the current mesh is ready to be rendered
  20830. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20831. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20832. * @returns true if all associated assets are ready (material, textures, shaders)
  20833. */
  20834. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20835. /**
  20836. * 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.
  20837. */
  20838. readonly areNormalsFrozen: boolean;
  20839. /**
  20840. * 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.
  20841. * @returns the current mesh
  20842. */
  20843. freezeNormals(): Mesh;
  20844. /**
  20845. * 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
  20846. * @returns the current mesh
  20847. */
  20848. unfreezeNormals(): Mesh;
  20849. /**
  20850. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20851. */
  20852. overridenInstanceCount: number;
  20853. /** @hidden */ preActivate(): Mesh;
  20854. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20855. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20856. /**
  20857. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20858. * This means the mesh underlying bounding box and sphere are recomputed.
  20859. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20860. * @returns the current mesh
  20861. */
  20862. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20863. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20864. /**
  20865. * This function will subdivide the mesh into multiple submeshes
  20866. * @param count defines the expected number of submeshes
  20867. */
  20868. subdivide(count: number): void;
  20869. /**
  20870. * Copy a FloatArray into a specific associated vertex buffer
  20871. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20872. * - VertexBuffer.PositionKind
  20873. * - VertexBuffer.UVKind
  20874. * - VertexBuffer.UV2Kind
  20875. * - VertexBuffer.UV3Kind
  20876. * - VertexBuffer.UV4Kind
  20877. * - VertexBuffer.UV5Kind
  20878. * - VertexBuffer.UV6Kind
  20879. * - VertexBuffer.ColorKind
  20880. * - VertexBuffer.MatricesIndicesKind
  20881. * - VertexBuffer.MatricesIndicesExtraKind
  20882. * - VertexBuffer.MatricesWeightsKind
  20883. * - VertexBuffer.MatricesWeightsExtraKind
  20884. * @param data defines the data source
  20885. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20886. * @param stride defines the data stride size (can be null)
  20887. * @returns the current mesh
  20888. */
  20889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20890. /**
  20891. * Flags an associated vertex buffer as updatable
  20892. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20893. * - VertexBuffer.PositionKind
  20894. * - VertexBuffer.UVKind
  20895. * - VertexBuffer.UV2Kind
  20896. * - VertexBuffer.UV3Kind
  20897. * - VertexBuffer.UV4Kind
  20898. * - VertexBuffer.UV5Kind
  20899. * - VertexBuffer.UV6Kind
  20900. * - VertexBuffer.ColorKind
  20901. * - VertexBuffer.MatricesIndicesKind
  20902. * - VertexBuffer.MatricesIndicesExtraKind
  20903. * - VertexBuffer.MatricesWeightsKind
  20904. * - VertexBuffer.MatricesWeightsExtraKind
  20905. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20906. */
  20907. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20908. /**
  20909. * Sets the mesh global Vertex Buffer
  20910. * @param buffer defines the buffer to use
  20911. * @returns the current mesh
  20912. */
  20913. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20914. /**
  20915. * Update a specific associated vertex buffer
  20916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20917. * - VertexBuffer.PositionKind
  20918. * - VertexBuffer.UVKind
  20919. * - VertexBuffer.UV2Kind
  20920. * - VertexBuffer.UV3Kind
  20921. * - VertexBuffer.UV4Kind
  20922. * - VertexBuffer.UV5Kind
  20923. * - VertexBuffer.UV6Kind
  20924. * - VertexBuffer.ColorKind
  20925. * - VertexBuffer.MatricesIndicesKind
  20926. * - VertexBuffer.MatricesIndicesExtraKind
  20927. * - VertexBuffer.MatricesWeightsKind
  20928. * - VertexBuffer.MatricesWeightsExtraKind
  20929. * @param data defines the data source
  20930. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20931. * @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)
  20932. * @returns the current mesh
  20933. */
  20934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20935. /**
  20936. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20937. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20938. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20939. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20940. * @returns the current mesh
  20941. */
  20942. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20943. /**
  20944. * Creates a un-shared specific occurence of the geometry for the mesh.
  20945. * @returns the current mesh
  20946. */
  20947. makeGeometryUnique(): Mesh;
  20948. /**
  20949. * Set the index buffer of this mesh
  20950. * @param indices defines the source data
  20951. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20952. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20953. * @returns the current mesh
  20954. */
  20955. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20956. /**
  20957. * Update the current index buffer
  20958. * @param indices defines the source data
  20959. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20960. * @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)
  20961. * @returns the current mesh
  20962. */
  20963. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20964. /**
  20965. * Invert the geometry to move from a right handed system to a left handed one.
  20966. * @returns the current mesh
  20967. */
  20968. toLeftHanded(): Mesh;
  20969. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20970. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20971. /**
  20972. * Registers for this mesh a javascript function called just before the rendering process
  20973. * @param func defines the function to call before rendering this mesh
  20974. * @returns the current mesh
  20975. */
  20976. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20977. /**
  20978. * Disposes a previously registered javascript function called before the rendering
  20979. * @param func defines the function to remove
  20980. * @returns the current mesh
  20981. */
  20982. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20983. /**
  20984. * Registers for this mesh a javascript function called just after the rendering is complete
  20985. * @param func defines the function to call after rendering this mesh
  20986. * @returns the current mesh
  20987. */
  20988. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20989. /**
  20990. * Disposes a previously registered javascript function called after the rendering.
  20991. * @param func defines the function to remove
  20992. * @returns the current mesh
  20993. */
  20994. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20995. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20996. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20997. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20998. /** @hidden */ freeze(): void;
  20999. /** @hidden */ unFreeze(): void;
  21000. /**
  21001. * 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
  21002. * @param subMesh defines the subMesh to render
  21003. * @param enableAlphaMode defines if alpha mode can be changed
  21004. * @returns the current mesh
  21005. */
  21006. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21007. private _onBeforeDraw;
  21008. /**
  21009. * Renormalize the mesh and patch it up if there are no weights
  21010. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21011. * However in the case of zero weights then we set just a single influence to 1.
  21012. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21013. */
  21014. cleanMatrixWeights(): void;
  21015. private normalizeSkinFourWeights;
  21016. private normalizeSkinWeightsAndExtra;
  21017. /**
  21018. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21019. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21020. * the user know there was an issue with importing the mesh
  21021. * @returns a validation object with skinned, valid and report string
  21022. */
  21023. validateSkinning(): {
  21024. skinned: boolean;
  21025. valid: boolean;
  21026. report: string;
  21027. };
  21028. /** @hidden */ checkDelayState(): Mesh;
  21029. private _queueLoad;
  21030. /**
  21031. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21032. * A mesh is in the frustum if its bounding box intersects the frustum
  21033. * @param frustumPlanes defines the frustum to test
  21034. * @returns true if the mesh is in the frustum planes
  21035. */
  21036. isInFrustum(frustumPlanes: Plane[]): boolean;
  21037. /**
  21038. * Sets the mesh material by the material or multiMaterial `id` property
  21039. * @param id is a string identifying the material or the multiMaterial
  21040. * @returns the current mesh
  21041. */
  21042. setMaterialByID(id: string): Mesh;
  21043. /**
  21044. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21045. * @returns an array of IAnimatable
  21046. */
  21047. getAnimatables(): IAnimatable[];
  21048. /**
  21049. * Modifies the mesh geometry according to the passed transformation matrix.
  21050. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21051. * The mesh normals are modified using the same transformation.
  21052. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21053. * @param transform defines the transform matrix to use
  21054. * @see http://doc.babylonjs.com/resources/baking_transformations
  21055. * @returns the current mesh
  21056. */
  21057. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21058. /**
  21059. * Modifies the mesh geometry according to its own current World Matrix.
  21060. * The mesh World Matrix is then reset.
  21061. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21062. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21063. * @see http://doc.babylonjs.com/resources/baking_transformations
  21064. * @returns the current mesh
  21065. */
  21066. bakeCurrentTransformIntoVertices(): Mesh;
  21067. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  21068. /** @hidden */ resetPointsArrayCache(): Mesh;
  21069. /** @hidden */ generatePointsArray(): boolean;
  21070. /**
  21071. * Returns a new Mesh object generated from the current mesh properties.
  21072. * This method must not get confused with createInstance()
  21073. * @param name is a string, the name given to the new mesh
  21074. * @param newParent can be any Node object (default `null`)
  21075. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21076. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21077. * @returns a new mesh
  21078. */
  21079. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21080. /**
  21081. * Releases resources associated with this mesh.
  21082. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21083. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21084. */
  21085. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21086. /**
  21087. * Modifies the mesh geometry according to a displacement map.
  21088. * 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.
  21089. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21090. * @param url is a string, the URL from the image file is to be downloaded.
  21091. * @param minHeight is the lower limit of the displacement.
  21092. * @param maxHeight is the upper limit of the displacement.
  21093. * @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.
  21094. * @param uvOffset is an optional vector2 used to offset UV.
  21095. * @param uvScale is an optional vector2 used to scale UV.
  21096. * @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.
  21097. * @returns the Mesh.
  21098. */
  21099. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21100. /**
  21101. * Modifies the mesh geometry according to a displacementMap buffer.
  21102. * 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.
  21103. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21104. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21105. * @param heightMapWidth is the width of the buffer image.
  21106. * @param heightMapHeight is the height of the buffer image.
  21107. * @param minHeight is the lower limit of the displacement.
  21108. * @param maxHeight is the upper limit of the displacement.
  21109. * @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.
  21110. * @param uvOffset is an optional vector2 used to offset UV.
  21111. * @param uvScale is an optional vector2 used to scale UV.
  21112. * @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.
  21113. * @returns the Mesh.
  21114. */
  21115. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21116. /**
  21117. * Modify the mesh to get a flat shading rendering.
  21118. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21119. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21120. * @returns current mesh
  21121. */
  21122. convertToFlatShadedMesh(): Mesh;
  21123. /**
  21124. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21125. * In other words, more vertices, no more indices and a single bigger VBO.
  21126. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21127. * @returns current mesh
  21128. */
  21129. convertToUnIndexedMesh(): Mesh;
  21130. /**
  21131. * Inverses facet orientations.
  21132. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21133. * @param flipNormals will also inverts the normals
  21134. * @returns current mesh
  21135. */
  21136. flipFaces(flipNormals?: boolean): Mesh;
  21137. /**
  21138. * Increase the number of facets and hence vertices in a mesh
  21139. * Vertex normals are interpolated from existing vertex normals
  21140. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21141. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21142. */
  21143. increaseVertices(numberPerEdge: number): void;
  21144. /**
  21145. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21146. * This will undo any application of covertToFlatShadedMesh
  21147. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21148. */
  21149. forceSharedVertices(): void;
  21150. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21151. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21152. /**
  21153. * Creates a new InstancedMesh object from the mesh model.
  21154. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21155. * @param name defines the name of the new instance
  21156. * @returns a new InstancedMesh
  21157. */
  21158. createInstance(name: string): InstancedMesh;
  21159. /**
  21160. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21161. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21162. * @returns the current mesh
  21163. */
  21164. synchronizeInstances(): Mesh;
  21165. /**
  21166. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21167. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21168. * This should be used together with the simplification to avoid disappearing triangles.
  21169. * @param successCallback an optional success callback to be called after the optimization finished.
  21170. * @returns the current mesh
  21171. */
  21172. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21173. /**
  21174. * Serialize current mesh
  21175. * @param serializationObject defines the object which will receive the serialization data
  21176. */
  21177. serialize(serializationObject: any): void;
  21178. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  21179. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21180. /**
  21181. * Returns a new Mesh object parsed from the source provided.
  21182. * @param parsedMesh is the source
  21183. * @param scene defines the hosting scene
  21184. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21185. * @returns a new Mesh
  21186. */
  21187. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21188. /**
  21189. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21190. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21191. * @param name defines the name of the mesh to create
  21192. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21193. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21194. * @param closePath creates a seam between the first and the last points of each path of the path array
  21195. * @param offset is taken in account only if the `pathArray` is containing a single path
  21196. * @param scene defines the hosting scene
  21197. * @param updatable defines if the mesh must be flagged as updatable
  21198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21199. * @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)
  21200. * @returns a new Mesh
  21201. */
  21202. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21203. /**
  21204. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21205. * @param name defines the name of the mesh to create
  21206. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21207. * @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
  21208. * @param scene defines the hosting scene
  21209. * @param updatable defines if the mesh must be flagged as updatable
  21210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21211. * @returns a new Mesh
  21212. */
  21213. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21214. /**
  21215. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21216. * @param name defines the name of the mesh to create
  21217. * @param size sets the size (float) of each box side (default 1)
  21218. * @param scene defines the hosting scene
  21219. * @param updatable defines if the mesh must be flagged as updatable
  21220. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21221. * @returns a new Mesh
  21222. */
  21223. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21224. /**
  21225. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21226. * @param name defines the name of the mesh to create
  21227. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21228. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21229. * @param scene defines the hosting scene
  21230. * @param updatable defines if the mesh must be flagged as updatable
  21231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21232. * @returns a new Mesh
  21233. */
  21234. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21235. /**
  21236. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21237. * @param name defines the name of the mesh to create
  21238. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21239. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21240. * @param scene defines the hosting scene
  21241. * @returns a new Mesh
  21242. */
  21243. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21244. /**
  21245. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21246. * @param name defines the name of the mesh to create
  21247. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21248. * @param diameterTop set the top cap diameter (floats, default 1)
  21249. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21250. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21251. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21252. * @param scene defines the hosting scene
  21253. * @param updatable defines if the mesh must be flagged as updatable
  21254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21255. * @returns a new Mesh
  21256. */
  21257. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21258. /**
  21259. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21260. * @param name defines the name of the mesh to create
  21261. * @param diameter sets the diameter size (float) of the torus (default 1)
  21262. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21263. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21264. * @param scene defines the hosting scene
  21265. * @param updatable defines if the mesh must be flagged as updatable
  21266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21267. * @returns a new Mesh
  21268. */
  21269. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21270. /**
  21271. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21272. * @param name defines the name of the mesh to create
  21273. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21274. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21275. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21276. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21277. * @param p the number of windings on X axis (positive integers, default 2)
  21278. * @param q the number of windings on Y axis (positive integers, default 3)
  21279. * @param scene defines the hosting scene
  21280. * @param updatable defines if the mesh must be flagged as updatable
  21281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21282. * @returns a new Mesh
  21283. */
  21284. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21285. /**
  21286. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21287. * @param name defines the name of the mesh to create
  21288. * @param points is an array successive Vector3
  21289. * @param scene defines the hosting scene
  21290. * @param updatable defines if the mesh must be flagged as updatable
  21291. * @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).
  21292. * @returns a new Mesh
  21293. */
  21294. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21295. /**
  21296. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21297. * @param name defines the name of the mesh to create
  21298. * @param points is an array successive Vector3
  21299. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21300. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21301. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21302. * @param scene defines the hosting scene
  21303. * @param updatable defines if the mesh must be flagged as updatable
  21304. * @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)
  21305. * @returns a new Mesh
  21306. */
  21307. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21308. /**
  21309. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21310. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21311. * 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.
  21312. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21313. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21314. * Remember you can only change the shape positions, not their number when updating a polygon.
  21315. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21316. * @param name defines the name of the mesh to create
  21317. * @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
  21318. * @param scene defines the hosting scene
  21319. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21320. * @param updatable defines if the mesh must be flagged as updatable
  21321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21322. * @param earcutInjection can be used to inject your own earcut reference
  21323. * @returns a new Mesh
  21324. */
  21325. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21326. /**
  21327. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21328. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21329. * @param name defines the name of the mesh to create
  21330. * @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
  21331. * @param depth defines the height of extrusion
  21332. * @param scene defines the hosting scene
  21333. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21334. * @param updatable defines if the mesh must be flagged as updatable
  21335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21336. * @param earcutInjection can be used to inject your own earcut reference
  21337. * @returns a new Mesh
  21338. */
  21339. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21340. /**
  21341. * Creates an extruded shape mesh.
  21342. * 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
  21343. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21344. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21345. * @param name defines the name of the mesh to create
  21346. * @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
  21347. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21348. * @param scale is the value to scale the shape
  21349. * @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
  21350. * @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
  21351. * @param scene defines the hosting scene
  21352. * @param updatable defines if the mesh must be flagged as updatable
  21353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21354. * @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)
  21355. * @returns a new Mesh
  21356. */
  21357. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21358. /**
  21359. * Creates an custom extruded shape mesh.
  21360. * The custom extrusion is a parametric shape.
  21361. * It has no predefined shape. Its final shape will depend on the input parameters.
  21362. * Please consider using the same method from the MeshBuilder class instead
  21363. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21364. * @param name defines the name of the mesh to create
  21365. * @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
  21366. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21367. * @param scaleFunction is a custom Javascript function called on each path point
  21368. * @param rotationFunction is a custom Javascript function called on each path point
  21369. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21370. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21371. * @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
  21372. * @param scene defines the hosting scene
  21373. * @param updatable defines if the mesh must be flagged as updatable
  21374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21375. * @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)
  21376. * @returns a new Mesh
  21377. */
  21378. 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;
  21379. /**
  21380. * Creates lathe mesh.
  21381. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21382. * Please consider using the same method from the MeshBuilder class instead
  21383. * @param name defines the name of the mesh to create
  21384. * @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
  21385. * @param radius is the radius value of the lathe
  21386. * @param tessellation is the side number of the lathe.
  21387. * @param scene defines the hosting scene
  21388. * @param updatable defines if the mesh must be flagged as updatable
  21389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21390. * @returns a new Mesh
  21391. */
  21392. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21393. /**
  21394. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21395. * @param name defines the name of the mesh to create
  21396. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21397. * @param scene defines the hosting scene
  21398. * @param updatable defines if the mesh must be flagged as updatable
  21399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21400. * @returns a new Mesh
  21401. */
  21402. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21403. /**
  21404. * Creates a ground mesh.
  21405. * Please consider using the same method from the MeshBuilder class instead
  21406. * @param name defines the name of the mesh to create
  21407. * @param width set the width of the ground
  21408. * @param height set the height of the ground
  21409. * @param subdivisions sets the number of subdivisions per side
  21410. * @param scene defines the hosting scene
  21411. * @param updatable defines if the mesh must be flagged as updatable
  21412. * @returns a new Mesh
  21413. */
  21414. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21415. /**
  21416. * Creates a tiled ground mesh.
  21417. * Please consider using the same method from the MeshBuilder class instead
  21418. * @param name defines the name of the mesh to create
  21419. * @param xmin set the ground minimum X coordinate
  21420. * @param zmin set the ground minimum Y coordinate
  21421. * @param xmax set the ground maximum X coordinate
  21422. * @param zmax set the ground maximum Z coordinate
  21423. * @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
  21424. * @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
  21425. * @param scene defines the hosting scene
  21426. * @param updatable defines if the mesh must be flagged as updatable
  21427. * @returns a new Mesh
  21428. */
  21429. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21430. w: number;
  21431. h: number;
  21432. }, precision: {
  21433. w: number;
  21434. h: number;
  21435. }, scene: Scene, updatable?: boolean): Mesh;
  21436. /**
  21437. * Creates a ground mesh from a height map.
  21438. * Please consider using the same method from the MeshBuilder class instead
  21439. * @see http://doc.babylonjs.com/babylon101/height_map
  21440. * @param name defines the name of the mesh to create
  21441. * @param url sets the URL of the height map image resource
  21442. * @param width set the ground width size
  21443. * @param height set the ground height size
  21444. * @param subdivisions sets the number of subdivision per side
  21445. * @param minHeight is the minimum altitude on the ground
  21446. * @param maxHeight is the maximum altitude on the ground
  21447. * @param scene defines the hosting scene
  21448. * @param updatable defines if the mesh must be flagged as updatable
  21449. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21450. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21451. * @returns a new Mesh
  21452. */
  21453. 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;
  21454. /**
  21455. * Creates a tube mesh.
  21456. * The tube is a parametric shape.
  21457. * It has no predefined shape. Its final shape will depend on the input parameters.
  21458. * Please consider using the same method from the MeshBuilder class instead
  21459. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21460. * @param name defines the name of the mesh to create
  21461. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21462. * @param radius sets the tube radius size
  21463. * @param tessellation is the number of sides on the tubular surface
  21464. * @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
  21465. * @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
  21466. * @param scene defines the hosting scene
  21467. * @param updatable defines if the mesh must be flagged as updatable
  21468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21469. * @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)
  21470. * @returns a new Mesh
  21471. */
  21472. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21473. (i: number, distance: number): number;
  21474. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21475. /**
  21476. * Creates a polyhedron mesh.
  21477. * Please consider using the same method from the MeshBuilder class instead.
  21478. * * 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
  21479. * * The parameter `size` (positive float, default 1) sets the polygon size
  21480. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21481. * * 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`
  21482. * * 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
  21483. * * 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)`)
  21484. * * 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
  21485. * * 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
  21486. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21487. * * If you create a double-sided mesh, you can choose what parts of 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
  21488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21489. * @param name defines the name of the mesh to create
  21490. * @param options defines the options used to create the mesh
  21491. * @param scene defines the hosting scene
  21492. * @returns a new Mesh
  21493. */
  21494. static CreatePolyhedron(name: string, options: {
  21495. type?: number;
  21496. size?: number;
  21497. sizeX?: number;
  21498. sizeY?: number;
  21499. sizeZ?: number;
  21500. custom?: any;
  21501. faceUV?: Vector4[];
  21502. faceColors?: Color4[];
  21503. updatable?: boolean;
  21504. sideOrientation?: number;
  21505. }, scene: Scene): Mesh;
  21506. /**
  21507. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21508. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21509. * * 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`)
  21510. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21511. * * 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
  21512. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21513. * * If you create a double-sided mesh, you can choose what parts of 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
  21514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21515. * @param name defines the name of the mesh
  21516. * @param options defines the options used to create the mesh
  21517. * @param scene defines the hosting scene
  21518. * @returns a new Mesh
  21519. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21520. */
  21521. static CreateIcoSphere(name: string, options: {
  21522. radius?: number;
  21523. flat?: boolean;
  21524. subdivisions?: number;
  21525. sideOrientation?: number;
  21526. updatable?: boolean;
  21527. }, scene: Scene): Mesh;
  21528. /**
  21529. * Creates a decal mesh.
  21530. * Please consider using the same method from the MeshBuilder class instead.
  21531. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21532. * @param name defines the name of the mesh
  21533. * @param sourceMesh defines the mesh receiving the decal
  21534. * @param position sets the position of the decal in world coordinates
  21535. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21536. * @param size sets the decal scaling
  21537. * @param angle sets the angle to rotate the decal
  21538. * @returns a new Mesh
  21539. */
  21540. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21541. /**
  21542. * Prepare internal position array for software CPU skinning
  21543. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21544. */
  21545. setPositionsForCPUSkinning(): Float32Array;
  21546. /**
  21547. * Prepare internal normal array for software CPU skinning
  21548. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21549. */
  21550. setNormalsForCPUSkinning(): Float32Array;
  21551. /**
  21552. * Updates the vertex buffer by applying transformation from the bones
  21553. * @param skeleton defines the skeleton to apply to current mesh
  21554. * @returns the current mesh
  21555. */
  21556. applySkeleton(skeleton: Skeleton): Mesh;
  21557. /**
  21558. * 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
  21559. * @param meshes defines the list of meshes to scan
  21560. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21561. */
  21562. static MinMax(meshes: AbstractMesh[]): {
  21563. min: Vector3;
  21564. max: Vector3;
  21565. };
  21566. /**
  21567. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21568. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21569. * @returns a vector3
  21570. */
  21571. static Center(meshesOrMinMaxVector: {
  21572. min: Vector3;
  21573. max: Vector3;
  21574. } | AbstractMesh[]): Vector3;
  21575. /**
  21576. * Merge the array of meshes into a single mesh for performance reasons.
  21577. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21578. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21579. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21580. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21581. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21582. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21583. * @returns a new mesh
  21584. */
  21585. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21586. /** @hidden */
  21587. addInstance(instance: InstancedMesh): void;
  21588. /** @hidden */
  21589. removeInstance(instance: InstancedMesh): void;
  21590. }
  21591. }
  21592. declare module BABYLON {
  21593. /**
  21594. * Base class for the main features of a material in Babylon.js
  21595. */
  21596. export class Material implements IAnimatable {
  21597. /**
  21598. * Returns the triangle fill mode
  21599. */
  21600. static readonly TriangleFillMode: number;
  21601. /**
  21602. * Returns the wireframe mode
  21603. */
  21604. static readonly WireFrameFillMode: number;
  21605. /**
  21606. * Returns the point fill mode
  21607. */
  21608. static readonly PointFillMode: number;
  21609. /**
  21610. * Returns the point list draw mode
  21611. */
  21612. static readonly PointListDrawMode: number;
  21613. /**
  21614. * Returns the line list draw mode
  21615. */
  21616. static readonly LineListDrawMode: number;
  21617. /**
  21618. * Returns the line loop draw mode
  21619. */
  21620. static readonly LineLoopDrawMode: number;
  21621. /**
  21622. * Returns the line strip draw mode
  21623. */
  21624. static readonly LineStripDrawMode: number;
  21625. /**
  21626. * Returns the triangle strip draw mode
  21627. */
  21628. static readonly TriangleStripDrawMode: number;
  21629. /**
  21630. * Returns the triangle fan draw mode
  21631. */
  21632. static readonly TriangleFanDrawMode: number;
  21633. /**
  21634. * Stores the clock-wise side orientation
  21635. */
  21636. static readonly ClockWiseSideOrientation: number;
  21637. /**
  21638. * Stores the counter clock-wise side orientation
  21639. */
  21640. static readonly CounterClockWiseSideOrientation: number;
  21641. /**
  21642. * The dirty texture flag value
  21643. */
  21644. static readonly TextureDirtyFlag: number;
  21645. /**
  21646. * The dirty light flag value
  21647. */
  21648. static readonly LightDirtyFlag: number;
  21649. /**
  21650. * The dirty fresnel flag value
  21651. */
  21652. static readonly FresnelDirtyFlag: number;
  21653. /**
  21654. * The dirty attribute flag value
  21655. */
  21656. static readonly AttributesDirtyFlag: number;
  21657. /**
  21658. * The dirty misc flag value
  21659. */
  21660. static readonly MiscDirtyFlag: number;
  21661. /**
  21662. * The all dirty flag value
  21663. */
  21664. static readonly AllDirtyFlag: number;
  21665. /**
  21666. * The ID of the material
  21667. */
  21668. id: string;
  21669. /**
  21670. * Gets or sets the unique id of the material
  21671. */
  21672. uniqueId: number;
  21673. /**
  21674. * The name of the material
  21675. */
  21676. name: string;
  21677. /**
  21678. * Gets or sets user defined metadata
  21679. */
  21680. metadata: any;
  21681. /**
  21682. * For internal use only. Please do not use.
  21683. */
  21684. reservedDataStore: any;
  21685. /**
  21686. * Specifies if the ready state should be checked on each call
  21687. */
  21688. checkReadyOnEveryCall: boolean;
  21689. /**
  21690. * Specifies if the ready state should be checked once
  21691. */
  21692. checkReadyOnlyOnce: boolean;
  21693. /**
  21694. * The state of the material
  21695. */
  21696. state: string;
  21697. /**
  21698. * The alpha value of the material
  21699. */
  21700. protected _alpha: number;
  21701. /**
  21702. * List of inspectable custom properties (used by the Inspector)
  21703. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21704. */
  21705. inspectableCustomProperties: IInspectable[];
  21706. /**
  21707. * Sets the alpha value of the material
  21708. */
  21709. /**
  21710. * Gets the alpha value of the material
  21711. */
  21712. alpha: number;
  21713. /**
  21714. * Specifies if back face culling is enabled
  21715. */
  21716. protected _backFaceCulling: boolean;
  21717. /**
  21718. * Sets the back-face culling state
  21719. */
  21720. /**
  21721. * Gets the back-face culling state
  21722. */
  21723. backFaceCulling: boolean;
  21724. /**
  21725. * Stores the value for side orientation
  21726. */
  21727. sideOrientation: number;
  21728. /**
  21729. * Callback triggered when the material is compiled
  21730. */
  21731. onCompiled: Nullable<(effect: Effect) => void>;
  21732. /**
  21733. * Callback triggered when an error occurs
  21734. */
  21735. onError: Nullable<(effect: Effect, errors: string) => void>;
  21736. /**
  21737. * Callback triggered to get the render target textures
  21738. */
  21739. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21740. /**
  21741. * Gets a boolean indicating that current material needs to register RTT
  21742. */
  21743. readonly hasRenderTargetTextures: boolean;
  21744. /**
  21745. * Specifies if the material should be serialized
  21746. */
  21747. doNotSerialize: boolean;
  21748. /**
  21749. * @hidden
  21750. */ storeEffectOnSubMeshes: boolean;
  21751. /**
  21752. * Stores the animations for the material
  21753. */
  21754. animations: Nullable<Array<Animation>>;
  21755. /**
  21756. * An event triggered when the material is disposed
  21757. */
  21758. onDisposeObservable: Observable<Material>;
  21759. /**
  21760. * An observer which watches for dispose events
  21761. */
  21762. private _onDisposeObserver;
  21763. private _onUnBindObservable;
  21764. /**
  21765. * Called during a dispose event
  21766. */
  21767. onDispose: () => void;
  21768. private _onBindObservable;
  21769. /**
  21770. * An event triggered when the material is bound
  21771. */
  21772. readonly onBindObservable: Observable<AbstractMesh>;
  21773. /**
  21774. * An observer which watches for bind events
  21775. */
  21776. private _onBindObserver;
  21777. /**
  21778. * Called during a bind event
  21779. */
  21780. onBind: (Mesh: AbstractMesh) => void;
  21781. /**
  21782. * An event triggered when the material is unbound
  21783. */
  21784. readonly onUnBindObservable: Observable<Material>;
  21785. /**
  21786. * Stores the value of the alpha mode
  21787. */
  21788. private _alphaMode;
  21789. /**
  21790. * Sets the value of the alpha mode.
  21791. *
  21792. * | Value | Type | Description |
  21793. * | --- | --- | --- |
  21794. * | 0 | ALPHA_DISABLE | |
  21795. * | 1 | ALPHA_ADD | |
  21796. * | 2 | ALPHA_COMBINE | |
  21797. * | 3 | ALPHA_SUBTRACT | |
  21798. * | 4 | ALPHA_MULTIPLY | |
  21799. * | 5 | ALPHA_MAXIMIZED | |
  21800. * | 6 | ALPHA_ONEONE | |
  21801. * | 7 | ALPHA_PREMULTIPLIED | |
  21802. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21803. * | 9 | ALPHA_INTERPOLATE | |
  21804. * | 10 | ALPHA_SCREENMODE | |
  21805. *
  21806. */
  21807. /**
  21808. * Gets the value of the alpha mode
  21809. */
  21810. alphaMode: number;
  21811. /**
  21812. * Stores the state of the need depth pre-pass value
  21813. */
  21814. private _needDepthPrePass;
  21815. /**
  21816. * Sets the need depth pre-pass value
  21817. */
  21818. /**
  21819. * Gets the depth pre-pass value
  21820. */
  21821. needDepthPrePass: boolean;
  21822. /**
  21823. * Specifies if depth writing should be disabled
  21824. */
  21825. disableDepthWrite: boolean;
  21826. /**
  21827. * Specifies if depth writing should be forced
  21828. */
  21829. forceDepthWrite: boolean;
  21830. /**
  21831. * Specifies if there should be a separate pass for culling
  21832. */
  21833. separateCullingPass: boolean;
  21834. /**
  21835. * Stores the state specifing if fog should be enabled
  21836. */
  21837. private _fogEnabled;
  21838. /**
  21839. * Sets the state for enabling fog
  21840. */
  21841. /**
  21842. * Gets the value of the fog enabled state
  21843. */
  21844. fogEnabled: boolean;
  21845. /**
  21846. * Stores the size of points
  21847. */
  21848. pointSize: number;
  21849. /**
  21850. * Stores the z offset value
  21851. */
  21852. zOffset: number;
  21853. /**
  21854. * Gets a value specifying if wireframe mode is enabled
  21855. */
  21856. /**
  21857. * Sets the state of wireframe mode
  21858. */
  21859. wireframe: boolean;
  21860. /**
  21861. * Gets the value specifying if point clouds are enabled
  21862. */
  21863. /**
  21864. * Sets the state of point cloud mode
  21865. */
  21866. pointsCloud: boolean;
  21867. /**
  21868. * Gets the material fill mode
  21869. */
  21870. /**
  21871. * Sets the material fill mode
  21872. */
  21873. fillMode: number;
  21874. /**
  21875. * @hidden
  21876. * Stores the effects for the material
  21877. */ effect: Nullable<Effect>;
  21878. /**
  21879. * @hidden
  21880. * Specifies if the material was previously ready
  21881. */ wasPreviouslyReady: boolean;
  21882. /**
  21883. * Specifies if uniform buffers should be used
  21884. */
  21885. private _useUBO;
  21886. /**
  21887. * Stores a reference to the scene
  21888. */
  21889. private _scene;
  21890. /**
  21891. * Stores the fill mode state
  21892. */
  21893. private _fillMode;
  21894. /**
  21895. * Specifies if the depth write state should be cached
  21896. */
  21897. private _cachedDepthWriteState;
  21898. /**
  21899. * Stores the uniform buffer
  21900. */
  21901. protected _uniformBuffer: UniformBuffer;
  21902. /** @hidden */ indexInSceneMaterialArray: number;
  21903. /** @hidden */
  21904. meshMap: Nullable<{
  21905. [id: string]: AbstractMesh | undefined;
  21906. }>;
  21907. /**
  21908. * Creates a material instance
  21909. * @param name defines the name of the material
  21910. * @param scene defines the scene to reference
  21911. * @param doNotAdd specifies if the material should be added to the scene
  21912. */
  21913. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21914. /**
  21915. * Returns a string representation of the current material
  21916. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21917. * @returns a string with material information
  21918. */
  21919. toString(fullDetails?: boolean): string;
  21920. /**
  21921. * Gets the class name of the material
  21922. * @returns a string with the class name of the material
  21923. */
  21924. getClassName(): string;
  21925. /**
  21926. * Specifies if updates for the material been locked
  21927. */
  21928. readonly isFrozen: boolean;
  21929. /**
  21930. * Locks updates for the material
  21931. */
  21932. freeze(): void;
  21933. /**
  21934. * Unlocks updates for the material
  21935. */
  21936. unfreeze(): void;
  21937. /**
  21938. * Specifies if the material is ready to be used
  21939. * @param mesh defines the mesh to check
  21940. * @param useInstances specifies if instances should be used
  21941. * @returns a boolean indicating if the material is ready to be used
  21942. */
  21943. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21944. /**
  21945. * Specifies that the submesh is ready to be used
  21946. * @param mesh defines the mesh to check
  21947. * @param subMesh defines which submesh to check
  21948. * @param useInstances specifies that instances should be used
  21949. * @returns a boolean indicating that the submesh is ready or not
  21950. */
  21951. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21952. /**
  21953. * Returns the material effect
  21954. * @returns the effect associated with the material
  21955. */
  21956. getEffect(): Nullable<Effect>;
  21957. /**
  21958. * Returns the current scene
  21959. * @returns a Scene
  21960. */
  21961. getScene(): Scene;
  21962. /**
  21963. * Specifies if the material will require alpha blending
  21964. * @returns a boolean specifying if alpha blending is needed
  21965. */
  21966. needAlphaBlending(): boolean;
  21967. /**
  21968. * Specifies if the mesh will require alpha blending
  21969. * @param mesh defines the mesh to check
  21970. * @returns a boolean specifying if alpha blending is needed for the mesh
  21971. */
  21972. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21973. /**
  21974. * Specifies if this material should be rendered in alpha test mode
  21975. * @returns a boolean specifying if an alpha test is needed.
  21976. */
  21977. needAlphaTesting(): boolean;
  21978. /**
  21979. * Gets the texture used for the alpha test
  21980. * @returns the texture to use for alpha testing
  21981. */
  21982. getAlphaTestTexture(): Nullable<BaseTexture>;
  21983. /**
  21984. * Marks the material to indicate that it needs to be re-calculated
  21985. */
  21986. markDirty(): void;
  21987. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21988. /**
  21989. * Binds the material to the mesh
  21990. * @param world defines the world transformation matrix
  21991. * @param mesh defines the mesh to bind the material to
  21992. */
  21993. bind(world: Matrix, mesh?: Mesh): void;
  21994. /**
  21995. * Binds the submesh to the material
  21996. * @param world defines the world transformation matrix
  21997. * @param mesh defines the mesh containing the submesh
  21998. * @param subMesh defines the submesh to bind the material to
  21999. */
  22000. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22001. /**
  22002. * Binds the world matrix to the material
  22003. * @param world defines the world transformation matrix
  22004. */
  22005. bindOnlyWorldMatrix(world: Matrix): void;
  22006. /**
  22007. * Binds the scene's uniform buffer to the effect.
  22008. * @param effect defines the effect to bind to the scene uniform buffer
  22009. * @param sceneUbo defines the uniform buffer storing scene data
  22010. */
  22011. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22012. /**
  22013. * Binds the view matrix to the effect
  22014. * @param effect defines the effect to bind the view matrix to
  22015. */
  22016. bindView(effect: Effect): void;
  22017. /**
  22018. * Binds the view projection matrix to the effect
  22019. * @param effect defines the effect to bind the view projection matrix to
  22020. */
  22021. bindViewProjection(effect: Effect): void;
  22022. /**
  22023. * Specifies if material alpha testing should be turned on for the mesh
  22024. * @param mesh defines the mesh to check
  22025. */
  22026. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22027. /**
  22028. * Processes to execute after binding the material to a mesh
  22029. * @param mesh defines the rendered mesh
  22030. */
  22031. protected _afterBind(mesh?: Mesh): void;
  22032. /**
  22033. * Unbinds the material from the mesh
  22034. */
  22035. unbind(): void;
  22036. /**
  22037. * Gets the active textures from the material
  22038. * @returns an array of textures
  22039. */
  22040. getActiveTextures(): BaseTexture[];
  22041. /**
  22042. * Specifies if the material uses a texture
  22043. * @param texture defines the texture to check against the material
  22044. * @returns a boolean specifying if the material uses the texture
  22045. */
  22046. hasTexture(texture: BaseTexture): boolean;
  22047. /**
  22048. * Makes a duplicate of the material, and gives it a new name
  22049. * @param name defines the new name for the duplicated material
  22050. * @returns the cloned material
  22051. */
  22052. clone(name: string): Nullable<Material>;
  22053. /**
  22054. * Gets the meshes bound to the material
  22055. * @returns an array of meshes bound to the material
  22056. */
  22057. getBindedMeshes(): AbstractMesh[];
  22058. /**
  22059. * Force shader compilation
  22060. * @param mesh defines the mesh associated with this material
  22061. * @param onCompiled defines a function to execute once the material is compiled
  22062. * @param options defines the options to configure the compilation
  22063. */
  22064. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22065. clipPlane: boolean;
  22066. }>): void;
  22067. /**
  22068. * Force shader compilation
  22069. * @param mesh defines the mesh that will use this material
  22070. * @param options defines additional options for compiling the shaders
  22071. * @returns a promise that resolves when the compilation completes
  22072. */
  22073. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22074. clipPlane: boolean;
  22075. }>): Promise<void>;
  22076. private static readonly _ImageProcessingDirtyCallBack;
  22077. private static readonly _TextureDirtyCallBack;
  22078. private static readonly _FresnelDirtyCallBack;
  22079. private static readonly _MiscDirtyCallBack;
  22080. private static readonly _LightsDirtyCallBack;
  22081. private static readonly _AttributeDirtyCallBack;
  22082. private static _FresnelAndMiscDirtyCallBack;
  22083. private static _TextureAndMiscDirtyCallBack;
  22084. private static readonly _DirtyCallbackArray;
  22085. private static readonly _RunDirtyCallBacks;
  22086. /**
  22087. * Marks a define in the material to indicate that it needs to be re-computed
  22088. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22089. */
  22090. markAsDirty(flag: number): void;
  22091. /**
  22092. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22093. * @param func defines a function which checks material defines against the submeshes
  22094. */
  22095. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22096. /**
  22097. * Indicates that image processing needs to be re-calculated for all submeshes
  22098. */
  22099. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22100. /**
  22101. * Indicates that textures need to be re-calculated for all submeshes
  22102. */
  22103. protected _markAllSubMeshesAsTexturesDirty(): void;
  22104. /**
  22105. * Indicates that fresnel needs to be re-calculated for all submeshes
  22106. */
  22107. protected _markAllSubMeshesAsFresnelDirty(): void;
  22108. /**
  22109. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22110. */
  22111. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22112. /**
  22113. * Indicates that lights need to be re-calculated for all submeshes
  22114. */
  22115. protected _markAllSubMeshesAsLightsDirty(): void;
  22116. /**
  22117. * Indicates that attributes need to be re-calculated for all submeshes
  22118. */
  22119. protected _markAllSubMeshesAsAttributesDirty(): void;
  22120. /**
  22121. * Indicates that misc needs to be re-calculated for all submeshes
  22122. */
  22123. protected _markAllSubMeshesAsMiscDirty(): void;
  22124. /**
  22125. * Indicates that textures and misc need to be re-calculated for all submeshes
  22126. */
  22127. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22128. /**
  22129. * Disposes the material
  22130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22132. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22133. */
  22134. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22135. /** @hidden */
  22136. private releaseVertexArrayObject;
  22137. /**
  22138. * Serializes this material
  22139. * @returns the serialized material object
  22140. */
  22141. serialize(): any;
  22142. /**
  22143. * Creates a material from parsed material data
  22144. * @param parsedMaterial defines parsed material data
  22145. * @param scene defines the hosting scene
  22146. * @param rootUrl defines the root URL to use to load textures
  22147. * @returns a new material
  22148. */
  22149. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22150. }
  22151. }
  22152. declare module BABYLON {
  22153. /**
  22154. * Base class for submeshes
  22155. */
  22156. export class BaseSubMesh {
  22157. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  22158. /** @hidden */ materialEffect: Nullable<Effect>;
  22159. /**
  22160. * Gets associated effect
  22161. */
  22162. readonly effect: Nullable<Effect>;
  22163. /**
  22164. * Sets associated effect (effect used to render this submesh)
  22165. * @param effect defines the effect to associate with
  22166. * @param defines defines the set of defines used to compile this effect
  22167. */
  22168. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22169. }
  22170. /**
  22171. * Defines a subdivision inside a mesh
  22172. */
  22173. export class SubMesh extends BaseSubMesh implements ICullable {
  22174. /** the material index to use */
  22175. materialIndex: number;
  22176. /** vertex index start */
  22177. verticesStart: number;
  22178. /** vertices count */
  22179. verticesCount: number;
  22180. /** index start */
  22181. indexStart: number;
  22182. /** indices count */
  22183. indexCount: number;
  22184. /** @hidden */ linesIndexCount: number;
  22185. private _mesh;
  22186. private _renderingMesh;
  22187. private _boundingInfo;
  22188. private _linesIndexBuffer;
  22189. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  22190. /** @hidden */ trianglePlanes: Plane[];
  22191. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  22192. /** @hidden */ renderId: number;
  22193. /** @hidden */ alphaIndex: number;
  22194. /** @hidden */ distanceToCamera: number;
  22195. /** @hidden */ id: number;
  22196. private _currentMaterial;
  22197. /**
  22198. * Add a new submesh to a mesh
  22199. * @param materialIndex defines the material index to use
  22200. * @param verticesStart defines vertex index start
  22201. * @param verticesCount defines vertices count
  22202. * @param indexStart defines index start
  22203. * @param indexCount defines indices count
  22204. * @param mesh defines the parent mesh
  22205. * @param renderingMesh defines an optional rendering mesh
  22206. * @param createBoundingBox defines if bounding box should be created for this submesh
  22207. * @returns the new submesh
  22208. */
  22209. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22210. /**
  22211. * Creates a new submesh
  22212. * @param materialIndex defines the material index to use
  22213. * @param verticesStart defines vertex index start
  22214. * @param verticesCount defines vertices count
  22215. * @param indexStart defines index start
  22216. * @param indexCount defines indices count
  22217. * @param mesh defines the parent mesh
  22218. * @param renderingMesh defines an optional rendering mesh
  22219. * @param createBoundingBox defines if bounding box should be created for this submesh
  22220. */
  22221. constructor(
  22222. /** the material index to use */
  22223. materialIndex: number,
  22224. /** vertex index start */
  22225. verticesStart: number,
  22226. /** vertices count */
  22227. verticesCount: number,
  22228. /** index start */
  22229. indexStart: number,
  22230. /** indices count */
  22231. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22232. /**
  22233. * Returns true if this submesh covers the entire parent mesh
  22234. * @ignorenaming
  22235. */
  22236. readonly IsGlobal: boolean;
  22237. /**
  22238. * Returns the submesh BoudingInfo object
  22239. * @returns current bounding info (or mesh's one if the submesh is global)
  22240. */
  22241. getBoundingInfo(): BoundingInfo;
  22242. /**
  22243. * Sets the submesh BoundingInfo
  22244. * @param boundingInfo defines the new bounding info to use
  22245. * @returns the SubMesh
  22246. */
  22247. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22248. /**
  22249. * Returns the mesh of the current submesh
  22250. * @return the parent mesh
  22251. */
  22252. getMesh(): AbstractMesh;
  22253. /**
  22254. * Returns the rendering mesh of the submesh
  22255. * @returns the rendering mesh (could be different from parent mesh)
  22256. */
  22257. getRenderingMesh(): Mesh;
  22258. /**
  22259. * Returns the submesh material
  22260. * @returns null or the current material
  22261. */
  22262. getMaterial(): Nullable<Material>;
  22263. /**
  22264. * Sets a new updated BoundingInfo object to the submesh
  22265. * @param data defines an optional position array to use to determine the bounding info
  22266. * @returns the SubMesh
  22267. */
  22268. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22269. /** @hidden */ checkCollision(collider: Collider): boolean;
  22270. /**
  22271. * Updates the submesh BoundingInfo
  22272. * @param world defines the world matrix to use to update the bounding info
  22273. * @returns the submesh
  22274. */
  22275. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22276. /**
  22277. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22278. * @param frustumPlanes defines the frustum planes
  22279. * @returns true if the submesh is intersecting with the frustum
  22280. */
  22281. isInFrustum(frustumPlanes: Plane[]): boolean;
  22282. /**
  22283. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22284. * @param frustumPlanes defines the frustum planes
  22285. * @returns true if the submesh is inside the frustum
  22286. */
  22287. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22288. /**
  22289. * Renders the submesh
  22290. * @param enableAlphaMode defines if alpha needs to be used
  22291. * @returns the submesh
  22292. */
  22293. render(enableAlphaMode: boolean): SubMesh;
  22294. /**
  22295. * @hidden
  22296. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22297. /**
  22298. * Checks if the submesh intersects with a ray
  22299. * @param ray defines the ray to test
  22300. * @returns true is the passed ray intersects the submesh bounding box
  22301. */
  22302. canIntersects(ray: Ray): boolean;
  22303. /**
  22304. * Intersects current submesh with a ray
  22305. * @param ray defines the ray to test
  22306. * @param positions defines mesh's positions array
  22307. * @param indices defines mesh's indices array
  22308. * @param fastCheck defines if only bounding info should be used
  22309. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22310. * @returns intersection info or null if no intersection
  22311. */
  22312. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22313. /** @hidden */
  22314. private _intersectLines;
  22315. /** @hidden */
  22316. private _intersectTriangles;
  22317. /** @hidden */
  22318. private _intersectUnIndexedTriangles;
  22319. /** @hidden */ rebuild(): void;
  22320. /**
  22321. * Creates a new submesh from the passed mesh
  22322. * @param newMesh defines the new hosting mesh
  22323. * @param newRenderingMesh defines an optional rendering mesh
  22324. * @returns the new submesh
  22325. */
  22326. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22327. /**
  22328. * Release associated resources
  22329. */
  22330. dispose(): void;
  22331. /**
  22332. * Gets the class name
  22333. * @returns the string "SubMesh".
  22334. */
  22335. getClassName(): string;
  22336. /**
  22337. * Creates a new submesh from indices data
  22338. * @param materialIndex the index of the main mesh material
  22339. * @param startIndex the index where to start the copy in the mesh indices array
  22340. * @param indexCount the number of indices to copy then from the startIndex
  22341. * @param mesh the main mesh to create the submesh from
  22342. * @param renderingMesh the optional rendering mesh
  22343. * @returns a new submesh
  22344. */
  22345. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22346. }
  22347. }
  22348. declare module BABYLON {
  22349. /**
  22350. * Class used to store geometry data (vertex buffers + index buffer)
  22351. */
  22352. export class Geometry implements IGetSetVerticesData {
  22353. /**
  22354. * Gets or sets the ID of the geometry
  22355. */
  22356. id: string;
  22357. /**
  22358. * Gets or sets the unique ID of the geometry
  22359. */
  22360. uniqueId: number;
  22361. /**
  22362. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22363. */
  22364. delayLoadState: number;
  22365. /**
  22366. * Gets the file containing the data to load when running in delay load state
  22367. */
  22368. delayLoadingFile: Nullable<string>;
  22369. /**
  22370. * Callback called when the geometry is updated
  22371. */
  22372. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22373. private _scene;
  22374. private _engine;
  22375. private _meshes;
  22376. private _totalVertices;
  22377. /** @hidden */ indices: IndicesArray;
  22378. /** @hidden */ vertexBuffers: {
  22379. [key: string]: VertexBuffer;
  22380. };
  22381. private _isDisposed;
  22382. private _extend;
  22383. private _boundingBias;
  22384. /** @hidden */ delayInfo: Array<string>;
  22385. private _indexBuffer;
  22386. private _indexBufferIsUpdatable;
  22387. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22388. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22389. /** @hidden */ softwareSkinningFrameId: number;
  22390. private _vertexArrayObjects;
  22391. private _updatable;
  22392. /** @hidden */ positions: Nullable<Vector3[]>;
  22393. /**
  22394. * 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
  22395. */
  22396. /**
  22397. * 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
  22398. */
  22399. boundingBias: Vector2;
  22400. /**
  22401. * Static function used to attach a new empty geometry to a mesh
  22402. * @param mesh defines the mesh to attach the geometry to
  22403. * @returns the new Geometry
  22404. */
  22405. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22406. /**
  22407. * Creates a new geometry
  22408. * @param id defines the unique ID
  22409. * @param scene defines the hosting scene
  22410. * @param vertexData defines the VertexData used to get geometry data
  22411. * @param updatable defines if geometry must be updatable (false by default)
  22412. * @param mesh defines the mesh that will be associated with the geometry
  22413. */
  22414. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22415. /**
  22416. * Gets the current extend of the geometry
  22417. */
  22418. readonly extend: {
  22419. minimum: Vector3;
  22420. maximum: Vector3;
  22421. };
  22422. /**
  22423. * Gets the hosting scene
  22424. * @returns the hosting Scene
  22425. */
  22426. getScene(): Scene;
  22427. /**
  22428. * Gets the hosting engine
  22429. * @returns the hosting Engine
  22430. */
  22431. getEngine(): Engine;
  22432. /**
  22433. * Defines if the geometry is ready to use
  22434. * @returns true if the geometry is ready to be used
  22435. */
  22436. isReady(): boolean;
  22437. /**
  22438. * Gets a value indicating that the geometry should not be serialized
  22439. */
  22440. readonly doNotSerialize: boolean;
  22441. /** @hidden */ rebuild(): void;
  22442. /**
  22443. * Affects all geometry data in one call
  22444. * @param vertexData defines the geometry data
  22445. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22446. */
  22447. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22448. /**
  22449. * Set specific vertex data
  22450. * @param kind defines the data kind (Position, normal, etc...)
  22451. * @param data defines the vertex data to use
  22452. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22453. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22454. */
  22455. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22456. /**
  22457. * Removes a specific vertex data
  22458. * @param kind defines the data kind (Position, normal, etc...)
  22459. */
  22460. removeVerticesData(kind: string): void;
  22461. /**
  22462. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22463. * @param buffer defines the vertex buffer to use
  22464. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22465. */
  22466. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22467. /**
  22468. * Update a specific vertex buffer
  22469. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22470. * It will do nothing if the buffer is not updatable
  22471. * @param kind defines the data kind (Position, normal, etc...)
  22472. * @param data defines the data to use
  22473. * @param offset defines the offset in the target buffer where to store the data
  22474. * @param useBytes set to true if the offset is in bytes
  22475. */
  22476. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22477. /**
  22478. * Update a specific vertex buffer
  22479. * This function will create a new buffer if the current one is not updatable
  22480. * @param kind defines the data kind (Position, normal, etc...)
  22481. * @param data defines the data to use
  22482. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22483. */
  22484. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22485. private _updateBoundingInfo;
  22486. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22487. /**
  22488. * Gets total number of vertices
  22489. * @returns the total number of vertices
  22490. */
  22491. getTotalVertices(): number;
  22492. /**
  22493. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22494. * @param kind defines the data kind (Position, normal, etc...)
  22495. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22496. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22497. * @returns a float array containing vertex data
  22498. */
  22499. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22500. /**
  22501. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22502. * @param kind defines the data kind (Position, normal, etc...)
  22503. * @returns true if the vertex buffer with the specified kind is updatable
  22504. */
  22505. isVertexBufferUpdatable(kind: string): boolean;
  22506. /**
  22507. * Gets a specific vertex buffer
  22508. * @param kind defines the data kind (Position, normal, etc...)
  22509. * @returns a VertexBuffer
  22510. */
  22511. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22512. /**
  22513. * Returns all vertex buffers
  22514. * @return an object holding all vertex buffers indexed by kind
  22515. */
  22516. getVertexBuffers(): Nullable<{
  22517. [key: string]: VertexBuffer;
  22518. }>;
  22519. /**
  22520. * Gets a boolean indicating if specific vertex buffer is present
  22521. * @param kind defines the data kind (Position, normal, etc...)
  22522. * @returns true if data is present
  22523. */
  22524. isVerticesDataPresent(kind: string): boolean;
  22525. /**
  22526. * Gets a list of all attached data kinds (Position, normal, etc...)
  22527. * @returns a list of string containing all kinds
  22528. */
  22529. getVerticesDataKinds(): string[];
  22530. /**
  22531. * Update index buffer
  22532. * @param indices defines the indices to store in the index buffer
  22533. * @param offset defines the offset in the target buffer where to store the data
  22534. * @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)
  22535. */
  22536. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22537. /**
  22538. * Creates a new index buffer
  22539. * @param indices defines the indices to store in the index buffer
  22540. * @param totalVertices defines the total number of vertices (could be null)
  22541. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22542. */
  22543. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22544. /**
  22545. * Return the total number of indices
  22546. * @returns the total number of indices
  22547. */
  22548. getTotalIndices(): number;
  22549. /**
  22550. * Gets the index buffer array
  22551. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22553. * @returns the index buffer array
  22554. */
  22555. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22556. /**
  22557. * Gets the index buffer
  22558. * @return the index buffer
  22559. */
  22560. getIndexBuffer(): Nullable<DataBuffer>;
  22561. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22562. /**
  22563. * Release the associated resources for a specific mesh
  22564. * @param mesh defines the source mesh
  22565. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22566. */
  22567. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22568. /**
  22569. * Apply current geometry to a given mesh
  22570. * @param mesh defines the mesh to apply geometry to
  22571. */
  22572. applyToMesh(mesh: Mesh): void;
  22573. private _updateExtend;
  22574. private _applyToMesh;
  22575. private notifyUpdate;
  22576. /**
  22577. * Load the geometry if it was flagged as delay loaded
  22578. * @param scene defines the hosting scene
  22579. * @param onLoaded defines a callback called when the geometry is loaded
  22580. */
  22581. load(scene: Scene, onLoaded?: () => void): void;
  22582. private _queueLoad;
  22583. /**
  22584. * Invert the geometry to move from a right handed system to a left handed one.
  22585. */
  22586. toLeftHanded(): void;
  22587. /** @hidden */ resetPointsArrayCache(): void;
  22588. /** @hidden */ generatePointsArray(): boolean;
  22589. /**
  22590. * Gets a value indicating if the geometry is disposed
  22591. * @returns true if the geometry was disposed
  22592. */
  22593. isDisposed(): boolean;
  22594. private _disposeVertexArrayObjects;
  22595. /**
  22596. * Free all associated resources
  22597. */
  22598. dispose(): void;
  22599. /**
  22600. * Clone the current geometry into a new geometry
  22601. * @param id defines the unique ID of the new geometry
  22602. * @returns a new geometry object
  22603. */
  22604. copy(id: string): Geometry;
  22605. /**
  22606. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22607. * @return a JSON representation of the current geometry data (without the vertices data)
  22608. */
  22609. serialize(): any;
  22610. private toNumberArray;
  22611. /**
  22612. * Serialize all vertices data into a JSON oject
  22613. * @returns a JSON representation of the current geometry data
  22614. */
  22615. serializeVerticeData(): any;
  22616. /**
  22617. * Extracts a clone of a mesh geometry
  22618. * @param mesh defines the source mesh
  22619. * @param id defines the unique ID of the new geometry object
  22620. * @returns the new geometry object
  22621. */
  22622. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22623. /**
  22624. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22625. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22626. * Be aware Math.random() could cause collisions, but:
  22627. * "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"
  22628. * @returns a string containing a new GUID
  22629. */
  22630. static RandomId(): string;
  22631. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22632. private static _CleanMatricesWeights;
  22633. /**
  22634. * Create a new geometry from persisted data (Using .babylon file format)
  22635. * @param parsedVertexData defines the persisted data
  22636. * @param scene defines the hosting scene
  22637. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22638. * @returns the new geometry object
  22639. */
  22640. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22641. }
  22642. }
  22643. declare module BABYLON {
  22644. /**
  22645. * Define an interface for all classes that will get and set the data on vertices
  22646. */
  22647. export interface IGetSetVerticesData {
  22648. /**
  22649. * Gets a boolean indicating if specific vertex data is present
  22650. * @param kind defines the vertex data kind to use
  22651. * @returns true is data kind is present
  22652. */
  22653. isVerticesDataPresent(kind: string): boolean;
  22654. /**
  22655. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22656. * @param kind defines the data kind (Position, normal, etc...)
  22657. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22659. * @returns a float array containing vertex data
  22660. */
  22661. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22662. /**
  22663. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22664. * @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.
  22665. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22666. * @returns the indices array or an empty array if the mesh has no geometry
  22667. */
  22668. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22669. /**
  22670. * Set specific vertex data
  22671. * @param kind defines the data kind (Position, normal, etc...)
  22672. * @param data defines the vertex data to use
  22673. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22674. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22675. */
  22676. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22677. /**
  22678. * Update a specific associated vertex buffer
  22679. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22680. * - VertexBuffer.PositionKind
  22681. * - VertexBuffer.UVKind
  22682. * - VertexBuffer.UV2Kind
  22683. * - VertexBuffer.UV3Kind
  22684. * - VertexBuffer.UV4Kind
  22685. * - VertexBuffer.UV5Kind
  22686. * - VertexBuffer.UV6Kind
  22687. * - VertexBuffer.ColorKind
  22688. * - VertexBuffer.MatricesIndicesKind
  22689. * - VertexBuffer.MatricesIndicesExtraKind
  22690. * - VertexBuffer.MatricesWeightsKind
  22691. * - VertexBuffer.MatricesWeightsExtraKind
  22692. * @param data defines the data source
  22693. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22694. * @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)
  22695. */
  22696. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22697. /**
  22698. * Creates a new index buffer
  22699. * @param indices defines the indices to store in the index buffer
  22700. * @param totalVertices defines the total number of vertices (could be null)
  22701. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22702. */
  22703. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22704. }
  22705. /**
  22706. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22707. */
  22708. export class VertexData {
  22709. /**
  22710. * Mesh side orientation : usually the external or front surface
  22711. */
  22712. static readonly FRONTSIDE: number;
  22713. /**
  22714. * Mesh side orientation : usually the internal or back surface
  22715. */
  22716. static readonly BACKSIDE: number;
  22717. /**
  22718. * Mesh side orientation : both internal and external or front and back surfaces
  22719. */
  22720. static readonly DOUBLESIDE: number;
  22721. /**
  22722. * Mesh side orientation : by default, `FRONTSIDE`
  22723. */
  22724. static readonly DEFAULTSIDE: number;
  22725. /**
  22726. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22727. */
  22728. positions: Nullable<FloatArray>;
  22729. /**
  22730. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22731. */
  22732. normals: Nullable<FloatArray>;
  22733. /**
  22734. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22735. */
  22736. tangents: Nullable<FloatArray>;
  22737. /**
  22738. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22739. */
  22740. uvs: Nullable<FloatArray>;
  22741. /**
  22742. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22743. */
  22744. uvs2: Nullable<FloatArray>;
  22745. /**
  22746. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22747. */
  22748. uvs3: Nullable<FloatArray>;
  22749. /**
  22750. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22751. */
  22752. uvs4: Nullable<FloatArray>;
  22753. /**
  22754. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22755. */
  22756. uvs5: Nullable<FloatArray>;
  22757. /**
  22758. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22759. */
  22760. uvs6: Nullable<FloatArray>;
  22761. /**
  22762. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22763. */
  22764. colors: Nullable<FloatArray>;
  22765. /**
  22766. * 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).
  22767. */
  22768. matricesIndices: Nullable<FloatArray>;
  22769. /**
  22770. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22771. */
  22772. matricesWeights: Nullable<FloatArray>;
  22773. /**
  22774. * An array extending the number of possible indices
  22775. */
  22776. matricesIndicesExtra: Nullable<FloatArray>;
  22777. /**
  22778. * An array extending the number of possible weights when the number of indices is extended
  22779. */
  22780. matricesWeightsExtra: Nullable<FloatArray>;
  22781. /**
  22782. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22783. */
  22784. indices: Nullable<IndicesArray>;
  22785. /**
  22786. * Uses the passed data array to set the set the values for the specified kind of data
  22787. * @param data a linear array of floating numbers
  22788. * @param kind the type of data that is being set, eg positions, colors etc
  22789. */
  22790. set(data: FloatArray, kind: string): void;
  22791. /**
  22792. * Associates the vertexData to the passed Mesh.
  22793. * Sets it as updatable or not (default `false`)
  22794. * @param mesh the mesh the vertexData is applied to
  22795. * @param updatable when used and having the value true allows new data to update the vertexData
  22796. * @returns the VertexData
  22797. */
  22798. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22799. /**
  22800. * Associates the vertexData to the passed Geometry.
  22801. * Sets it as updatable or not (default `false`)
  22802. * @param geometry the geometry the vertexData is applied to
  22803. * @param updatable when used and having the value true allows new data to update the vertexData
  22804. * @returns VertexData
  22805. */
  22806. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22807. /**
  22808. * Updates the associated mesh
  22809. * @param mesh the mesh to be updated
  22810. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22811. * @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
  22812. * @returns VertexData
  22813. */
  22814. updateMesh(mesh: Mesh): VertexData;
  22815. /**
  22816. * Updates the associated geometry
  22817. * @param geometry the geometry to be updated
  22818. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22819. * @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
  22820. * @returns VertexData.
  22821. */
  22822. updateGeometry(geometry: Geometry): VertexData;
  22823. private _applyTo;
  22824. private _update;
  22825. /**
  22826. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22827. * @param matrix the transforming matrix
  22828. * @returns the VertexData
  22829. */
  22830. transform(matrix: Matrix): VertexData;
  22831. /**
  22832. * Merges the passed VertexData into the current one
  22833. * @param other the VertexData to be merged into the current one
  22834. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22835. * @returns the modified VertexData
  22836. */
  22837. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22838. private _mergeElement;
  22839. private _validate;
  22840. /**
  22841. * Serializes the VertexData
  22842. * @returns a serialized object
  22843. */
  22844. serialize(): any;
  22845. /**
  22846. * Extracts the vertexData from a mesh
  22847. * @param mesh the mesh from which to extract the VertexData
  22848. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22849. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22850. * @returns the object VertexData associated to the passed mesh
  22851. */
  22852. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22853. /**
  22854. * Extracts the vertexData from the geometry
  22855. * @param geometry the geometry from which to extract the VertexData
  22856. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22857. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22858. * @returns the object VertexData associated to the passed mesh
  22859. */
  22860. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22861. private static _ExtractFrom;
  22862. /**
  22863. * Creates the VertexData for a Ribbon
  22864. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22865. * * pathArray array of paths, each of which an array of successive Vector3
  22866. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22867. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22868. * * 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
  22869. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22870. * * 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)
  22871. * * 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)
  22872. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22873. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22874. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22875. * @returns the VertexData of the ribbon
  22876. */
  22877. static CreateRibbon(options: {
  22878. pathArray: Vector3[][];
  22879. closeArray?: boolean;
  22880. closePath?: boolean;
  22881. offset?: number;
  22882. sideOrientation?: number;
  22883. frontUVs?: Vector4;
  22884. backUVs?: Vector4;
  22885. invertUV?: boolean;
  22886. uvs?: Vector2[];
  22887. colors?: Color4[];
  22888. }): VertexData;
  22889. /**
  22890. * Creates the VertexData for a box
  22891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22892. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22893. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22894. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22895. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22896. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22897. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22898. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22899. * * 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)
  22900. * * 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)
  22901. * @returns the VertexData of the box
  22902. */
  22903. static CreateBox(options: {
  22904. size?: number;
  22905. width?: number;
  22906. height?: number;
  22907. depth?: number;
  22908. faceUV?: Vector4[];
  22909. faceColors?: Color4[];
  22910. sideOrientation?: number;
  22911. frontUVs?: Vector4;
  22912. backUVs?: Vector4;
  22913. }): VertexData;
  22914. /**
  22915. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22916. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22917. * * segments sets the number of horizontal strips optional, default 32
  22918. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22919. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22920. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22921. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22922. * * 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
  22923. * * 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
  22924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22925. * * 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)
  22926. * * 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)
  22927. * @returns the VertexData of the ellipsoid
  22928. */
  22929. static CreateSphere(options: {
  22930. segments?: number;
  22931. diameter?: number;
  22932. diameterX?: number;
  22933. diameterY?: number;
  22934. diameterZ?: number;
  22935. arc?: number;
  22936. slice?: number;
  22937. sideOrientation?: number;
  22938. frontUVs?: Vector4;
  22939. backUVs?: Vector4;
  22940. }): VertexData;
  22941. /**
  22942. * Creates the VertexData for a cylinder, cone or prism
  22943. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22944. * * height sets the height (y direction) of the cylinder, optional, default 2
  22945. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22946. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22947. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22948. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22949. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22950. * * 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
  22951. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22952. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22953. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22954. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22956. * * 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)
  22957. * * 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)
  22958. * @returns the VertexData of the cylinder, cone or prism
  22959. */
  22960. static CreateCylinder(options: {
  22961. height?: number;
  22962. diameterTop?: number;
  22963. diameterBottom?: number;
  22964. diameter?: number;
  22965. tessellation?: number;
  22966. subdivisions?: number;
  22967. arc?: number;
  22968. faceColors?: Color4[];
  22969. faceUV?: Vector4[];
  22970. hasRings?: boolean;
  22971. enclose?: boolean;
  22972. sideOrientation?: number;
  22973. frontUVs?: Vector4;
  22974. backUVs?: Vector4;
  22975. }): VertexData;
  22976. /**
  22977. * Creates the VertexData for a torus
  22978. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22979. * * diameter the diameter of the torus, optional default 1
  22980. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22981. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22983. * * 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)
  22984. * * 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)
  22985. * @returns the VertexData of the torus
  22986. */
  22987. static CreateTorus(options: {
  22988. diameter?: number;
  22989. thickness?: number;
  22990. tessellation?: number;
  22991. sideOrientation?: number;
  22992. frontUVs?: Vector4;
  22993. backUVs?: Vector4;
  22994. }): VertexData;
  22995. /**
  22996. * Creates the VertexData of the LineSystem
  22997. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22998. * - lines an array of lines, each line being an array of successive Vector3
  22999. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23000. * @returns the VertexData of the LineSystem
  23001. */
  23002. static CreateLineSystem(options: {
  23003. lines: Vector3[][];
  23004. colors?: Nullable<Color4[][]>;
  23005. }): VertexData;
  23006. /**
  23007. * Create the VertexData for a DashedLines
  23008. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23009. * - points an array successive Vector3
  23010. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23011. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23012. * - dashNb the intended total number of dashes, optional, default 200
  23013. * @returns the VertexData for the DashedLines
  23014. */
  23015. static CreateDashedLines(options: {
  23016. points: Vector3[];
  23017. dashSize?: number;
  23018. gapSize?: number;
  23019. dashNb?: number;
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData for a Ground
  23023. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23024. * - width the width (x direction) of the ground, optional, default 1
  23025. * - height the height (z direction) of the ground, optional, default 1
  23026. * - subdivisions the number of subdivisions per side, optional, default 1
  23027. * @returns the VertexData of the Ground
  23028. */
  23029. static CreateGround(options: {
  23030. width?: number;
  23031. height?: number;
  23032. subdivisions?: number;
  23033. subdivisionsX?: number;
  23034. subdivisionsY?: number;
  23035. }): VertexData;
  23036. /**
  23037. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23038. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23039. * * xmin the ground minimum X coordinate, optional, default -1
  23040. * * zmin the ground minimum Z coordinate, optional, default -1
  23041. * * xmax the ground maximum X coordinate, optional, default 1
  23042. * * zmax the ground maximum Z coordinate, optional, default 1
  23043. * * 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}
  23044. * * 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}
  23045. * @returns the VertexData of the TiledGround
  23046. */
  23047. static CreateTiledGround(options: {
  23048. xmin: number;
  23049. zmin: number;
  23050. xmax: number;
  23051. zmax: number;
  23052. subdivisions?: {
  23053. w: number;
  23054. h: number;
  23055. };
  23056. precision?: {
  23057. w: number;
  23058. h: number;
  23059. };
  23060. }): VertexData;
  23061. /**
  23062. * Creates the VertexData of the Ground designed from a heightmap
  23063. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23064. * * width the width (x direction) of the ground
  23065. * * height the height (z direction) of the ground
  23066. * * subdivisions the number of subdivisions per side
  23067. * * minHeight the minimum altitude on the ground, optional, default 0
  23068. * * maxHeight the maximum altitude on the ground, optional default 1
  23069. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23070. * * buffer the array holding the image color data
  23071. * * bufferWidth the width of image
  23072. * * bufferHeight the height of image
  23073. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23074. * @returns the VertexData of the Ground designed from a heightmap
  23075. */
  23076. static CreateGroundFromHeightMap(options: {
  23077. width: number;
  23078. height: number;
  23079. subdivisions: number;
  23080. minHeight: number;
  23081. maxHeight: number;
  23082. colorFilter: Color3;
  23083. buffer: Uint8Array;
  23084. bufferWidth: number;
  23085. bufferHeight: number;
  23086. alphaFilter: number;
  23087. }): VertexData;
  23088. /**
  23089. * Creates the VertexData for a Plane
  23090. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23091. * * size sets the width and height of the plane to the value of size, optional default 1
  23092. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23093. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23095. * * 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)
  23096. * * 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)
  23097. * @returns the VertexData of the box
  23098. */
  23099. static CreatePlane(options: {
  23100. size?: number;
  23101. width?: number;
  23102. height?: number;
  23103. sideOrientation?: number;
  23104. frontUVs?: Vector4;
  23105. backUVs?: Vector4;
  23106. }): VertexData;
  23107. /**
  23108. * Creates the VertexData of the Disc or regular Polygon
  23109. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23110. * * radius the radius of the disc, optional default 0.5
  23111. * * tessellation the number of polygon sides, optional, default 64
  23112. * * 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
  23113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23114. * * 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)
  23115. * * 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)
  23116. * @returns the VertexData of the box
  23117. */
  23118. static CreateDisc(options: {
  23119. radius?: number;
  23120. tessellation?: number;
  23121. arc?: number;
  23122. sideOrientation?: number;
  23123. frontUVs?: Vector4;
  23124. backUVs?: Vector4;
  23125. }): VertexData;
  23126. /**
  23127. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23128. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23129. * @param polygon a mesh built from polygonTriangulation.build()
  23130. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23131. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23132. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23133. * @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)
  23134. * @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)
  23135. * @returns the VertexData of the Polygon
  23136. */
  23137. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23138. /**
  23139. * Creates the VertexData of the IcoSphere
  23140. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23141. * * radius the radius of the IcoSphere, optional default 1
  23142. * * radiusX allows stretching in the x direction, optional, default radius
  23143. * * radiusY allows stretching in the y direction, optional, default radius
  23144. * * radiusZ allows stretching in the z direction, optional, default radius
  23145. * * flat when true creates a flat shaded mesh, optional, default true
  23146. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * 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)
  23149. * * 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)
  23150. * @returns the VertexData of the IcoSphere
  23151. */
  23152. static CreateIcoSphere(options: {
  23153. radius?: number;
  23154. radiusX?: number;
  23155. radiusY?: number;
  23156. radiusZ?: number;
  23157. flat?: boolean;
  23158. subdivisions?: number;
  23159. sideOrientation?: number;
  23160. frontUVs?: Vector4;
  23161. backUVs?: Vector4;
  23162. }): VertexData;
  23163. /**
  23164. * Creates the VertexData for a Polyhedron
  23165. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23166. * * type provided types are:
  23167. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23168. * * 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)
  23169. * * size the size of the IcoSphere, optional default 1
  23170. * * sizeX allows stretching in the x direction, optional, default size
  23171. * * sizeY allows stretching in the y direction, optional, default size
  23172. * * sizeZ allows stretching in the z direction, optional, default size
  23173. * * 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
  23174. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23175. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23176. * * flat when true creates a flat shaded mesh, optional, default true
  23177. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23179. * * 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)
  23180. * * 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)
  23181. * @returns the VertexData of the Polyhedron
  23182. */
  23183. static CreatePolyhedron(options: {
  23184. type?: number;
  23185. size?: number;
  23186. sizeX?: number;
  23187. sizeY?: number;
  23188. sizeZ?: number;
  23189. custom?: any;
  23190. faceUV?: Vector4[];
  23191. faceColors?: Color4[];
  23192. flat?: boolean;
  23193. sideOrientation?: number;
  23194. frontUVs?: Vector4;
  23195. backUVs?: Vector4;
  23196. }): VertexData;
  23197. /**
  23198. * Creates the VertexData for a TorusKnot
  23199. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23200. * * radius the radius of the torus knot, optional, default 2
  23201. * * tube the thickness of the tube, optional, default 0.5
  23202. * * radialSegments the number of sides on each tube segments, optional, default 32
  23203. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23204. * * p the number of windings around the z axis, optional, default 2
  23205. * * q the number of windings around the x axis, optional, default 3
  23206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23207. * * 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)
  23208. * * 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)
  23209. * @returns the VertexData of the Torus Knot
  23210. */
  23211. static CreateTorusKnot(options: {
  23212. radius?: number;
  23213. tube?: number;
  23214. radialSegments?: number;
  23215. tubularSegments?: number;
  23216. p?: number;
  23217. q?: number;
  23218. sideOrientation?: number;
  23219. frontUVs?: Vector4;
  23220. backUVs?: Vector4;
  23221. }): VertexData;
  23222. /**
  23223. * Compute normals for given positions and indices
  23224. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23225. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23226. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23227. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23228. * * facetNormals : optional array of facet normals (vector3)
  23229. * * facetPositions : optional array of facet positions (vector3)
  23230. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23231. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23232. * * bInfo : optional bounding info, required for facetPartitioning computation
  23233. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23234. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23235. * * useRightHandedSystem: optional boolean to for right handed system computation
  23236. * * depthSort : optional boolean to enable the facet depth sort computation
  23237. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23238. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23239. */
  23240. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23241. facetNormals?: any;
  23242. facetPositions?: any;
  23243. facetPartitioning?: any;
  23244. ratio?: number;
  23245. bInfo?: any;
  23246. bbSize?: Vector3;
  23247. subDiv?: any;
  23248. useRightHandedSystem?: boolean;
  23249. depthSort?: boolean;
  23250. distanceTo?: Vector3;
  23251. depthSortedFacets?: any;
  23252. }): void;
  23253. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23254. /**
  23255. * Applies VertexData created from the imported parameters to the geometry
  23256. * @param parsedVertexData the parsed data from an imported file
  23257. * @param geometry the geometry to apply the VertexData to
  23258. */
  23259. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23260. }
  23261. }
  23262. declare module BABYLON {
  23263. /**
  23264. * Class containing static functions to help procedurally build meshes
  23265. */
  23266. export class DiscBuilder {
  23267. /**
  23268. * Creates a plane polygonal mesh. By default, this is a disc
  23269. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23270. * * 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
  23271. * * 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
  23272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23275. * @param name defines the name of the mesh
  23276. * @param options defines the options used to create the mesh
  23277. * @param scene defines the hosting scene
  23278. * @returns the plane polygonal mesh
  23279. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23280. */
  23281. static CreateDisc(name: string, options: {
  23282. radius?: number;
  23283. tessellation?: number;
  23284. arc?: number;
  23285. updatable?: boolean;
  23286. sideOrientation?: number;
  23287. frontUVs?: Vector4;
  23288. backUVs?: Vector4;
  23289. }, scene?: Nullable<Scene>): Mesh;
  23290. }
  23291. }
  23292. declare module BABYLON {
  23293. /**
  23294. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23295. *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.
  23296. * The SPS is also a particle system. It provides some methods to manage the particles.
  23297. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23298. *
  23299. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23300. */
  23301. export class SolidParticleSystem implements IDisposable {
  23302. /**
  23303. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23304. * Example : var p = SPS.particles[i];
  23305. */
  23306. particles: SolidParticle[];
  23307. /**
  23308. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23309. */
  23310. nbParticles: number;
  23311. /**
  23312. * If the particles must ever face the camera (default false). Useful for planar particles.
  23313. */
  23314. billboard: boolean;
  23315. /**
  23316. * Recompute normals when adding a shape
  23317. */
  23318. recomputeNormals: boolean;
  23319. /**
  23320. * This a counter ofr your own usage. It's not set by any SPS functions.
  23321. */
  23322. counter: number;
  23323. /**
  23324. * The SPS name. This name is also given to the underlying mesh.
  23325. */
  23326. name: string;
  23327. /**
  23328. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23329. */
  23330. mesh: Mesh;
  23331. /**
  23332. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23333. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23334. */
  23335. vars: any;
  23336. /**
  23337. * This array is populated when the SPS is set as 'pickable'.
  23338. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23339. * Each element of this array is an object `{idx: int, faceId: int}`.
  23340. * `idx` is the picked particle index in the `SPS.particles` array
  23341. * `faceId` is the picked face index counted within this particle.
  23342. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23343. */
  23344. pickedParticles: {
  23345. idx: number;
  23346. faceId: number;
  23347. }[];
  23348. /**
  23349. * This array is populated when `enableDepthSort` is set to true.
  23350. * Each element of this array is an instance of the class DepthSortedParticle.
  23351. */
  23352. depthSortedParticles: DepthSortedParticle[];
  23353. /**
  23354. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23355. * @hidden
  23356. */ bSphereOnly: boolean;
  23357. /**
  23358. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23359. * @hidden
  23360. */ bSphereRadiusFactor: number;
  23361. private _scene;
  23362. private _positions;
  23363. private _indices;
  23364. private _normals;
  23365. private _colors;
  23366. private _uvs;
  23367. private _indices32;
  23368. private _positions32;
  23369. private _normals32;
  23370. private _fixedNormal32;
  23371. private _colors32;
  23372. private _uvs32;
  23373. private _index;
  23374. private _updatable;
  23375. private _pickable;
  23376. private _isVisibilityBoxLocked;
  23377. private _alwaysVisible;
  23378. private _depthSort;
  23379. private _shapeCounter;
  23380. private _copy;
  23381. private _color;
  23382. private _computeParticleColor;
  23383. private _computeParticleTexture;
  23384. private _computeParticleRotation;
  23385. private _computeParticleVertex;
  23386. private _computeBoundingBox;
  23387. private _depthSortParticles;
  23388. private _camera;
  23389. private _mustUnrotateFixedNormals;
  23390. private _particlesIntersect;
  23391. private _needs32Bits;
  23392. /**
  23393. * Creates a SPS (Solid Particle System) object.
  23394. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23395. * @param scene (Scene) is the scene in which the SPS is added.
  23396. * @param options defines the options of the sps e.g.
  23397. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23398. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23399. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23400. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23401. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23402. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23403. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23404. */
  23405. constructor(name: string, scene: Scene, options?: {
  23406. updatable?: boolean;
  23407. isPickable?: boolean;
  23408. enableDepthSort?: boolean;
  23409. particleIntersection?: boolean;
  23410. boundingSphereOnly?: boolean;
  23411. bSphereRadiusFactor?: number;
  23412. });
  23413. /**
  23414. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23415. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23416. * @returns the created mesh
  23417. */
  23418. buildMesh(): Mesh;
  23419. /**
  23420. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23421. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23422. * Thus the particles generated from `digest()` have their property `position` set yet.
  23423. * @param mesh ( Mesh ) is the mesh to be digested
  23424. * @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
  23425. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23426. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23427. * @returns the current SPS
  23428. */
  23429. digest(mesh: Mesh, options?: {
  23430. facetNb?: number;
  23431. number?: number;
  23432. delta?: number;
  23433. }): SolidParticleSystem;
  23434. private _unrotateFixedNormals;
  23435. private _resetCopy;
  23436. private _meshBuilder;
  23437. private _posToShape;
  23438. private _uvsToShapeUV;
  23439. private _addParticle;
  23440. /**
  23441. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23442. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23443. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23444. * @param nb (positive integer) the number of particles to be created from this model
  23445. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23446. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23447. * @returns the number of shapes in the system
  23448. */
  23449. addShape(mesh: Mesh, nb: number, options?: {
  23450. positionFunction?: any;
  23451. vertexFunction?: any;
  23452. }): number;
  23453. private _rebuildParticle;
  23454. /**
  23455. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23456. * @returns the SPS.
  23457. */
  23458. rebuildMesh(): SolidParticleSystem;
  23459. /**
  23460. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23461. * This method calls `updateParticle()` for each particle of the SPS.
  23462. * For an animated SPS, it is usually called within the render loop.
  23463. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23464. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23465. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23466. * @returns the SPS.
  23467. */
  23468. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23469. /**
  23470. * Disposes the SPS.
  23471. */
  23472. dispose(): void;
  23473. /**
  23474. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23476. * @returns the SPS.
  23477. */
  23478. refreshVisibleSize(): SolidParticleSystem;
  23479. /**
  23480. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23481. * @param size the size (float) of the visibility box
  23482. * note : this doesn't lock the SPS mesh bounding box.
  23483. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23484. */
  23485. setVisibilityBox(size: number): void;
  23486. /**
  23487. * Gets whether the SPS as always visible or not
  23488. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23489. */
  23490. /**
  23491. * Sets the SPS as always visible or not
  23492. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23493. */
  23494. isAlwaysVisible: boolean;
  23495. /**
  23496. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23497. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23498. */
  23499. /**
  23500. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23501. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23502. */
  23503. isVisibilityBoxLocked: boolean;
  23504. /**
  23505. * Tells to `setParticles()` to compute the particle rotations or not.
  23506. * Default value : true. The SPS is faster when it's set to false.
  23507. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23508. */
  23509. /**
  23510. * Gets if `setParticles()` computes the particle rotations or not.
  23511. * Default value : true. The SPS is faster when it's set to false.
  23512. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23513. */
  23514. computeParticleRotation: boolean;
  23515. /**
  23516. * Tells to `setParticles()` to compute the particle colors or not.
  23517. * Default value : true. The SPS is faster when it's set to false.
  23518. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23519. */
  23520. /**
  23521. * Gets if `setParticles()` computes the particle colors or not.
  23522. * Default value : true. The SPS is faster when it's set to false.
  23523. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23524. */
  23525. computeParticleColor: boolean;
  23526. /**
  23527. * Gets if `setParticles()` computes the particle textures or not.
  23528. * Default value : true. The SPS is faster when it's set to false.
  23529. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23530. */
  23531. computeParticleTexture: boolean;
  23532. /**
  23533. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23534. * Default value : false. The SPS is faster when it's set to false.
  23535. * Note : the particle custom vertex positions aren't stored values.
  23536. */
  23537. /**
  23538. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23539. * Default value : false. The SPS is faster when it's set to false.
  23540. * Note : the particle custom vertex positions aren't stored values.
  23541. */
  23542. computeParticleVertex: boolean;
  23543. /**
  23544. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23545. */
  23546. /**
  23547. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23548. */
  23549. computeBoundingBox: boolean;
  23550. /**
  23551. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23552. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23553. * Default : `true`
  23554. */
  23555. /**
  23556. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23557. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23558. * Default : `true`
  23559. */
  23560. depthSortParticles: boolean;
  23561. /**
  23562. * This function does nothing. It may be overwritten to set all the particle first values.
  23563. * The SPS doesn't call this function, you may have to call it by your own.
  23564. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23565. */
  23566. initParticles(): void;
  23567. /**
  23568. * This function does nothing. It may be overwritten to recycle a particle.
  23569. * The SPS doesn't call this function, you may have to call it by your own.
  23570. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23571. * @param particle The particle to recycle
  23572. * @returns the recycled particle
  23573. */
  23574. recycleParticle(particle: SolidParticle): SolidParticle;
  23575. /**
  23576. * Updates a particle : this function should be overwritten by the user.
  23577. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23578. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23579. * @example : just set a particle position or velocity and recycle conditions
  23580. * @param particle The particle to update
  23581. * @returns the updated particle
  23582. */
  23583. updateParticle(particle: SolidParticle): SolidParticle;
  23584. /**
  23585. * Updates a vertex of a particle : it can be overwritten by the user.
  23586. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23587. * @param particle the current particle
  23588. * @param vertex the current index of the current particle
  23589. * @param pt the index of the current vertex in the particle shape
  23590. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23591. * @example : just set a vertex particle position
  23592. * @returns the updated vertex
  23593. */
  23594. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23595. /**
  23596. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23597. * This does nothing and may be overwritten by the user.
  23598. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23599. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23600. * @param update the boolean update value actually passed to setParticles()
  23601. */
  23602. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23603. /**
  23604. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23605. * This will be passed three parameters.
  23606. * This does nothing and may be overwritten by the user.
  23607. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23608. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23609. * @param update the boolean update value actually passed to setParticles()
  23610. */
  23611. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23612. }
  23613. }
  23614. declare module BABYLON {
  23615. /**
  23616. * Represents one particle of a solid particle system.
  23617. */
  23618. export class SolidParticle {
  23619. /**
  23620. * particle global index
  23621. */
  23622. idx: number;
  23623. /**
  23624. * The color of the particle
  23625. */
  23626. color: Nullable<Color4>;
  23627. /**
  23628. * The world space position of the particle.
  23629. */
  23630. position: Vector3;
  23631. /**
  23632. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23633. */
  23634. rotation: Vector3;
  23635. /**
  23636. * The world space rotation quaternion of the particle.
  23637. */
  23638. rotationQuaternion: Nullable<Quaternion>;
  23639. /**
  23640. * The scaling of the particle.
  23641. */
  23642. scaling: Vector3;
  23643. /**
  23644. * The uvs of the particle.
  23645. */
  23646. uvs: Vector4;
  23647. /**
  23648. * The current speed of the particle.
  23649. */
  23650. velocity: Vector3;
  23651. /**
  23652. * The pivot point in the particle local space.
  23653. */
  23654. pivot: Vector3;
  23655. /**
  23656. * Must the particle be translated from its pivot point in its local space ?
  23657. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23658. * Default : false
  23659. */
  23660. translateFromPivot: boolean;
  23661. /**
  23662. * Is the particle active or not ?
  23663. */
  23664. alive: boolean;
  23665. /**
  23666. * Is the particle visible or not ?
  23667. */
  23668. isVisible: boolean;
  23669. /**
  23670. * Index of this particle in the global "positions" array (Internal use)
  23671. * @hidden
  23672. */ pos: number;
  23673. /**
  23674. * @hidden Index of this particle in the global "indices" array (Internal use)
  23675. */ ind: number;
  23676. /**
  23677. * @hidden ModelShape of this particle (Internal use)
  23678. */ model: ModelShape;
  23679. /**
  23680. * ModelShape id of this particle
  23681. */
  23682. shapeId: number;
  23683. /**
  23684. * Index of the particle in its shape id (Internal use)
  23685. */
  23686. idxInShape: number;
  23687. /**
  23688. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23689. */ modelBoundingInfo: BoundingInfo;
  23690. /**
  23691. * @hidden Particle BoundingInfo object (Internal use)
  23692. */ boundingInfo: BoundingInfo;
  23693. /**
  23694. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23695. */ sps: SolidParticleSystem;
  23696. /**
  23697. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23698. */ stillInvisible: boolean;
  23699. /**
  23700. * @hidden Last computed particle rotation matrix
  23701. */ rotationMatrix: number[];
  23702. /**
  23703. * Parent particle Id, if any.
  23704. * Default null.
  23705. */
  23706. parentId: Nullable<number>;
  23707. /**
  23708. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23709. * The possible values are :
  23710. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23711. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23714. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23715. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23716. * */
  23717. cullingStrategy: number;
  23718. /**
  23719. * @hidden Internal global position in the SPS.
  23720. */ globalPosition: Vector3;
  23721. /**
  23722. * Creates a Solid Particle object.
  23723. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23724. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23725. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23726. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23727. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23728. * @param shapeId (integer) is the model shape identifier in the SPS.
  23729. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23730. * @param sps defines the sps it is associated to
  23731. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23732. */
  23733. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23734. /**
  23735. * Legacy support, changed scale to scaling
  23736. */
  23737. /**
  23738. * Legacy support, changed scale to scaling
  23739. */
  23740. scale: Vector3;
  23741. /**
  23742. * Legacy support, changed quaternion to rotationQuaternion
  23743. */
  23744. /**
  23745. * Legacy support, changed quaternion to rotationQuaternion
  23746. */
  23747. quaternion: Nullable<Quaternion>;
  23748. /**
  23749. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23750. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23751. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23752. * @returns true if it intersects
  23753. */
  23754. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23755. /**
  23756. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23757. * A particle is in the frustum if its bounding box intersects the frustum
  23758. * @param frustumPlanes defines the frustum to test
  23759. * @returns true if the particle is in the frustum planes
  23760. */
  23761. isInFrustum(frustumPlanes: Plane[]): boolean;
  23762. /**
  23763. * get the rotation matrix of the particle
  23764. * @hidden
  23765. */
  23766. getRotationMatrix(m: Matrix): void;
  23767. }
  23768. /**
  23769. * Represents the shape of the model used by one particle of a solid particle system.
  23770. * SPS internal tool, don't use it manually.
  23771. */
  23772. export class ModelShape {
  23773. /**
  23774. * The shape id
  23775. * @hidden
  23776. */
  23777. shapeID: number;
  23778. /**
  23779. * flat array of model positions (internal use)
  23780. * @hidden
  23781. */ shape: Vector3[];
  23782. /**
  23783. * flat array of model UVs (internal use)
  23784. * @hidden
  23785. */ shapeUV: number[];
  23786. /**
  23787. * length of the shape in the model indices array (internal use)
  23788. * @hidden
  23789. */ indicesLength: number;
  23790. /**
  23791. * Custom position function (internal use)
  23792. * @hidden
  23793. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23794. /**
  23795. * Custom vertex function (internal use)
  23796. * @hidden
  23797. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23798. /**
  23799. * 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.
  23800. * SPS internal tool, don't use it manually.
  23801. * @hidden
  23802. */
  23803. 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>);
  23804. }
  23805. /**
  23806. * Represents a Depth Sorted Particle in the solid particle system.
  23807. */
  23808. export class DepthSortedParticle {
  23809. /**
  23810. * Index of the particle in the "indices" array
  23811. */
  23812. ind: number;
  23813. /**
  23814. * Length of the particle shape in the "indices" array
  23815. */
  23816. indicesLength: number;
  23817. /**
  23818. * Squared distance from the particle to the camera
  23819. */
  23820. sqDistance: number;
  23821. }
  23822. }
  23823. declare module BABYLON {
  23824. /**
  23825. * Class used to store all common mesh properties
  23826. */
  23827. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23828. /** No occlusion */
  23829. static OCCLUSION_TYPE_NONE: number;
  23830. /** Occlusion set to optimisitic */
  23831. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23832. /** Occlusion set to strict */
  23833. static OCCLUSION_TYPE_STRICT: number;
  23834. /** Use an accurante occlusion algorithm */
  23835. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23836. /** Use a conservative occlusion algorithm */
  23837. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23838. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23839. * Test order :
  23840. * Is the bounding sphere outside the frustum ?
  23841. * If not, are the bounding box vertices outside the frustum ?
  23842. * It not, then the cullable object is in the frustum.
  23843. */
  23844. static readonly CULLINGSTRATEGY_STANDARD: number;
  23845. /** Culling strategy : Bounding Sphere Only.
  23846. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23847. * It's also less accurate than the standard because some not visible objects can still be selected.
  23848. * Test : is the bounding sphere outside the frustum ?
  23849. * If not, then the cullable object is in the frustum.
  23850. */
  23851. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23852. /** Culling strategy : Optimistic Inclusion.
  23853. * This in an inclusion test first, then the standard exclusion test.
  23854. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23855. * 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.
  23856. * Anyway, it's as accurate as the standard strategy.
  23857. * Test :
  23858. * Is the cullable object bounding sphere center in the frustum ?
  23859. * If not, apply the default culling strategy.
  23860. */
  23861. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23862. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23863. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23864. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23865. * 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.
  23866. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23867. * Test :
  23868. * Is the cullable object bounding sphere center in the frustum ?
  23869. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23870. */
  23871. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23872. /**
  23873. * No billboard
  23874. */
  23875. static readonly BILLBOARDMODE_NONE: number;
  23876. /** Billboard on X axis */
  23877. static readonly BILLBOARDMODE_X: number;
  23878. /** Billboard on Y axis */
  23879. static readonly BILLBOARDMODE_Y: number;
  23880. /** Billboard on Z axis */
  23881. static readonly BILLBOARDMODE_Z: number;
  23882. /** Billboard on all axes */
  23883. static readonly BILLBOARDMODE_ALL: number;
  23884. private _facetData;
  23885. /**
  23886. * The culling strategy to use to check whether the mesh must be rendered or not.
  23887. * This value can be changed at any time and will be used on the next render mesh selection.
  23888. * The possible values are :
  23889. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23890. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23891. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23892. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23893. * Please read each static variable documentation to get details about the culling process.
  23894. * */
  23895. cullingStrategy: number;
  23896. /**
  23897. * Gets the number of facets in the mesh
  23898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23899. */
  23900. readonly facetNb: number;
  23901. /**
  23902. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23904. */
  23905. partitioningSubdivisions: number;
  23906. /**
  23907. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23908. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23910. */
  23911. partitioningBBoxRatio: number;
  23912. /**
  23913. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23914. * Works only for updatable meshes.
  23915. * Doesn't work with multi-materials
  23916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23917. */
  23918. mustDepthSortFacets: boolean;
  23919. /**
  23920. * The location (Vector3) where the facet depth sort must be computed from.
  23921. * By default, the active camera position.
  23922. * Used only when facet depth sort is enabled
  23923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23924. */
  23925. facetDepthSortFrom: Vector3;
  23926. /**
  23927. * gets a boolean indicating if facetData is enabled
  23928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23929. */
  23930. readonly isFacetDataEnabled: boolean;
  23931. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23932. /**
  23933. * An event triggered when this mesh collides with another one
  23934. */
  23935. onCollideObservable: Observable<AbstractMesh>;
  23936. private _onCollideObserver;
  23937. /** Set a function to call when this mesh collides with another one */
  23938. onCollide: () => void;
  23939. /**
  23940. * An event triggered when the collision's position changes
  23941. */
  23942. onCollisionPositionChangeObservable: Observable<Vector3>;
  23943. private _onCollisionPositionChangeObserver;
  23944. /** Set a function to call when the collision's position changes */
  23945. onCollisionPositionChange: () => void;
  23946. /**
  23947. * An event triggered when material is changed
  23948. */
  23949. onMaterialChangedObservable: Observable<AbstractMesh>;
  23950. /**
  23951. * Gets or sets the orientation for POV movement & rotation
  23952. */
  23953. definedFacingForward: boolean;
  23954. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23955. private _visibility;
  23956. /** @hidden */ isActive: boolean;
  23957. /** @hidden */ onlyForInstances: boolean;
  23958. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23959. /**
  23960. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23961. */
  23962. /**
  23963. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23964. */
  23965. visibility: number;
  23966. /** Gets or sets the alpha index used to sort transparent meshes
  23967. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23968. */
  23969. alphaIndex: number;
  23970. /**
  23971. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23972. */
  23973. isVisible: boolean;
  23974. /**
  23975. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23976. */
  23977. isPickable: boolean;
  23978. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23979. showSubMeshesBoundingBox: boolean;
  23980. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23982. */
  23983. isBlocker: boolean;
  23984. /**
  23985. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23986. */
  23987. enablePointerMoveEvents: boolean;
  23988. /**
  23989. * Specifies the rendering group id for this mesh (0 by default)
  23990. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23991. */
  23992. renderingGroupId: number;
  23993. private _material;
  23994. /** Gets or sets current material */
  23995. material: Nullable<Material>;
  23996. private _receiveShadows;
  23997. /**
  23998. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23999. * @see http://doc.babylonjs.com/babylon101/shadows
  24000. */
  24001. receiveShadows: boolean;
  24002. /** Defines color to use when rendering outline */
  24003. outlineColor: Color3;
  24004. /** Define width to use when rendering outline */
  24005. outlineWidth: number;
  24006. /** Defines color to use when rendering overlay */
  24007. overlayColor: Color3;
  24008. /** Defines alpha to use when rendering overlay */
  24009. overlayAlpha: number;
  24010. private _hasVertexAlpha;
  24011. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24012. hasVertexAlpha: boolean;
  24013. private _useVertexColors;
  24014. /** 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) */
  24015. useVertexColors: boolean;
  24016. private _computeBonesUsingShaders;
  24017. /**
  24018. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24019. */
  24020. computeBonesUsingShaders: boolean;
  24021. private _numBoneInfluencers;
  24022. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24023. numBoneInfluencers: number;
  24024. private _applyFog;
  24025. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24026. applyFog: boolean;
  24027. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24028. useOctreeForRenderingSelection: boolean;
  24029. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24030. useOctreeForPicking: boolean;
  24031. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24032. useOctreeForCollisions: boolean;
  24033. private _layerMask;
  24034. /**
  24035. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24036. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24037. */
  24038. layerMask: number;
  24039. /**
  24040. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24041. */
  24042. alwaysSelectAsActiveMesh: boolean;
  24043. /**
  24044. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24045. */
  24046. doNotSyncBoundingInfo: boolean;
  24047. /**
  24048. * Gets or sets the current action manager
  24049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24050. */
  24051. actionManager: Nullable<AbstractActionManager>;
  24052. private _checkCollisions;
  24053. private _collisionMask;
  24054. private _collisionGroup;
  24055. /**
  24056. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24058. */
  24059. ellipsoid: Vector3;
  24060. /**
  24061. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24063. */
  24064. ellipsoidOffset: Vector3;
  24065. private _collider;
  24066. private _oldPositionForCollisions;
  24067. private _diffPositionForCollisions;
  24068. /**
  24069. * Gets or sets a collision mask used to mask collisions (default is -1).
  24070. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24071. */
  24072. collisionMask: number;
  24073. /**
  24074. * Gets or sets the current collision group mask (-1 by default).
  24075. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24076. */
  24077. collisionGroup: number;
  24078. /**
  24079. * Defines edge width used when edgesRenderer is enabled
  24080. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24081. */
  24082. edgesWidth: number;
  24083. /**
  24084. * Defines edge color used when edgesRenderer is enabled
  24085. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24086. */
  24087. edgesColor: Color4;
  24088. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  24089. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  24090. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  24091. /** @hidden */ renderId: number;
  24092. /**
  24093. * Gets or sets the list of subMeshes
  24094. * @see http://doc.babylonjs.com/how_to/multi_materials
  24095. */
  24096. subMeshes: SubMesh[];
  24097. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  24098. /** @hidden */ unIndexed: boolean;
  24099. /** @hidden */ lightSources: Light[];
  24100. /** Gets the list of lights affecting that mesh */
  24101. readonly lightSources: Light[];
  24102. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24103. /** @hidden */ waitingData: {
  24104. lods: Nullable<any>;
  24105. actions: Nullable<any>;
  24106. freezeWorldMatrix: Nullable<boolean>;
  24107. };
  24108. private _skeleton;
  24109. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  24110. /**
  24111. * Gets or sets a skeleton to apply skining transformations
  24112. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24113. */
  24114. skeleton: Nullable<Skeleton>;
  24115. /**
  24116. * An event triggered when the mesh is rebuilt.
  24117. */
  24118. onRebuildObservable: Observable<AbstractMesh>;
  24119. /**
  24120. * Creates a new AbstractMesh
  24121. * @param name defines the name of the mesh
  24122. * @param scene defines the hosting scene
  24123. */
  24124. constructor(name: string, scene?: Nullable<Scene>);
  24125. /**
  24126. * Returns the string "AbstractMesh"
  24127. * @returns "AbstractMesh"
  24128. */
  24129. getClassName(): string;
  24130. /**
  24131. * Gets a string representation of the current mesh
  24132. * @param fullDetails defines a boolean indicating if full details must be included
  24133. * @returns a string representation of the current mesh
  24134. */
  24135. toString(fullDetails?: boolean): string;
  24136. /**
  24137. * @hidden
  24138. */
  24139. protected _getEffectiveParent(): Nullable<Node>;
  24140. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24141. /** @hidden */ rebuild(): void;
  24142. /** @hidden */ resyncLightSources(): void;
  24143. /** @hidden */ resyncLighSource(light: Light): void;
  24144. /** @hidden */ unBindEffect(): void;
  24145. /** @hidden */ removeLightSource(light: Light): void;
  24146. private _markSubMeshesAsDirty;
  24147. /** @hidden */ markSubMeshesAsLightDirty(): void;
  24148. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  24149. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  24150. /**
  24151. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24152. */
  24153. scaling: Vector3;
  24154. /**
  24155. * Returns true if the mesh is blocked. Implemented by child classes
  24156. */
  24157. readonly isBlocked: boolean;
  24158. /**
  24159. * Returns the mesh itself by default. Implemented by child classes
  24160. * @param camera defines the camera to use to pick the right LOD level
  24161. * @returns the currentAbstractMesh
  24162. */
  24163. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24164. /**
  24165. * Returns 0 by default. Implemented by child classes
  24166. * @returns an integer
  24167. */
  24168. getTotalVertices(): number;
  24169. /**
  24170. * Returns a positive integer : the total number of indices in this mesh geometry.
  24171. * @returns the numner of indices or zero if the mesh has no geometry.
  24172. */
  24173. getTotalIndices(): number;
  24174. /**
  24175. * Returns null by default. Implemented by child classes
  24176. * @returns null
  24177. */
  24178. getIndices(): Nullable<IndicesArray>;
  24179. /**
  24180. * Returns the array of the requested vertex data kind. Implemented by child classes
  24181. * @param kind defines the vertex data kind to use
  24182. * @returns null
  24183. */
  24184. getVerticesData(kind: string): Nullable<FloatArray>;
  24185. /**
  24186. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24187. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24188. * Note that a new underlying VertexBuffer object is created each call.
  24189. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24190. * @param kind defines vertex data kind:
  24191. * * VertexBuffer.PositionKind
  24192. * * VertexBuffer.UVKind
  24193. * * VertexBuffer.UV2Kind
  24194. * * VertexBuffer.UV3Kind
  24195. * * VertexBuffer.UV4Kind
  24196. * * VertexBuffer.UV5Kind
  24197. * * VertexBuffer.UV6Kind
  24198. * * VertexBuffer.ColorKind
  24199. * * VertexBuffer.MatricesIndicesKind
  24200. * * VertexBuffer.MatricesIndicesExtraKind
  24201. * * VertexBuffer.MatricesWeightsKind
  24202. * * VertexBuffer.MatricesWeightsExtraKind
  24203. * @param data defines the data source
  24204. * @param updatable defines if the data must be flagged as updatable (or static)
  24205. * @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
  24206. * @returns the current mesh
  24207. */
  24208. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24209. /**
  24210. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24211. * If the mesh has no geometry, it is simply returned as it is.
  24212. * @param kind defines vertex data kind:
  24213. * * VertexBuffer.PositionKind
  24214. * * VertexBuffer.UVKind
  24215. * * VertexBuffer.UV2Kind
  24216. * * VertexBuffer.UV3Kind
  24217. * * VertexBuffer.UV4Kind
  24218. * * VertexBuffer.UV5Kind
  24219. * * VertexBuffer.UV6Kind
  24220. * * VertexBuffer.ColorKind
  24221. * * VertexBuffer.MatricesIndicesKind
  24222. * * VertexBuffer.MatricesIndicesExtraKind
  24223. * * VertexBuffer.MatricesWeightsKind
  24224. * * VertexBuffer.MatricesWeightsExtraKind
  24225. * @param data defines the data source
  24226. * @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
  24227. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24228. * @returns the current mesh
  24229. */
  24230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24231. /**
  24232. * Sets the mesh indices,
  24233. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24234. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24235. * @param totalVertices Defines the total number of vertices
  24236. * @returns the current mesh
  24237. */
  24238. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24239. /**
  24240. * Gets a boolean indicating if specific vertex data is present
  24241. * @param kind defines the vertex data kind to use
  24242. * @returns true is data kind is present
  24243. */
  24244. isVerticesDataPresent(kind: string): boolean;
  24245. /**
  24246. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24247. * @returns a BoundingInfo
  24248. */
  24249. getBoundingInfo(): BoundingInfo;
  24250. /**
  24251. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24252. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24253. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24254. * @returns the current mesh
  24255. */
  24256. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24257. /**
  24258. * Overwrite the current bounding info
  24259. * @param boundingInfo defines the new bounding info
  24260. * @returns the current mesh
  24261. */
  24262. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24263. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24264. readonly useBones: boolean;
  24265. /** @hidden */ preActivate(): void;
  24266. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  24267. /** @hidden */ activate(renderId: number): boolean;
  24268. /** @hidden */ postActivate(): void;
  24269. /** @hidden */ freeze(): void;
  24270. /** @hidden */ unFreeze(): void;
  24271. /**
  24272. * Gets the current world matrix
  24273. * @returns a Matrix
  24274. */
  24275. getWorldMatrix(): Matrix;
  24276. /** @hidden */ getWorldMatrixDeterminant(): number;
  24277. /**
  24278. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24279. */
  24280. readonly isAnInstance: boolean;
  24281. /**
  24282. * Perform relative position change from the point of view of behind the front of the mesh.
  24283. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24284. * Supports definition of mesh facing forward or backward
  24285. * @param amountRight defines the distance on the right axis
  24286. * @param amountUp defines the distance on the up axis
  24287. * @param amountForward defines the distance on the forward axis
  24288. * @returns the current mesh
  24289. */
  24290. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24291. /**
  24292. * Calculate relative position change from the point of view of behind the front of the mesh.
  24293. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24294. * Supports definition of mesh facing forward or backward
  24295. * @param amountRight defines the distance on the right axis
  24296. * @param amountUp defines the distance on the up axis
  24297. * @param amountForward defines the distance on the forward axis
  24298. * @returns the new displacement vector
  24299. */
  24300. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24301. /**
  24302. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24303. * Supports definition of mesh facing forward or backward
  24304. * @param flipBack defines the flip
  24305. * @param twirlClockwise defines the twirl
  24306. * @param tiltRight defines the tilt
  24307. * @returns the current mesh
  24308. */
  24309. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24310. /**
  24311. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24312. * Supports definition of mesh facing forward or backward.
  24313. * @param flipBack defines the flip
  24314. * @param twirlClockwise defines the twirl
  24315. * @param tiltRight defines the tilt
  24316. * @returns the new rotation vector
  24317. */
  24318. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24319. /**
  24320. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24321. * This means the mesh underlying bounding box and sphere are recomputed.
  24322. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24323. * @returns the current mesh
  24324. */
  24325. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24326. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24327. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24328. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  24329. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24330. /** @hidden */
  24331. protected _afterComputeWorldMatrix(): void;
  24332. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24333. /**
  24334. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24335. * A mesh is in the frustum if its bounding box intersects the frustum
  24336. * @param frustumPlanes defines the frustum to test
  24337. * @returns true if the mesh is in the frustum planes
  24338. */
  24339. isInFrustum(frustumPlanes: Plane[]): boolean;
  24340. /**
  24341. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24342. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24343. * @param frustumPlanes defines the frustum to test
  24344. * @returns true if the mesh is completely in the frustum planes
  24345. */
  24346. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24347. /**
  24348. * True if the mesh intersects another mesh or a SolidParticle object
  24349. * @param mesh defines a target mesh or SolidParticle to test
  24350. * @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)
  24351. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24352. * @returns true if there is an intersection
  24353. */
  24354. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24355. /**
  24356. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24357. * @param point defines the point to test
  24358. * @returns true if there is an intersection
  24359. */
  24360. intersectsPoint(point: Vector3): boolean;
  24361. /**
  24362. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24364. */
  24365. checkCollisions: boolean;
  24366. /**
  24367. * Gets Collider object used to compute collisions (not physics)
  24368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24369. */
  24370. readonly collider: Nullable<Collider>;
  24371. /**
  24372. * Move the mesh using collision engine
  24373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24374. * @param displacement defines the requested displacement vector
  24375. * @returns the current mesh
  24376. */
  24377. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24378. private _onCollisionPositionChange;
  24379. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24380. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24381. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24382. /** @hidden */ generatePointsArray(): boolean;
  24383. /**
  24384. * Checks if the passed Ray intersects with the mesh
  24385. * @param ray defines the ray to use
  24386. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24387. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24388. * @returns the picking info
  24389. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24390. */
  24391. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24392. /**
  24393. * Clones the current mesh
  24394. * @param name defines the mesh name
  24395. * @param newParent defines the new mesh parent
  24396. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24397. * @returns the new mesh
  24398. */
  24399. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24400. /**
  24401. * Disposes all the submeshes of the current meshnp
  24402. * @returns the current mesh
  24403. */
  24404. releaseSubMeshes(): AbstractMesh;
  24405. /**
  24406. * Releases resources associated with this abstract mesh.
  24407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24409. */
  24410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24411. /**
  24412. * Adds the passed mesh as a child to the current mesh
  24413. * @param mesh defines the child mesh
  24414. * @returns the current mesh
  24415. */
  24416. addChild(mesh: AbstractMesh): AbstractMesh;
  24417. /**
  24418. * Removes the passed mesh from the current mesh children list
  24419. * @param mesh defines the child mesh
  24420. * @returns the current mesh
  24421. */
  24422. removeChild(mesh: AbstractMesh): AbstractMesh;
  24423. /** @hidden */
  24424. private _initFacetData;
  24425. /**
  24426. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24427. * This method can be called within the render loop.
  24428. * 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
  24429. * @returns the current mesh
  24430. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24431. */
  24432. updateFacetData(): AbstractMesh;
  24433. /**
  24434. * Returns the facetLocalNormals array.
  24435. * The normals are expressed in the mesh local spac
  24436. * @returns an array of Vector3
  24437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24438. */
  24439. getFacetLocalNormals(): Vector3[];
  24440. /**
  24441. * Returns the facetLocalPositions array.
  24442. * The facet positions are expressed in the mesh local space
  24443. * @returns an array of Vector3
  24444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24445. */
  24446. getFacetLocalPositions(): Vector3[];
  24447. /**
  24448. * Returns the facetLocalPartioning array
  24449. * @returns an array of array of numbers
  24450. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24451. */
  24452. getFacetLocalPartitioning(): number[][];
  24453. /**
  24454. * Returns the i-th facet position in the world system.
  24455. * This method allocates a new Vector3 per call
  24456. * @param i defines the facet index
  24457. * @returns a new Vector3
  24458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24459. */
  24460. getFacetPosition(i: number): Vector3;
  24461. /**
  24462. * Sets the reference Vector3 with the i-th facet position in the world system
  24463. * @param i defines the facet index
  24464. * @param ref defines the target vector
  24465. * @returns the current mesh
  24466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24467. */
  24468. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24469. /**
  24470. * Returns the i-th facet normal in the world system.
  24471. * This method allocates a new Vector3 per call
  24472. * @param i defines the facet index
  24473. * @returns a new Vector3
  24474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24475. */
  24476. getFacetNormal(i: number): Vector3;
  24477. /**
  24478. * Sets the reference Vector3 with the i-th facet normal in the world system
  24479. * @param i defines the facet index
  24480. * @param ref defines the target vector
  24481. * @returns the current mesh
  24482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24483. */
  24484. getFacetNormalToRef(i: number, ref: Vector3): this;
  24485. /**
  24486. * 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)
  24487. * @param x defines x coordinate
  24488. * @param y defines y coordinate
  24489. * @param z defines z coordinate
  24490. * @returns the array of facet indexes
  24491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24492. */
  24493. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24494. /**
  24495. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24496. * @param projected sets as the (x,y,z) world projection on the facet
  24497. * @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
  24498. * @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
  24499. * @param x defines x coordinate
  24500. * @param y defines y coordinate
  24501. * @param z defines z coordinate
  24502. * @returns the face index if found (or null instead)
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24504. */
  24505. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24506. /**
  24507. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24508. * @param projected sets as the (x,y,z) local projection on the facet
  24509. * @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
  24510. * @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
  24511. * @param x defines x coordinate
  24512. * @param y defines y coordinate
  24513. * @param z defines z coordinate
  24514. * @returns the face index if found (or null instead)
  24515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24516. */
  24517. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24518. /**
  24519. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24520. * @returns the parameters
  24521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24522. */
  24523. getFacetDataParameters(): any;
  24524. /**
  24525. * Disables the feature FacetData and frees the related memory
  24526. * @returns the current mesh
  24527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24528. */
  24529. disableFacetData(): AbstractMesh;
  24530. /**
  24531. * Updates the AbstractMesh indices array
  24532. * @param indices defines the data source
  24533. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24534. * @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)
  24535. * @returns the current mesh
  24536. */
  24537. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24538. /**
  24539. * Creates new normals data for the mesh
  24540. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24541. * @returns the current mesh
  24542. */
  24543. createNormals(updatable: boolean): AbstractMesh;
  24544. /**
  24545. * Align the mesh with a normal
  24546. * @param normal defines the normal to use
  24547. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24548. * @returns the current mesh
  24549. */
  24550. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24551. /** @hidden */ checkOcclusionQuery(): boolean;
  24552. }
  24553. }
  24554. declare module BABYLON {
  24555. /**
  24556. * Interface used to define ActionEvent
  24557. */
  24558. export interface IActionEvent {
  24559. /** The mesh or sprite that triggered the action */
  24560. source: any;
  24561. /** The X mouse cursor position at the time of the event */
  24562. pointerX: number;
  24563. /** The Y mouse cursor position at the time of the event */
  24564. pointerY: number;
  24565. /** The mesh that is currently pointed at (can be null) */
  24566. meshUnderPointer: Nullable<AbstractMesh>;
  24567. /** the original (browser) event that triggered the ActionEvent */
  24568. sourceEvent?: any;
  24569. /** additional data for the event */
  24570. additionalData?: any;
  24571. }
  24572. /**
  24573. * ActionEvent is the event being sent when an action is triggered.
  24574. */
  24575. export class ActionEvent implements IActionEvent {
  24576. /** The mesh or sprite that triggered the action */
  24577. source: any;
  24578. /** The X mouse cursor position at the time of the event */
  24579. pointerX: number;
  24580. /** The Y mouse cursor position at the time of the event */
  24581. pointerY: number;
  24582. /** The mesh that is currently pointed at (can be null) */
  24583. meshUnderPointer: Nullable<AbstractMesh>;
  24584. /** the original (browser) event that triggered the ActionEvent */
  24585. sourceEvent?: any;
  24586. /** additional data for the event */
  24587. additionalData?: any;
  24588. /**
  24589. * Creates a new ActionEvent
  24590. * @param source The mesh or sprite that triggered the action
  24591. * @param pointerX The X mouse cursor position at the time of the event
  24592. * @param pointerY The Y mouse cursor position at the time of the event
  24593. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24594. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24595. * @param additionalData additional data for the event
  24596. */
  24597. constructor(
  24598. /** The mesh or sprite that triggered the action */
  24599. source: any,
  24600. /** The X mouse cursor position at the time of the event */
  24601. pointerX: number,
  24602. /** The Y mouse cursor position at the time of the event */
  24603. pointerY: number,
  24604. /** The mesh that is currently pointed at (can be null) */
  24605. meshUnderPointer: Nullable<AbstractMesh>,
  24606. /** the original (browser) event that triggered the ActionEvent */
  24607. sourceEvent?: any,
  24608. /** additional data for the event */
  24609. additionalData?: any);
  24610. /**
  24611. * Helper function to auto-create an ActionEvent from a source mesh.
  24612. * @param source The source mesh that triggered the event
  24613. * @param evt The original (browser) event
  24614. * @param additionalData additional data for the event
  24615. * @returns the new ActionEvent
  24616. */
  24617. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24618. /**
  24619. * Helper function to auto-create an ActionEvent from a source sprite
  24620. * @param source The source sprite that triggered the event
  24621. * @param scene Scene associated with the sprite
  24622. * @param evt The original (browser) event
  24623. * @param additionalData additional data for the event
  24624. * @returns the new ActionEvent
  24625. */
  24626. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24627. /**
  24628. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24629. * @param scene the scene where the event occurred
  24630. * @param evt The original (browser) event
  24631. * @returns the new ActionEvent
  24632. */
  24633. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24634. /**
  24635. * Helper function to auto-create an ActionEvent from a primitive
  24636. * @param prim defines the target primitive
  24637. * @param pointerPos defines the pointer position
  24638. * @param evt The original (browser) event
  24639. * @param additionalData additional data for the event
  24640. * @returns the new ActionEvent
  24641. */
  24642. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24643. }
  24644. }
  24645. declare module BABYLON {
  24646. /**
  24647. * Abstract class used to decouple action Manager from scene and meshes.
  24648. * Do not instantiate.
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24650. */
  24651. export abstract class AbstractActionManager implements IDisposable {
  24652. /** Gets the list of active triggers */
  24653. static Triggers: {
  24654. [key: string]: number;
  24655. };
  24656. /** Gets the cursor to use when hovering items */
  24657. hoverCursor: string;
  24658. /** Gets the list of actions */
  24659. actions: IAction[];
  24660. /**
  24661. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24662. */
  24663. isRecursive: boolean;
  24664. /**
  24665. * Releases all associated resources
  24666. */
  24667. abstract dispose(): void;
  24668. /**
  24669. * Does this action manager has pointer triggers
  24670. */
  24671. abstract readonly hasPointerTriggers: boolean;
  24672. /**
  24673. * Does this action manager has pick triggers
  24674. */
  24675. abstract readonly hasPickTriggers: boolean;
  24676. /**
  24677. * Process a specific trigger
  24678. * @param trigger defines the trigger to process
  24679. * @param evt defines the event details to be processed
  24680. */
  24681. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24682. /**
  24683. * Does this action manager handles actions of any of the given triggers
  24684. * @param triggers defines the triggers to be tested
  24685. * @return a boolean indicating whether one (or more) of the triggers is handled
  24686. */
  24687. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24688. /**
  24689. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24690. * speed.
  24691. * @param triggerA defines the trigger to be tested
  24692. * @param triggerB defines the trigger to be tested
  24693. * @return a boolean indicating whether one (or more) of the triggers is handled
  24694. */
  24695. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24696. /**
  24697. * Does this action manager handles actions of a given trigger
  24698. * @param trigger defines the trigger to be tested
  24699. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24700. * @return whether the trigger is handled
  24701. */
  24702. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24703. /**
  24704. * Serialize this manager to a JSON object
  24705. * @param name defines the property name to store this manager
  24706. * @returns a JSON representation of this manager
  24707. */
  24708. abstract serialize(name: string): any;
  24709. /**
  24710. * Registers an action to this action manager
  24711. * @param action defines the action to be registered
  24712. * @return the action amended (prepared) after registration
  24713. */
  24714. abstract registerAction(action: IAction): Nullable<IAction>;
  24715. /**
  24716. * Unregisters an action to this action manager
  24717. * @param action defines the action to be unregistered
  24718. * @return a boolean indicating whether the action has been unregistered
  24719. */
  24720. abstract unregisterAction(action: IAction): Boolean;
  24721. /**
  24722. * Does exist one action manager with at least one trigger
  24723. **/
  24724. static readonly HasTriggers: boolean;
  24725. /**
  24726. * Does exist one action manager with at least one pick trigger
  24727. **/
  24728. static readonly HasPickTriggers: boolean;
  24729. /**
  24730. * Does exist one action manager that handles actions of a given trigger
  24731. * @param trigger defines the trigger to be tested
  24732. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24733. **/
  24734. static HasSpecificTrigger(trigger: number): boolean;
  24735. }
  24736. }
  24737. declare module BABYLON {
  24738. /**
  24739. * Defines how a node can be built from a string name.
  24740. */
  24741. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24742. /**
  24743. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24744. */
  24745. export class Node implements IBehaviorAware<Node> {
  24746. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24747. private static _NodeConstructors;
  24748. /**
  24749. * Add a new node constructor
  24750. * @param type defines the type name of the node to construct
  24751. * @param constructorFunc defines the constructor function
  24752. */
  24753. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24754. /**
  24755. * Returns a node constructor based on type name
  24756. * @param type defines the type name
  24757. * @param name defines the new node name
  24758. * @param scene defines the hosting scene
  24759. * @param options defines optional options to transmit to constructors
  24760. * @returns the new constructor or null
  24761. */
  24762. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24763. /**
  24764. * Gets or sets the name of the node
  24765. */
  24766. name: string;
  24767. /**
  24768. * Gets or sets the id of the node
  24769. */
  24770. id: string;
  24771. /**
  24772. * Gets or sets the unique id of the node
  24773. */
  24774. uniqueId: number;
  24775. /**
  24776. * Gets or sets a string used to store user defined state for the node
  24777. */
  24778. state: string;
  24779. /**
  24780. * Gets or sets an object used to store user defined information for the node
  24781. */
  24782. metadata: any;
  24783. /**
  24784. * For internal use only. Please do not use.
  24785. */
  24786. reservedDataStore: any;
  24787. /**
  24788. * List of inspectable custom properties (used by the Inspector)
  24789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24790. */
  24791. inspectableCustomProperties: IInspectable[];
  24792. /**
  24793. * Gets or sets a boolean used to define if the node must be serialized
  24794. */
  24795. doNotSerialize: boolean;
  24796. /** @hidden */ isDisposed: boolean;
  24797. /**
  24798. * Gets a list of Animations associated with the node
  24799. */
  24800. animations: Animation[];
  24801. protected _ranges: {
  24802. [name: string]: Nullable<AnimationRange>;
  24803. };
  24804. /**
  24805. * Callback raised when the node is ready to be used
  24806. */
  24807. onReady: Nullable<(node: Node) => void>;
  24808. private _isEnabled;
  24809. private _isParentEnabled;
  24810. private _isReady;
  24811. /** @hidden */ currentRenderId: number;
  24812. private _parentUpdateId;
  24813. /** @hidden */ childUpdateId: number;
  24814. /** @hidden */ waitingParentId: Nullable<string>;
  24815. /** @hidden */ scene: Scene;
  24816. /** @hidden */ cache: any;
  24817. private _parentNode;
  24818. private _children;
  24819. /** @hidden */ worldMatrix: Matrix;
  24820. /** @hidden */ worldMatrixDeterminant: number;
  24821. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24822. /** @hidden */
  24823. private _sceneRootNodesIndex;
  24824. /**
  24825. * Gets a boolean indicating if the node has been disposed
  24826. * @returns true if the node was disposed
  24827. */
  24828. isDisposed(): boolean;
  24829. /**
  24830. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24831. * @see https://doc.babylonjs.com/how_to/parenting
  24832. */
  24833. parent: Nullable<Node>;
  24834. private addToSceneRootNodes;
  24835. private removeFromSceneRootNodes;
  24836. private _animationPropertiesOverride;
  24837. /**
  24838. * Gets or sets the animation properties override
  24839. */
  24840. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24841. /**
  24842. * Gets a string idenfifying the name of the class
  24843. * @returns "Node" string
  24844. */
  24845. getClassName(): string;
  24846. /** @hidden */ protected readonly _isNode: boolean;
  24847. /**
  24848. * An event triggered when the mesh is disposed
  24849. */
  24850. onDisposeObservable: Observable<Node>;
  24851. private _onDisposeObserver;
  24852. /**
  24853. * Sets a callback that will be raised when the node will be disposed
  24854. */
  24855. onDispose: () => void;
  24856. /**
  24857. * Creates a new Node
  24858. * @param name the name and id to be given to this node
  24859. * @param scene the scene this node will be added to
  24860. * @param addToRootNodes the node will be added to scene.rootNodes
  24861. */
  24862. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24863. /**
  24864. * Gets the scene of the node
  24865. * @returns a scene
  24866. */
  24867. getScene(): Scene;
  24868. /**
  24869. * Gets the engine of the node
  24870. * @returns a Engine
  24871. */
  24872. getEngine(): Engine;
  24873. private _behaviors;
  24874. /**
  24875. * Attach a behavior to the node
  24876. * @see http://doc.babylonjs.com/features/behaviour
  24877. * @param behavior defines the behavior to attach
  24878. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24879. * @returns the current Node
  24880. */
  24881. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24882. /**
  24883. * Remove an attached behavior
  24884. * @see http://doc.babylonjs.com/features/behaviour
  24885. * @param behavior defines the behavior to attach
  24886. * @returns the current Node
  24887. */
  24888. removeBehavior(behavior: Behavior<Node>): Node;
  24889. /**
  24890. * Gets the list of attached behaviors
  24891. * @see http://doc.babylonjs.com/features/behaviour
  24892. */
  24893. readonly behaviors: Behavior<Node>[];
  24894. /**
  24895. * Gets an attached behavior by name
  24896. * @param name defines the name of the behavior to look for
  24897. * @see http://doc.babylonjs.com/features/behaviour
  24898. * @returns null if behavior was not found else the requested behavior
  24899. */
  24900. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24901. /**
  24902. * Returns the latest update of the World matrix
  24903. * @returns a Matrix
  24904. */
  24905. getWorldMatrix(): Matrix;
  24906. /** @hidden */ getWorldMatrixDeterminant(): number;
  24907. /**
  24908. * Returns directly the latest state of the mesh World matrix.
  24909. * A Matrix is returned.
  24910. */
  24911. readonly worldMatrixFromCache: Matrix;
  24912. /** @hidden */ initCache(): void;
  24913. /** @hidden */
  24914. updateCache(force?: boolean): void;
  24915. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24916. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24917. /** @hidden */ isSynchronized(): boolean;
  24918. /** @hidden */ markSyncedWithParent(): void;
  24919. /** @hidden */
  24920. isSynchronizedWithParent(): boolean;
  24921. /** @hidden */
  24922. isSynchronized(): boolean;
  24923. /**
  24924. * Is this node ready to be used/rendered
  24925. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24926. * @return true if the node is ready
  24927. */
  24928. isReady(completeCheck?: boolean): boolean;
  24929. /**
  24930. * Is this node enabled?
  24931. * 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
  24932. * @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
  24933. * @return whether this node (and its parent) is enabled
  24934. */
  24935. isEnabled(checkAncestors?: boolean): boolean;
  24936. /** @hidden */
  24937. protected _syncParentEnabledState(): void;
  24938. /**
  24939. * Set the enabled state of this node
  24940. * @param value defines the new enabled state
  24941. */
  24942. setEnabled(value: boolean): void;
  24943. /**
  24944. * Is this node a descendant of the given node?
  24945. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24946. * @param ancestor defines the parent node to inspect
  24947. * @returns a boolean indicating if this node is a descendant of the given node
  24948. */
  24949. isDescendantOf(ancestor: Node): boolean;
  24950. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24951. /**
  24952. * Will return all nodes that have this node as ascendant
  24953. * @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
  24954. * @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
  24955. * @return all children nodes of all types
  24956. */
  24957. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24958. /**
  24959. * Get all child-meshes of this node
  24960. * @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)
  24961. * @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
  24962. * @returns an array of AbstractMesh
  24963. */
  24964. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24965. /**
  24966. * Get all direct children of this node
  24967. * @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
  24968. * @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)
  24969. * @returns an array of Node
  24970. */
  24971. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24972. /** @hidden */ setReady(state: boolean): void;
  24973. /**
  24974. * Get an animation by name
  24975. * @param name defines the name of the animation to look for
  24976. * @returns null if not found else the requested animation
  24977. */
  24978. getAnimationByName(name: string): Nullable<Animation>;
  24979. /**
  24980. * Creates an animation range for this node
  24981. * @param name defines the name of the range
  24982. * @param from defines the starting key
  24983. * @param to defines the end key
  24984. */
  24985. createAnimationRange(name: string, from: number, to: number): void;
  24986. /**
  24987. * Delete a specific animation range
  24988. * @param name defines the name of the range to delete
  24989. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24990. */
  24991. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24992. /**
  24993. * Get an animation range by name
  24994. * @param name defines the name of the animation range to look for
  24995. * @returns null if not found else the requested animation range
  24996. */
  24997. getAnimationRange(name: string): Nullable<AnimationRange>;
  24998. /**
  24999. * Gets the list of all animation ranges defined on this node
  25000. * @returns an array
  25001. */
  25002. getAnimationRanges(): Nullable<AnimationRange>[];
  25003. /**
  25004. * Will start the animation sequence
  25005. * @param name defines the range frames for animation sequence
  25006. * @param loop defines if the animation should loop (false by default)
  25007. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25008. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25009. * @returns the object created for this animation. If range does not exist, it will return null
  25010. */
  25011. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25012. /**
  25013. * Serialize animation ranges into a JSON compatible object
  25014. * @returns serialization object
  25015. */
  25016. serializeAnimationRanges(): any;
  25017. /**
  25018. * Computes the world matrix of the node
  25019. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25020. * @returns the world matrix
  25021. */
  25022. computeWorldMatrix(force?: boolean): Matrix;
  25023. /**
  25024. * Releases resources associated with this node.
  25025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25027. */
  25028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25029. /**
  25030. * Parse animation range data from a serialization object and store them into a given node
  25031. * @param node defines where to store the animation ranges
  25032. * @param parsedNode defines the serialization object to read data from
  25033. * @param scene defines the hosting scene
  25034. */
  25035. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25036. /**
  25037. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25038. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25039. * @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
  25040. * @returns the new bounding vectors
  25041. */
  25042. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25043. min: Vector3;
  25044. max: Vector3;
  25045. };
  25046. }
  25047. }
  25048. declare module BABYLON {
  25049. /**
  25050. * @hidden
  25051. */
  25052. export class _IAnimationState {
  25053. key: number;
  25054. repeatCount: number;
  25055. workValue?: any;
  25056. loopMode?: number;
  25057. offsetValue?: any;
  25058. highLimitValue?: any;
  25059. }
  25060. /**
  25061. * Class used to store any kind of animation
  25062. */
  25063. export class Animation {
  25064. /**Name of the animation */
  25065. name: string;
  25066. /**Property to animate */
  25067. targetProperty: string;
  25068. /**The frames per second of the animation */
  25069. framePerSecond: number;
  25070. /**The data type of the animation */
  25071. dataType: number;
  25072. /**The loop mode of the animation */
  25073. loopMode?: number | undefined;
  25074. /**Specifies if blending should be enabled */
  25075. enableBlending?: boolean | undefined;
  25076. /**
  25077. * Use matrix interpolation instead of using direct key value when animating matrices
  25078. */
  25079. static AllowMatricesInterpolation: boolean;
  25080. /**
  25081. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25082. */
  25083. static AllowMatrixDecomposeForInterpolation: boolean;
  25084. /**
  25085. * Stores the key frames of the animation
  25086. */
  25087. private _keys;
  25088. /**
  25089. * Stores the easing function of the animation
  25090. */
  25091. private _easingFunction;
  25092. /**
  25093. * @hidden Internal use only
  25094. */ runtimeAnimations: RuntimeAnimation[];
  25095. /**
  25096. * The set of event that will be linked to this animation
  25097. */
  25098. private _events;
  25099. /**
  25100. * Stores an array of target property paths
  25101. */
  25102. targetPropertyPath: string[];
  25103. /**
  25104. * Stores the blending speed of the animation
  25105. */
  25106. blendingSpeed: number;
  25107. /**
  25108. * Stores the animation ranges for the animation
  25109. */
  25110. private _ranges;
  25111. /**
  25112. * @hidden Internal use
  25113. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25114. /**
  25115. * Sets up an animation
  25116. * @param property The property to animate
  25117. * @param animationType The animation type to apply
  25118. * @param framePerSecond The frames per second of the animation
  25119. * @param easingFunction The easing function used in the animation
  25120. * @returns The created animation
  25121. */
  25122. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25123. /**
  25124. * Create and start an animation on a node
  25125. * @param name defines the name of the global animation that will be run on all nodes
  25126. * @param node defines the root node where the animation will take place
  25127. * @param targetProperty defines property to animate
  25128. * @param framePerSecond defines the number of frame per second yo use
  25129. * @param totalFrame defines the number of frames in total
  25130. * @param from defines the initial value
  25131. * @param to defines the final value
  25132. * @param loopMode defines which loop mode you want to use (off by default)
  25133. * @param easingFunction defines the easing function to use (linear by default)
  25134. * @param onAnimationEnd defines the callback to call when animation end
  25135. * @returns the animatable created for this animation
  25136. */
  25137. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25138. /**
  25139. * Create and start an animation on a node and its descendants
  25140. * @param name defines the name of the global animation that will be run on all nodes
  25141. * @param node defines the root node where the animation will take place
  25142. * @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
  25143. * @param targetProperty defines property to animate
  25144. * @param framePerSecond defines the number of frame per second to use
  25145. * @param totalFrame defines the number of frames in total
  25146. * @param from defines the initial value
  25147. * @param to defines the final value
  25148. * @param loopMode defines which loop mode you want to use (off by default)
  25149. * @param easingFunction defines the easing function to use (linear by default)
  25150. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25151. * @returns the list of animatables created for all nodes
  25152. * @example https://www.babylonjs-playground.com/#MH0VLI
  25153. */
  25154. 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[]>;
  25155. /**
  25156. * Creates a new animation, merges it with the existing animations and starts it
  25157. * @param name Name of the animation
  25158. * @param node Node which contains the scene that begins the animations
  25159. * @param targetProperty Specifies which property to animate
  25160. * @param framePerSecond The frames per second of the animation
  25161. * @param totalFrame The total number of frames
  25162. * @param from The frame at the beginning of the animation
  25163. * @param to The frame at the end of the animation
  25164. * @param loopMode Specifies the loop mode of the animation
  25165. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25166. * @param onAnimationEnd Callback to run once the animation is complete
  25167. * @returns Nullable animation
  25168. */
  25169. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25170. /**
  25171. * Transition property of an host to the target Value
  25172. * @param property The property to transition
  25173. * @param targetValue The target Value of the property
  25174. * @param host The object where the property to animate belongs
  25175. * @param scene Scene used to run the animation
  25176. * @param frameRate Framerate (in frame/s) to use
  25177. * @param transition The transition type we want to use
  25178. * @param duration The duration of the animation, in milliseconds
  25179. * @param onAnimationEnd Callback trigger at the end of the animation
  25180. * @returns Nullable animation
  25181. */
  25182. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25183. /**
  25184. * Return the array of runtime animations currently using this animation
  25185. */
  25186. readonly runtimeAnimations: RuntimeAnimation[];
  25187. /**
  25188. * Specifies if any of the runtime animations are currently running
  25189. */
  25190. readonly hasRunningRuntimeAnimations: boolean;
  25191. /**
  25192. * Initializes the animation
  25193. * @param name Name of the animation
  25194. * @param targetProperty Property to animate
  25195. * @param framePerSecond The frames per second of the animation
  25196. * @param dataType The data type of the animation
  25197. * @param loopMode The loop mode of the animation
  25198. * @param enableBlending Specifies if blending should be enabled
  25199. */
  25200. constructor(
  25201. /**Name of the animation */
  25202. name: string,
  25203. /**Property to animate */
  25204. targetProperty: string,
  25205. /**The frames per second of the animation */
  25206. framePerSecond: number,
  25207. /**The data type of the animation */
  25208. dataType: number,
  25209. /**The loop mode of the animation */
  25210. loopMode?: number | undefined,
  25211. /**Specifies if blending should be enabled */
  25212. enableBlending?: boolean | undefined);
  25213. /**
  25214. * Converts the animation to a string
  25215. * @param fullDetails support for multiple levels of logging within scene loading
  25216. * @returns String form of the animation
  25217. */
  25218. toString(fullDetails?: boolean): string;
  25219. /**
  25220. * Add an event to this animation
  25221. * @param event Event to add
  25222. */
  25223. addEvent(event: AnimationEvent): void;
  25224. /**
  25225. * Remove all events found at the given frame
  25226. * @param frame The frame to remove events from
  25227. */
  25228. removeEvents(frame: number): void;
  25229. /**
  25230. * Retrieves all the events from the animation
  25231. * @returns Events from the animation
  25232. */
  25233. getEvents(): AnimationEvent[];
  25234. /**
  25235. * Creates an animation range
  25236. * @param name Name of the animation range
  25237. * @param from Starting frame of the animation range
  25238. * @param to Ending frame of the animation
  25239. */
  25240. createRange(name: string, from: number, to: number): void;
  25241. /**
  25242. * Deletes an animation range by name
  25243. * @param name Name of the animation range to delete
  25244. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25245. */
  25246. deleteRange(name: string, deleteFrames?: boolean): void;
  25247. /**
  25248. * Gets the animation range by name, or null if not defined
  25249. * @param name Name of the animation range
  25250. * @returns Nullable animation range
  25251. */
  25252. getRange(name: string): Nullable<AnimationRange>;
  25253. /**
  25254. * Gets the key frames from the animation
  25255. * @returns The key frames of the animation
  25256. */
  25257. getKeys(): Array<IAnimationKey>;
  25258. /**
  25259. * Gets the highest frame rate of the animation
  25260. * @returns Highest frame rate of the animation
  25261. */
  25262. getHighestFrame(): number;
  25263. /**
  25264. * Gets the easing function of the animation
  25265. * @returns Easing function of the animation
  25266. */
  25267. getEasingFunction(): IEasingFunction;
  25268. /**
  25269. * Sets the easing function of the animation
  25270. * @param easingFunction A custom mathematical formula for animation
  25271. */
  25272. setEasingFunction(easingFunction: EasingFunction): void;
  25273. /**
  25274. * Interpolates a scalar linearly
  25275. * @param startValue Start value of the animation curve
  25276. * @param endValue End value of the animation curve
  25277. * @param gradient Scalar amount to interpolate
  25278. * @returns Interpolated scalar value
  25279. */
  25280. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25281. /**
  25282. * Interpolates a scalar cubically
  25283. * @param startValue Start value of the animation curve
  25284. * @param outTangent End tangent of the animation
  25285. * @param endValue End value of the animation curve
  25286. * @param inTangent Start tangent of the animation curve
  25287. * @param gradient Scalar amount to interpolate
  25288. * @returns Interpolated scalar value
  25289. */
  25290. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25291. /**
  25292. * Interpolates a quaternion using a spherical linear interpolation
  25293. * @param startValue Start value of the animation curve
  25294. * @param endValue End value of the animation curve
  25295. * @param gradient Scalar amount to interpolate
  25296. * @returns Interpolated quaternion value
  25297. */
  25298. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25299. /**
  25300. * Interpolates a quaternion cubically
  25301. * @param startValue Start value of the animation curve
  25302. * @param outTangent End tangent of the animation curve
  25303. * @param endValue End value of the animation curve
  25304. * @param inTangent Start tangent of the animation curve
  25305. * @param gradient Scalar amount to interpolate
  25306. * @returns Interpolated quaternion value
  25307. */
  25308. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25309. /**
  25310. * Interpolates a Vector3 linearl
  25311. * @param startValue Start value of the animation curve
  25312. * @param endValue End value of the animation curve
  25313. * @param gradient Scalar amount to interpolate
  25314. * @returns Interpolated scalar value
  25315. */
  25316. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25317. /**
  25318. * Interpolates a Vector3 cubically
  25319. * @param startValue Start value of the animation curve
  25320. * @param outTangent End tangent of the animation
  25321. * @param endValue End value of the animation curve
  25322. * @param inTangent Start tangent of the animation curve
  25323. * @param gradient Scalar amount to interpolate
  25324. * @returns InterpolatedVector3 value
  25325. */
  25326. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25327. /**
  25328. * Interpolates a Vector2 linearly
  25329. * @param startValue Start value of the animation curve
  25330. * @param endValue End value of the animation curve
  25331. * @param gradient Scalar amount to interpolate
  25332. * @returns Interpolated Vector2 value
  25333. */
  25334. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25335. /**
  25336. * Interpolates a Vector2 cubically
  25337. * @param startValue Start value of the animation curve
  25338. * @param outTangent End tangent of the animation
  25339. * @param endValue End value of the animation curve
  25340. * @param inTangent Start tangent of the animation curve
  25341. * @param gradient Scalar amount to interpolate
  25342. * @returns Interpolated Vector2 value
  25343. */
  25344. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25345. /**
  25346. * Interpolates a size linearly
  25347. * @param startValue Start value of the animation curve
  25348. * @param endValue End value of the animation curve
  25349. * @param gradient Scalar amount to interpolate
  25350. * @returns Interpolated Size value
  25351. */
  25352. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25353. /**
  25354. * Interpolates a Color3 linearly
  25355. * @param startValue Start value of the animation curve
  25356. * @param endValue End value of the animation curve
  25357. * @param gradient Scalar amount to interpolate
  25358. * @returns Interpolated Color3 value
  25359. */
  25360. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25361. /**
  25362. * @hidden Internal use only
  25363. */ getKeyValue(value: any): any;
  25364. /**
  25365. * @hidden Internal use only
  25366. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  25367. /**
  25368. * Defines the function to use to interpolate matrices
  25369. * @param startValue defines the start matrix
  25370. * @param endValue defines the end matrix
  25371. * @param gradient defines the gradient between both matrices
  25372. * @param result defines an optional target matrix where to store the interpolation
  25373. * @returns the interpolated matrix
  25374. */
  25375. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25376. /**
  25377. * Makes a copy of the animation
  25378. * @returns Cloned animation
  25379. */
  25380. clone(): Animation;
  25381. /**
  25382. * Sets the key frames of the animation
  25383. * @param values The animation key frames to set
  25384. */
  25385. setKeys(values: Array<IAnimationKey>): void;
  25386. /**
  25387. * Serializes the animation to an object
  25388. * @returns Serialized object
  25389. */
  25390. serialize(): any;
  25391. /**
  25392. * Float animation type
  25393. */
  25394. private static _ANIMATIONTYPE_FLOAT;
  25395. /**
  25396. * Vector3 animation type
  25397. */
  25398. private static _ANIMATIONTYPE_VECTOR3;
  25399. /**
  25400. * Quaternion animation type
  25401. */
  25402. private static _ANIMATIONTYPE_QUATERNION;
  25403. /**
  25404. * Matrix animation type
  25405. */
  25406. private static _ANIMATIONTYPE_MATRIX;
  25407. /**
  25408. * Color3 animation type
  25409. */
  25410. private static _ANIMATIONTYPE_COLOR3;
  25411. /**
  25412. * Vector2 animation type
  25413. */
  25414. private static _ANIMATIONTYPE_VECTOR2;
  25415. /**
  25416. * Size animation type
  25417. */
  25418. private static _ANIMATIONTYPE_SIZE;
  25419. /**
  25420. * Relative Loop Mode
  25421. */
  25422. private static _ANIMATIONLOOPMODE_RELATIVE;
  25423. /**
  25424. * Cycle Loop Mode
  25425. */
  25426. private static _ANIMATIONLOOPMODE_CYCLE;
  25427. /**
  25428. * Constant Loop Mode
  25429. */
  25430. private static _ANIMATIONLOOPMODE_CONSTANT;
  25431. /**
  25432. * Get the float animation type
  25433. */
  25434. static readonly ANIMATIONTYPE_FLOAT: number;
  25435. /**
  25436. * Get the Vector3 animation type
  25437. */
  25438. static readonly ANIMATIONTYPE_VECTOR3: number;
  25439. /**
  25440. * Get the Vector2 animation type
  25441. */
  25442. static readonly ANIMATIONTYPE_VECTOR2: number;
  25443. /**
  25444. * Get the Size animation type
  25445. */
  25446. static readonly ANIMATIONTYPE_SIZE: number;
  25447. /**
  25448. * Get the Quaternion animation type
  25449. */
  25450. static readonly ANIMATIONTYPE_QUATERNION: number;
  25451. /**
  25452. * Get the Matrix animation type
  25453. */
  25454. static readonly ANIMATIONTYPE_MATRIX: number;
  25455. /**
  25456. * Get the Color3 animation type
  25457. */
  25458. static readonly ANIMATIONTYPE_COLOR3: number;
  25459. /**
  25460. * Get the Relative Loop Mode
  25461. */
  25462. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25463. /**
  25464. * Get the Cycle Loop Mode
  25465. */
  25466. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25467. /**
  25468. * Get the Constant Loop Mode
  25469. */
  25470. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25471. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25472. /**
  25473. * Parses an animation object and creates an animation
  25474. * @param parsedAnimation Parsed animation object
  25475. * @returns Animation object
  25476. */
  25477. static Parse(parsedAnimation: any): Animation;
  25478. /**
  25479. * Appends the serialized animations from the source animations
  25480. * @param source Source containing the animations
  25481. * @param destination Target to store the animations
  25482. */
  25483. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25484. }
  25485. }
  25486. declare module BABYLON {
  25487. /**
  25488. * Base class of all the textures in babylon.
  25489. * It groups all the common properties the materials, post process, lights... might need
  25490. * in order to make a correct use of the texture.
  25491. */
  25492. export class BaseTexture implements IAnimatable {
  25493. /**
  25494. * Default anisotropic filtering level for the application.
  25495. * It is set to 4 as a good tradeoff between perf and quality.
  25496. */
  25497. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25498. /**
  25499. * Gets or sets the unique id of the texture
  25500. */
  25501. uniqueId: number;
  25502. /**
  25503. * Define the name of the texture.
  25504. */
  25505. name: string;
  25506. /**
  25507. * Gets or sets an object used to store user defined information.
  25508. */
  25509. metadata: any;
  25510. /**
  25511. * For internal use only. Please do not use.
  25512. */
  25513. reservedDataStore: any;
  25514. private _hasAlpha;
  25515. /**
  25516. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25517. */
  25518. hasAlpha: boolean;
  25519. /**
  25520. * Defines if the alpha value should be determined via the rgb values.
  25521. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25522. */
  25523. getAlphaFromRGB: boolean;
  25524. /**
  25525. * Intensity or strength of the texture.
  25526. * It is commonly used by materials to fine tune the intensity of the texture
  25527. */
  25528. level: number;
  25529. /**
  25530. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25531. * This is part of the texture as textures usually maps to one uv set.
  25532. */
  25533. coordinatesIndex: number;
  25534. private _coordinatesMode;
  25535. /**
  25536. * How a texture is mapped.
  25537. *
  25538. * | Value | Type | Description |
  25539. * | ----- | ----------------------------------- | ----------- |
  25540. * | 0 | EXPLICIT_MODE | |
  25541. * | 1 | SPHERICAL_MODE | |
  25542. * | 2 | PLANAR_MODE | |
  25543. * | 3 | CUBIC_MODE | |
  25544. * | 4 | PROJECTION_MODE | |
  25545. * | 5 | SKYBOX_MODE | |
  25546. * | 6 | INVCUBIC_MODE | |
  25547. * | 7 | EQUIRECTANGULAR_MODE | |
  25548. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25549. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25550. */
  25551. coordinatesMode: number;
  25552. /**
  25553. * | Value | Type | Description |
  25554. * | ----- | ------------------ | ----------- |
  25555. * | 0 | CLAMP_ADDRESSMODE | |
  25556. * | 1 | WRAP_ADDRESSMODE | |
  25557. * | 2 | MIRROR_ADDRESSMODE | |
  25558. */
  25559. wrapU: number;
  25560. /**
  25561. * | Value | Type | Description |
  25562. * | ----- | ------------------ | ----------- |
  25563. * | 0 | CLAMP_ADDRESSMODE | |
  25564. * | 1 | WRAP_ADDRESSMODE | |
  25565. * | 2 | MIRROR_ADDRESSMODE | |
  25566. */
  25567. wrapV: number;
  25568. /**
  25569. * | Value | Type | Description |
  25570. * | ----- | ------------------ | ----------- |
  25571. * | 0 | CLAMP_ADDRESSMODE | |
  25572. * | 1 | WRAP_ADDRESSMODE | |
  25573. * | 2 | MIRROR_ADDRESSMODE | |
  25574. */
  25575. wrapR: number;
  25576. /**
  25577. * With compliant hardware and browser (supporting anisotropic filtering)
  25578. * this defines the level of anisotropic filtering in the texture.
  25579. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25580. */
  25581. anisotropicFilteringLevel: number;
  25582. /**
  25583. * Define if the texture is a cube texture or if false a 2d texture.
  25584. */
  25585. isCube: boolean;
  25586. /**
  25587. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25588. */
  25589. is3D: boolean;
  25590. /**
  25591. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25592. * HDR texture are usually stored in linear space.
  25593. * This only impacts the PBR and Background materials
  25594. */
  25595. gammaSpace: boolean;
  25596. /**
  25597. * Gets whether or not the texture contains RGBD data.
  25598. */
  25599. readonly isRGBD: boolean;
  25600. /**
  25601. * Is Z inverted in the texture (useful in a cube texture).
  25602. */
  25603. invertZ: boolean;
  25604. /**
  25605. * Are mip maps generated for this texture or not.
  25606. */
  25607. readonly noMipmap: boolean;
  25608. /**
  25609. * @hidden
  25610. */
  25611. lodLevelInAlpha: boolean;
  25612. /**
  25613. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25614. */
  25615. lodGenerationOffset: number;
  25616. /**
  25617. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25618. */
  25619. lodGenerationScale: number;
  25620. /**
  25621. * Define if the texture is a render target.
  25622. */
  25623. isRenderTarget: boolean;
  25624. /**
  25625. * Define the unique id of the texture in the scene.
  25626. */
  25627. readonly uid: string;
  25628. /**
  25629. * Return a string representation of the texture.
  25630. * @returns the texture as a string
  25631. */
  25632. toString(): string;
  25633. /**
  25634. * Get the class name of the texture.
  25635. * @returns "BaseTexture"
  25636. */
  25637. getClassName(): string;
  25638. /**
  25639. * Define the list of animation attached to the texture.
  25640. */
  25641. animations: Animation[];
  25642. /**
  25643. * An event triggered when the texture is disposed.
  25644. */
  25645. onDisposeObservable: Observable<BaseTexture>;
  25646. private _onDisposeObserver;
  25647. /**
  25648. * Callback triggered when the texture has been disposed.
  25649. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25650. */
  25651. onDispose: () => void;
  25652. /**
  25653. * Define the current state of the loading sequence when in delayed load mode.
  25654. */
  25655. delayLoadState: number;
  25656. private _scene;
  25657. /** @hidden */ texture: Nullable<InternalTexture>;
  25658. private _uid;
  25659. /**
  25660. * Define if the texture is preventinga material to render or not.
  25661. * If not and the texture is not ready, the engine will use a default black texture instead.
  25662. */
  25663. readonly isBlocking: boolean;
  25664. /**
  25665. * Instantiates a new BaseTexture.
  25666. * Base class of all the textures in babylon.
  25667. * It groups all the common properties the materials, post process, lights... might need
  25668. * in order to make a correct use of the texture.
  25669. * @param scene Define the scene the texture blongs to
  25670. */
  25671. constructor(scene: Nullable<Scene>);
  25672. /**
  25673. * Get the scene the texture belongs to.
  25674. * @returns the scene or null if undefined
  25675. */
  25676. getScene(): Nullable<Scene>;
  25677. /**
  25678. * Get the texture transform matrix used to offset tile the texture for istance.
  25679. * @returns the transformation matrix
  25680. */
  25681. getTextureMatrix(): Matrix;
  25682. /**
  25683. * Get the texture reflection matrix used to rotate/transform the reflection.
  25684. * @returns the reflection matrix
  25685. */
  25686. getReflectionTextureMatrix(): Matrix;
  25687. /**
  25688. * Get the underlying lower level texture from Babylon.
  25689. * @returns the insternal texture
  25690. */
  25691. getInternalTexture(): Nullable<InternalTexture>;
  25692. /**
  25693. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25694. * @returns true if ready or not blocking
  25695. */
  25696. isReadyOrNotBlocking(): boolean;
  25697. /**
  25698. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25699. * @returns true if fully ready
  25700. */
  25701. isReady(): boolean;
  25702. private _cachedSize;
  25703. /**
  25704. * Get the size of the texture.
  25705. * @returns the texture size.
  25706. */
  25707. getSize(): ISize;
  25708. /**
  25709. * Get the base size of the texture.
  25710. * It can be different from the size if the texture has been resized for POT for instance
  25711. * @returns the base size
  25712. */
  25713. getBaseSize(): ISize;
  25714. /**
  25715. * Update the sampling mode of the texture.
  25716. * Default is Trilinear mode.
  25717. *
  25718. * | Value | Type | Description |
  25719. * | ----- | ------------------ | ----------- |
  25720. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25721. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25722. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25723. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25724. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25725. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25726. * | 7 | NEAREST_LINEAR | |
  25727. * | 8 | NEAREST_NEAREST | |
  25728. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25729. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25730. * | 11 | LINEAR_LINEAR | |
  25731. * | 12 | LINEAR_NEAREST | |
  25732. *
  25733. * > _mag_: magnification filter (close to the viewer)
  25734. * > _min_: minification filter (far from the viewer)
  25735. * > _mip_: filter used between mip map levels
  25736. *@param samplingMode Define the new sampling mode of the texture
  25737. */
  25738. updateSamplingMode(samplingMode: number): void;
  25739. /**
  25740. * Scales the texture if is `canRescale()`
  25741. * @param ratio the resize factor we want to use to rescale
  25742. */
  25743. scale(ratio: number): void;
  25744. /**
  25745. * Get if the texture can rescale.
  25746. */
  25747. readonly canRescale: boolean;
  25748. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25749. /** @hidden */ rebuild(): void;
  25750. /**
  25751. * Triggers the load sequence in delayed load mode.
  25752. */
  25753. delayLoad(): void;
  25754. /**
  25755. * Clones the texture.
  25756. * @returns the cloned texture
  25757. */
  25758. clone(): Nullable<BaseTexture>;
  25759. /**
  25760. * Get the texture underlying type (INT, FLOAT...)
  25761. */
  25762. readonly textureType: number;
  25763. /**
  25764. * Get the texture underlying format (RGB, RGBA...)
  25765. */
  25766. readonly textureFormat: number;
  25767. /**
  25768. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25769. * This will returns an RGBA array buffer containing either in values (0-255) or
  25770. * float values (0-1) depending of the underlying buffer type.
  25771. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25772. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25773. * @param buffer defines a user defined buffer to fill with data (can be null)
  25774. * @returns The Array buffer containing the pixels data.
  25775. */
  25776. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25777. /**
  25778. * Release and destroy the underlying lower level texture aka internalTexture.
  25779. */
  25780. releaseInternalTexture(): void;
  25781. /**
  25782. * Get the polynomial representation of the texture data.
  25783. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25784. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25785. */
  25786. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25787. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25788. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25789. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25790. /**
  25791. * Dispose the texture and release its associated resources.
  25792. */
  25793. dispose(): void;
  25794. /**
  25795. * Serialize the texture into a JSON representation that can be parsed later on.
  25796. * @returns the JSON representation of the texture
  25797. */
  25798. serialize(): any;
  25799. /**
  25800. * Helper function to be called back once a list of texture contains only ready textures.
  25801. * @param textures Define the list of textures to wait for
  25802. * @param callback Define the callback triggered once the entire list will be ready
  25803. */
  25804. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25805. }
  25806. }
  25807. declare module BABYLON {
  25808. /**
  25809. * Uniform buffer objects.
  25810. *
  25811. * Handles blocks of uniform on the GPU.
  25812. *
  25813. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25814. *
  25815. * For more information, please refer to :
  25816. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25817. */
  25818. export class UniformBuffer {
  25819. private _engine;
  25820. private _buffer;
  25821. private _data;
  25822. private _bufferData;
  25823. private _dynamic?;
  25824. private _uniformLocations;
  25825. private _uniformSizes;
  25826. private _uniformLocationPointer;
  25827. private _needSync;
  25828. private _noUBO;
  25829. private _currentEffect;
  25830. private static _MAX_UNIFORM_SIZE;
  25831. private static _tempBuffer;
  25832. /**
  25833. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25834. * This is dynamic to allow compat with webgl 1 and 2.
  25835. * You will need to pass the name of the uniform as well as the value.
  25836. */
  25837. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25838. /**
  25839. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25840. * This is dynamic to allow compat with webgl 1 and 2.
  25841. * You will need to pass the name of the uniform as well as the value.
  25842. */
  25843. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25844. /**
  25845. * Lambda to Update a single float in a uniform buffer.
  25846. * This is dynamic to allow compat with webgl 1 and 2.
  25847. * You will need to pass the name of the uniform as well as the value.
  25848. */
  25849. updateFloat: (name: string, x: number) => void;
  25850. /**
  25851. * Lambda to Update a vec2 of float in a uniform buffer.
  25852. * This is dynamic to allow compat with webgl 1 and 2.
  25853. * You will need to pass the name of the uniform as well as the value.
  25854. */
  25855. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25856. /**
  25857. * Lambda to Update a vec3 of float in a uniform buffer.
  25858. * This is dynamic to allow compat with webgl 1 and 2.
  25859. * You will need to pass the name of the uniform as well as the value.
  25860. */
  25861. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25862. /**
  25863. * Lambda to Update a vec4 of float in a uniform buffer.
  25864. * This is dynamic to allow compat with webgl 1 and 2.
  25865. * You will need to pass the name of the uniform as well as the value.
  25866. */
  25867. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25868. /**
  25869. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25870. * This is dynamic to allow compat with webgl 1 and 2.
  25871. * You will need to pass the name of the uniform as well as the value.
  25872. */
  25873. updateMatrix: (name: string, mat: Matrix) => void;
  25874. /**
  25875. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25876. * This is dynamic to allow compat with webgl 1 and 2.
  25877. * You will need to pass the name of the uniform as well as the value.
  25878. */
  25879. updateVector3: (name: string, vector: Vector3) => void;
  25880. /**
  25881. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25882. * This is dynamic to allow compat with webgl 1 and 2.
  25883. * You will need to pass the name of the uniform as well as the value.
  25884. */
  25885. updateVector4: (name: string, vector: Vector4) => void;
  25886. /**
  25887. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25888. * This is dynamic to allow compat with webgl 1 and 2.
  25889. * You will need to pass the name of the uniform as well as the value.
  25890. */
  25891. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25892. /**
  25893. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25894. * This is dynamic to allow compat with webgl 1 and 2.
  25895. * You will need to pass the name of the uniform as well as the value.
  25896. */
  25897. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25898. /**
  25899. * Instantiates a new Uniform buffer objects.
  25900. *
  25901. * Handles blocks of uniform on the GPU.
  25902. *
  25903. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25904. *
  25905. * For more information, please refer to :
  25906. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25907. * @param engine Define the engine the buffer is associated with
  25908. * @param data Define the data contained in the buffer
  25909. * @param dynamic Define if the buffer is updatable
  25910. */
  25911. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25912. /**
  25913. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25914. * or just falling back on setUniformXXX calls.
  25915. */
  25916. readonly useUbo: boolean;
  25917. /**
  25918. * Indicates if the WebGL underlying uniform buffer is in sync
  25919. * with the javascript cache data.
  25920. */
  25921. readonly isSync: boolean;
  25922. /**
  25923. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25924. * Also, a dynamic UniformBuffer will disable cache verification and always
  25925. * update the underlying WebGL uniform buffer to the GPU.
  25926. * @returns if Dynamic, otherwise false
  25927. */
  25928. isDynamic(): boolean;
  25929. /**
  25930. * The data cache on JS side.
  25931. * @returns the underlying data as a float array
  25932. */
  25933. getData(): Float32Array;
  25934. /**
  25935. * The underlying WebGL Uniform buffer.
  25936. * @returns the webgl buffer
  25937. */
  25938. getBuffer(): Nullable<DataBuffer>;
  25939. /**
  25940. * std140 layout specifies how to align data within an UBO structure.
  25941. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25942. * for specs.
  25943. */
  25944. private _fillAlignment;
  25945. /**
  25946. * Adds an uniform in the buffer.
  25947. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25948. * for the layout to be correct !
  25949. * @param name Name of the uniform, as used in the uniform block in the shader.
  25950. * @param size Data size, or data directly.
  25951. */
  25952. addUniform(name: string, size: number | number[]): void;
  25953. /**
  25954. * Adds a Matrix 4x4 to the uniform buffer.
  25955. * @param name Name of the uniform, as used in the uniform block in the shader.
  25956. * @param mat A 4x4 matrix.
  25957. */
  25958. addMatrix(name: string, mat: Matrix): void;
  25959. /**
  25960. * Adds a vec2 to the uniform buffer.
  25961. * @param name Name of the uniform, as used in the uniform block in the shader.
  25962. * @param x Define the x component value of the vec2
  25963. * @param y Define the y component value of the vec2
  25964. */
  25965. addFloat2(name: string, x: number, y: number): void;
  25966. /**
  25967. * Adds a vec3 to the uniform buffer.
  25968. * @param name Name of the uniform, as used in the uniform block in the shader.
  25969. * @param x Define the x component value of the vec3
  25970. * @param y Define the y component value of the vec3
  25971. * @param z Define the z component value of the vec3
  25972. */
  25973. addFloat3(name: string, x: number, y: number, z: number): void;
  25974. /**
  25975. * Adds a vec3 to the uniform buffer.
  25976. * @param name Name of the uniform, as used in the uniform block in the shader.
  25977. * @param color Define the vec3 from a Color
  25978. */
  25979. addColor3(name: string, color: Color3): void;
  25980. /**
  25981. * Adds a vec4 to the uniform buffer.
  25982. * @param name Name of the uniform, as used in the uniform block in the shader.
  25983. * @param color Define the rgb components from a Color
  25984. * @param alpha Define the a component of the vec4
  25985. */
  25986. addColor4(name: string, color: Color3, alpha: number): void;
  25987. /**
  25988. * Adds a vec3 to the uniform buffer.
  25989. * @param name Name of the uniform, as used in the uniform block in the shader.
  25990. * @param vector Define the vec3 components from a Vector
  25991. */
  25992. addVector3(name: string, vector: Vector3): void;
  25993. /**
  25994. * Adds a Matrix 3x3 to the uniform buffer.
  25995. * @param name Name of the uniform, as used in the uniform block in the shader.
  25996. */
  25997. addMatrix3x3(name: string): void;
  25998. /**
  25999. * Adds a Matrix 2x2 to the uniform buffer.
  26000. * @param name Name of the uniform, as used in the uniform block in the shader.
  26001. */
  26002. addMatrix2x2(name: string): void;
  26003. /**
  26004. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26005. */
  26006. create(): void;
  26007. /** @hidden */ rebuild(): void;
  26008. /**
  26009. * Updates the WebGL Uniform Buffer on the GPU.
  26010. * If the `dynamic` flag is set to true, no cache comparison is done.
  26011. * Otherwise, the buffer will be updated only if the cache differs.
  26012. */
  26013. update(): void;
  26014. /**
  26015. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26016. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26017. * @param data Define the flattened data
  26018. * @param size Define the size of the data.
  26019. */
  26020. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26021. private _updateMatrix3x3ForUniform;
  26022. private _updateMatrix3x3ForEffect;
  26023. private _updateMatrix2x2ForEffect;
  26024. private _updateMatrix2x2ForUniform;
  26025. private _updateFloatForEffect;
  26026. private _updateFloatForUniform;
  26027. private _updateFloat2ForEffect;
  26028. private _updateFloat2ForUniform;
  26029. private _updateFloat3ForEffect;
  26030. private _updateFloat3ForUniform;
  26031. private _updateFloat4ForEffect;
  26032. private _updateFloat4ForUniform;
  26033. private _updateMatrixForEffect;
  26034. private _updateMatrixForUniform;
  26035. private _updateVector3ForEffect;
  26036. private _updateVector3ForUniform;
  26037. private _updateVector4ForEffect;
  26038. private _updateVector4ForUniform;
  26039. private _updateColor3ForEffect;
  26040. private _updateColor3ForUniform;
  26041. private _updateColor4ForEffect;
  26042. private _updateColor4ForUniform;
  26043. /**
  26044. * Sets a sampler uniform on the effect.
  26045. * @param name Define the name of the sampler.
  26046. * @param texture Define the texture to set in the sampler
  26047. */
  26048. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26049. /**
  26050. * Directly updates the value of the uniform in the cache AND on the GPU.
  26051. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26052. * @param data Define the flattened data
  26053. */
  26054. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26055. /**
  26056. * Binds this uniform buffer to an effect.
  26057. * @param effect Define the effect to bind the buffer to
  26058. * @param name Name of the uniform block in the shader.
  26059. */
  26060. bindToEffect(effect: Effect, name: string): void;
  26061. /**
  26062. * Disposes the uniform buffer.
  26063. */
  26064. dispose(): void;
  26065. }
  26066. }
  26067. declare module BABYLON {
  26068. /**
  26069. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26071. */
  26072. export class Analyser {
  26073. /**
  26074. * Gets or sets the smoothing
  26075. * @ignorenaming
  26076. */
  26077. SMOOTHING: number;
  26078. /**
  26079. * Gets or sets the FFT table size
  26080. * @ignorenaming
  26081. */
  26082. FFT_SIZE: number;
  26083. /**
  26084. * Gets or sets the bar graph amplitude
  26085. * @ignorenaming
  26086. */
  26087. BARGRAPHAMPLITUDE: number;
  26088. /**
  26089. * Gets or sets the position of the debug canvas
  26090. * @ignorenaming
  26091. */
  26092. DEBUGCANVASPOS: {
  26093. x: number;
  26094. y: number;
  26095. };
  26096. /**
  26097. * Gets or sets the debug canvas size
  26098. * @ignorenaming
  26099. */
  26100. DEBUGCANVASSIZE: {
  26101. width: number;
  26102. height: number;
  26103. };
  26104. private _byteFreqs;
  26105. private _byteTime;
  26106. private _floatFreqs;
  26107. private _webAudioAnalyser;
  26108. private _debugCanvas;
  26109. private _debugCanvasContext;
  26110. private _scene;
  26111. private _registerFunc;
  26112. private _audioEngine;
  26113. /**
  26114. * Creates a new analyser
  26115. * @param scene defines hosting scene
  26116. */
  26117. constructor(scene: Scene);
  26118. /**
  26119. * Get the number of data values you will have to play with for the visualization
  26120. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26121. * @returns a number
  26122. */
  26123. getFrequencyBinCount(): number;
  26124. /**
  26125. * Gets the current frequency data as a byte array
  26126. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26127. * @returns a Uint8Array
  26128. */
  26129. getByteFrequencyData(): Uint8Array;
  26130. /**
  26131. * Gets the current waveform as a byte array
  26132. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26133. * @returns a Uint8Array
  26134. */
  26135. getByteTimeDomainData(): Uint8Array;
  26136. /**
  26137. * Gets the current frequency data as a float array
  26138. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26139. * @returns a Float32Array
  26140. */
  26141. getFloatFrequencyData(): Float32Array;
  26142. /**
  26143. * Renders the debug canvas
  26144. */
  26145. drawDebugCanvas(): void;
  26146. /**
  26147. * Stops rendering the debug canvas and removes it
  26148. */
  26149. stopDebugCanvas(): void;
  26150. /**
  26151. * Connects two audio nodes
  26152. * @param inputAudioNode defines first node to connect
  26153. * @param outputAudioNode defines second node to connect
  26154. */
  26155. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26156. /**
  26157. * Releases all associated resources
  26158. */
  26159. dispose(): void;
  26160. }
  26161. }
  26162. declare module BABYLON {
  26163. /**
  26164. * This represents an audio engine and it is responsible
  26165. * to play, synchronize and analyse sounds throughout the application.
  26166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26167. */
  26168. export interface IAudioEngine extends IDisposable {
  26169. /**
  26170. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26171. */
  26172. readonly canUseWebAudio: boolean;
  26173. /**
  26174. * Gets the current AudioContext if available.
  26175. */
  26176. readonly audioContext: Nullable<AudioContext>;
  26177. /**
  26178. * The master gain node defines the global audio volume of your audio engine.
  26179. */
  26180. readonly masterGain: GainNode;
  26181. /**
  26182. * Gets whether or not mp3 are supported by your browser.
  26183. */
  26184. readonly isMP3supported: boolean;
  26185. /**
  26186. * Gets whether or not ogg are supported by your browser.
  26187. */
  26188. readonly isOGGsupported: boolean;
  26189. /**
  26190. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26191. * @ignoreNaming
  26192. */
  26193. WarnedWebAudioUnsupported: boolean;
  26194. /**
  26195. * Defines if the audio engine relies on a custom unlocked button.
  26196. * In this case, the embedded button will not be displayed.
  26197. */
  26198. useCustomUnlockedButton: boolean;
  26199. /**
  26200. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26201. */
  26202. readonly unlocked: boolean;
  26203. /**
  26204. * Event raised when audio has been unlocked on the browser.
  26205. */
  26206. onAudioUnlockedObservable: Observable<AudioEngine>;
  26207. /**
  26208. * Event raised when audio has been locked on the browser.
  26209. */
  26210. onAudioLockedObservable: Observable<AudioEngine>;
  26211. /**
  26212. * Flags the audio engine in Locked state.
  26213. * This happens due to new browser policies preventing audio to autoplay.
  26214. */
  26215. lock(): void;
  26216. /**
  26217. * Unlocks the audio engine once a user action has been done on the dom.
  26218. * This is helpful to resume play once browser policies have been satisfied.
  26219. */
  26220. unlock(): void;
  26221. }
  26222. /**
  26223. * This represents the default audio engine used in babylon.
  26224. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26226. */
  26227. export class AudioEngine implements IAudioEngine {
  26228. private _audioContext;
  26229. private _audioContextInitialized;
  26230. private _muteButton;
  26231. private _hostElement;
  26232. /**
  26233. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26234. */
  26235. canUseWebAudio: boolean;
  26236. /**
  26237. * The master gain node defines the global audio volume of your audio engine.
  26238. */
  26239. masterGain: GainNode;
  26240. /**
  26241. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26242. * @ignoreNaming
  26243. */
  26244. WarnedWebAudioUnsupported: boolean;
  26245. /**
  26246. * Gets whether or not mp3 are supported by your browser.
  26247. */
  26248. isMP3supported: boolean;
  26249. /**
  26250. * Gets whether or not ogg are supported by your browser.
  26251. */
  26252. isOGGsupported: boolean;
  26253. /**
  26254. * Gets whether audio has been unlocked on the device.
  26255. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26256. * a user interaction has happened.
  26257. */
  26258. unlocked: boolean;
  26259. /**
  26260. * Defines if the audio engine relies on a custom unlocked button.
  26261. * In this case, the embedded button will not be displayed.
  26262. */
  26263. useCustomUnlockedButton: boolean;
  26264. /**
  26265. * Event raised when audio has been unlocked on the browser.
  26266. */
  26267. onAudioUnlockedObservable: Observable<AudioEngine>;
  26268. /**
  26269. * Event raised when audio has been locked on the browser.
  26270. */
  26271. onAudioLockedObservable: Observable<AudioEngine>;
  26272. /**
  26273. * Gets the current AudioContext if available.
  26274. */
  26275. readonly audioContext: Nullable<AudioContext>;
  26276. private _connectedAnalyser;
  26277. /**
  26278. * Instantiates a new audio engine.
  26279. *
  26280. * There should be only one per page as some browsers restrict the number
  26281. * of audio contexts you can create.
  26282. * @param hostElement defines the host element where to display the mute icon if necessary
  26283. */
  26284. constructor(hostElement?: Nullable<HTMLElement>);
  26285. /**
  26286. * Flags the audio engine in Locked state.
  26287. * This happens due to new browser policies preventing audio to autoplay.
  26288. */
  26289. lock(): void;
  26290. /**
  26291. * Unlocks the audio engine once a user action has been done on the dom.
  26292. * This is helpful to resume play once browser policies have been satisfied.
  26293. */
  26294. unlock(): void;
  26295. private _resumeAudioContext;
  26296. private _initializeAudioContext;
  26297. private _tryToRun;
  26298. private _triggerRunningState;
  26299. private _triggerSuspendedState;
  26300. private _displayMuteButton;
  26301. private _moveButtonToTopLeft;
  26302. private _onResize;
  26303. private _hideMuteButton;
  26304. /**
  26305. * Destroy and release the resources associated with the audio ccontext.
  26306. */
  26307. dispose(): void;
  26308. /**
  26309. * Gets the global volume sets on the master gain.
  26310. * @returns the global volume if set or -1 otherwise
  26311. */
  26312. getGlobalVolume(): number;
  26313. /**
  26314. * Sets the global volume of your experience (sets on the master gain).
  26315. * @param newVolume Defines the new global volume of the application
  26316. */
  26317. setGlobalVolume(newVolume: number): void;
  26318. /**
  26319. * Connect the audio engine to an audio analyser allowing some amazing
  26320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26322. * @param analyser The analyser to connect to the engine
  26323. */
  26324. connectToAnalyser(analyser: Analyser): void;
  26325. }
  26326. }
  26327. declare module BABYLON {
  26328. /**
  26329. * Interface used to present a loading screen while loading a scene
  26330. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26331. */
  26332. export interface ILoadingScreen {
  26333. /**
  26334. * Function called to display the loading screen
  26335. */
  26336. displayLoadingUI: () => void;
  26337. /**
  26338. * Function called to hide the loading screen
  26339. */
  26340. hideLoadingUI: () => void;
  26341. /**
  26342. * Gets or sets the color to use for the background
  26343. */
  26344. loadingUIBackgroundColor: string;
  26345. /**
  26346. * Gets or sets the text to display while loading
  26347. */
  26348. loadingUIText: string;
  26349. }
  26350. /**
  26351. * Class used for the default loading screen
  26352. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26353. */
  26354. export class DefaultLoadingScreen implements ILoadingScreen {
  26355. private _renderingCanvas;
  26356. private _loadingText;
  26357. private _loadingDivBackgroundColor;
  26358. private _loadingDiv;
  26359. private _loadingTextDiv;
  26360. /**
  26361. * Creates a new default loading screen
  26362. * @param _renderingCanvas defines the canvas used to render the scene
  26363. * @param _loadingText defines the default text to display
  26364. * @param _loadingDivBackgroundColor defines the default background color
  26365. */
  26366. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26367. /**
  26368. * Function called to display the loading screen
  26369. */
  26370. displayLoadingUI(): void;
  26371. /**
  26372. * Function called to hide the loading screen
  26373. */
  26374. hideLoadingUI(): void;
  26375. /**
  26376. * Gets or sets the text to display while loading
  26377. */
  26378. loadingUIText: string;
  26379. /**
  26380. * Gets or sets the color to use for the background
  26381. */
  26382. loadingUIBackgroundColor: string;
  26383. private _resizeLoadingUI;
  26384. }
  26385. }
  26386. declare module BABYLON {
  26387. /** @hidden */
  26388. export class WebGLPipelineContext implements IPipelineContext {
  26389. engine: Engine;
  26390. program: Nullable<WebGLProgram>;
  26391. context?: WebGLRenderingContext;
  26392. vertexShader?: WebGLShader;
  26393. fragmentShader?: WebGLShader;
  26394. isParallelCompiled: boolean;
  26395. onCompiled?: () => void;
  26396. transformFeedback?: WebGLTransformFeedback | null;
  26397. readonly isAsync: boolean;
  26398. readonly isReady: boolean; handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26399. }
  26400. }
  26401. declare module BABYLON {
  26402. /** @hidden */
  26403. export class WebGLDataBuffer extends DataBuffer {
  26404. private _buffer;
  26405. constructor(resource: WebGLBuffer);
  26406. readonly underlyingResource: any;
  26407. }
  26408. }
  26409. declare module BABYLON {
  26410. /**
  26411. * Settings for finer control over video usage
  26412. */
  26413. export interface VideoTextureSettings {
  26414. /**
  26415. * Applies `autoplay` to video, if specified
  26416. */
  26417. autoPlay?: boolean;
  26418. /**
  26419. * Applies `loop` to video, if specified
  26420. */
  26421. loop?: boolean;
  26422. /**
  26423. * Automatically updates internal texture from video at every frame in the render loop
  26424. */
  26425. autoUpdateTexture: boolean;
  26426. /**
  26427. * Image src displayed during the video loading or until the user interacts with the video.
  26428. */
  26429. poster?: string;
  26430. }
  26431. /**
  26432. * If you want to display a video in your scene, this is the special texture for that.
  26433. * This special texture works similar to other textures, with the exception of a few parameters.
  26434. * @see https://doc.babylonjs.com/how_to/video_texture
  26435. */
  26436. export class VideoTexture extends Texture {
  26437. /**
  26438. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26439. */
  26440. readonly autoUpdateTexture: boolean;
  26441. /**
  26442. * The video instance used by the texture internally
  26443. */
  26444. readonly video: HTMLVideoElement;
  26445. private _onUserActionRequestedObservable;
  26446. /**
  26447. * Event triggerd when a dom action is required by the user to play the video.
  26448. * This happens due to recent changes in browser policies preventing video to auto start.
  26449. */
  26450. readonly onUserActionRequestedObservable: Observable<Texture>;
  26451. private _generateMipMaps;
  26452. private _engine;
  26453. private _stillImageCaptured;
  26454. private _displayingPosterTexture;
  26455. private _settings;
  26456. private _createInternalTextureOnEvent;
  26457. /**
  26458. * Creates a video texture.
  26459. * If you want to display a video in your scene, this is the special texture for that.
  26460. * This special texture works similar to other textures, with the exception of a few parameters.
  26461. * @see https://doc.babylonjs.com/how_to/video_texture
  26462. * @param name optional name, will detect from video source, if not defined
  26463. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26464. * @param scene is obviously the current scene.
  26465. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26466. * @param invertY is false by default but can be used to invert video on Y axis
  26467. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26468. * @param settings allows finer control over video usage
  26469. */
  26470. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26471. private _getName;
  26472. private _getVideo;
  26473. private _createInternalTexture;
  26474. private reset;
  26475. /**
  26476. * @hidden Internal method to initiate `update`.
  26477. */ rebuild(): void;
  26478. /**
  26479. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26480. */
  26481. update(): void;
  26482. /**
  26483. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26484. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26485. */
  26486. updateTexture(isVisible: boolean): void;
  26487. protected _updateInternalTexture: () => void;
  26488. /**
  26489. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26490. * @param url New url.
  26491. */
  26492. updateURL(url: string): void;
  26493. /**
  26494. * Dispose the texture and release its associated resources.
  26495. */
  26496. dispose(): void;
  26497. /**
  26498. * Creates a video texture straight from a stream.
  26499. * @param scene Define the scene the texture should be created in
  26500. * @param stream Define the stream the texture should be created from
  26501. * @returns The created video texture as a promise
  26502. */
  26503. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26504. /**
  26505. * Creates a video texture straight from your WebCam video feed.
  26506. * @param scene Define the scene the texture should be created in
  26507. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26508. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26509. * @returns The created video texture as a promise
  26510. */
  26511. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26512. minWidth: number;
  26513. maxWidth: number;
  26514. minHeight: number;
  26515. maxHeight: number;
  26516. deviceId: string;
  26517. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26518. /**
  26519. * Creates a video texture straight from your WebCam video feed.
  26520. * @param scene Define the scene the texture should be created in
  26521. * @param onReady Define a callback to triggered once the texture will be ready
  26522. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26523. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26524. */
  26525. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26526. minWidth: number;
  26527. maxWidth: number;
  26528. minHeight: number;
  26529. maxHeight: number;
  26530. deviceId: string;
  26531. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26532. }
  26533. }
  26534. declare module BABYLON {
  26535. /**
  26536. * Interface for attribute information associated with buffer instanciation
  26537. */
  26538. export class InstancingAttributeInfo {
  26539. /**
  26540. * Index/offset of the attribute in the vertex shader
  26541. */
  26542. index: number;
  26543. /**
  26544. * size of the attribute, 1, 2, 3 or 4
  26545. */
  26546. attributeSize: number;
  26547. /**
  26548. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26549. * default is FLOAT
  26550. */
  26551. attribyteType: number;
  26552. /**
  26553. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26554. */
  26555. normalized: boolean;
  26556. /**
  26557. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26558. */
  26559. offset: number;
  26560. /**
  26561. * Name of the GLSL attribute, for debugging purpose only
  26562. */
  26563. attributeName: string;
  26564. }
  26565. /**
  26566. * Define options used to create a depth texture
  26567. */
  26568. export class DepthTextureCreationOptions {
  26569. /** Specifies whether or not a stencil should be allocated in the texture */
  26570. generateStencil?: boolean;
  26571. /** Specifies whether or not bilinear filtering is enable on the texture */
  26572. bilinearFiltering?: boolean;
  26573. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26574. comparisonFunction?: number;
  26575. /** Specifies if the created texture is a cube texture */
  26576. isCube?: boolean;
  26577. }
  26578. /**
  26579. * Class used to describe the capabilities of the engine relatively to the current browser
  26580. */
  26581. export class EngineCapabilities {
  26582. /** Maximum textures units per fragment shader */
  26583. maxTexturesImageUnits: number;
  26584. /** Maximum texture units per vertex shader */
  26585. maxVertexTextureImageUnits: number;
  26586. /** Maximum textures units in the entire pipeline */
  26587. maxCombinedTexturesImageUnits: number;
  26588. /** Maximum texture size */
  26589. maxTextureSize: number;
  26590. /** Maximum cube texture size */
  26591. maxCubemapTextureSize: number;
  26592. /** Maximum render texture size */
  26593. maxRenderTextureSize: number;
  26594. /** Maximum number of vertex attributes */
  26595. maxVertexAttribs: number;
  26596. /** Maximum number of varyings */
  26597. maxVaryingVectors: number;
  26598. /** Maximum number of uniforms per vertex shader */
  26599. maxVertexUniformVectors: number;
  26600. /** Maximum number of uniforms per fragment shader */
  26601. maxFragmentUniformVectors: number;
  26602. /** Defines if standard derivates (dx/dy) are supported */
  26603. standardDerivatives: boolean;
  26604. /** Defines if s3tc texture compression is supported */
  26605. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26606. /** Defines if pvrtc texture compression is supported */
  26607. pvrtc: any;
  26608. /** Defines if etc1 texture compression is supported */
  26609. etc1: any;
  26610. /** Defines if etc2 texture compression is supported */
  26611. etc2: any;
  26612. /** Defines if astc texture compression is supported */
  26613. astc: any;
  26614. /** Defines if float textures are supported */
  26615. textureFloat: boolean;
  26616. /** Defines if vertex array objects are supported */
  26617. vertexArrayObject: boolean;
  26618. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26619. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26620. /** Gets the maximum level of anisotropy supported */
  26621. maxAnisotropy: number;
  26622. /** Defines if instancing is supported */
  26623. instancedArrays: boolean;
  26624. /** Defines if 32 bits indices are supported */
  26625. uintIndices: boolean;
  26626. /** Defines if high precision shaders are supported */
  26627. highPrecisionShaderSupported: boolean;
  26628. /** Defines if depth reading in the fragment shader is supported */
  26629. fragmentDepthSupported: boolean;
  26630. /** Defines if float texture linear filtering is supported*/
  26631. textureFloatLinearFiltering: boolean;
  26632. /** Defines if rendering to float textures is supported */
  26633. textureFloatRender: boolean;
  26634. /** Defines if half float textures are supported*/
  26635. textureHalfFloat: boolean;
  26636. /** Defines if half float texture linear filtering is supported*/
  26637. textureHalfFloatLinearFiltering: boolean;
  26638. /** Defines if rendering to half float textures is supported */
  26639. textureHalfFloatRender: boolean;
  26640. /** Defines if textureLOD shader command is supported */
  26641. textureLOD: boolean;
  26642. /** Defines if draw buffers extension is supported */
  26643. drawBuffersExtension: boolean;
  26644. /** Defines if depth textures are supported */
  26645. depthTextureExtension: boolean;
  26646. /** Defines if float color buffer are supported */
  26647. colorBufferFloat: boolean;
  26648. /** Gets disjoint timer query extension (null if not supported) */
  26649. timerQuery: EXT_disjoint_timer_query;
  26650. /** Defines if timestamp can be used with timer query */
  26651. canUseTimestampForTimerQuery: boolean;
  26652. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26653. multiview: any;
  26654. /** Function used to let the system compiles shaders in background */
  26655. parallelShaderCompile: {
  26656. COMPLETION_STATUS_KHR: number;
  26657. };
  26658. }
  26659. /** Interface defining initialization parameters for Engine class */
  26660. export interface EngineOptions extends WebGLContextAttributes {
  26661. /**
  26662. * Defines if the engine should no exceed a specified device ratio
  26663. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26664. */
  26665. limitDeviceRatio?: number;
  26666. /**
  26667. * Defines if webvr should be enabled automatically
  26668. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26669. */
  26670. autoEnableWebVR?: boolean;
  26671. /**
  26672. * Defines if webgl2 should be turned off even if supported
  26673. * @see http://doc.babylonjs.com/features/webgl2
  26674. */
  26675. disableWebGL2Support?: boolean;
  26676. /**
  26677. * Defines if webaudio should be initialized as well
  26678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26679. */
  26680. audioEngine?: boolean;
  26681. /**
  26682. * Defines if animations should run using a deterministic lock step
  26683. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26684. */
  26685. deterministicLockstep?: boolean;
  26686. /** Defines the maximum steps to use with deterministic lock step mode */
  26687. lockstepMaxSteps?: number;
  26688. /**
  26689. * Defines that engine should ignore context lost events
  26690. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26691. */
  26692. doNotHandleContextLost?: boolean;
  26693. /**
  26694. * Defines that engine should ignore modifying touch action attribute and style
  26695. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26696. */
  26697. doNotHandleTouchAction?: boolean;
  26698. /**
  26699. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26700. */
  26701. useHighPrecisionFloats?: boolean;
  26702. }
  26703. /**
  26704. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26705. */
  26706. export class Engine {
  26707. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26708. static ExceptionList: ({
  26709. key: string;
  26710. capture: string;
  26711. captureConstraint: number;
  26712. targets: string[];
  26713. } | {
  26714. key: string;
  26715. capture: null;
  26716. captureConstraint: null;
  26717. targets: string[];
  26718. })[];
  26719. /** Gets the list of created engines */
  26720. static readonly Instances: Engine[];
  26721. /**
  26722. * Gets the latest created engine
  26723. */
  26724. static readonly LastCreatedEngine: Nullable<Engine>;
  26725. /**
  26726. * Gets the latest created scene
  26727. */
  26728. static readonly LastCreatedScene: Nullable<Scene>;
  26729. /**
  26730. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26731. * @param flag defines which part of the materials must be marked as dirty
  26732. * @param predicate defines a predicate used to filter which materials should be affected
  26733. */
  26734. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26735. /**
  26736. * Hidden
  26737. */ private static _TextureLoaders: IInternalTextureLoader[];
  26738. /** Defines that alpha blending is disabled */
  26739. static readonly ALPHA_DISABLE: number;
  26740. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26741. static readonly ALPHA_ADD: number;
  26742. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26743. static readonly ALPHA_COMBINE: number;
  26744. /** Defines that alpha blending to DEST - SRC * DEST */
  26745. static readonly ALPHA_SUBTRACT: number;
  26746. /** Defines that alpha blending to SRC * DEST */
  26747. static readonly ALPHA_MULTIPLY: number;
  26748. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26749. static readonly ALPHA_MAXIMIZED: number;
  26750. /** Defines that alpha blending to SRC + DEST */
  26751. static readonly ALPHA_ONEONE: number;
  26752. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26753. static readonly ALPHA_PREMULTIPLIED: number;
  26754. /**
  26755. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26756. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26757. */
  26758. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26759. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26760. static readonly ALPHA_INTERPOLATE: number;
  26761. /**
  26762. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26763. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26764. */
  26765. static readonly ALPHA_SCREENMODE: number;
  26766. /** Defines that the ressource is not delayed*/
  26767. static readonly DELAYLOADSTATE_NONE: number;
  26768. /** Defines that the ressource was successfully delay loaded */
  26769. static readonly DELAYLOADSTATE_LOADED: number;
  26770. /** Defines that the ressource is currently delay loading */
  26771. static readonly DELAYLOADSTATE_LOADING: number;
  26772. /** Defines that the ressource is delayed and has not started loading */
  26773. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26774. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26775. static readonly NEVER: number;
  26776. /** 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 */
  26777. static readonly ALWAYS: number;
  26778. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26779. static readonly LESS: number;
  26780. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26781. static readonly EQUAL: number;
  26782. /** 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 */
  26783. static readonly LEQUAL: number;
  26784. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26785. static readonly GREATER: number;
  26786. /** 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 */
  26787. static readonly GEQUAL: number;
  26788. /** 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 */
  26789. static readonly NOTEQUAL: number;
  26790. /** Passed to stencilOperation to specify that stencil value must be kept */
  26791. static readonly KEEP: number;
  26792. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26793. static readonly REPLACE: number;
  26794. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26795. static readonly INCR: number;
  26796. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26797. static readonly DECR: number;
  26798. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26799. static readonly INVERT: number;
  26800. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26801. static readonly INCR_WRAP: number;
  26802. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26803. static readonly DECR_WRAP: number;
  26804. /** Texture is not repeating outside of 0..1 UVs */
  26805. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26806. /** Texture is repeating outside of 0..1 UVs */
  26807. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26808. /** Texture is repeating and mirrored */
  26809. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26810. /** ALPHA */
  26811. static readonly TEXTUREFORMAT_ALPHA: number;
  26812. /** LUMINANCE */
  26813. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26814. /** LUMINANCE_ALPHA */
  26815. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26816. /** RGB */
  26817. static readonly TEXTUREFORMAT_RGB: number;
  26818. /** RGBA */
  26819. static readonly TEXTUREFORMAT_RGBA: number;
  26820. /** RED */
  26821. static readonly TEXTUREFORMAT_RED: number;
  26822. /** RED (2nd reference) */
  26823. static readonly TEXTUREFORMAT_R: number;
  26824. /** RG */
  26825. static readonly TEXTUREFORMAT_RG: number;
  26826. /** RED_INTEGER */
  26827. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26828. /** RED_INTEGER (2nd reference) */
  26829. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26830. /** RG_INTEGER */
  26831. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26832. /** RGB_INTEGER */
  26833. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26834. /** RGBA_INTEGER */
  26835. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26836. /** UNSIGNED_BYTE */
  26837. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26838. /** UNSIGNED_BYTE (2nd reference) */
  26839. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26840. /** FLOAT */
  26841. static readonly TEXTURETYPE_FLOAT: number;
  26842. /** HALF_FLOAT */
  26843. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26844. /** BYTE */
  26845. static readonly TEXTURETYPE_BYTE: number;
  26846. /** SHORT */
  26847. static readonly TEXTURETYPE_SHORT: number;
  26848. /** UNSIGNED_SHORT */
  26849. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26850. /** INT */
  26851. static readonly TEXTURETYPE_INT: number;
  26852. /** UNSIGNED_INT */
  26853. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26854. /** UNSIGNED_SHORT_4_4_4_4 */
  26855. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26856. /** UNSIGNED_SHORT_5_5_5_1 */
  26857. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26858. /** UNSIGNED_SHORT_5_6_5 */
  26859. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26860. /** UNSIGNED_INT_2_10_10_10_REV */
  26861. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26862. /** UNSIGNED_INT_24_8 */
  26863. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26864. /** UNSIGNED_INT_10F_11F_11F_REV */
  26865. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26866. /** UNSIGNED_INT_5_9_9_9_REV */
  26867. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26868. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26869. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26870. /** nearest is mag = nearest and min = nearest and mip = linear */
  26871. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26872. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26873. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26874. /** Trilinear is mag = linear and min = linear and mip = linear */
  26875. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26876. /** nearest is mag = nearest and min = nearest and mip = linear */
  26877. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26879. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26880. /** Trilinear is mag = linear and min = linear and mip = linear */
  26881. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26882. /** mag = nearest and min = nearest and mip = nearest */
  26883. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26884. /** mag = nearest and min = linear and mip = nearest */
  26885. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26886. /** mag = nearest and min = linear and mip = linear */
  26887. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26888. /** mag = nearest and min = linear and mip = none */
  26889. static readonly TEXTURE_NEAREST_LINEAR: number;
  26890. /** mag = nearest and min = nearest and mip = none */
  26891. static readonly TEXTURE_NEAREST_NEAREST: number;
  26892. /** mag = linear and min = nearest and mip = nearest */
  26893. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26894. /** mag = linear and min = nearest and mip = linear */
  26895. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26896. /** mag = linear and min = linear and mip = none */
  26897. static readonly TEXTURE_LINEAR_LINEAR: number;
  26898. /** mag = linear and min = nearest and mip = none */
  26899. static readonly TEXTURE_LINEAR_NEAREST: number;
  26900. /** Explicit coordinates mode */
  26901. static readonly TEXTURE_EXPLICIT_MODE: number;
  26902. /** Spherical coordinates mode */
  26903. static readonly TEXTURE_SPHERICAL_MODE: number;
  26904. /** Planar coordinates mode */
  26905. static readonly TEXTURE_PLANAR_MODE: number;
  26906. /** Cubic coordinates mode */
  26907. static readonly TEXTURE_CUBIC_MODE: number;
  26908. /** Projection coordinates mode */
  26909. static readonly TEXTURE_PROJECTION_MODE: number;
  26910. /** Skybox coordinates mode */
  26911. static readonly TEXTURE_SKYBOX_MODE: number;
  26912. /** Inverse Cubic coordinates mode */
  26913. static readonly TEXTURE_INVCUBIC_MODE: number;
  26914. /** Equirectangular coordinates mode */
  26915. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26916. /** Equirectangular Fixed coordinates mode */
  26917. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26918. /** Equirectangular Fixed Mirrored coordinates mode */
  26919. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26920. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26921. static readonly SCALEMODE_FLOOR: number;
  26922. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26923. static readonly SCALEMODE_NEAREST: number;
  26924. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26925. static readonly SCALEMODE_CEILING: number;
  26926. /**
  26927. * Returns the current npm package of the sdk
  26928. */
  26929. static readonly NpmPackage: string;
  26930. /**
  26931. * Returns the current version of the framework
  26932. */
  26933. static readonly Version: string;
  26934. /**
  26935. * Returns a string describing the current engine
  26936. */
  26937. readonly description: string;
  26938. /**
  26939. * Gets or sets the epsilon value used by collision engine
  26940. */
  26941. static CollisionsEpsilon: number;
  26942. /**
  26943. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26944. */
  26945. static ShadersRepository: string;
  26946. /**
  26947. * Method called to create the default loading screen.
  26948. * This can be overriden in your own app.
  26949. * @param canvas The rendering canvas element
  26950. * @returns The loading screen
  26951. */
  26952. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26953. /**
  26954. * Method called to create the default rescale post process on each engine.
  26955. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26956. /**
  26957. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26958. */
  26959. forcePOTTextures: boolean;
  26960. /**
  26961. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26962. */
  26963. isFullscreen: boolean;
  26964. /**
  26965. * Gets a boolean indicating if the pointer is currently locked
  26966. */
  26967. isPointerLock: boolean;
  26968. /**
  26969. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26970. */
  26971. cullBackFaces: boolean;
  26972. /**
  26973. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26974. */
  26975. renderEvenInBackground: boolean;
  26976. /**
  26977. * Gets or sets a boolean indicating that cache can be kept between frames
  26978. */
  26979. preventCacheWipeBetweenFrames: boolean;
  26980. /**
  26981. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26982. **/
  26983. enableOfflineSupport: boolean;
  26984. /**
  26985. * 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)
  26986. **/
  26987. disableManifestCheck: boolean;
  26988. /**
  26989. * Gets the list of created scenes
  26990. */
  26991. scenes: Scene[];
  26992. /**
  26993. * Event raised when a new scene is created
  26994. */
  26995. onNewSceneAddedObservable: Observable<Scene>;
  26996. /**
  26997. * Gets the list of created postprocesses
  26998. */
  26999. postProcesses: PostProcess[];
  27000. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27001. validateShaderPrograms: boolean;
  27002. /**
  27003. * Observable event triggered each time the rendering canvas is resized
  27004. */
  27005. onResizeObservable: Observable<Engine>;
  27006. /**
  27007. * Observable event triggered each time the canvas loses focus
  27008. */
  27009. onCanvasBlurObservable: Observable<Engine>;
  27010. /**
  27011. * Observable event triggered each time the canvas gains focus
  27012. */
  27013. onCanvasFocusObservable: Observable<Engine>;
  27014. /**
  27015. * Observable event triggered each time the canvas receives pointerout event
  27016. */
  27017. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27018. /**
  27019. * Observable event triggered before each texture is initialized
  27020. */
  27021. onBeforeTextureInitObservable: Observable<Texture>;
  27022. /**
  27023. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27024. */
  27025. disableUniformBuffers: boolean;
  27026. /** @hidden */ uniformBuffers: UniformBuffer[];
  27027. /**
  27028. * Gets a boolean indicating that the engine supports uniform buffers
  27029. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27030. */
  27031. readonly supportsUniformBuffers: boolean;
  27032. /**
  27033. * Observable raised when the engine begins a new frame
  27034. */
  27035. onBeginFrameObservable: Observable<Engine>;
  27036. /**
  27037. * If set, will be used to request the next animation frame for the render loop
  27038. */
  27039. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27040. /**
  27041. * Observable raised when the engine ends the current frame
  27042. */
  27043. onEndFrameObservable: Observable<Engine>;
  27044. /**
  27045. * Observable raised when the engine is about to compile a shader
  27046. */
  27047. onBeforeShaderCompilationObservable: Observable<Engine>;
  27048. /**
  27049. * Observable raised when the engine has jsut compiled a shader
  27050. */
  27051. onAfterShaderCompilationObservable: Observable<Engine>;
  27052. /** @hidden */ gl: WebGLRenderingContext;
  27053. private _renderingCanvas;
  27054. private _windowIsBackground;
  27055. private _webGLVersion;
  27056. protected _highPrecisionShadersAllowed: boolean;
  27057. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27058. /**
  27059. * Gets a boolean indicating that only power of 2 textures are supported
  27060. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27061. */
  27062. readonly needPOTTextures: boolean;
  27063. /** @hidden */ badOS: boolean;
  27064. /** @hidden */ badDesktopOS: boolean;
  27065. /**
  27066. * Gets the audio engine
  27067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27068. * @ignorenaming
  27069. */
  27070. static audioEngine: IAudioEngine;
  27071. /**
  27072. * Default AudioEngine factory responsible of creating the Audio Engine.
  27073. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27074. */
  27075. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27076. /**
  27077. * Default offline support factory responsible of creating a tool used to store data locally.
  27078. * By default, this will create a Database object if the workload has been embedded.
  27079. */
  27080. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27081. private _onFocus;
  27082. private _onBlur;
  27083. private _onCanvasPointerOut;
  27084. private _onCanvasBlur;
  27085. private _onCanvasFocus;
  27086. private _onFullscreenChange;
  27087. private _onPointerLockChange;
  27088. private _hardwareScalingLevel;
  27089. /** @hidden */ caps: EngineCapabilities;
  27090. private _pointerLockRequested;
  27091. private _isStencilEnable;
  27092. private _colorWrite;
  27093. private _loadingScreen;
  27094. /** @hidden */ drawCalls: PerfCounter;
  27095. private _glVersion;
  27096. private _glRenderer;
  27097. private _glVendor;
  27098. private _videoTextureSupported;
  27099. private _renderingQueueLaunched;
  27100. private _activeRenderLoops;
  27101. private _deterministicLockstep;
  27102. private _lockstepMaxSteps;
  27103. /**
  27104. * Observable signaled when a context lost event is raised
  27105. */
  27106. onContextLostObservable: Observable<Engine>;
  27107. /**
  27108. * Observable signaled when a context restored event is raised
  27109. */
  27110. onContextRestoredObservable: Observable<Engine>;
  27111. private _onContextLost;
  27112. private _onContextRestored;
  27113. private _contextWasLost;
  27114. /** @hidden */ doNotHandleContextLost: boolean;
  27115. /**
  27116. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27118. */
  27119. doNotHandleContextLost: boolean;
  27120. private _performanceMonitor;
  27121. private _fps;
  27122. private _deltaTime;
  27123. /**
  27124. * Turn this value on if you want to pause FPS computation when in background
  27125. */
  27126. disablePerformanceMonitorInBackground: boolean;
  27127. /**
  27128. * Gets the performance monitor attached to this engine
  27129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27130. */
  27131. readonly performanceMonitor: PerformanceMonitor;
  27132. /**
  27133. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27134. */
  27135. disableVertexArrayObjects: boolean;
  27136. /** @hidden */
  27137. protected _depthCullingState: _DepthCullingState;
  27138. /** @hidden */
  27139. protected _stencilState: _StencilState;
  27140. /** @hidden */
  27141. protected _alphaState: _AlphaState;
  27142. /** @hidden */
  27143. protected _alphaMode: number;
  27144. /** @hidden */ internalTexturesCache: InternalTexture[];
  27145. /** @hidden */
  27146. protected _activeChannel: number;
  27147. private _currentTextureChannel;
  27148. /** @hidden */
  27149. protected _boundTexturesCache: {
  27150. [key: string]: Nullable<InternalTexture>;
  27151. };
  27152. /** @hidden */
  27153. protected _currentEffect: Nullable<Effect>;
  27154. /** @hidden */
  27155. protected _currentProgram: Nullable<WebGLProgram>;
  27156. private _compiledEffects;
  27157. private _vertexAttribArraysEnabled;
  27158. /** @hidden */
  27159. protected _cachedViewport: Nullable<Viewport>;
  27160. private _cachedVertexArrayObject;
  27161. /** @hidden */
  27162. protected _cachedVertexBuffers: any;
  27163. /** @hidden */
  27164. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27165. /** @hidden */
  27166. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27167. /** @hidden */ currentRenderTarget: Nullable<InternalTexture>;
  27168. private _uintIndicesCurrentlySet;
  27169. private _currentBoundBuffer;
  27170. /** @hidden */
  27171. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27172. private _currentBufferPointers;
  27173. private _currentInstanceLocations;
  27174. private _currentInstanceBuffers;
  27175. private _textureUnits;
  27176. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  27177. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  27178. private _rescalePostProcess;
  27179. private _dummyFramebuffer;
  27180. private _externalData;
  27181. /** @hidden */ bindedRenderFunction: any;
  27182. private _vaoRecordInProgress;
  27183. private _mustWipeVertexAttributes;
  27184. private _emptyTexture;
  27185. private _emptyCubeTexture;
  27186. private _emptyTexture3D;
  27187. /** @hidden */ frameHandler: number;
  27188. private _nextFreeTextureSlots;
  27189. private _maxSimultaneousTextures;
  27190. private _activeRequests;
  27191. private _texturesSupported;
  27192. /** @hidden */ textureFormatInUse: Nullable<string>;
  27193. /**
  27194. * Gets the list of texture formats supported
  27195. */
  27196. readonly texturesSupported: Array<string>;
  27197. /**
  27198. * Gets the list of texture formats in use
  27199. */
  27200. readonly textureFormatInUse: Nullable<string>;
  27201. /**
  27202. * Gets the current viewport
  27203. */
  27204. readonly currentViewport: Nullable<Viewport>;
  27205. /**
  27206. * Gets the default empty texture
  27207. */
  27208. readonly emptyTexture: InternalTexture;
  27209. /**
  27210. * Gets the default empty 3D texture
  27211. */
  27212. readonly emptyTexture3D: InternalTexture;
  27213. /**
  27214. * Gets the default empty cube texture
  27215. */
  27216. readonly emptyCubeTexture: InternalTexture;
  27217. /**
  27218. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27219. */
  27220. readonly premultipliedAlpha: boolean;
  27221. /**
  27222. * Creates a new engine
  27223. * @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
  27224. * @param antialias defines enable antialiasing (default: false)
  27225. * @param options defines further options to be sent to the getContext() function
  27226. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27227. */
  27228. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27229. /**
  27230. * Initializes a webVR display and starts listening to display change events
  27231. * The onVRDisplayChangedObservable will be notified upon these changes
  27232. * @returns The onVRDisplayChangedObservable
  27233. */
  27234. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27235. /** @hidden */ prepareVRComponent(): void;
  27236. /** @hidden */ connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27237. /** @hidden */ submitVRFrame(): void;
  27238. /**
  27239. * Call this function to leave webVR mode
  27240. * Will do nothing if webVR is not supported or if there is no webVR device
  27241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27242. */
  27243. disableVR(): void;
  27244. /**
  27245. * Gets a boolean indicating that the system is in VR mode and is presenting
  27246. * @returns true if VR mode is engaged
  27247. */
  27248. isVRPresenting(): boolean;
  27249. /** @hidden */ requestVRFrame(): void;
  27250. private _disableTouchAction;
  27251. private _rebuildInternalTextures;
  27252. private _rebuildEffects;
  27253. /**
  27254. * Gets a boolean indicating if all created effects are ready
  27255. * @returns true if all effects are ready
  27256. */
  27257. areAllEffectsReady(): boolean;
  27258. private _rebuildBuffers;
  27259. private _initGLContext;
  27260. /**
  27261. * Gets version of the current webGL context
  27262. */
  27263. readonly webGLVersion: number;
  27264. /**
  27265. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27266. */
  27267. readonly isStencilEnable: boolean;
  27268. /** @hidden */ prepareWorkingCanvas(): void;
  27269. /**
  27270. * Reset the texture cache to empty state
  27271. */
  27272. resetTextureCache(): void;
  27273. /**
  27274. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27275. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27276. * @returns true if engine is in deterministic lock step mode
  27277. */
  27278. isDeterministicLockStep(): boolean;
  27279. /**
  27280. * Gets the max steps when engine is running in deterministic lock step
  27281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27282. * @returns the max steps
  27283. */
  27284. getLockstepMaxSteps(): number;
  27285. /**
  27286. * Gets an object containing information about the current webGL context
  27287. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27288. */
  27289. getGlInfo(): {
  27290. vendor: string;
  27291. renderer: string;
  27292. version: string;
  27293. };
  27294. /**
  27295. * Gets current aspect ratio
  27296. * @param camera defines the camera to use to get the aspect ratio
  27297. * @param useScreen defines if screen size must be used (or the current render target if any)
  27298. * @returns a number defining the aspect ratio
  27299. */
  27300. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27301. /**
  27302. * Gets current screen aspect ratio
  27303. * @returns a number defining the aspect ratio
  27304. */
  27305. getScreenAspectRatio(): number;
  27306. /**
  27307. * Gets the current render width
  27308. * @param useScreen defines if screen size must be used (or the current render target if any)
  27309. * @returns a number defining the current render width
  27310. */
  27311. getRenderWidth(useScreen?: boolean): number;
  27312. /**
  27313. * Gets the current render height
  27314. * @param useScreen defines if screen size must be used (or the current render target if any)
  27315. * @returns a number defining the current render height
  27316. */
  27317. getRenderHeight(useScreen?: boolean): number;
  27318. /**
  27319. * Gets the HTML canvas attached with the current webGL context
  27320. * @returns a HTML canvas
  27321. */
  27322. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27323. /**
  27324. * Gets the client rect of the HTML canvas attached with the current webGL context
  27325. * @returns a client rectanglee
  27326. */
  27327. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27328. /**
  27329. * Defines the hardware scaling level.
  27330. * By default the hardware scaling level is computed from the window device ratio.
  27331. * 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.
  27332. * @param level defines the level to use
  27333. */
  27334. setHardwareScalingLevel(level: number): void;
  27335. /**
  27336. * Gets the current hardware scaling level.
  27337. * By default the hardware scaling level is computed from the window device ratio.
  27338. * 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.
  27339. * @returns a number indicating the current hardware scaling level
  27340. */
  27341. getHardwareScalingLevel(): number;
  27342. /**
  27343. * Gets the list of loaded textures
  27344. * @returns an array containing all loaded textures
  27345. */
  27346. getLoadedTexturesCache(): InternalTexture[];
  27347. /**
  27348. * Gets the object containing all engine capabilities
  27349. * @returns the EngineCapabilities object
  27350. */
  27351. getCaps(): EngineCapabilities;
  27352. /**
  27353. * Gets the current depth function
  27354. * @returns a number defining the depth function
  27355. */
  27356. getDepthFunction(): Nullable<number>;
  27357. /**
  27358. * Sets the current depth function
  27359. * @param depthFunc defines the function to use
  27360. */
  27361. setDepthFunction(depthFunc: number): void;
  27362. /**
  27363. * Sets the current depth function to GREATER
  27364. */
  27365. setDepthFunctionToGreater(): void;
  27366. /**
  27367. * Sets the current depth function to GEQUAL
  27368. */
  27369. setDepthFunctionToGreaterOrEqual(): void;
  27370. /**
  27371. * Sets the current depth function to LESS
  27372. */
  27373. setDepthFunctionToLess(): void;
  27374. private _cachedStencilBuffer;
  27375. private _cachedStencilFunction;
  27376. private _cachedStencilMask;
  27377. private _cachedStencilOperationPass;
  27378. private _cachedStencilOperationFail;
  27379. private _cachedStencilOperationDepthFail;
  27380. private _cachedStencilReference;
  27381. /**
  27382. * Caches the the state of the stencil buffer
  27383. */
  27384. cacheStencilState(): void;
  27385. /**
  27386. * Restores the state of the stencil buffer
  27387. */
  27388. restoreStencilState(): void;
  27389. /**
  27390. * Sets the current depth function to LEQUAL
  27391. */
  27392. setDepthFunctionToLessOrEqual(): void;
  27393. /**
  27394. * Gets a boolean indicating if stencil buffer is enabled
  27395. * @returns the current stencil buffer state
  27396. */
  27397. getStencilBuffer(): boolean;
  27398. /**
  27399. * Enable or disable the stencil buffer
  27400. * @param enable defines if the stencil buffer must be enabled or disabled
  27401. */
  27402. setStencilBuffer(enable: boolean): void;
  27403. /**
  27404. * Gets the current stencil mask
  27405. * @returns a number defining the new stencil mask to use
  27406. */
  27407. getStencilMask(): number;
  27408. /**
  27409. * Sets the current stencil mask
  27410. * @param mask defines the new stencil mask to use
  27411. */
  27412. setStencilMask(mask: number): void;
  27413. /**
  27414. * Gets the current stencil function
  27415. * @returns a number defining the stencil function to use
  27416. */
  27417. getStencilFunction(): number;
  27418. /**
  27419. * Gets the current stencil reference value
  27420. * @returns a number defining the stencil reference value to use
  27421. */
  27422. getStencilFunctionReference(): number;
  27423. /**
  27424. * Gets the current stencil mask
  27425. * @returns a number defining the stencil mask to use
  27426. */
  27427. getStencilFunctionMask(): number;
  27428. /**
  27429. * Sets the current stencil function
  27430. * @param stencilFunc defines the new stencil function to use
  27431. */
  27432. setStencilFunction(stencilFunc: number): void;
  27433. /**
  27434. * Sets the current stencil reference
  27435. * @param reference defines the new stencil reference to use
  27436. */
  27437. setStencilFunctionReference(reference: number): void;
  27438. /**
  27439. * Sets the current stencil mask
  27440. * @param mask defines the new stencil mask to use
  27441. */
  27442. setStencilFunctionMask(mask: number): void;
  27443. /**
  27444. * Gets the current stencil operation when stencil fails
  27445. * @returns a number defining stencil operation to use when stencil fails
  27446. */
  27447. getStencilOperationFail(): number;
  27448. /**
  27449. * Gets the current stencil operation when depth fails
  27450. * @returns a number defining stencil operation to use when depth fails
  27451. */
  27452. getStencilOperationDepthFail(): number;
  27453. /**
  27454. * Gets the current stencil operation when stencil passes
  27455. * @returns a number defining stencil operation to use when stencil passes
  27456. */
  27457. getStencilOperationPass(): number;
  27458. /**
  27459. * Sets the stencil operation to use when stencil fails
  27460. * @param operation defines the stencil operation to use when stencil fails
  27461. */
  27462. setStencilOperationFail(operation: number): void;
  27463. /**
  27464. * Sets the stencil operation to use when depth fails
  27465. * @param operation defines the stencil operation to use when depth fails
  27466. */
  27467. setStencilOperationDepthFail(operation: number): void;
  27468. /**
  27469. * Sets the stencil operation to use when stencil passes
  27470. * @param operation defines the stencil operation to use when stencil passes
  27471. */
  27472. setStencilOperationPass(operation: number): void;
  27473. /**
  27474. * Sets a boolean indicating if the dithering state is enabled or disabled
  27475. * @param value defines the dithering state
  27476. */
  27477. setDitheringState(value: boolean): void;
  27478. /**
  27479. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27480. * @param value defines the rasterizer state
  27481. */
  27482. setRasterizerState(value: boolean): void;
  27483. /**
  27484. * stop executing a render loop function and remove it from the execution array
  27485. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27486. */
  27487. stopRenderLoop(renderFunction?: () => void): void;
  27488. /** @hidden */ renderLoop(): void;
  27489. /**
  27490. * Register and execute a render loop. The engine can have more than one render function
  27491. * @param renderFunction defines the function to continuously execute
  27492. */
  27493. runRenderLoop(renderFunction: () => void): void;
  27494. /**
  27495. * Toggle full screen mode
  27496. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27497. */
  27498. switchFullscreen(requestPointerLock: boolean): void;
  27499. /**
  27500. * Enters full screen mode
  27501. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27502. */
  27503. enterFullscreen(requestPointerLock: boolean): void;
  27504. /**
  27505. * Exits full screen mode
  27506. */
  27507. exitFullscreen(): void;
  27508. /**
  27509. * Clear the current render buffer or the current render target (if any is set up)
  27510. * @param color defines the color to use
  27511. * @param backBuffer defines if the back buffer must be cleared
  27512. * @param depth defines if the depth buffer must be cleared
  27513. * @param stencil defines if the stencil buffer must be cleared
  27514. */
  27515. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27516. /**
  27517. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27518. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27519. * @param y defines the y-coordinate of the corner of the clear rectangle
  27520. * @param width defines the width of the clear rectangle
  27521. * @param height defines the height of the clear rectangle
  27522. * @param clearColor defines the clear color
  27523. */
  27524. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27525. /**
  27526. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27527. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27528. * @param y defines the y-coordinate of the corner of the clear rectangle
  27529. * @param width defines the width of the clear rectangle
  27530. * @param height defines the height of the clear rectangle
  27531. */
  27532. enableScissor(x: number, y: number, width: number, height: number): void;
  27533. /**
  27534. * Disable previously set scissor test rectangle
  27535. */
  27536. disableScissor(): void;
  27537. private _viewportCached;
  27538. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27539. /**
  27540. * Set the WebGL's viewport
  27541. * @param viewport defines the viewport element to be used
  27542. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27543. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27544. */
  27545. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27546. /**
  27547. * Directly set the WebGL Viewport
  27548. * @param x defines the x coordinate of the viewport (in screen space)
  27549. * @param y defines the y coordinate of the viewport (in screen space)
  27550. * @param width defines the width of the viewport (in screen space)
  27551. * @param height defines the height of the viewport (in screen space)
  27552. * @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
  27553. */
  27554. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27555. /**
  27556. * Begin a new frame
  27557. */
  27558. beginFrame(): void;
  27559. /**
  27560. * Enf the current frame
  27561. */
  27562. endFrame(): void;
  27563. /**
  27564. * Resize the view according to the canvas' size
  27565. */
  27566. resize(): void;
  27567. /**
  27568. * Force a specific size of the canvas
  27569. * @param width defines the new canvas' width
  27570. * @param height defines the new canvas' height
  27571. */
  27572. setSize(width: number, height: number): void;
  27573. /**
  27574. * Binds the frame buffer to the specified texture.
  27575. * @param texture The texture to render to or null for the default canvas
  27576. * @param faceIndex The face of the texture to render to in case of cube texture
  27577. * @param requiredWidth The width of the target to render to
  27578. * @param requiredHeight The height of the target to render to
  27579. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27580. * @param depthStencilTexture The depth stencil texture to use to render
  27581. * @param lodLevel defines le lod level to bind to the frame buffer
  27582. */
  27583. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27584. /** @hidden */ bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27585. /**
  27586. * Unbind the current render target texture from the webGL context
  27587. * @param texture defines the render target texture to unbind
  27588. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27589. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27590. */
  27591. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27592. /**
  27593. * Force the mipmap generation for the given render target texture
  27594. * @param texture defines the render target texture to use
  27595. */
  27596. generateMipMapsForCubemap(texture: InternalTexture): void;
  27597. /**
  27598. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27599. */
  27600. flushFramebuffer(): void;
  27601. /**
  27602. * Unbind the current render target and bind the default framebuffer
  27603. */
  27604. restoreDefaultFramebuffer(): void;
  27605. /**
  27606. * Create an uniform buffer
  27607. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27608. * @param elements defines the content of the uniform buffer
  27609. * @returns the webGL uniform buffer
  27610. */
  27611. createUniformBuffer(elements: FloatArray): DataBuffer;
  27612. /**
  27613. * Create a dynamic uniform buffer
  27614. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27615. * @param elements defines the content of the uniform buffer
  27616. * @returns the webGL uniform buffer
  27617. */
  27618. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27619. /**
  27620. * Update an existing uniform buffer
  27621. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27622. * @param uniformBuffer defines the target uniform buffer
  27623. * @param elements defines the content to update
  27624. * @param offset defines the offset in the uniform buffer where update should start
  27625. * @param count defines the size of the data to update
  27626. */
  27627. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27628. private _resetVertexBufferBinding;
  27629. /**
  27630. * Creates a vertex buffer
  27631. * @param data the data for the vertex buffer
  27632. * @returns the new WebGL static buffer
  27633. */
  27634. createVertexBuffer(data: DataArray): DataBuffer;
  27635. /**
  27636. * Creates a dynamic vertex buffer
  27637. * @param data the data for the dynamic vertex buffer
  27638. * @returns the new WebGL dynamic buffer
  27639. */
  27640. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27641. /**
  27642. * Update a dynamic index buffer
  27643. * @param indexBuffer defines the target index buffer
  27644. * @param indices defines the data to update
  27645. * @param offset defines the offset in the target index buffer where update should start
  27646. */
  27647. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27648. /**
  27649. * Updates a dynamic vertex buffer.
  27650. * @param vertexBuffer the vertex buffer to update
  27651. * @param data the data used to update the vertex buffer
  27652. * @param byteOffset the byte offset of the data
  27653. * @param byteLength the byte length of the data
  27654. */
  27655. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27656. private _resetIndexBufferBinding;
  27657. /**
  27658. * Creates a new index buffer
  27659. * @param indices defines the content of the index buffer
  27660. * @param updatable defines if the index buffer must be updatable
  27661. * @returns a new webGL buffer
  27662. */
  27663. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27664. /**
  27665. * Bind a webGL buffer to the webGL context
  27666. * @param buffer defines the buffer to bind
  27667. */
  27668. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27669. /**
  27670. * Bind an uniform buffer to the current webGL context
  27671. * @param buffer defines the buffer to bind
  27672. */
  27673. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27674. /**
  27675. * Bind a buffer to the current webGL context at a given location
  27676. * @param buffer defines the buffer to bind
  27677. * @param location defines the index where to bind the buffer
  27678. */
  27679. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27680. /**
  27681. * Bind a specific block at a given index in a specific shader program
  27682. * @param pipelineContext defines the pipeline context to use
  27683. * @param blockName defines the block name
  27684. * @param index defines the index where to bind the block
  27685. */
  27686. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27687. private bindIndexBuffer;
  27688. private bindBuffer;
  27689. /**
  27690. * update the bound buffer with the given data
  27691. * @param data defines the data to update
  27692. */
  27693. updateArrayBuffer(data: Float32Array): void;
  27694. private _vertexAttribPointer;
  27695. private _bindIndexBufferWithCache;
  27696. private _bindVertexBuffersAttributes;
  27697. /**
  27698. * Records a vertex array object
  27699. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27700. * @param vertexBuffers defines the list of vertex buffers to store
  27701. * @param indexBuffer defines the index buffer to store
  27702. * @param effect defines the effect to store
  27703. * @returns the new vertex array object
  27704. */
  27705. recordVertexArrayObject(vertexBuffers: {
  27706. [key: string]: VertexBuffer;
  27707. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27708. /**
  27709. * Bind a specific vertex array object
  27710. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27711. * @param vertexArrayObject defines the vertex array object to bind
  27712. * @param indexBuffer defines the index buffer to bind
  27713. */
  27714. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27715. /**
  27716. * Bind webGl buffers directly to the webGL context
  27717. * @param vertexBuffer defines the vertex buffer to bind
  27718. * @param indexBuffer defines the index buffer to bind
  27719. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27720. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27721. * @param effect defines the effect associated with the vertex buffer
  27722. */
  27723. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27724. private _unbindVertexArrayObject;
  27725. /**
  27726. * Bind a list of vertex buffers to the webGL context
  27727. * @param vertexBuffers defines the list of vertex buffers to bind
  27728. * @param indexBuffer defines the index buffer to bind
  27729. * @param effect defines the effect associated with the vertex buffers
  27730. */
  27731. bindBuffers(vertexBuffers: {
  27732. [key: string]: Nullable<VertexBuffer>;
  27733. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27734. /**
  27735. * Unbind all instance attributes
  27736. */
  27737. unbindInstanceAttributes(): void;
  27738. /**
  27739. * Release and free the memory of a vertex array object
  27740. * @param vao defines the vertex array object to delete
  27741. */
  27742. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27743. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  27744. /**
  27745. * Creates a webGL buffer to use with instanciation
  27746. * @param capacity defines the size of the buffer
  27747. * @returns the webGL buffer
  27748. */
  27749. createInstancesBuffer(capacity: number): DataBuffer;
  27750. /**
  27751. * Delete a webGL buffer used with instanciation
  27752. * @param buffer defines the webGL buffer to delete
  27753. */
  27754. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27755. /**
  27756. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27757. * @param instancesBuffer defines the webGL buffer to update and bind
  27758. * @param data defines the data to store in the buffer
  27759. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27760. */
  27761. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27762. /**
  27763. * Apply all cached states (depth, culling, stencil and alpha)
  27764. */
  27765. applyStates(): void;
  27766. /**
  27767. * Send a draw order
  27768. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27769. * @param indexStart defines the starting index
  27770. * @param indexCount defines the number of index to draw
  27771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27772. */
  27773. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27774. /**
  27775. * Draw a list of points
  27776. * @param verticesStart defines the index of first vertex to draw
  27777. * @param verticesCount defines the count of vertices to draw
  27778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27779. */
  27780. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27781. /**
  27782. * Draw a list of unindexed primitives
  27783. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27784. * @param verticesStart defines the index of first vertex to draw
  27785. * @param verticesCount defines the count of vertices to draw
  27786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27787. */
  27788. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27789. /**
  27790. * Draw a list of indexed primitives
  27791. * @param fillMode defines the primitive to use
  27792. * @param indexStart defines the starting index
  27793. * @param indexCount defines the number of index to draw
  27794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27795. */
  27796. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27797. /**
  27798. * Draw a list of unindexed primitives
  27799. * @param fillMode defines the primitive to use
  27800. * @param verticesStart defines the index of first vertex to draw
  27801. * @param verticesCount defines the count of vertices to draw
  27802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27803. */
  27804. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27805. private _drawMode;
  27806. /** @hidden */ releaseEffect(effect: Effect): void;
  27807. /** @hidden */ deletePipelineContext(pipelineContext: IPipelineContext): void;
  27808. /**
  27809. * Create a new effect (used to store vertex/fragment shaders)
  27810. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27811. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27812. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27813. * @param samplers defines an array of string used to represent textures
  27814. * @param defines defines the string containing the defines to use to compile the shaders
  27815. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27816. * @param onCompiled defines a function to call when the effect creation is successful
  27817. * @param onError defines a function to call when the effect creation has failed
  27818. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27819. * @returns the new Effect
  27820. */
  27821. 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;
  27822. private _compileShader;
  27823. private _compileRawShader;
  27824. /**
  27825. * Directly creates a webGL program
  27826. * @param pipelineContext defines the pipeline context to attach to
  27827. * @param vertexCode defines the vertex shader code to use
  27828. * @param fragmentCode defines the fragment shader code to use
  27829. * @param context defines the webGL context to use (if not set, the current one will be used)
  27830. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27831. * @returns the new webGL program
  27832. */
  27833. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27834. /**
  27835. * Creates a webGL program
  27836. * @param pipelineContext defines the pipeline context to attach to
  27837. * @param vertexCode defines the vertex shader code to use
  27838. * @param fragmentCode defines the fragment shader code to use
  27839. * @param defines defines the string containing the defines to use to compile the shaders
  27840. * @param context defines the webGL context to use (if not set, the current one will be used)
  27841. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27842. * @returns the new webGL program
  27843. */
  27844. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27845. /**
  27846. * Creates a new pipeline context
  27847. * @returns the new pipeline
  27848. */
  27849. createPipelineContext(): WebGLPipelineContext;
  27850. private _createShaderProgram;
  27851. private _finalizePipelineContext;
  27852. /** @hidden */ preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27853. /** @hidden */ isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27854. /** @hidden */ executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27855. /**
  27856. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27857. * @param pipelineContext defines the pipeline context to use
  27858. * @param uniformsNames defines the list of uniform names
  27859. * @returns an array of webGL uniform locations
  27860. */
  27861. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27862. /**
  27863. * Gets the lsit of active attributes for a given webGL program
  27864. * @param pipelineContext defines the pipeline context to use
  27865. * @param attributesNames defines the list of attribute names to get
  27866. * @returns an array of indices indicating the offset of each attribute
  27867. */
  27868. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27869. /**
  27870. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27871. * @param effect defines the effect to activate
  27872. */
  27873. enableEffect(effect: Nullable<Effect>): void;
  27874. /**
  27875. * Set the value of an uniform to an array of int32
  27876. * @param uniform defines the webGL uniform location where to store the value
  27877. * @param array defines the array of int32 to store
  27878. */
  27879. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27880. /**
  27881. * Set the value of an uniform to an array of int32 (stored as vec2)
  27882. * @param uniform defines the webGL uniform location where to store the value
  27883. * @param array defines the array of int32 to store
  27884. */
  27885. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27886. /**
  27887. * Set the value of an uniform to an array of int32 (stored as vec3)
  27888. * @param uniform defines the webGL uniform location where to store the value
  27889. * @param array defines the array of int32 to store
  27890. */
  27891. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27892. /**
  27893. * Set the value of an uniform to an array of int32 (stored as vec4)
  27894. * @param uniform defines the webGL uniform location where to store the value
  27895. * @param array defines the array of int32 to store
  27896. */
  27897. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27898. /**
  27899. * Set the value of an uniform to an array of float32
  27900. * @param uniform defines the webGL uniform location where to store the value
  27901. * @param array defines the array of float32 to store
  27902. */
  27903. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27904. /**
  27905. * Set the value of an uniform to an array of float32 (stored as vec2)
  27906. * @param uniform defines the webGL uniform location where to store the value
  27907. * @param array defines the array of float32 to store
  27908. */
  27909. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27910. /**
  27911. * Set the value of an uniform to an array of float32 (stored as vec3)
  27912. * @param uniform defines the webGL uniform location where to store the value
  27913. * @param array defines the array of float32 to store
  27914. */
  27915. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27916. /**
  27917. * Set the value of an uniform to an array of float32 (stored as vec4)
  27918. * @param uniform defines the webGL uniform location where to store the value
  27919. * @param array defines the array of float32 to store
  27920. */
  27921. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27922. /**
  27923. * Set the value of an uniform to an array of number
  27924. * @param uniform defines the webGL uniform location where to store the value
  27925. * @param array defines the array of number to store
  27926. */
  27927. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27928. /**
  27929. * Set the value of an uniform to an array of number (stored as vec2)
  27930. * @param uniform defines the webGL uniform location where to store the value
  27931. * @param array defines the array of number to store
  27932. */
  27933. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27934. /**
  27935. * Set the value of an uniform to an array of number (stored as vec3)
  27936. * @param uniform defines the webGL uniform location where to store the value
  27937. * @param array defines the array of number to store
  27938. */
  27939. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27940. /**
  27941. * Set the value of an uniform to an array of number (stored as vec4)
  27942. * @param uniform defines the webGL uniform location where to store the value
  27943. * @param array defines the array of number to store
  27944. */
  27945. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27946. /**
  27947. * Set the value of an uniform to an array of float32 (stored as matrices)
  27948. * @param uniform defines the webGL uniform location where to store the value
  27949. * @param matrices defines the array of float32 to store
  27950. */
  27951. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27952. /**
  27953. * Set the value of an uniform to a matrix
  27954. * @param uniform defines the webGL uniform location where to store the value
  27955. * @param matrix defines the matrix to store
  27956. */
  27957. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27958. /**
  27959. * Set the value of an uniform to a matrix (3x3)
  27960. * @param uniform defines the webGL uniform location where to store the value
  27961. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27962. */
  27963. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27964. /**
  27965. * Set the value of an uniform to a matrix (2x2)
  27966. * @param uniform defines the webGL uniform location where to store the value
  27967. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27968. */
  27969. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27970. /**
  27971. * Set the value of an uniform to a number (int)
  27972. * @param uniform defines the webGL uniform location where to store the value
  27973. * @param value defines the int number to store
  27974. */
  27975. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27976. /**
  27977. * Set the value of an uniform to a number (float)
  27978. * @param uniform defines the webGL uniform location where to store the value
  27979. * @param value defines the float number to store
  27980. */
  27981. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27982. /**
  27983. * Set the value of an uniform to a vec2
  27984. * @param uniform defines the webGL uniform location where to store the value
  27985. * @param x defines the 1st component of the value
  27986. * @param y defines the 2nd component of the value
  27987. */
  27988. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27989. /**
  27990. * Set the value of an uniform to a vec3
  27991. * @param uniform defines the webGL uniform location where to store the value
  27992. * @param x defines the 1st component of the value
  27993. * @param y defines the 2nd component of the value
  27994. * @param z defines the 3rd component of the value
  27995. */
  27996. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27997. /**
  27998. * Set the value of an uniform to a boolean
  27999. * @param uniform defines the webGL uniform location where to store the value
  28000. * @param bool defines the boolean to store
  28001. */
  28002. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28003. /**
  28004. * Set the value of an uniform to a vec4
  28005. * @param uniform defines the webGL uniform location where to store the value
  28006. * @param x defines the 1st component of the value
  28007. * @param y defines the 2nd component of the value
  28008. * @param z defines the 3rd component of the value
  28009. * @param w defines the 4th component of the value
  28010. */
  28011. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28012. /**
  28013. * Set the value of an uniform to a Color3
  28014. * @param uniform defines the webGL uniform location where to store the value
  28015. * @param color3 defines the color to store
  28016. */
  28017. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28018. /**
  28019. * Set the value of an uniform to a Color3 and an alpha value
  28020. * @param uniform defines the webGL uniform location where to store the value
  28021. * @param color3 defines the color to store
  28022. * @param alpha defines the alpha component to store
  28023. */
  28024. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28025. /**
  28026. * Sets a Color4 on a uniform variable
  28027. * @param uniform defines the uniform location
  28028. * @param color4 defines the value to be set
  28029. */
  28030. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28031. /**
  28032. * Set various states to the webGL context
  28033. * @param culling defines backface culling state
  28034. * @param zOffset defines the value to apply to zOffset (0 by default)
  28035. * @param force defines if states must be applied even if cache is up to date
  28036. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28037. */
  28038. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28039. /**
  28040. * Set the z offset to apply to current rendering
  28041. * @param value defines the offset to apply
  28042. */
  28043. setZOffset(value: number): void;
  28044. /**
  28045. * Gets the current value of the zOffset
  28046. * @returns the current zOffset state
  28047. */
  28048. getZOffset(): number;
  28049. /**
  28050. * Enable or disable depth buffering
  28051. * @param enable defines the state to set
  28052. */
  28053. setDepthBuffer(enable: boolean): void;
  28054. /**
  28055. * Gets a boolean indicating if depth writing is enabled
  28056. * @returns the current depth writing state
  28057. */
  28058. getDepthWrite(): boolean;
  28059. /**
  28060. * Enable or disable depth writing
  28061. * @param enable defines the state to set
  28062. */
  28063. setDepthWrite(enable: boolean): void;
  28064. /**
  28065. * Enable or disable color writing
  28066. * @param enable defines the state to set
  28067. */
  28068. setColorWrite(enable: boolean): void;
  28069. /**
  28070. * Gets a boolean indicating if color writing is enabled
  28071. * @returns the current color writing state
  28072. */
  28073. getColorWrite(): boolean;
  28074. /**
  28075. * Sets alpha constants used by some alpha blending modes
  28076. * @param r defines the red component
  28077. * @param g defines the green component
  28078. * @param b defines the blue component
  28079. * @param a defines the alpha component
  28080. */
  28081. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28082. /**
  28083. * Sets the current alpha mode
  28084. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28085. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28086. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28087. */
  28088. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28089. /**
  28090. * Gets the current alpha mode
  28091. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28092. * @returns the current alpha mode
  28093. */
  28094. getAlphaMode(): number;
  28095. /**
  28096. * Clears the list of texture accessible through engine.
  28097. * This can help preventing texture load conflict due to name collision.
  28098. */
  28099. clearInternalTexturesCache(): void;
  28100. /**
  28101. * Force the entire cache to be cleared
  28102. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28103. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28104. */
  28105. wipeCaches(bruteForce?: boolean): void;
  28106. /**
  28107. * Set the compressed texture format to use, based on the formats you have, and the formats
  28108. * supported by the hardware / browser.
  28109. *
  28110. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28111. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28112. * to API arguments needed to compressed textures. This puts the burden on the container
  28113. * generator to house the arcane code for determining these for current & future formats.
  28114. *
  28115. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28116. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28117. *
  28118. * Note: The result of this call is not taken into account when a texture is base64.
  28119. *
  28120. * @param formatsAvailable defines the list of those format families you have created
  28121. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28122. *
  28123. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28124. * @returns The extension selected.
  28125. */
  28126. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28127. /** @hidden */ getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28128. min: number;
  28129. mag: number;
  28130. };
  28131. /** @hidden */ createTexture(): WebGLTexture;
  28132. /**
  28133. * Usually called from Texture.ts.
  28134. * Passed information to create a WebGLTexture
  28135. * @param urlArg defines a value which contains one of the following:
  28136. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28137. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28138. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28139. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28140. * @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)
  28141. * @param scene needed for loading to the correct scene
  28142. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28143. * @param onLoad optional callback to be called upon successful completion
  28144. * @param onError optional callback to be called upon failure
  28145. * @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
  28146. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28147. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28148. * @param forcedExtension defines the extension to use to pick the right loader
  28149. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28150. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28151. */
  28152. 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;
  28153. private _rescaleTexture;
  28154. private _unpackFlipYCached;
  28155. /**
  28156. * In case you are sharing the context with other applications, it might
  28157. * be interested to not cache the unpack flip y state to ensure a consistent
  28158. * value would be set.
  28159. */
  28160. enableUnpackFlipYCached: boolean;
  28161. /** @hidden */ unpackFlipY(value: boolean): void;
  28162. /** @hidden */ getUnpackAlignement(): number;
  28163. /**
  28164. * Creates a dynamic texture
  28165. * @param width defines the width of the texture
  28166. * @param height defines the height of the texture
  28167. * @param generateMipMaps defines if the engine should generate the mip levels
  28168. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28169. * @returns the dynamic texture inside an InternalTexture
  28170. */
  28171. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28172. /**
  28173. * Update the sampling mode of a given texture
  28174. * @param samplingMode defines the required sampling mode
  28175. * @param texture defines the texture to update
  28176. */
  28177. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28178. /**
  28179. * Update the content of a dynamic texture
  28180. * @param texture defines the texture to update
  28181. * @param canvas defines the canvas containing the source
  28182. * @param invertY defines if data must be stored with Y axis inverted
  28183. * @param premulAlpha defines if alpha is stored as premultiplied
  28184. * @param format defines the format of the data
  28185. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28186. */
  28187. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28188. /**
  28189. * Update a video texture
  28190. * @param texture defines the texture to update
  28191. * @param video defines the video element to use
  28192. * @param invertY defines if data must be stored with Y axis inverted
  28193. */
  28194. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28195. /**
  28196. * Updates a depth texture Comparison Mode and Function.
  28197. * If the comparison Function is equal to 0, the mode will be set to none.
  28198. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28199. * @param texture The texture to set the comparison function for
  28200. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28201. */
  28202. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28203. /** @hidden */ setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28204. width: number;
  28205. height: number;
  28206. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28207. /**
  28208. * Creates a depth stencil texture.
  28209. * This is only available in WebGL 2 or with the depth texture extension available.
  28210. * @param size The size of face edge in the texture.
  28211. * @param options The options defining the texture.
  28212. * @returns The texture
  28213. */
  28214. createDepthStencilTexture(size: number | {
  28215. width: number;
  28216. height: number;
  28217. }, options: DepthTextureCreationOptions): InternalTexture;
  28218. /**
  28219. * Creates a depth stencil texture.
  28220. * This is only available in WebGL 2 or with the depth texture extension available.
  28221. * @param size The size of face edge in the texture.
  28222. * @param options The options defining the texture.
  28223. * @returns The texture
  28224. */
  28225. private _createDepthStencilTexture;
  28226. /**
  28227. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28228. * @param renderTarget The render target to set the frame buffer for
  28229. */
  28230. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28231. /**
  28232. * Creates a new render target texture
  28233. * @param size defines the size of the texture
  28234. * @param options defines the options used to create the texture
  28235. * @returns a new render target texture stored in an InternalTexture
  28236. */
  28237. createRenderTargetTexture(size: number | {
  28238. width: number;
  28239. height: number;
  28240. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28241. /** @hidden */ setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28242. /**
  28243. * Updates the sample count of a render target texture
  28244. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28245. * @param texture defines the texture to update
  28246. * @param samples defines the sample count to set
  28247. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28248. */
  28249. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28250. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28251. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28252. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28253. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28254. /**
  28255. * @hidden
  28256. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28257. private _prepareWebGLTextureContinuation;
  28258. private _prepareWebGLTexture;
  28259. /** @hidden */ convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28260. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28261. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28262. private setProgram;
  28263. private _boundUniforms;
  28264. /**
  28265. * Binds an effect to the webGL context
  28266. * @param effect defines the effect to bind
  28267. */
  28268. bindSamplers(effect: Effect): void;
  28269. private _activateCurrentTexture;
  28270. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28271. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28272. /**
  28273. * Sets a texture to the webGL context from a postprocess
  28274. * @param channel defines the channel to use
  28275. * @param postProcess defines the source postprocess
  28276. */
  28277. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28278. /**
  28279. * Binds the output of the passed in post process to the texture channel specified
  28280. * @param channel The channel the texture should be bound to
  28281. * @param postProcess The post process which's output should be bound
  28282. */
  28283. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28284. /**
  28285. * Unbind all textures from the webGL context
  28286. */
  28287. unbindAllTextures(): void;
  28288. /**
  28289. * Sets a texture to the according uniform.
  28290. * @param channel The texture channel
  28291. * @param uniform The uniform to set
  28292. * @param texture The texture to apply
  28293. */
  28294. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28295. /**
  28296. * Sets a depth stencil texture from a render target to the according uniform.
  28297. * @param channel The texture channel
  28298. * @param uniform The uniform to set
  28299. * @param texture The render target texture containing the depth stencil texture to apply
  28300. */
  28301. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28302. private _bindSamplerUniformToChannel;
  28303. private _getTextureWrapMode;
  28304. private _setTexture;
  28305. /**
  28306. * Sets an array of texture to the webGL context
  28307. * @param channel defines the channel where the texture array must be set
  28308. * @param uniform defines the associated uniform location
  28309. * @param textures defines the array of textures to bind
  28310. */
  28311. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28312. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28313. private _setTextureParameterFloat;
  28314. private _setTextureParameterInteger;
  28315. /**
  28316. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28317. * @param x defines the x coordinate of the rectangle where pixels must be read
  28318. * @param y defines the y coordinate of the rectangle where pixels must be read
  28319. * @param width defines the width of the rectangle where pixels must be read
  28320. * @param height defines the height of the rectangle where pixels must be read
  28321. * @returns a Uint8Array containing RGBA colors
  28322. */
  28323. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28324. /**
  28325. * Add an externaly attached data from its key.
  28326. * This method call will fail and return false, if such key already exists.
  28327. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28328. * @param key the unique key that identifies the data
  28329. * @param data the data object to associate to the key for this Engine instance
  28330. * @return true if no such key were already present and the data was added successfully, false otherwise
  28331. */
  28332. addExternalData<T>(key: string, data: T): boolean;
  28333. /**
  28334. * Get an externaly attached data from its key
  28335. * @param key the unique key that identifies the data
  28336. * @return the associated data, if present (can be null), or undefined if not present
  28337. */
  28338. getExternalData<T>(key: string): T;
  28339. /**
  28340. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28341. * @param key the unique key that identifies the data
  28342. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28343. * @return the associated data, can be null if the factory returned null.
  28344. */
  28345. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28346. /**
  28347. * Remove an externaly attached data from the Engine instance
  28348. * @param key the unique key that identifies the data
  28349. * @return true if the data was successfully removed, false if it doesn't exist
  28350. */
  28351. removeExternalData(key: string): boolean;
  28352. /**
  28353. * Unbind all vertex attributes from the webGL context
  28354. */
  28355. unbindAllAttributes(): void;
  28356. /**
  28357. * 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
  28358. */
  28359. releaseEffects(): void;
  28360. /**
  28361. * Dispose and release all associated resources
  28362. */
  28363. dispose(): void;
  28364. /**
  28365. * Display the loading screen
  28366. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28367. */
  28368. displayLoadingUI(): void;
  28369. /**
  28370. * Hide the loading screen
  28371. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28372. */
  28373. hideLoadingUI(): void;
  28374. /**
  28375. * Gets the current loading screen object
  28376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28377. */
  28378. /**
  28379. * Sets the current loading screen object
  28380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28381. */
  28382. loadingScreen: ILoadingScreen;
  28383. /**
  28384. * Sets the current loading screen text
  28385. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28386. */
  28387. loadingUIText: string;
  28388. /**
  28389. * Sets the current loading screen background color
  28390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28391. */
  28392. loadingUIBackgroundColor: string;
  28393. /**
  28394. * Attach a new callback raised when context lost event is fired
  28395. * @param callback defines the callback to call
  28396. */
  28397. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28398. /**
  28399. * Attach a new callback raised when context restored event is fired
  28400. * @param callback defines the callback to call
  28401. */
  28402. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28403. /**
  28404. * Gets the source code of the vertex shader associated with a specific webGL program
  28405. * @param program defines the program to use
  28406. * @returns a string containing the source code of the vertex shader associated with the program
  28407. */
  28408. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28409. /**
  28410. * Gets the source code of the fragment shader associated with a specific webGL program
  28411. * @param program defines the program to use
  28412. * @returns a string containing the source code of the fragment shader associated with the program
  28413. */
  28414. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28415. /**
  28416. * Get the current error code of the webGL context
  28417. * @returns the error code
  28418. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28419. */
  28420. getError(): number;
  28421. /**
  28422. * Gets the current framerate
  28423. * @returns a number representing the framerate
  28424. */
  28425. getFps(): number;
  28426. /**
  28427. * Gets the time spent between current and previous frame
  28428. * @returns a number representing the delta time in ms
  28429. */
  28430. getDeltaTime(): number;
  28431. private _measureFps;
  28432. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28433. private _canRenderToFloatFramebuffer;
  28434. private _canRenderToHalfFloatFramebuffer;
  28435. private _canRenderToFramebuffer;
  28436. /** @hidden */ getWebGLTextureType(type: number): number;
  28437. /** @hidden */ getInternalFormat(format: number): number;
  28438. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28439. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28440. /** @hidden */ 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;
  28441. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28442. /**
  28443. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28444. * @returns true if the engine can be created
  28445. * @ignorenaming
  28446. */
  28447. static isSupported(): boolean;
  28448. }
  28449. }
  28450. declare module BABYLON {
  28451. /**
  28452. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28453. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28454. */
  28455. export class EffectFallbacks {
  28456. private _defines;
  28457. private _currentRank;
  28458. private _maxRank;
  28459. private _mesh;
  28460. /**
  28461. * Removes the fallback from the bound mesh.
  28462. */
  28463. unBindMesh(): void;
  28464. /**
  28465. * Adds a fallback on the specified property.
  28466. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28467. * @param define The name of the define in the shader
  28468. */
  28469. addFallback(rank: number, define: string): void;
  28470. /**
  28471. * Sets the mesh to use CPU skinning when needing to fallback.
  28472. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28473. * @param mesh The mesh to use the fallbacks.
  28474. */
  28475. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28476. /**
  28477. * Checks to see if more fallbacks are still availible.
  28478. */
  28479. readonly isMoreFallbacks: boolean;
  28480. /**
  28481. * Removes the defines that shoould be removed when falling back.
  28482. * @param currentDefines defines the current define statements for the shader.
  28483. * @param effect defines the current effect we try to compile
  28484. * @returns The resulting defines with defines of the current rank removed.
  28485. */
  28486. reduce(currentDefines: string, effect: Effect): string;
  28487. }
  28488. /**
  28489. * Options to be used when creating an effect.
  28490. */
  28491. export class EffectCreationOptions {
  28492. /**
  28493. * Atrributes that will be used in the shader.
  28494. */
  28495. attributes: string[];
  28496. /**
  28497. * Uniform varible names that will be set in the shader.
  28498. */
  28499. uniformsNames: string[];
  28500. /**
  28501. * Uniform buffer varible names that will be set in the shader.
  28502. */
  28503. uniformBuffersNames: string[];
  28504. /**
  28505. * Sampler texture variable names that will be set in the shader.
  28506. */
  28507. samplers: string[];
  28508. /**
  28509. * Define statements that will be set in the shader.
  28510. */
  28511. defines: any;
  28512. /**
  28513. * Possible fallbacks for this effect to improve performance when needed.
  28514. */
  28515. fallbacks: Nullable<EffectFallbacks>;
  28516. /**
  28517. * Callback that will be called when the shader is compiled.
  28518. */
  28519. onCompiled: Nullable<(effect: Effect) => void>;
  28520. /**
  28521. * Callback that will be called if an error occurs during shader compilation.
  28522. */
  28523. onError: Nullable<(effect: Effect, errors: string) => void>;
  28524. /**
  28525. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28526. */
  28527. indexParameters: any;
  28528. /**
  28529. * Max number of lights that can be used in the shader.
  28530. */
  28531. maxSimultaneousLights: number;
  28532. /**
  28533. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28534. */
  28535. transformFeedbackVaryings: Nullable<string[]>;
  28536. }
  28537. /**
  28538. * Effect containing vertex and fragment shader that can be executed on an object.
  28539. */
  28540. export class Effect implements IDisposable {
  28541. /**
  28542. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28543. */
  28544. static ShadersRepository: string;
  28545. /**
  28546. * Name of the effect.
  28547. */
  28548. name: any;
  28549. /**
  28550. * String container all the define statements that should be set on the shader.
  28551. */
  28552. defines: string;
  28553. /**
  28554. * Callback that will be called when the shader is compiled.
  28555. */
  28556. onCompiled: Nullable<(effect: Effect) => void>;
  28557. /**
  28558. * Callback that will be called if an error occurs during shader compilation.
  28559. */
  28560. onError: Nullable<(effect: Effect, errors: string) => void>;
  28561. /**
  28562. * Callback that will be called when effect is bound.
  28563. */
  28564. onBind: Nullable<(effect: Effect) => void>;
  28565. /**
  28566. * Unique ID of the effect.
  28567. */
  28568. uniqueId: number;
  28569. /**
  28570. * Observable that will be called when the shader is compiled.
  28571. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28572. */
  28573. onCompileObservable: Observable<Effect>;
  28574. /**
  28575. * Observable that will be called if an error occurs during shader compilation.
  28576. */
  28577. onErrorObservable: Observable<Effect>;
  28578. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28579. /**
  28580. * Observable that will be called when effect is bound.
  28581. */
  28582. readonly onBindObservable: Observable<Effect>;
  28583. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28584. private static _uniqueIdSeed;
  28585. private _engine;
  28586. private _uniformBuffersNames;
  28587. private _uniformsNames;
  28588. private _samplerList;
  28589. private _samplers;
  28590. private _isReady;
  28591. private _compilationError;
  28592. private _attributesNames;
  28593. private _attributes;
  28594. private _uniforms;
  28595. /**
  28596. * Key for the effect.
  28597. * @hidden
  28598. */ key: string;
  28599. private _indexParameters;
  28600. private _fallbacks;
  28601. private _vertexSourceCode;
  28602. private _fragmentSourceCode;
  28603. private _vertexSourceCodeOverride;
  28604. private _fragmentSourceCodeOverride;
  28605. private _transformFeedbackVaryings;
  28606. /**
  28607. * Compiled shader to webGL program.
  28608. * @hidden
  28609. */ pipelineContext: IPipelineContext;
  28610. private _valueCache;
  28611. private static _baseCache;
  28612. /**
  28613. * Instantiates an effect.
  28614. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28615. * @param baseName Name of the effect.
  28616. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28617. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28618. * @param samplers List of sampler variables that will be passed to the shader.
  28619. * @param engine Engine to be used to render the effect
  28620. * @param defines Define statements to be added to the shader.
  28621. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28622. * @param onCompiled Callback that will be called when the shader is compiled.
  28623. * @param onError Callback that will be called if an error occurs during shader compilation.
  28624. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28625. */
  28626. 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);
  28627. /**
  28628. * Unique key for this effect
  28629. */
  28630. readonly key: string;
  28631. /**
  28632. * If the effect has been compiled and prepared.
  28633. * @returns if the effect is compiled and prepared.
  28634. */
  28635. isReady(): boolean;
  28636. /**
  28637. * The engine the effect was initialized with.
  28638. * @returns the engine.
  28639. */
  28640. getEngine(): Engine;
  28641. /**
  28642. * The pipeline context for this effect
  28643. * @returns the associated pipeline context
  28644. */
  28645. getPipelineContext(): IPipelineContext;
  28646. /**
  28647. * The set of names of attribute variables for the shader.
  28648. * @returns An array of attribute names.
  28649. */
  28650. getAttributesNames(): string[];
  28651. /**
  28652. * Returns the attribute at the given index.
  28653. * @param index The index of the attribute.
  28654. * @returns The location of the attribute.
  28655. */
  28656. getAttributeLocation(index: number): number;
  28657. /**
  28658. * Returns the attribute based on the name of the variable.
  28659. * @param name of the attribute to look up.
  28660. * @returns the attribute location.
  28661. */
  28662. getAttributeLocationByName(name: string): number;
  28663. /**
  28664. * The number of attributes.
  28665. * @returns the numnber of attributes.
  28666. */
  28667. getAttributesCount(): number;
  28668. /**
  28669. * Gets the index of a uniform variable.
  28670. * @param uniformName of the uniform to look up.
  28671. * @returns the index.
  28672. */
  28673. getUniformIndex(uniformName: string): number;
  28674. /**
  28675. * Returns the attribute based on the name of the variable.
  28676. * @param uniformName of the uniform to look up.
  28677. * @returns the location of the uniform.
  28678. */
  28679. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28680. /**
  28681. * Returns an array of sampler variable names
  28682. * @returns The array of sampler variable neames.
  28683. */
  28684. getSamplers(): string[];
  28685. /**
  28686. * The error from the last compilation.
  28687. * @returns the error string.
  28688. */
  28689. getCompilationError(): string;
  28690. /**
  28691. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28692. * @param func The callback to be used.
  28693. */
  28694. executeWhenCompiled(func: (effect: Effect) => void): void;
  28695. private _checkIsReady;
  28696. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28697. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28698. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28699. private _processShaderConversion;
  28700. private _processIncludes;
  28701. private _processPrecision;
  28702. /**
  28703. * Recompiles the webGL program
  28704. * @param vertexSourceCode The source code for the vertex shader.
  28705. * @param fragmentSourceCode The source code for the fragment shader.
  28706. * @param onCompiled Callback called when completed.
  28707. * @param onError Callback called on error.
  28708. * @hidden
  28709. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28710. /**
  28711. * Prepares the effect
  28712. * @hidden
  28713. */ prepareEffect(): void;
  28714. /**
  28715. * Checks if the effect is supported. (Must be called after compilation)
  28716. */
  28717. readonly isSupported: boolean;
  28718. /**
  28719. * Binds a texture to the engine to be used as output of the shader.
  28720. * @param channel Name of the output variable.
  28721. * @param texture Texture to bind.
  28722. * @hidden
  28723. */ bindTexture(channel: string, texture: InternalTexture): void;
  28724. /**
  28725. * Sets a texture on the engine to be used in the shader.
  28726. * @param channel Name of the sampler variable.
  28727. * @param texture Texture to set.
  28728. */
  28729. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28730. /**
  28731. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28732. * @param channel Name of the sampler variable.
  28733. * @param texture Texture to set.
  28734. */
  28735. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28736. /**
  28737. * Sets an array of textures on the engine to be used in the shader.
  28738. * @param channel Name of the variable.
  28739. * @param textures Textures to set.
  28740. */
  28741. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28742. /**
  28743. * 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)
  28744. * @param channel Name of the sampler variable.
  28745. * @param postProcess Post process to get the input texture from.
  28746. */
  28747. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28748. /**
  28749. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28750. * 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)
  28751. * @param channel Name of the sampler variable.
  28752. * @param postProcess Post process to get the output texture from.
  28753. */
  28754. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28755. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28756. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28757. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28758. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28759. /**
  28760. * Binds a buffer to a uniform.
  28761. * @param buffer Buffer to bind.
  28762. * @param name Name of the uniform variable to bind to.
  28763. */
  28764. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28765. /**
  28766. * Binds block to a uniform.
  28767. * @param blockName Name of the block to bind.
  28768. * @param index Index to bind.
  28769. */
  28770. bindUniformBlock(blockName: string, index: number): void;
  28771. /**
  28772. * Sets an interger value on a uniform variable.
  28773. * @param uniformName Name of the variable.
  28774. * @param value Value to be set.
  28775. * @returns this effect.
  28776. */
  28777. setInt(uniformName: string, value: number): Effect;
  28778. /**
  28779. * Sets an int array on a uniform variable.
  28780. * @param uniformName Name of the variable.
  28781. * @param array array to be set.
  28782. * @returns this effect.
  28783. */
  28784. setIntArray(uniformName: string, array: Int32Array): Effect;
  28785. /**
  28786. * 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)
  28787. * @param uniformName Name of the variable.
  28788. * @param array array to be set.
  28789. * @returns this effect.
  28790. */
  28791. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28792. /**
  28793. * 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)
  28794. * @param uniformName Name of the variable.
  28795. * @param array array to be set.
  28796. * @returns this effect.
  28797. */
  28798. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28799. /**
  28800. * 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)
  28801. * @param uniformName Name of the variable.
  28802. * @param array array to be set.
  28803. * @returns this effect.
  28804. */
  28805. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28806. /**
  28807. * Sets an float array on a uniform variable.
  28808. * @param uniformName Name of the variable.
  28809. * @param array array to be set.
  28810. * @returns this effect.
  28811. */
  28812. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28813. /**
  28814. * 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)
  28815. * @param uniformName Name of the variable.
  28816. * @param array array to be set.
  28817. * @returns this effect.
  28818. */
  28819. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28820. /**
  28821. * 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)
  28822. * @param uniformName Name of the variable.
  28823. * @param array array to be set.
  28824. * @returns this effect.
  28825. */
  28826. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28827. /**
  28828. * 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)
  28829. * @param uniformName Name of the variable.
  28830. * @param array array to be set.
  28831. * @returns this effect.
  28832. */
  28833. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28834. /**
  28835. * Sets an array on a uniform variable.
  28836. * @param uniformName Name of the variable.
  28837. * @param array array to be set.
  28838. * @returns this effect.
  28839. */
  28840. setArray(uniformName: string, array: number[]): Effect;
  28841. /**
  28842. * 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)
  28843. * @param uniformName Name of the variable.
  28844. * @param array array to be set.
  28845. * @returns this effect.
  28846. */
  28847. setArray2(uniformName: string, array: number[]): Effect;
  28848. /**
  28849. * 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)
  28850. * @param uniformName Name of the variable.
  28851. * @param array array to be set.
  28852. * @returns this effect.
  28853. */
  28854. setArray3(uniformName: string, array: number[]): Effect;
  28855. /**
  28856. * 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)
  28857. * @param uniformName Name of the variable.
  28858. * @param array array to be set.
  28859. * @returns this effect.
  28860. */
  28861. setArray4(uniformName: string, array: number[]): Effect;
  28862. /**
  28863. * Sets matrices on a uniform variable.
  28864. * @param uniformName Name of the variable.
  28865. * @param matrices matrices to be set.
  28866. * @returns this effect.
  28867. */
  28868. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28869. /**
  28870. * Sets matrix on a uniform variable.
  28871. * @param uniformName Name of the variable.
  28872. * @param matrix matrix to be set.
  28873. * @returns this effect.
  28874. */
  28875. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28876. /**
  28877. * 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)
  28878. * @param uniformName Name of the variable.
  28879. * @param matrix matrix to be set.
  28880. * @returns this effect.
  28881. */
  28882. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28883. /**
  28884. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28885. * @param uniformName Name of the variable.
  28886. * @param matrix matrix to be set.
  28887. * @returns this effect.
  28888. */
  28889. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28890. /**
  28891. * Sets a float on a uniform variable.
  28892. * @param uniformName Name of the variable.
  28893. * @param value value to be set.
  28894. * @returns this effect.
  28895. */
  28896. setFloat(uniformName: string, value: number): Effect;
  28897. /**
  28898. * Sets a boolean on a uniform variable.
  28899. * @param uniformName Name of the variable.
  28900. * @param bool value to be set.
  28901. * @returns this effect.
  28902. */
  28903. setBool(uniformName: string, bool: boolean): Effect;
  28904. /**
  28905. * Sets a Vector2 on a uniform variable.
  28906. * @param uniformName Name of the variable.
  28907. * @param vector2 vector2 to be set.
  28908. * @returns this effect.
  28909. */
  28910. setVector2(uniformName: string, vector2: Vector2): Effect;
  28911. /**
  28912. * Sets a float2 on a uniform variable.
  28913. * @param uniformName Name of the variable.
  28914. * @param x First float in float2.
  28915. * @param y Second float in float2.
  28916. * @returns this effect.
  28917. */
  28918. setFloat2(uniformName: string, x: number, y: number): Effect;
  28919. /**
  28920. * Sets a Vector3 on a uniform variable.
  28921. * @param uniformName Name of the variable.
  28922. * @param vector3 Value to be set.
  28923. * @returns this effect.
  28924. */
  28925. setVector3(uniformName: string, vector3: Vector3): Effect;
  28926. /**
  28927. * Sets a float3 on a uniform variable.
  28928. * @param uniformName Name of the variable.
  28929. * @param x First float in float3.
  28930. * @param y Second float in float3.
  28931. * @param z Third float in float3.
  28932. * @returns this effect.
  28933. */
  28934. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28935. /**
  28936. * Sets a Vector4 on a uniform variable.
  28937. * @param uniformName Name of the variable.
  28938. * @param vector4 Value to be set.
  28939. * @returns this effect.
  28940. */
  28941. setVector4(uniformName: string, vector4: Vector4): Effect;
  28942. /**
  28943. * Sets a float4 on a uniform variable.
  28944. * @param uniformName Name of the variable.
  28945. * @param x First float in float4.
  28946. * @param y Second float in float4.
  28947. * @param z Third float in float4.
  28948. * @param w Fourth float in float4.
  28949. * @returns this effect.
  28950. */
  28951. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28952. /**
  28953. * Sets a Color3 on a uniform variable.
  28954. * @param uniformName Name of the variable.
  28955. * @param color3 Value to be set.
  28956. * @returns this effect.
  28957. */
  28958. setColor3(uniformName: string, color3: Color3): Effect;
  28959. /**
  28960. * Sets a Color4 on a uniform variable.
  28961. * @param uniformName Name of the variable.
  28962. * @param color3 Value to be set.
  28963. * @param alpha Alpha value to be set.
  28964. * @returns this effect.
  28965. */
  28966. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28967. /**
  28968. * Sets a Color4 on a uniform variable
  28969. * @param uniformName defines the name of the variable
  28970. * @param color4 defines the value to be set
  28971. * @returns this effect.
  28972. */
  28973. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28974. /** Release all associated resources */
  28975. dispose(): void;
  28976. /**
  28977. * This function will add a new shader to the shader store
  28978. * @param name the name of the shader
  28979. * @param pixelShader optional pixel shader content
  28980. * @param vertexShader optional vertex shader content
  28981. */
  28982. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28983. /**
  28984. * Store of each shader (The can be looked up using effect.key)
  28985. */
  28986. static ShadersStore: {
  28987. [key: string]: string;
  28988. };
  28989. /**
  28990. * Store of each included file for a shader (The can be looked up using effect.key)
  28991. */
  28992. static IncludesShadersStore: {
  28993. [key: string]: string;
  28994. };
  28995. /**
  28996. * Resets the cache of effects.
  28997. */
  28998. static ResetCache(): void;
  28999. }
  29000. }
  29001. declare module BABYLON {
  29002. /**
  29003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29005. * 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;
  29006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29007. */
  29008. export class ColorCurves {
  29009. private _dirty;
  29010. private _tempColor;
  29011. private _globalCurve;
  29012. private _highlightsCurve;
  29013. private _midtonesCurve;
  29014. private _shadowsCurve;
  29015. private _positiveCurve;
  29016. private _negativeCurve;
  29017. private _globalHue;
  29018. private _globalDensity;
  29019. private _globalSaturation;
  29020. private _globalExposure;
  29021. /**
  29022. * Gets the global Hue value.
  29023. * 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).
  29024. */
  29025. /**
  29026. * Sets the global Hue value.
  29027. * 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).
  29028. */
  29029. globalHue: number;
  29030. /**
  29031. * Gets the global Density value.
  29032. * 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.
  29033. * Values less than zero provide a filter of opposite hue.
  29034. */
  29035. /**
  29036. * Sets the global Density value.
  29037. * 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.
  29038. * Values less than zero provide a filter of opposite hue.
  29039. */
  29040. globalDensity: number;
  29041. /**
  29042. * Gets the global Saturation value.
  29043. * 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.
  29044. */
  29045. /**
  29046. * Sets the global Saturation value.
  29047. * 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.
  29048. */
  29049. globalSaturation: number;
  29050. /**
  29051. * Gets the global Exposure value.
  29052. * 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.
  29053. */
  29054. /**
  29055. * Sets the global Exposure value.
  29056. * 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.
  29057. */
  29058. globalExposure: number;
  29059. private _highlightsHue;
  29060. private _highlightsDensity;
  29061. private _highlightsSaturation;
  29062. private _highlightsExposure;
  29063. /**
  29064. * Gets the highlights Hue value.
  29065. * 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).
  29066. */
  29067. /**
  29068. * Sets the highlights Hue value.
  29069. * 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).
  29070. */
  29071. highlightsHue: number;
  29072. /**
  29073. * Gets the highlights Density value.
  29074. * 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.
  29075. * Values less than zero provide a filter of opposite hue.
  29076. */
  29077. /**
  29078. * Sets the highlights Density value.
  29079. * 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.
  29080. * Values less than zero provide a filter of opposite hue.
  29081. */
  29082. highlightsDensity: number;
  29083. /**
  29084. * Gets the highlights Saturation value.
  29085. * 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.
  29086. */
  29087. /**
  29088. * Sets the highlights Saturation value.
  29089. * 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.
  29090. */
  29091. highlightsSaturation: number;
  29092. /**
  29093. * Gets the highlights Exposure value.
  29094. * 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.
  29095. */
  29096. /**
  29097. * Sets the highlights Exposure value.
  29098. * 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.
  29099. */
  29100. highlightsExposure: number;
  29101. private _midtonesHue;
  29102. private _midtonesDensity;
  29103. private _midtonesSaturation;
  29104. private _midtonesExposure;
  29105. /**
  29106. * Gets the midtones Hue value.
  29107. * 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).
  29108. */
  29109. /**
  29110. * Sets the midtones Hue value.
  29111. * 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).
  29112. */
  29113. midtonesHue: number;
  29114. /**
  29115. * Gets the midtones Density value.
  29116. * 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.
  29117. * Values less than zero provide a filter of opposite hue.
  29118. */
  29119. /**
  29120. * Sets the midtones Density value.
  29121. * 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.
  29122. * Values less than zero provide a filter of opposite hue.
  29123. */
  29124. midtonesDensity: number;
  29125. /**
  29126. * Gets the midtones Saturation value.
  29127. * 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.
  29128. */
  29129. /**
  29130. * Sets the midtones Saturation value.
  29131. * 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.
  29132. */
  29133. midtonesSaturation: number;
  29134. /**
  29135. * Gets the midtones Exposure value.
  29136. * 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.
  29137. */
  29138. /**
  29139. * Sets the midtones Exposure value.
  29140. * 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.
  29141. */
  29142. midtonesExposure: number;
  29143. private _shadowsHue;
  29144. private _shadowsDensity;
  29145. private _shadowsSaturation;
  29146. private _shadowsExposure;
  29147. /**
  29148. * Gets the shadows Hue value.
  29149. * 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).
  29150. */
  29151. /**
  29152. * Sets the shadows Hue value.
  29153. * 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).
  29154. */
  29155. shadowsHue: number;
  29156. /**
  29157. * Gets the shadows Density value.
  29158. * 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.
  29159. * Values less than zero provide a filter of opposite hue.
  29160. */
  29161. /**
  29162. * Sets the shadows Density value.
  29163. * 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.
  29164. * Values less than zero provide a filter of opposite hue.
  29165. */
  29166. shadowsDensity: number;
  29167. /**
  29168. * Gets the shadows Saturation value.
  29169. * 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.
  29170. */
  29171. /**
  29172. * Sets the shadows Saturation value.
  29173. * 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.
  29174. */
  29175. shadowsSaturation: number;
  29176. /**
  29177. * Gets the shadows Exposure value.
  29178. * 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.
  29179. */
  29180. /**
  29181. * Sets the shadows Exposure value.
  29182. * 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.
  29183. */
  29184. shadowsExposure: number;
  29185. /**
  29186. * Returns the class name
  29187. * @returns The class name
  29188. */
  29189. getClassName(): string;
  29190. /**
  29191. * Binds the color curves to the shader.
  29192. * @param colorCurves The color curve to bind
  29193. * @param effect The effect to bind to
  29194. * @param positiveUniform The positive uniform shader parameter
  29195. * @param neutralUniform The neutral uniform shader parameter
  29196. * @param negativeUniform The negative uniform shader parameter
  29197. */
  29198. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29199. /**
  29200. * Prepare the list of uniforms associated with the ColorCurves effects.
  29201. * @param uniformsList The list of uniforms used in the effect
  29202. */
  29203. static PrepareUniforms(uniformsList: string[]): void;
  29204. /**
  29205. * Returns color grading data based on a hue, density, saturation and exposure value.
  29206. * @param filterHue The hue of the color filter.
  29207. * @param filterDensity The density of the color filter.
  29208. * @param saturation The saturation.
  29209. * @param exposure The exposure.
  29210. * @param result The result data container.
  29211. */
  29212. private getColorGradingDataToRef;
  29213. /**
  29214. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29215. * @param value The input slider value in range [-100,100].
  29216. * @returns Adjusted value.
  29217. */
  29218. private static applyColorGradingSliderNonlinear;
  29219. /**
  29220. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29221. * @param hue The hue (H) input.
  29222. * @param saturation The saturation (S) input.
  29223. * @param brightness The brightness (B) input.
  29224. * @result An RGBA color represented as Vector4.
  29225. */
  29226. private static fromHSBToRef;
  29227. /**
  29228. * Returns a value clamped between min and max
  29229. * @param value The value to clamp
  29230. * @param min The minimum of value
  29231. * @param max The maximum of value
  29232. * @returns The clamped value.
  29233. */
  29234. private static clamp;
  29235. /**
  29236. * Clones the current color curve instance.
  29237. * @return The cloned curves
  29238. */
  29239. clone(): ColorCurves;
  29240. /**
  29241. * Serializes the current color curve instance to a json representation.
  29242. * @return a JSON representation
  29243. */
  29244. serialize(): any;
  29245. /**
  29246. * Parses the color curve from a json representation.
  29247. * @param source the JSON source to parse
  29248. * @return The parsed curves
  29249. */
  29250. static Parse(source: any): ColorCurves;
  29251. }
  29252. }
  29253. declare module BABYLON {
  29254. /**
  29255. * Interface to follow in your material defines to integrate easily the
  29256. * Image proccessing functions.
  29257. * @hidden
  29258. */
  29259. export interface IImageProcessingConfigurationDefines {
  29260. IMAGEPROCESSING: boolean;
  29261. VIGNETTE: boolean;
  29262. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29263. VIGNETTEBLENDMODEOPAQUE: boolean;
  29264. TONEMAPPING: boolean;
  29265. TONEMAPPING_ACES: boolean;
  29266. CONTRAST: boolean;
  29267. EXPOSURE: boolean;
  29268. COLORCURVES: boolean;
  29269. COLORGRADING: boolean;
  29270. COLORGRADING3D: boolean;
  29271. SAMPLER3DGREENDEPTH: boolean;
  29272. SAMPLER3DBGRMAP: boolean;
  29273. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29274. }
  29275. /**
  29276. * @hidden
  29277. */
  29278. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29279. IMAGEPROCESSING: boolean;
  29280. VIGNETTE: boolean;
  29281. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29282. VIGNETTEBLENDMODEOPAQUE: boolean;
  29283. TONEMAPPING: boolean;
  29284. TONEMAPPING_ACES: boolean;
  29285. CONTRAST: boolean;
  29286. COLORCURVES: boolean;
  29287. COLORGRADING: boolean;
  29288. COLORGRADING3D: boolean;
  29289. SAMPLER3DGREENDEPTH: boolean;
  29290. SAMPLER3DBGRMAP: boolean;
  29291. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29292. EXPOSURE: boolean;
  29293. constructor();
  29294. }
  29295. /**
  29296. * This groups together the common properties used for image processing either in direct forward pass
  29297. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29298. * or not.
  29299. */
  29300. export class ImageProcessingConfiguration {
  29301. /**
  29302. * Default tone mapping applied in BabylonJS.
  29303. */
  29304. static readonly TONEMAPPING_STANDARD: number;
  29305. /**
  29306. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29307. * to other engines rendering to increase portability.
  29308. */
  29309. static readonly TONEMAPPING_ACES: number;
  29310. /**
  29311. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29312. */
  29313. colorCurves: Nullable<ColorCurves>;
  29314. private _colorCurvesEnabled;
  29315. /**
  29316. * Gets wether the color curves effect is enabled.
  29317. */
  29318. /**
  29319. * Sets wether the color curves effect is enabled.
  29320. */
  29321. colorCurvesEnabled: boolean;
  29322. private _colorGradingTexture;
  29323. /**
  29324. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29325. */
  29326. /**
  29327. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29328. */
  29329. colorGradingTexture: Nullable<BaseTexture>;
  29330. private _colorGradingEnabled;
  29331. /**
  29332. * Gets wether the color grading effect is enabled.
  29333. */
  29334. /**
  29335. * Sets wether the color grading effect is enabled.
  29336. */
  29337. colorGradingEnabled: boolean;
  29338. private _colorGradingWithGreenDepth;
  29339. /**
  29340. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29341. */
  29342. /**
  29343. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29344. */
  29345. colorGradingWithGreenDepth: boolean;
  29346. private _colorGradingBGR;
  29347. /**
  29348. * Gets wether the color grading texture contains BGR values.
  29349. */
  29350. /**
  29351. * Sets wether the color grading texture contains BGR values.
  29352. */
  29353. colorGradingBGR: boolean;
  29354. /** @hidden */ exposure: number;
  29355. /**
  29356. * Gets the Exposure used in the effect.
  29357. */
  29358. /**
  29359. * Sets the Exposure used in the effect.
  29360. */
  29361. exposure: number;
  29362. private _toneMappingEnabled;
  29363. /**
  29364. * Gets wether the tone mapping effect is enabled.
  29365. */
  29366. /**
  29367. * Sets wether the tone mapping effect is enabled.
  29368. */
  29369. toneMappingEnabled: boolean;
  29370. private _toneMappingType;
  29371. /**
  29372. * Gets the type of tone mapping effect.
  29373. */
  29374. /**
  29375. * Sets the type of tone mapping effect used in BabylonJS.
  29376. */
  29377. toneMappingType: number;
  29378. protected _contrast: number;
  29379. /**
  29380. * Gets the contrast used in the effect.
  29381. */
  29382. /**
  29383. * Sets the contrast used in the effect.
  29384. */
  29385. contrast: number;
  29386. /**
  29387. * Vignette stretch size.
  29388. */
  29389. vignetteStretch: number;
  29390. /**
  29391. * Vignette centre X Offset.
  29392. */
  29393. vignetteCentreX: number;
  29394. /**
  29395. * Vignette centre Y Offset.
  29396. */
  29397. vignetteCentreY: number;
  29398. /**
  29399. * Vignette weight or intensity of the vignette effect.
  29400. */
  29401. vignetteWeight: number;
  29402. /**
  29403. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29404. * if vignetteEnabled is set to true.
  29405. */
  29406. vignetteColor: Color4;
  29407. /**
  29408. * Camera field of view used by the Vignette effect.
  29409. */
  29410. vignetteCameraFov: number;
  29411. private _vignetteBlendMode;
  29412. /**
  29413. * Gets the vignette blend mode allowing different kind of effect.
  29414. */
  29415. /**
  29416. * Sets the vignette blend mode allowing different kind of effect.
  29417. */
  29418. vignetteBlendMode: number;
  29419. private _vignetteEnabled;
  29420. /**
  29421. * Gets wether the vignette effect is enabled.
  29422. */
  29423. /**
  29424. * Sets wether the vignette effect is enabled.
  29425. */
  29426. vignetteEnabled: boolean;
  29427. private _applyByPostProcess;
  29428. /**
  29429. * Gets wether the image processing is applied through a post process or not.
  29430. */
  29431. /**
  29432. * Sets wether the image processing is applied through a post process or not.
  29433. */
  29434. applyByPostProcess: boolean;
  29435. private _isEnabled;
  29436. /**
  29437. * Gets wether the image processing is enabled or not.
  29438. */
  29439. /**
  29440. * Sets wether the image processing is enabled or not.
  29441. */
  29442. isEnabled: boolean;
  29443. /**
  29444. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29445. */
  29446. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29447. /**
  29448. * Method called each time the image processing information changes requires to recompile the effect.
  29449. */
  29450. protected _updateParameters(): void;
  29451. /**
  29452. * Gets the current class name.
  29453. * @return "ImageProcessingConfiguration"
  29454. */
  29455. getClassName(): string;
  29456. /**
  29457. * Prepare the list of uniforms associated with the Image Processing effects.
  29458. * @param uniforms The list of uniforms used in the effect
  29459. * @param defines the list of defines currently in use
  29460. */
  29461. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29462. /**
  29463. * Prepare the list of samplers associated with the Image Processing effects.
  29464. * @param samplersList The list of uniforms used in the effect
  29465. * @param defines the list of defines currently in use
  29466. */
  29467. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29468. /**
  29469. * Prepare the list of defines associated to the shader.
  29470. * @param defines the list of defines to complete
  29471. * @param forPostProcess Define if we are currently in post process mode or not
  29472. */
  29473. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29474. /**
  29475. * Returns true if all the image processing information are ready.
  29476. * @returns True if ready, otherwise, false
  29477. */
  29478. isReady(): boolean;
  29479. /**
  29480. * Binds the image processing to the shader.
  29481. * @param effect The effect to bind to
  29482. * @param aspectRatio Define the current aspect ratio of the effect
  29483. */
  29484. bind(effect: Effect, aspectRatio?: number): void;
  29485. /**
  29486. * Clones the current image processing instance.
  29487. * @return The cloned image processing
  29488. */
  29489. clone(): ImageProcessingConfiguration;
  29490. /**
  29491. * Serializes the current image processing instance to a json representation.
  29492. * @return a JSON representation
  29493. */
  29494. serialize(): any;
  29495. /**
  29496. * Parses the image processing from a json representation.
  29497. * @param source the JSON source to parse
  29498. * @return The parsed image processing
  29499. */
  29500. static Parse(source: any): ImageProcessingConfiguration;
  29501. private static _VIGNETTEMODE_MULTIPLY;
  29502. private static _VIGNETTEMODE_OPAQUE;
  29503. /**
  29504. * Used to apply the vignette as a mix with the pixel color.
  29505. */
  29506. static readonly VIGNETTEMODE_MULTIPLY: number;
  29507. /**
  29508. * Used to apply the vignette as a replacement of the pixel color.
  29509. */
  29510. static readonly VIGNETTEMODE_OPAQUE: number;
  29511. }
  29512. }
  29513. declare module BABYLON {
  29514. /**
  29515. * This represents all the required information to add a fresnel effect on a material:
  29516. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29517. */
  29518. export class FresnelParameters {
  29519. private _isEnabled;
  29520. /**
  29521. * Define if the fresnel effect is enable or not.
  29522. */
  29523. isEnabled: boolean;
  29524. /**
  29525. * Define the color used on edges (grazing angle)
  29526. */
  29527. leftColor: Color3;
  29528. /**
  29529. * Define the color used on center
  29530. */
  29531. rightColor: Color3;
  29532. /**
  29533. * Define bias applied to computed fresnel term
  29534. */
  29535. bias: number;
  29536. /**
  29537. * Defined the power exponent applied to fresnel term
  29538. */
  29539. power: number;
  29540. /**
  29541. * Clones the current fresnel and its valuues
  29542. * @returns a clone fresnel configuration
  29543. */
  29544. clone(): FresnelParameters;
  29545. /**
  29546. * Serializes the current fresnel parameters to a JSON representation.
  29547. * @return the JSON serialization
  29548. */
  29549. serialize(): any;
  29550. /**
  29551. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29552. * @param parsedFresnelParameters Define the JSON representation
  29553. * @returns the parsed parameters
  29554. */
  29555. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29556. }
  29557. }
  29558. declare module BABYLON {
  29559. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29560. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29561. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29562. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29563. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29564. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29565. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29566. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29567. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29568. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29569. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29570. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29571. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29572. /**
  29573. * Decorator used to define property that can be serialized as reference to a camera
  29574. * @param sourceName defines the name of the property to decorate
  29575. */
  29576. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29577. /**
  29578. * Class used to help serialization objects
  29579. */
  29580. export class SerializationHelper {
  29581. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29582. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29583. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29584. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29585. /**
  29586. * Appends the serialized animations from the source animations
  29587. * @param source Source containing the animations
  29588. * @param destination Target to store the animations
  29589. */
  29590. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29591. /**
  29592. * Static function used to serialized a specific entity
  29593. * @param entity defines the entity to serialize
  29594. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29595. * @returns a JSON compatible object representing the serialization of the entity
  29596. */
  29597. static Serialize<T>(entity: T, serializationObject?: any): any;
  29598. /**
  29599. * Creates a new entity from a serialization data object
  29600. * @param creationFunction defines a function used to instanciated the new entity
  29601. * @param source defines the source serialization data
  29602. * @param scene defines the hosting scene
  29603. * @param rootUrl defines the root url for resources
  29604. * @returns a new entity
  29605. */
  29606. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29607. /**
  29608. * Clones an object
  29609. * @param creationFunction defines the function used to instanciate the new object
  29610. * @param source defines the source object
  29611. * @returns the cloned object
  29612. */
  29613. static Clone<T>(creationFunction: () => T, source: T): T;
  29614. /**
  29615. * Instanciates a new object based on a source one (some data will be shared between both object)
  29616. * @param creationFunction defines the function used to instanciate the new object
  29617. * @param source defines the source object
  29618. * @returns the new object
  29619. */
  29620. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29621. }
  29622. }
  29623. declare module BABYLON {
  29624. /**
  29625. * This is the base class of all the camera used in the application.
  29626. * @see http://doc.babylonjs.com/features/cameras
  29627. */
  29628. export class Camera extends Node {
  29629. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29630. /**
  29631. * This is the default projection mode used by the cameras.
  29632. * It helps recreating a feeling of perspective and better appreciate depth.
  29633. * This is the best way to simulate real life cameras.
  29634. */
  29635. static readonly PERSPECTIVE_CAMERA: number;
  29636. /**
  29637. * This helps creating camera with an orthographic mode.
  29638. * 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.
  29639. */
  29640. static readonly ORTHOGRAPHIC_CAMERA: number;
  29641. /**
  29642. * This is the default FOV mode for perspective cameras.
  29643. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29644. */
  29645. static readonly FOVMODE_VERTICAL_FIXED: number;
  29646. /**
  29647. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29648. */
  29649. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29650. /**
  29651. * This specifies ther is no need for a camera rig.
  29652. * Basically only one eye is rendered corresponding to the camera.
  29653. */
  29654. static readonly RIG_MODE_NONE: number;
  29655. /**
  29656. * Simulates a camera Rig with one blue eye and one red eye.
  29657. * This can be use with 3d blue and red glasses.
  29658. */
  29659. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29660. /**
  29661. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29662. */
  29663. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29664. /**
  29665. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29666. */
  29667. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29668. /**
  29669. * Defines that both eyes of the camera will be rendered over under each other.
  29670. */
  29671. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29672. /**
  29673. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29674. */
  29675. static readonly RIG_MODE_VR: number;
  29676. /**
  29677. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29678. */
  29679. static readonly RIG_MODE_WEBVR: number;
  29680. /**
  29681. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29682. */
  29683. static readonly RIG_MODE_CUSTOM: number;
  29684. /**
  29685. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29686. */
  29687. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29688. /**
  29689. * Define the input manager associated with the camera.
  29690. */
  29691. inputs: CameraInputsManager<Camera>;
  29692. /** @hidden */ position: Vector3;
  29693. /**
  29694. * Define the current local position of the camera in the scene
  29695. */
  29696. position: Vector3;
  29697. /**
  29698. * The vector the camera should consider as up.
  29699. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29700. */
  29701. upVector: Vector3;
  29702. /**
  29703. * Define the current limit on the left side for an orthographic camera
  29704. * In scene unit
  29705. */
  29706. orthoLeft: Nullable<number>;
  29707. /**
  29708. * Define the current limit on the right side for an orthographic camera
  29709. * In scene unit
  29710. */
  29711. orthoRight: Nullable<number>;
  29712. /**
  29713. * Define the current limit on the bottom side for an orthographic camera
  29714. * In scene unit
  29715. */
  29716. orthoBottom: Nullable<number>;
  29717. /**
  29718. * Define the current limit on the top side for an orthographic camera
  29719. * In scene unit
  29720. */
  29721. orthoTop: Nullable<number>;
  29722. /**
  29723. * Field Of View is set in Radians. (default is 0.8)
  29724. */
  29725. fov: number;
  29726. /**
  29727. * Define the minimum distance the camera can see from.
  29728. * This is important to note that the depth buffer are not infinite and the closer it starts
  29729. * the more your scene might encounter depth fighting issue.
  29730. */
  29731. minZ: number;
  29732. /**
  29733. * Define the maximum distance the camera can see to.
  29734. * This is important to note that the depth buffer are not infinite and the further it end
  29735. * the more your scene might encounter depth fighting issue.
  29736. */
  29737. maxZ: number;
  29738. /**
  29739. * Define the default inertia of the camera.
  29740. * This helps giving a smooth feeling to the camera movement.
  29741. */
  29742. inertia: number;
  29743. /**
  29744. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29745. */
  29746. mode: number;
  29747. /**
  29748. * Define wether the camera is intermediate.
  29749. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29750. */
  29751. isIntermediate: boolean;
  29752. /**
  29753. * Define the viewport of the camera.
  29754. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29755. */
  29756. viewport: Viewport;
  29757. /**
  29758. * Restricts the camera to viewing objects with the same layerMask.
  29759. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29760. */
  29761. layerMask: number;
  29762. /**
  29763. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29764. */
  29765. fovMode: number;
  29766. /**
  29767. * Rig mode of the camera.
  29768. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29769. * This is normally controlled byt the camera themselves as internal use.
  29770. */
  29771. cameraRigMode: number;
  29772. /**
  29773. * Defines the distance between both "eyes" in case of a RIG
  29774. */
  29775. interaxialDistance: number;
  29776. /**
  29777. * Defines if stereoscopic rendering is done side by side or over under.
  29778. */
  29779. isStereoscopicSideBySide: boolean;
  29780. /**
  29781. * 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
  29782. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29783. * else in the scene.
  29784. */
  29785. customRenderTargets: RenderTargetTexture[];
  29786. /**
  29787. * When set, the camera will render to this render target instead of the default canvas
  29788. */
  29789. outputRenderTarget: Nullable<RenderTargetTexture>;
  29790. /**
  29791. * Observable triggered when the camera view matrix has changed.
  29792. */
  29793. onViewMatrixChangedObservable: Observable<Camera>;
  29794. /**
  29795. * Observable triggered when the camera Projection matrix has changed.
  29796. */
  29797. onProjectionMatrixChangedObservable: Observable<Camera>;
  29798. /**
  29799. * Observable triggered when the inputs have been processed.
  29800. */
  29801. onAfterCheckInputsObservable: Observable<Camera>;
  29802. /**
  29803. * Observable triggered when reset has been called and applied to the camera.
  29804. */
  29805. onRestoreStateObservable: Observable<Camera>;
  29806. /** @hidden */ cameraRigParams: any;
  29807. /** @hidden */ rigCameras: Camera[];
  29808. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29809. protected _webvrViewMatrix: Matrix;
  29810. /** @hidden */ skipRendering: boolean;
  29811. /** @hidden */ projectionMatrix: Matrix;
  29812. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29813. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29814. protected _globalPosition: Vector3;
  29815. /** hidden */ computedViewMatrix: Matrix;
  29816. private _doNotComputeProjectionMatrix;
  29817. private _transformMatrix;
  29818. private _frustumPlanes;
  29819. private _refreshFrustumPlanes;
  29820. private _storedFov;
  29821. private _stateStored;
  29822. /**
  29823. * Instantiates a new camera object.
  29824. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29825. * @see http://doc.babylonjs.com/features/cameras
  29826. * @param name Defines the name of the camera in the scene
  29827. * @param position Defines the position of the camera
  29828. * @param scene Defines the scene the camera belongs too
  29829. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29830. */
  29831. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29832. /**
  29833. * Store current camera state (fov, position, etc..)
  29834. * @returns the camera
  29835. */
  29836. storeState(): Camera;
  29837. /**
  29838. * Restores the camera state values if it has been stored. You must call storeState() first
  29839. */
  29840. protected _restoreStateValues(): boolean;
  29841. /**
  29842. * Restored camera state. You must call storeState() first.
  29843. * @returns true if restored and false otherwise
  29844. */
  29845. restoreState(): boolean;
  29846. /**
  29847. * Gets the class name of the camera.
  29848. * @returns the class name
  29849. */
  29850. getClassName(): string;
  29851. /** @hidden */ protected readonly _isCamera: boolean;
  29852. /**
  29853. * Gets a string representation of the camera useful for debug purpose.
  29854. * @param fullDetails Defines that a more verboe level of logging is required
  29855. * @returns the string representation
  29856. */
  29857. toString(fullDetails?: boolean): string;
  29858. /**
  29859. * Gets the current world space position of the camera.
  29860. */
  29861. readonly globalPosition: Vector3;
  29862. /**
  29863. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29864. * @returns the active meshe list
  29865. */
  29866. getActiveMeshes(): SmartArray<AbstractMesh>;
  29867. /**
  29868. * Check wether a mesh is part of the current active mesh list of the camera
  29869. * @param mesh Defines the mesh to check
  29870. * @returns true if active, false otherwise
  29871. */
  29872. isActiveMesh(mesh: Mesh): boolean;
  29873. /**
  29874. * Is this camera ready to be used/rendered
  29875. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29876. * @return true if the camera is ready
  29877. */
  29878. isReady(completeCheck?: boolean): boolean;
  29879. /** @hidden */ initCache(): void;
  29880. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29881. /** @hidden */ isSynchronized(): boolean;
  29882. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29883. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29884. /**
  29885. * Attach the input controls to a specific dom element to get the input from.
  29886. * @param element Defines the element the controls should be listened from
  29887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29888. */
  29889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29890. /**
  29891. * Detach the current controls from the specified dom element.
  29892. * @param element Defines the element to stop listening the inputs from
  29893. */
  29894. detachControl(element: HTMLElement): void;
  29895. /**
  29896. * Update the camera state according to the different inputs gathered during the frame.
  29897. */
  29898. update(): void;
  29899. /** @hidden */ checkInputs(): void;
  29900. /** @hidden */
  29901. readonly rigCameras: Camera[];
  29902. /**
  29903. * Gets the post process used by the rig cameras
  29904. */
  29905. readonly rigPostProcess: Nullable<PostProcess>;
  29906. /**
  29907. * Internal, gets the first post proces.
  29908. * @returns the first post process to be run on this camera.
  29909. */ getFirstPostProcess(): Nullable<PostProcess>;
  29910. private _cascadePostProcessesToRigCams;
  29911. /**
  29912. * Attach a post process to the camera.
  29913. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29914. * @param postProcess The post process to attach to the camera
  29915. * @param insertAt The position of the post process in case several of them are in use in the scene
  29916. * @returns the position the post process has been inserted at
  29917. */
  29918. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29919. /**
  29920. * Detach a post process to the camera.
  29921. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29922. * @param postProcess The post process to detach from the camera
  29923. */
  29924. detachPostProcess(postProcess: PostProcess): void;
  29925. /**
  29926. * Gets the current world matrix of the camera
  29927. */
  29928. getWorldMatrix(): Matrix;
  29929. /** @hidden */ getViewMatrix(): Matrix;
  29930. /**
  29931. * Gets the current view matrix of the camera.
  29932. * @param force forces the camera to recompute the matrix without looking at the cached state
  29933. * @returns the view matrix
  29934. */
  29935. getViewMatrix(force?: boolean): Matrix;
  29936. /**
  29937. * Freeze the projection matrix.
  29938. * It will prevent the cache check of the camera projection compute and can speed up perf
  29939. * if no parameter of the camera are meant to change
  29940. * @param projection Defines manually a projection if necessary
  29941. */
  29942. freezeProjectionMatrix(projection?: Matrix): void;
  29943. /**
  29944. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29945. */
  29946. unfreezeProjectionMatrix(): void;
  29947. /**
  29948. * Gets the current projection matrix of the camera.
  29949. * @param force forces the camera to recompute the matrix without looking at the cached state
  29950. * @returns the projection matrix
  29951. */
  29952. getProjectionMatrix(force?: boolean): Matrix;
  29953. /**
  29954. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29955. * @returns a Matrix
  29956. */
  29957. getTransformationMatrix(): Matrix;
  29958. private _updateFrustumPlanes;
  29959. /**
  29960. * Checks if a cullable object (mesh...) is in the camera frustum
  29961. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29962. * @param target The object to check
  29963. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29964. * @returns true if the object is in frustum otherwise false
  29965. */
  29966. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29967. /**
  29968. * Checks if a cullable object (mesh...) is in the camera frustum
  29969. * Unlike isInFrustum this cheks the full bounding box
  29970. * @param target The object to check
  29971. * @returns true if the object is in frustum otherwise false
  29972. */
  29973. isCompletelyInFrustum(target: ICullable): boolean;
  29974. /**
  29975. * Gets a ray in the forward direction from the camera.
  29976. * @param length Defines the length of the ray to create
  29977. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29978. * @param origin Defines the start point of the ray which defaults to the camera position
  29979. * @returns the forward ray
  29980. */
  29981. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29982. /**
  29983. * Releases resources associated with this node.
  29984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29986. */
  29987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29988. /** @hidden */ isLeftCamera: boolean;
  29989. /**
  29990. * Gets the left camera of a rig setup in case of Rigged Camera
  29991. */
  29992. readonly isLeftCamera: boolean;
  29993. /** @hidden */ isRightCamera: boolean;
  29994. /**
  29995. * Gets the right camera of a rig setup in case of Rigged Camera
  29996. */
  29997. readonly isRightCamera: boolean;
  29998. /**
  29999. * Gets the left camera of a rig setup in case of Rigged Camera
  30000. */
  30001. readonly leftCamera: Nullable<FreeCamera>;
  30002. /**
  30003. * Gets the right camera of a rig setup in case of Rigged Camera
  30004. */
  30005. readonly rightCamera: Nullable<FreeCamera>;
  30006. /**
  30007. * Gets the left camera target of a rig setup in case of Rigged Camera
  30008. * @returns the target position
  30009. */
  30010. getLeftTarget(): Nullable<Vector3>;
  30011. /**
  30012. * Gets the right camera target of a rig setup in case of Rigged Camera
  30013. * @returns the target position
  30014. */
  30015. getRightTarget(): Nullable<Vector3>;
  30016. /**
  30017. * @hidden
  30018. */
  30019. setCameraRigMode(mode: number, rigParams: any): void;
  30020. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30021. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30022. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30023. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30024. /** @hidden */ getVRProjectionMatrix(): Matrix;
  30025. protected _updateCameraRotationMatrix(): void;
  30026. protected _updateWebVRCameraRotationMatrix(): void;
  30027. /**
  30028. * This function MUST be overwritten by the different WebVR cameras available.
  30029. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30030. * @hidden
  30031. */ getWebVRProjectionMatrix(): Matrix;
  30032. /**
  30033. * This function MUST be overwritten by the different WebVR cameras available.
  30034. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30035. * @hidden
  30036. */ getWebVRViewMatrix(): Matrix;
  30037. /** @hidden */
  30038. setCameraRigParameter(name: string, value: any): void;
  30039. /**
  30040. * needs to be overridden by children so sub has required properties to be copied
  30041. * @hidden
  30042. */
  30043. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30044. /**
  30045. * May need to be overridden by children
  30046. * @hidden
  30047. */ updateRigCameras(): void;
  30048. /** @hidden */ setupInputs(): void;
  30049. /**
  30050. * Serialiaze the camera setup to a json represention
  30051. * @returns the JSON representation
  30052. */
  30053. serialize(): any;
  30054. /**
  30055. * Clones the current camera.
  30056. * @param name The cloned camera name
  30057. * @returns the cloned camera
  30058. */
  30059. clone(name: string): Camera;
  30060. /**
  30061. * Gets the direction of the camera relative to a given local axis.
  30062. * @param localAxis Defines the reference axis to provide a relative direction.
  30063. * @return the direction
  30064. */
  30065. getDirection(localAxis: Vector3): Vector3;
  30066. /**
  30067. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30068. * @param localAxis Defines the reference axis to provide a relative direction.
  30069. * @param result Defines the vector to store the result in
  30070. */
  30071. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30072. /**
  30073. * Gets a camera constructor for a given camera type
  30074. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30075. * @param name The name of the camera the result will be able to instantiate
  30076. * @param scene The scene the result will construct the camera in
  30077. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30078. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30079. * @returns a factory method to construc the camera
  30080. */
  30081. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30082. /**
  30083. * Compute the world matrix of the camera.
  30084. * @returns the camera workd matrix
  30085. */
  30086. computeWorldMatrix(): Matrix;
  30087. /**
  30088. * Parse a JSON and creates the camera from the parsed information
  30089. * @param parsedCamera The JSON to parse
  30090. * @param scene The scene to instantiate the camera in
  30091. * @returns the newly constructed camera
  30092. */
  30093. static Parse(parsedCamera: any, scene: Scene): Camera;
  30094. }
  30095. }
  30096. declare module BABYLON {
  30097. /**
  30098. * Interface for any object that can request an animation frame
  30099. */
  30100. export interface ICustomAnimationFrameRequester {
  30101. /**
  30102. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30103. */
  30104. renderFunction?: Function;
  30105. /**
  30106. * Called to request the next frame to render to
  30107. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30108. */
  30109. requestAnimationFrame: Function;
  30110. /**
  30111. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30112. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30113. */
  30114. requestID?: number;
  30115. }
  30116. /**
  30117. * Interface containing an array of animations
  30118. */
  30119. export interface IAnimatable {
  30120. /**
  30121. * Array of animations
  30122. */
  30123. animations: Nullable<Array<Animation>>;
  30124. }
  30125. /** Interface used by value gradients (color, factor, ...) */
  30126. export interface IValueGradient {
  30127. /**
  30128. * Gets or sets the gradient value (between 0 and 1)
  30129. */
  30130. gradient: number;
  30131. }
  30132. /** Class used to store color4 gradient */
  30133. export class ColorGradient implements IValueGradient {
  30134. /**
  30135. * Gets or sets the gradient value (between 0 and 1)
  30136. */
  30137. gradient: number;
  30138. /**
  30139. * Gets or sets first associated color
  30140. */
  30141. color1: Color4;
  30142. /**
  30143. * Gets or sets second associated color
  30144. */
  30145. color2?: Color4;
  30146. /**
  30147. * Will get a color picked randomly between color1 and color2.
  30148. * If color2 is undefined then color1 will be used
  30149. * @param result defines the target Color4 to store the result in
  30150. */
  30151. getColorToRef(result: Color4): void;
  30152. }
  30153. /** Class used to store color 3 gradient */
  30154. export class Color3Gradient implements IValueGradient {
  30155. /**
  30156. * Gets or sets the gradient value (between 0 and 1)
  30157. */
  30158. gradient: number;
  30159. /**
  30160. * Gets or sets the associated color
  30161. */
  30162. color: Color3;
  30163. }
  30164. /** Class used to store factor gradient */
  30165. export class FactorGradient implements IValueGradient {
  30166. /**
  30167. * Gets or sets the gradient value (between 0 and 1)
  30168. */
  30169. gradient: number;
  30170. /**
  30171. * Gets or sets first associated factor
  30172. */
  30173. factor1: number;
  30174. /**
  30175. * Gets or sets second associated factor
  30176. */
  30177. factor2?: number;
  30178. /**
  30179. * Will get a number picked randomly between factor1 and factor2.
  30180. * If factor2 is undefined then factor1 will be used
  30181. * @returns the picked number
  30182. */
  30183. getFactor(): number;
  30184. }
  30185. /**
  30186. * @ignore
  30187. * Application error to support additional information when loading a file
  30188. */
  30189. export class LoadFileError extends Error {
  30190. /** defines the optional web request */
  30191. request?: WebRequest | undefined;
  30192. private static _setPrototypeOf;
  30193. /**
  30194. * Creates a new LoadFileError
  30195. * @param message defines the message of the error
  30196. * @param request defines the optional web request
  30197. */
  30198. constructor(message: string,
  30199. /** defines the optional web request */
  30200. request?: WebRequest | undefined);
  30201. }
  30202. /**
  30203. * Class used to define a retry strategy when error happens while loading assets
  30204. */
  30205. export class RetryStrategy {
  30206. /**
  30207. * Function used to defines an exponential back off strategy
  30208. * @param maxRetries defines the maximum number of retries (3 by default)
  30209. * @param baseInterval defines the interval between retries
  30210. * @returns the strategy function to use
  30211. */
  30212. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30213. }
  30214. /**
  30215. * File request interface
  30216. */
  30217. export interface IFileRequest {
  30218. /**
  30219. * Raised when the request is complete (success or error).
  30220. */
  30221. onCompleteObservable: Observable<IFileRequest>;
  30222. /**
  30223. * Aborts the request for a file.
  30224. */
  30225. abort: () => void;
  30226. }
  30227. /**
  30228. * Class containing a set of static utilities functions
  30229. */
  30230. export class Tools {
  30231. /**
  30232. * Gets or sets the base URL to use to load assets
  30233. */
  30234. static BaseUrl: string;
  30235. /**
  30236. * Enable/Disable Custom HTTP Request Headers globally.
  30237. * default = false
  30238. * @see CustomRequestHeaders
  30239. */
  30240. static UseCustomRequestHeaders: boolean;
  30241. /**
  30242. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30243. * i.e. when loading files, where the server/service expects an Authorization header
  30244. */
  30245. static CustomRequestHeaders: {
  30246. [key: string]: string;
  30247. };
  30248. /**
  30249. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30250. */
  30251. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30252. /**
  30253. * Default behaviour for cors in the application.
  30254. * It can be a string if the expected behavior is identical in the entire app.
  30255. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30256. */
  30257. static CorsBehavior: string | ((url: string | string[]) => string);
  30258. /**
  30259. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30260. * @ignorenaming
  30261. */
  30262. static UseFallbackTexture: boolean;
  30263. /**
  30264. * Use this object to register external classes like custom textures or material
  30265. * to allow the laoders to instantiate them
  30266. */
  30267. static RegisteredExternalClasses: {
  30268. [key: string]: Object;
  30269. };
  30270. /**
  30271. * Texture content used if a texture cannot loaded
  30272. * @ignorenaming
  30273. */
  30274. static fallbackTexture: string;
  30275. /**
  30276. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30277. * @param u defines the coordinate on X axis
  30278. * @param v defines the coordinate on Y axis
  30279. * @param width defines the width of the source data
  30280. * @param height defines the height of the source data
  30281. * @param pixels defines the source byte array
  30282. * @param color defines the output color
  30283. */
  30284. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30285. /**
  30286. * Interpolates between a and b via alpha
  30287. * @param a The lower value (returned when alpha = 0)
  30288. * @param b The upper value (returned when alpha = 1)
  30289. * @param alpha The interpolation-factor
  30290. * @return The mixed value
  30291. */
  30292. static Mix(a: number, b: number, alpha: number): number;
  30293. /**
  30294. * Tries to instantiate a new object from a given class name
  30295. * @param className defines the class name to instantiate
  30296. * @returns the new object or null if the system was not able to do the instantiation
  30297. */
  30298. static Instantiate(className: string): any;
  30299. /**
  30300. * Provides a slice function that will work even on IE
  30301. * @param data defines the array to slice
  30302. * @param start defines the start of the data (optional)
  30303. * @param end defines the end of the data (optional)
  30304. * @returns the new sliced array
  30305. */
  30306. static Slice<T>(data: T, start?: number, end?: number): T;
  30307. /**
  30308. * Polyfill for setImmediate
  30309. * @param action defines the action to execute after the current execution block
  30310. */
  30311. static SetImmediate(action: () => void): void;
  30312. /**
  30313. * Function indicating if a number is an exponent of 2
  30314. * @param value defines the value to test
  30315. * @returns true if the value is an exponent of 2
  30316. */
  30317. static IsExponentOfTwo(value: number): boolean;
  30318. private static _tmpFloatArray;
  30319. /**
  30320. * Returns the nearest 32-bit single precision float representation of a Number
  30321. * @param value A Number. If the parameter is of a different type, it will get converted
  30322. * to a number or to NaN if it cannot be converted
  30323. * @returns number
  30324. */
  30325. static FloatRound(value: number): number;
  30326. /**
  30327. * Find the next highest power of two.
  30328. * @param x Number to start search from.
  30329. * @return Next highest power of two.
  30330. */
  30331. static CeilingPOT(x: number): number;
  30332. /**
  30333. * Find the next lowest power of two.
  30334. * @param x Number to start search from.
  30335. * @return Next lowest power of two.
  30336. */
  30337. static FloorPOT(x: number): number;
  30338. /**
  30339. * Find the nearest power of two.
  30340. * @param x Number to start search from.
  30341. * @return Next nearest power of two.
  30342. */
  30343. static NearestPOT(x: number): number;
  30344. /**
  30345. * Get the closest exponent of two
  30346. * @param value defines the value to approximate
  30347. * @param max defines the maximum value to return
  30348. * @param mode defines how to define the closest value
  30349. * @returns closest exponent of two of the given value
  30350. */
  30351. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30352. /**
  30353. * Extracts the filename from a path
  30354. * @param path defines the path to use
  30355. * @returns the filename
  30356. */
  30357. static GetFilename(path: string): string;
  30358. /**
  30359. * Extracts the "folder" part of a path (everything before the filename).
  30360. * @param uri The URI to extract the info from
  30361. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30362. * @returns The "folder" part of the path
  30363. */
  30364. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30365. /**
  30366. * Extracts text content from a DOM element hierarchy
  30367. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30368. */
  30369. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30370. /**
  30371. * Convert an angle in radians to degrees
  30372. * @param angle defines the angle to convert
  30373. * @returns the angle in degrees
  30374. */
  30375. static ToDegrees(angle: number): number;
  30376. /**
  30377. * Convert an angle in degrees to radians
  30378. * @param angle defines the angle to convert
  30379. * @returns the angle in radians
  30380. */
  30381. static ToRadians(angle: number): number;
  30382. /**
  30383. * Encode a buffer to a base64 string
  30384. * @param buffer defines the buffer to encode
  30385. * @returns the encoded string
  30386. */
  30387. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30388. /**
  30389. * Extracts minimum and maximum values from a list of indexed positions
  30390. * @param positions defines the positions to use
  30391. * @param indices defines the indices to the positions
  30392. * @param indexStart defines the start index
  30393. * @param indexCount defines the end index
  30394. * @param bias defines bias value to add to the result
  30395. * @return minimum and maximum values
  30396. */
  30397. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30398. minimum: Vector3;
  30399. maximum: Vector3;
  30400. };
  30401. /**
  30402. * Extracts minimum and maximum values from a list of positions
  30403. * @param positions defines the positions to use
  30404. * @param start defines the start index in the positions array
  30405. * @param count defines the number of positions to handle
  30406. * @param bias defines bias value to add to the result
  30407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30408. * @return minimum and maximum values
  30409. */
  30410. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30411. minimum: Vector3;
  30412. maximum: Vector3;
  30413. };
  30414. /**
  30415. * Returns an array if obj is not an array
  30416. * @param obj defines the object to evaluate as an array
  30417. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30418. * @returns either obj directly if obj is an array or a new array containing obj
  30419. */
  30420. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30421. /**
  30422. * Gets the pointer prefix to use
  30423. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30424. */
  30425. static GetPointerPrefix(): string;
  30426. /**
  30427. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30428. * @param func - the function to be called
  30429. * @param requester - the object that will request the next frame. Falls back to window.
  30430. * @returns frame number
  30431. */
  30432. static QueueNewFrame(func: () => void, requester?: any): number;
  30433. /**
  30434. * Ask the browser to promote the current element to fullscreen rendering mode
  30435. * @param element defines the DOM element to promote
  30436. */
  30437. static RequestFullscreen(element: HTMLElement): void;
  30438. /**
  30439. * Asks the browser to exit fullscreen mode
  30440. */
  30441. static ExitFullscreen(): void;
  30442. /**
  30443. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30444. * @param url define the url we are trying
  30445. * @param element define the dom element where to configure the cors policy
  30446. */
  30447. static SetCorsBehavior(url: string | string[], element: {
  30448. crossOrigin: string | null;
  30449. }): void;
  30450. /**
  30451. * Removes unwanted characters from an url
  30452. * @param url defines the url to clean
  30453. * @returns the cleaned url
  30454. */
  30455. static CleanUrl(url: string): string;
  30456. /**
  30457. * Gets or sets a function used to pre-process url before using them to load assets
  30458. */
  30459. static PreprocessUrl: (url: string) => string;
  30460. /**
  30461. * Loads an image as an HTMLImageElement.
  30462. * @param input url string, ArrayBuffer, or Blob to load
  30463. * @param onLoad callback called when the image successfully loads
  30464. * @param onError callback called when the image fails to load
  30465. * @param offlineProvider offline provider for caching
  30466. * @returns the HTMLImageElement of the loaded image
  30467. */
  30468. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30469. /**
  30470. * Loads a file
  30471. * @param url url string, ArrayBuffer, or Blob to load
  30472. * @param onSuccess callback called when the file successfully loads
  30473. * @param onProgress callback called while file is loading (if the server supports this mode)
  30474. * @param offlineProvider defines the offline provider for caching
  30475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30476. * @param onError callback called when the file fails to load
  30477. * @returns a file request object
  30478. */
  30479. 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;
  30480. /**
  30481. * Load a script (identified by an url). When the url returns, the
  30482. * content of this file is added into a new script element, attached to the DOM (body element)
  30483. * @param scriptUrl defines the url of the script to laod
  30484. * @param onSuccess defines the callback called when the script is loaded
  30485. * @param onError defines the callback to call if an error occurs
  30486. * @param scriptId defines the id of the script element
  30487. */
  30488. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30489. /**
  30490. * Load an asynchronous script (identified by an url). When the url returns, the
  30491. * content of this file is added into a new script element, attached to the DOM (body element)
  30492. * @param scriptUrl defines the url of the script to laod
  30493. * @param scriptId defines the id of the script element
  30494. * @returns a promise request object
  30495. */
  30496. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30497. /**
  30498. * Loads a file from a blob
  30499. * @param fileToLoad defines the blob to use
  30500. * @param callback defines the callback to call when data is loaded
  30501. * @param progressCallback defines the callback to call during loading process
  30502. * @returns a file request object
  30503. */
  30504. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30505. /**
  30506. * Loads a file
  30507. * @param fileToLoad defines the file to load
  30508. * @param callback defines the callback to call when data is loaded
  30509. * @param progressCallBack defines the callback to call during loading process
  30510. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30511. * @returns a file request object
  30512. */
  30513. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30514. /**
  30515. * Creates a data url from a given string content
  30516. * @param content defines the content to convert
  30517. * @returns the new data url link
  30518. */
  30519. static FileAsURL(content: string): string;
  30520. /**
  30521. * Format the given number to a specific decimal format
  30522. * @param value defines the number to format
  30523. * @param decimals defines the number of decimals to use
  30524. * @returns the formatted string
  30525. */
  30526. static Format(value: number, decimals?: number): string;
  30527. /**
  30528. * Checks if a given vector is inside a specific range
  30529. * @param v defines the vector to test
  30530. * @param min defines the minimum range
  30531. * @param max defines the maximum range
  30532. */
  30533. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30534. /**
  30535. * Tries to copy an object by duplicating every property
  30536. * @param source defines the source object
  30537. * @param destination defines the target object
  30538. * @param doNotCopyList defines a list of properties to avoid
  30539. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30540. */
  30541. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30542. /**
  30543. * Gets a boolean indicating if the given object has no own property
  30544. * @param obj defines the object to test
  30545. * @returns true if object has no own property
  30546. */
  30547. static IsEmpty(obj: any): boolean;
  30548. /**
  30549. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30550. * @param str Source string
  30551. * @param suffix Suffix to search for in the source string
  30552. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30553. */
  30554. static EndsWith(str: string, suffix: string): boolean;
  30555. /**
  30556. * Function used to register events at window level
  30557. * @param events defines the events to register
  30558. */
  30559. static RegisterTopRootEvents(events: {
  30560. name: string;
  30561. handler: Nullable<(e: FocusEvent) => any>;
  30562. }[]): void;
  30563. /**
  30564. * Function used to unregister events from window level
  30565. * @param events defines the events to unregister
  30566. */
  30567. static UnregisterTopRootEvents(events: {
  30568. name: string;
  30569. handler: Nullable<(e: FocusEvent) => any>;
  30570. }[]): void;
  30571. /**
  30572. * @ignore
  30573. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30574. /**
  30575. * Dumps the current bound framebuffer
  30576. * @param width defines the rendering width
  30577. * @param height defines the rendering height
  30578. * @param engine defines the hosting engine
  30579. * @param successCallback defines the callback triggered once the data are available
  30580. * @param mimeType defines the mime type of the result
  30581. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30582. */
  30583. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30584. /**
  30585. * Converts the canvas data to blob.
  30586. * This acts as a polyfill for browsers not supporting the to blob function.
  30587. * @param canvas Defines the canvas to extract the data from
  30588. * @param successCallback Defines the callback triggered once the data are available
  30589. * @param mimeType Defines the mime type of the result
  30590. */
  30591. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30592. /**
  30593. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30594. * @param successCallback defines the callback triggered once the data are available
  30595. * @param mimeType defines the mime type of the result
  30596. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30597. */
  30598. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30599. /**
  30600. * Downloads a blob in the browser
  30601. * @param blob defines the blob to download
  30602. * @param fileName defines the name of the downloaded file
  30603. */
  30604. static Download(blob: Blob, fileName: string): void;
  30605. /**
  30606. * Captures a screenshot of the current rendering
  30607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30608. * @param engine defines the rendering engine
  30609. * @param camera defines the source camera
  30610. * @param size This parameter can be set to a single number or to an object with the
  30611. * following (optional) properties: precision, width, height. If a single number is passed,
  30612. * it will be used for both width and height. If an object is passed, the screenshot size
  30613. * will be derived from the parameters. The precision property is a multiplier allowing
  30614. * rendering at a higher or lower resolution
  30615. * @param successCallback defines the callback receives a single parameter which contains the
  30616. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30617. * src parameter of an <img> to display it
  30618. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30619. * Check your browser for supported MIME types
  30620. */
  30621. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30622. /**
  30623. * Generates an image screenshot from the specified camera.
  30624. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30625. * @param engine The engine to use for rendering
  30626. * @param camera The camera to use for rendering
  30627. * @param size This parameter can be set to a single number or to an object with the
  30628. * following (optional) properties: precision, width, height. If a single number is passed,
  30629. * it will be used for both width and height. If an object is passed, the screenshot size
  30630. * will be derived from the parameters. The precision property is a multiplier allowing
  30631. * rendering at a higher or lower resolution
  30632. * @param successCallback The callback receives a single parameter which contains the
  30633. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30634. * src parameter of an <img> to display it
  30635. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30636. * Check your browser for supported MIME types
  30637. * @param samples Texture samples (default: 1)
  30638. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30639. * @param fileName A name for for the downloaded file.
  30640. */
  30641. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30642. /**
  30643. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30644. * Be aware Math.random() could cause collisions, but:
  30645. * "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"
  30646. * @returns a pseudo random id
  30647. */
  30648. static RandomId(): string;
  30649. /**
  30650. * Test if the given uri is a base64 string
  30651. * @param uri The uri to test
  30652. * @return True if the uri is a base64 string or false otherwise
  30653. */
  30654. static IsBase64(uri: string): boolean;
  30655. /**
  30656. * Decode the given base64 uri.
  30657. * @param uri The uri to decode
  30658. * @return The decoded base64 data.
  30659. */
  30660. static DecodeBase64(uri: string): ArrayBuffer;
  30661. /**
  30662. * Gets the absolute url.
  30663. * @param url the input url
  30664. * @return the absolute url
  30665. */
  30666. static GetAbsoluteUrl(url: string): string;
  30667. /**
  30668. * No log
  30669. */
  30670. static readonly NoneLogLevel: number;
  30671. /**
  30672. * Only message logs
  30673. */
  30674. static readonly MessageLogLevel: number;
  30675. /**
  30676. * Only warning logs
  30677. */
  30678. static readonly WarningLogLevel: number;
  30679. /**
  30680. * Only error logs
  30681. */
  30682. static readonly ErrorLogLevel: number;
  30683. /**
  30684. * All logs
  30685. */
  30686. static readonly AllLogLevel: number;
  30687. /**
  30688. * Gets a value indicating the number of loading errors
  30689. * @ignorenaming
  30690. */
  30691. static readonly errorsCount: number;
  30692. /**
  30693. * Callback called when a new log is added
  30694. */
  30695. static OnNewCacheEntry: (entry: string) => void;
  30696. /**
  30697. * Log a message to the console
  30698. * @param message defines the message to log
  30699. */
  30700. static Log(message: string): void;
  30701. /**
  30702. * Write a warning message to the console
  30703. * @param message defines the message to log
  30704. */
  30705. static Warn(message: string): void;
  30706. /**
  30707. * Write an error message to the console
  30708. * @param message defines the message to log
  30709. */
  30710. static Error(message: string): void;
  30711. /**
  30712. * Gets current log cache (list of logs)
  30713. */
  30714. static readonly LogCache: string;
  30715. /**
  30716. * Clears the log cache
  30717. */
  30718. static ClearLogCache(): void;
  30719. /**
  30720. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30721. */
  30722. static LogLevels: number;
  30723. /**
  30724. * Checks if the loaded document was accessed via `file:`-Protocol.
  30725. * @returns boolean
  30726. */
  30727. static IsFileURL(): boolean;
  30728. /**
  30729. * Checks if the window object exists
  30730. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30731. */
  30732. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30733. /**
  30734. * No performance log
  30735. */
  30736. static readonly PerformanceNoneLogLevel: number;
  30737. /**
  30738. * Use user marks to log performance
  30739. */
  30740. static readonly PerformanceUserMarkLogLevel: number;
  30741. /**
  30742. * Log performance to the console
  30743. */
  30744. static readonly PerformanceConsoleLogLevel: number;
  30745. private static _performance;
  30746. /**
  30747. * Sets the current performance log level
  30748. */
  30749. static PerformanceLogLevel: number;
  30750. private static _StartPerformanceCounterDisabled;
  30751. private static _EndPerformanceCounterDisabled;
  30752. private static _StartUserMark;
  30753. private static _EndUserMark;
  30754. private static _StartPerformanceConsole;
  30755. private static _EndPerformanceConsole;
  30756. /**
  30757. * Starts a performance counter
  30758. */
  30759. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30760. /**
  30761. * Ends a specific performance coutner
  30762. */
  30763. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30764. /**
  30765. * Gets either window.performance.now() if supported or Date.now() else
  30766. */
  30767. static readonly Now: number;
  30768. /**
  30769. * This method will return the name of the class used to create the instance of the given object.
  30770. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30771. * @param object the object to get the class name from
  30772. * @param isType defines if the object is actually a type
  30773. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30774. */
  30775. static GetClassName(object: any, isType?: boolean): string;
  30776. /**
  30777. * Gets the first element of an array satisfying a given predicate
  30778. * @param array defines the array to browse
  30779. * @param predicate defines the predicate to use
  30780. * @returns null if not found or the element
  30781. */
  30782. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30783. /**
  30784. * This method will return the name of the full name of the class, including its owning module (if any).
  30785. * 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).
  30786. * @param object the object to get the class name from
  30787. * @param isType defines if the object is actually a type
  30788. * @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.
  30789. * @ignorenaming
  30790. */
  30791. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30792. /**
  30793. * Returns a promise that resolves after the given amount of time.
  30794. * @param delay Number of milliseconds to delay
  30795. * @returns Promise that resolves after the given amount of time
  30796. */
  30797. static DelayAsync(delay: number): Promise<void>;
  30798. /**
  30799. * Gets the current gradient from an array of IValueGradient
  30800. * @param ratio defines the current ratio to get
  30801. * @param gradients defines the array of IValueGradient
  30802. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30803. */
  30804. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30805. }
  30806. /**
  30807. * This class is used to track a performance counter which is number based.
  30808. * The user has access to many properties which give statistics of different nature.
  30809. *
  30810. * The implementer can track two kinds of Performance Counter: time and count.
  30811. * 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.
  30812. * 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.
  30813. */
  30814. export class PerfCounter {
  30815. /**
  30816. * Gets or sets a global boolean to turn on and off all the counters
  30817. */
  30818. static Enabled: boolean;
  30819. /**
  30820. * Returns the smallest value ever
  30821. */
  30822. readonly min: number;
  30823. /**
  30824. * Returns the biggest value ever
  30825. */
  30826. readonly max: number;
  30827. /**
  30828. * Returns the average value since the performance counter is running
  30829. */
  30830. readonly average: number;
  30831. /**
  30832. * Returns the average value of the last second the counter was monitored
  30833. */
  30834. readonly lastSecAverage: number;
  30835. /**
  30836. * Returns the current value
  30837. */
  30838. readonly current: number;
  30839. /**
  30840. * Gets the accumulated total
  30841. */
  30842. readonly total: number;
  30843. /**
  30844. * Gets the total value count
  30845. */
  30846. readonly count: number;
  30847. /**
  30848. * Creates a new counter
  30849. */
  30850. constructor();
  30851. /**
  30852. * Call this method to start monitoring a new frame.
  30853. * 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.
  30854. */
  30855. fetchNewFrame(): void;
  30856. /**
  30857. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30858. * @param newCount the count value to add to the monitored count
  30859. * @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.
  30860. */
  30861. addCount(newCount: number, fetchResult: boolean): void;
  30862. /**
  30863. * Start monitoring this performance counter
  30864. */
  30865. beginMonitoring(): void;
  30866. /**
  30867. * Compute the time lapsed since the previous beginMonitoring() call.
  30868. * @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
  30869. */
  30870. endMonitoring(newFrame?: boolean): void;
  30871. private _fetchResult;
  30872. private _startMonitoringTime;
  30873. private _min;
  30874. private _max;
  30875. private _average;
  30876. private _current;
  30877. private _totalValueCount;
  30878. private _totalAccumulated;
  30879. private _lastSecAverage;
  30880. private _lastSecAccumulated;
  30881. private _lastSecTime;
  30882. private _lastSecValueCount;
  30883. }
  30884. /**
  30885. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30886. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30887. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30888. * @param name The name of the class, case should be preserved
  30889. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30890. */
  30891. export function className(name: string, module?: string): (target: Object) => void;
  30892. /**
  30893. * An implementation of a loop for asynchronous functions.
  30894. */
  30895. export class AsyncLoop {
  30896. /**
  30897. * Defines the number of iterations for the loop
  30898. */
  30899. iterations: number;
  30900. /**
  30901. * Defines the current index of the loop.
  30902. */
  30903. index: number;
  30904. private _done;
  30905. private _fn;
  30906. private _successCallback;
  30907. /**
  30908. * Constructor.
  30909. * @param iterations the number of iterations.
  30910. * @param func the function to run each iteration
  30911. * @param successCallback the callback that will be called upon succesful execution
  30912. * @param offset starting offset.
  30913. */
  30914. constructor(
  30915. /**
  30916. * Defines the number of iterations for the loop
  30917. */
  30918. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30919. /**
  30920. * Execute the next iteration. Must be called after the last iteration was finished.
  30921. */
  30922. executeNext(): void;
  30923. /**
  30924. * Break the loop and run the success callback.
  30925. */
  30926. breakLoop(): void;
  30927. /**
  30928. * Create and run an async loop.
  30929. * @param iterations the number of iterations.
  30930. * @param fn the function to run each iteration
  30931. * @param successCallback the callback that will be called upon succesful execution
  30932. * @param offset starting offset.
  30933. * @returns the created async loop object
  30934. */
  30935. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30936. /**
  30937. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30938. * @param iterations total number of iterations
  30939. * @param syncedIterations number of synchronous iterations in each async iteration.
  30940. * @param fn the function to call each iteration.
  30941. * @param callback a success call back that will be called when iterating stops.
  30942. * @param breakFunction a break condition (optional)
  30943. * @param timeout timeout settings for the setTimeout function. default - 0.
  30944. * @returns the created async loop object
  30945. */
  30946. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30947. }
  30948. }
  30949. declare module BABYLON {
  30950. /** @hidden */
  30951. export interface ICollisionCoordinator {
  30952. createCollider(): Collider;
  30953. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30954. init(scene: Scene): void;
  30955. }
  30956. /** @hidden */
  30957. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30958. private _scene;
  30959. private _scaledPosition;
  30960. private _scaledVelocity;
  30961. private _finalPosition;
  30962. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30963. createCollider(): Collider;
  30964. init(scene: Scene): void;
  30965. private _collideWithWorld;
  30966. }
  30967. }
  30968. declare module BABYLON {
  30969. /**
  30970. * Class used to manage all inputs for the scene.
  30971. */
  30972. export class InputManager {
  30973. /** The distance in pixel that you have to move to prevent some events */
  30974. static DragMovementThreshold: number;
  30975. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30976. static LongPressDelay: number;
  30977. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30978. static DoubleClickDelay: number;
  30979. /** If you need to check double click without raising a single click at first click, enable this flag */
  30980. static ExclusiveDoubleClickMode: boolean;
  30981. private _wheelEventName;
  30982. private _onPointerMove;
  30983. private _onPointerDown;
  30984. private _onPointerUp;
  30985. private _initClickEvent;
  30986. private _initActionManager;
  30987. private _delayedSimpleClick;
  30988. private _delayedSimpleClickTimeout;
  30989. private _previousDelayedSimpleClickTimeout;
  30990. private _meshPickProceed;
  30991. private _previousButtonPressed;
  30992. private _currentPickResult;
  30993. private _previousPickResult;
  30994. private _totalPointersPressed;
  30995. private _doubleClickOccured;
  30996. private _pointerOverMesh;
  30997. private _pickedDownMesh;
  30998. private _pickedUpMesh;
  30999. private _pointerX;
  31000. private _pointerY;
  31001. private _unTranslatedPointerX;
  31002. private _unTranslatedPointerY;
  31003. private _startingPointerPosition;
  31004. private _previousStartingPointerPosition;
  31005. private _startingPointerTime;
  31006. private _previousStartingPointerTime;
  31007. private _pointerCaptures;
  31008. private _onKeyDown;
  31009. private _onKeyUp;
  31010. private _onCanvasFocusObserver;
  31011. private _onCanvasBlurObserver;
  31012. private _scene;
  31013. /**
  31014. * Creates a new InputManager
  31015. * @param scene defines the hosting scene
  31016. */
  31017. constructor(scene: Scene);
  31018. /**
  31019. * Gets the mesh that is currently under the pointer
  31020. */
  31021. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31022. /**
  31023. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31024. */
  31025. readonly unTranslatedPointer: Vector2;
  31026. /**
  31027. * Gets or sets the current on-screen X position of the pointer
  31028. */
  31029. pointerX: number;
  31030. /**
  31031. * Gets or sets the current on-screen Y position of the pointer
  31032. */
  31033. pointerY: number;
  31034. private _updatePointerPosition;
  31035. private _processPointerMove;
  31036. private _setRayOnPointerInfo;
  31037. private _checkPrePointerObservable;
  31038. /**
  31039. * Use this method to simulate a pointer move on a mesh
  31040. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31041. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31042. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31043. */
  31044. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31045. /**
  31046. * Use this method to simulate a pointer down on a mesh
  31047. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31048. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31049. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31050. */
  31051. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31052. private _processPointerDown;
  31053. /** @hidden */ isPointerSwiping(): boolean;
  31054. /**
  31055. * Use this method to simulate a pointer up on a mesh
  31056. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31057. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31058. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31059. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31060. */
  31061. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31062. private _processPointerUp;
  31063. /**
  31064. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31065. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31066. * @returns true if the pointer was captured
  31067. */
  31068. isPointerCaptured(pointerId?: number): boolean;
  31069. /**
  31070. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31071. * @param attachUp defines if you want to attach events to pointerup
  31072. * @param attachDown defines if you want to attach events to pointerdown
  31073. * @param attachMove defines if you want to attach events to pointermove
  31074. */
  31075. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31076. /**
  31077. * Detaches all event handlers
  31078. */
  31079. detachControl(): void;
  31080. /**
  31081. * Force the value of meshUnderPointer
  31082. * @param mesh defines the mesh to use
  31083. */
  31084. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31085. /**
  31086. * Gets the mesh under the pointer
  31087. * @returns a Mesh or null if no mesh is under the pointer
  31088. */
  31089. getPointerOverMesh(): Nullable<AbstractMesh>;
  31090. }
  31091. }
  31092. declare module BABYLON {
  31093. /**
  31094. * This class defines the direct association between an animation and a target
  31095. */
  31096. export class TargetedAnimation {
  31097. /**
  31098. * Animation to perform
  31099. */
  31100. animation: Animation;
  31101. /**
  31102. * Target to animate
  31103. */
  31104. target: any;
  31105. }
  31106. /**
  31107. * Use this class to create coordinated animations on multiple targets
  31108. */
  31109. export class AnimationGroup implements IDisposable {
  31110. /** The name of the animation group */
  31111. name: string;
  31112. private _scene;
  31113. private _targetedAnimations;
  31114. private _animatables;
  31115. private _from;
  31116. private _to;
  31117. private _isStarted;
  31118. private _isPaused;
  31119. private _speedRatio;
  31120. /**
  31121. * Gets or sets the unique id of the node
  31122. */
  31123. uniqueId: number;
  31124. /**
  31125. * This observable will notify when one animation have ended
  31126. */
  31127. onAnimationEndObservable: Observable<TargetedAnimation>;
  31128. /**
  31129. * Observer raised when one animation loops
  31130. */
  31131. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31132. /**
  31133. * This observable will notify when all animations have ended.
  31134. */
  31135. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31136. /**
  31137. * This observable will notify when all animations have paused.
  31138. */
  31139. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31140. /**
  31141. * This observable will notify when all animations are playing.
  31142. */
  31143. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31144. /**
  31145. * Gets the first frame
  31146. */
  31147. readonly from: number;
  31148. /**
  31149. * Gets the last frame
  31150. */
  31151. readonly to: number;
  31152. /**
  31153. * Define if the animations are started
  31154. */
  31155. readonly isStarted: boolean;
  31156. /**
  31157. * Gets a value indicating that the current group is playing
  31158. */
  31159. readonly isPlaying: boolean;
  31160. /**
  31161. * Gets or sets the speed ratio to use for all animations
  31162. */
  31163. /**
  31164. * Gets or sets the speed ratio to use for all animations
  31165. */
  31166. speedRatio: number;
  31167. /**
  31168. * Gets the targeted animations for this animation group
  31169. */
  31170. readonly targetedAnimations: Array<TargetedAnimation>;
  31171. /**
  31172. * returning the list of animatables controlled by this animation group.
  31173. */
  31174. readonly animatables: Array<Animatable>;
  31175. /**
  31176. * Instantiates a new Animation Group.
  31177. * This helps managing several animations at once.
  31178. * @see http://doc.babylonjs.com/how_to/group
  31179. * @param name Defines the name of the group
  31180. * @param scene Defines the scene the group belongs to
  31181. */
  31182. constructor(
  31183. /** The name of the animation group */
  31184. name: string, scene?: Nullable<Scene>);
  31185. /**
  31186. * Add an animation (with its target) in the group
  31187. * @param animation defines the animation we want to add
  31188. * @param target defines the target of the animation
  31189. * @returns the TargetedAnimation object
  31190. */
  31191. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31192. /**
  31193. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31194. * It can add constant keys at begin or end
  31195. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31196. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31197. * @returns the animation group
  31198. */
  31199. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31200. /**
  31201. * Start all animations on given targets
  31202. * @param loop defines if animations must loop
  31203. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31204. * @param from defines the from key (optional)
  31205. * @param to defines the to key (optional)
  31206. * @returns the current animation group
  31207. */
  31208. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31209. /**
  31210. * Pause all animations
  31211. * @returns the animation group
  31212. */
  31213. pause(): AnimationGroup;
  31214. /**
  31215. * Play all animations to initial state
  31216. * This function will start() the animations if they were not started or will restart() them if they were paused
  31217. * @param loop defines if animations must loop
  31218. * @returns the animation group
  31219. */
  31220. play(loop?: boolean): AnimationGroup;
  31221. /**
  31222. * Reset all animations to initial state
  31223. * @returns the animation group
  31224. */
  31225. reset(): AnimationGroup;
  31226. /**
  31227. * Restart animations from key 0
  31228. * @returns the animation group
  31229. */
  31230. restart(): AnimationGroup;
  31231. /**
  31232. * Stop all animations
  31233. * @returns the animation group
  31234. */
  31235. stop(): AnimationGroup;
  31236. /**
  31237. * Set animation weight for all animatables
  31238. * @param weight defines the weight to use
  31239. * @return the animationGroup
  31240. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31241. */
  31242. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31243. /**
  31244. * Synchronize and normalize all animatables with a source animatable
  31245. * @param root defines the root animatable to synchronize with
  31246. * @return the animationGroup
  31247. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31248. */
  31249. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31250. /**
  31251. * Goes to a specific frame in this animation group
  31252. * @param frame the frame number to go to
  31253. * @return the animationGroup
  31254. */
  31255. goToFrame(frame: number): AnimationGroup;
  31256. /**
  31257. * Dispose all associated resources
  31258. */
  31259. dispose(): void;
  31260. private _checkAnimationGroupEnded;
  31261. /**
  31262. * Clone the current animation group and returns a copy
  31263. * @param newName defines the name of the new group
  31264. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31265. * @returns the new aniamtion group
  31266. */
  31267. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31268. /**
  31269. * Returns a new AnimationGroup object parsed from the source provided.
  31270. * @param parsedAnimationGroup defines the source
  31271. * @param scene defines the scene that will receive the animationGroup
  31272. * @returns a new AnimationGroup
  31273. */
  31274. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31275. /**
  31276. * Returns the string "AnimationGroup"
  31277. * @returns "AnimationGroup"
  31278. */
  31279. getClassName(): string;
  31280. /**
  31281. * Creates a detailled string about the object
  31282. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31283. * @returns a string representing the object
  31284. */
  31285. toString(fullDetails?: boolean): string;
  31286. }
  31287. }
  31288. declare module BABYLON {
  31289. /**
  31290. * Define an interface for all classes that will hold resources
  31291. */
  31292. export interface IDisposable {
  31293. /**
  31294. * Releases all held resources
  31295. */
  31296. dispose(): void;
  31297. }
  31298. /** Interface defining initialization parameters for Scene class */
  31299. export interface SceneOptions {
  31300. /**
  31301. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31302. * It will improve performance when the number of geometries becomes important.
  31303. */
  31304. useGeometryUniqueIdsMap?: boolean;
  31305. /**
  31306. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31307. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31308. */
  31309. useMaterialMeshMap?: boolean;
  31310. /**
  31311. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31312. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31313. */
  31314. useClonedMeshhMap?: boolean;
  31315. }
  31316. /**
  31317. * Represents a scene to be rendered by the engine.
  31318. * @see http://doc.babylonjs.com/features/scene
  31319. */
  31320. export class Scene extends AbstractScene implements IAnimatable {
  31321. private static _uniqueIdCounter;
  31322. /** The fog is deactivated */
  31323. static readonly FOGMODE_NONE: number;
  31324. /** The fog density is following an exponential function */
  31325. static readonly FOGMODE_EXP: number;
  31326. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31327. static readonly FOGMODE_EXP2: number;
  31328. /** The fog density is following a linear function. */
  31329. static readonly FOGMODE_LINEAR: number;
  31330. /**
  31331. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31332. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31333. */
  31334. static MinDeltaTime: number;
  31335. /**
  31336. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31338. */
  31339. static MaxDeltaTime: number;
  31340. /**
  31341. * Factory used to create the default material.
  31342. * @param name The name of the material to create
  31343. * @param scene The scene to create the material for
  31344. * @returns The default material
  31345. */
  31346. static DefaultMaterialFactory(scene: Scene): Material;
  31347. /**
  31348. * Factory used to create the a collision coordinator.
  31349. * @returns The collision coordinator
  31350. */
  31351. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31352. /** @hidden */ inputManager: InputManager;
  31353. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31354. cameraToUseForPointers: Nullable<Camera>;
  31355. /** @hidden */ protected readonly _isScene: boolean;
  31356. /**
  31357. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31358. */
  31359. autoClear: boolean;
  31360. /**
  31361. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31362. */
  31363. autoClearDepthAndStencil: boolean;
  31364. /**
  31365. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31366. */
  31367. clearColor: Color4;
  31368. /**
  31369. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31370. */
  31371. ambientColor: Color3;
  31372. /**
  31373. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31374. * It should only be one of the following (if not the default embedded one):
  31375. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31376. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31377. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31378. * The material properties need to be setup according to the type of texture in use.
  31379. */
  31380. environmentBRDFTexture: BaseTexture;
  31381. /** @hidden */
  31382. protected _environmentTexture: Nullable<BaseTexture>;
  31383. /**
  31384. * Texture used in all pbr material as the reflection texture.
  31385. * As in the majority of the scene they are the same (exception for multi room and so on),
  31386. * this is easier to reference from here than from all the materials.
  31387. */
  31388. /**
  31389. * Texture used in all pbr material as the reflection texture.
  31390. * As in the majority of the scene they are the same (exception for multi room and so on),
  31391. * this is easier to set here than in all the materials.
  31392. */
  31393. environmentTexture: Nullable<BaseTexture>;
  31394. /** @hidden */
  31395. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31396. /**
  31397. * Default image processing configuration used either in the rendering
  31398. * Forward main pass or through the imageProcessingPostProcess if present.
  31399. * As in the majority of the scene they are the same (exception for multi camera),
  31400. * this is easier to reference from here than from all the materials and post process.
  31401. *
  31402. * No setter as we it is a shared configuration, you can set the values instead.
  31403. */
  31404. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31405. private _forceWireframe;
  31406. /**
  31407. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31408. */
  31409. forceWireframe: boolean;
  31410. private _forcePointsCloud;
  31411. /**
  31412. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31413. */
  31414. forcePointsCloud: boolean;
  31415. /**
  31416. * Gets or sets the active clipplane 1
  31417. */
  31418. clipPlane: Nullable<Plane>;
  31419. /**
  31420. * Gets or sets the active clipplane 2
  31421. */
  31422. clipPlane2: Nullable<Plane>;
  31423. /**
  31424. * Gets or sets the active clipplane 3
  31425. */
  31426. clipPlane3: Nullable<Plane>;
  31427. /**
  31428. * Gets or sets the active clipplane 4
  31429. */
  31430. clipPlane4: Nullable<Plane>;
  31431. /**
  31432. * Gets or sets a boolean indicating if animations are enabled
  31433. */
  31434. animationsEnabled: boolean;
  31435. private _animationPropertiesOverride;
  31436. /**
  31437. * Gets or sets the animation properties override
  31438. */
  31439. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31440. /**
  31441. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31442. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31443. */
  31444. useConstantAnimationDeltaTime: boolean;
  31445. /**
  31446. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31447. * Please note that it requires to run a ray cast through the scene on every frame
  31448. */
  31449. constantlyUpdateMeshUnderPointer: boolean;
  31450. /**
  31451. * Defines the HTML cursor to use when hovering over interactive elements
  31452. */
  31453. hoverCursor: string;
  31454. /**
  31455. * Defines the HTML default cursor to use (empty by default)
  31456. */
  31457. defaultCursor: string;
  31458. /**
  31459. * This is used to call preventDefault() on pointer down
  31460. * in order to block unwanted artifacts like system double clicks
  31461. */
  31462. preventDefaultOnPointerDown: boolean;
  31463. /**
  31464. * This is used to call preventDefault() on pointer up
  31465. * in order to block unwanted artifacts like system double clicks
  31466. */
  31467. preventDefaultOnPointerUp: boolean;
  31468. /**
  31469. * Gets or sets user defined metadata
  31470. */
  31471. metadata: any;
  31472. /**
  31473. * For internal use only. Please do not use.
  31474. */
  31475. reservedDataStore: any;
  31476. /**
  31477. * Gets the name of the plugin used to load this scene (null by default)
  31478. */
  31479. loadingPluginName: string;
  31480. /**
  31481. * Use this array to add regular expressions used to disable offline support for specific urls
  31482. */
  31483. disableOfflineSupportExceptionRules: RegExp[];
  31484. /**
  31485. * An event triggered when the scene is disposed.
  31486. */
  31487. onDisposeObservable: Observable<Scene>;
  31488. private _onDisposeObserver;
  31489. /** Sets a function to be executed when this scene is disposed. */
  31490. onDispose: () => void;
  31491. /**
  31492. * An event triggered before rendering the scene (right after animations and physics)
  31493. */
  31494. onBeforeRenderObservable: Observable<Scene>;
  31495. private _onBeforeRenderObserver;
  31496. /** Sets a function to be executed before rendering this scene */
  31497. beforeRender: Nullable<() => void>;
  31498. /**
  31499. * An event triggered after rendering the scene
  31500. */
  31501. onAfterRenderObservable: Observable<Scene>;
  31502. private _onAfterRenderObserver;
  31503. /** Sets a function to be executed after rendering this scene */
  31504. afterRender: Nullable<() => void>;
  31505. /**
  31506. * An event triggered before animating the scene
  31507. */
  31508. onBeforeAnimationsObservable: Observable<Scene>;
  31509. /**
  31510. * An event triggered after animations processing
  31511. */
  31512. onAfterAnimationsObservable: Observable<Scene>;
  31513. /**
  31514. * An event triggered before draw calls are ready to be sent
  31515. */
  31516. onBeforeDrawPhaseObservable: Observable<Scene>;
  31517. /**
  31518. * An event triggered after draw calls have been sent
  31519. */
  31520. onAfterDrawPhaseObservable: Observable<Scene>;
  31521. /**
  31522. * An event triggered when the scene is ready
  31523. */
  31524. onReadyObservable: Observable<Scene>;
  31525. /**
  31526. * An event triggered before rendering a camera
  31527. */
  31528. onBeforeCameraRenderObservable: Observable<Camera>;
  31529. private _onBeforeCameraRenderObserver;
  31530. /** Sets a function to be executed before rendering a camera*/
  31531. beforeCameraRender: () => void;
  31532. /**
  31533. * An event triggered after rendering a camera
  31534. */
  31535. onAfterCameraRenderObservable: Observable<Camera>;
  31536. private _onAfterCameraRenderObserver;
  31537. /** Sets a function to be executed after rendering a camera*/
  31538. afterCameraRender: () => void;
  31539. /**
  31540. * An event triggered when active meshes evaluation is about to start
  31541. */
  31542. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31543. /**
  31544. * An event triggered when active meshes evaluation is done
  31545. */
  31546. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31547. /**
  31548. * An event triggered when particles rendering is about to start
  31549. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31550. */
  31551. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31552. /**
  31553. * An event triggered when particles rendering is done
  31554. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31555. */
  31556. onAfterParticlesRenderingObservable: Observable<Scene>;
  31557. /**
  31558. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31559. */
  31560. onDataLoadedObservable: Observable<Scene>;
  31561. /**
  31562. * An event triggered when a camera is created
  31563. */
  31564. onNewCameraAddedObservable: Observable<Camera>;
  31565. /**
  31566. * An event triggered when a camera is removed
  31567. */
  31568. onCameraRemovedObservable: Observable<Camera>;
  31569. /**
  31570. * An event triggered when a light is created
  31571. */
  31572. onNewLightAddedObservable: Observable<Light>;
  31573. /**
  31574. * An event triggered when a light is removed
  31575. */
  31576. onLightRemovedObservable: Observable<Light>;
  31577. /**
  31578. * An event triggered when a geometry is created
  31579. */
  31580. onNewGeometryAddedObservable: Observable<Geometry>;
  31581. /**
  31582. * An event triggered when a geometry is removed
  31583. */
  31584. onGeometryRemovedObservable: Observable<Geometry>;
  31585. /**
  31586. * An event triggered when a transform node is created
  31587. */
  31588. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31589. /**
  31590. * An event triggered when a transform node is removed
  31591. */
  31592. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31593. /**
  31594. * An event triggered when a mesh is created
  31595. */
  31596. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31597. /**
  31598. * An event triggered when a mesh is removed
  31599. */
  31600. onMeshRemovedObservable: Observable<AbstractMesh>;
  31601. /**
  31602. * An event triggered when a skeleton is created
  31603. */
  31604. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31605. /**
  31606. * An event triggered when a skeleton is removed
  31607. */
  31608. onSkeletonRemovedObservable: Observable<Skeleton>;
  31609. /**
  31610. * An event triggered when a material is created
  31611. */
  31612. onNewMaterialAddedObservable: Observable<Material>;
  31613. /**
  31614. * An event triggered when a material is removed
  31615. */
  31616. onMaterialRemovedObservable: Observable<Material>;
  31617. /**
  31618. * An event triggered when a texture is created
  31619. */
  31620. onNewTextureAddedObservable: Observable<BaseTexture>;
  31621. /**
  31622. * An event triggered when a texture is removed
  31623. */
  31624. onTextureRemovedObservable: Observable<BaseTexture>;
  31625. /**
  31626. * An event triggered when render targets are about to be rendered
  31627. * Can happen multiple times per frame.
  31628. */
  31629. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31630. /**
  31631. * An event triggered when render targets were rendered.
  31632. * Can happen multiple times per frame.
  31633. */
  31634. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31635. /**
  31636. * An event triggered before calculating deterministic simulation step
  31637. */
  31638. onBeforeStepObservable: Observable<Scene>;
  31639. /**
  31640. * An event triggered after calculating deterministic simulation step
  31641. */
  31642. onAfterStepObservable: Observable<Scene>;
  31643. /**
  31644. * An event triggered when the activeCamera property is updated
  31645. */
  31646. onActiveCameraChanged: Observable<Scene>;
  31647. /**
  31648. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31649. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31650. * 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)
  31651. */
  31652. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31653. /**
  31654. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31655. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31656. * 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)
  31657. */
  31658. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31659. /**
  31660. * This Observable will when a mesh has been imported into the scene.
  31661. */
  31662. onMeshImportedObservable: Observable<AbstractMesh>;
  31663. /**
  31664. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31665. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31666. */
  31667. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31668. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31669. /**
  31670. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31671. */
  31672. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31673. /**
  31674. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31675. */
  31676. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31677. /**
  31678. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31679. */
  31680. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31681. /** Callback called when a pointer move is detected */
  31682. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31683. /** Callback called when a pointer down is detected */
  31684. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31685. /** Callback called when a pointer up is detected */
  31686. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31687. /** Callback called when a pointer pick is detected */
  31688. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31689. /**
  31690. * 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).
  31691. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31692. */
  31693. onPrePointerObservable: Observable<PointerInfoPre>;
  31694. /**
  31695. * Observable event triggered each time an input event is received from the rendering canvas
  31696. */
  31697. onPointerObservable: Observable<PointerInfo>;
  31698. /**
  31699. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31700. */
  31701. readonly unTranslatedPointer: Vector2;
  31702. /**
  31703. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  31704. */
  31705. static DragMovementThreshold: number;
  31706. /**
  31707. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  31708. */
  31709. static LongPressDelay: number;
  31710. /**
  31711. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  31712. */
  31713. static DoubleClickDelay: number;
  31714. /** If you need to check double click without raising a single click at first click, enable this flag */
  31715. static ExclusiveDoubleClickMode: boolean;
  31716. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31717. /**
  31718. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31719. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31720. */
  31721. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31722. /**
  31723. * Observable event triggered each time an keyboard event is received from the hosting window
  31724. */
  31725. onKeyboardObservable: Observable<KeyboardInfo>;
  31726. private _useRightHandedSystem;
  31727. /**
  31728. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31729. */
  31730. useRightHandedSystem: boolean;
  31731. private _timeAccumulator;
  31732. private _currentStepId;
  31733. private _currentInternalStep;
  31734. /**
  31735. * Sets the step Id used by deterministic lock step
  31736. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31737. * @param newStepId defines the step Id
  31738. */
  31739. setStepId(newStepId: number): void;
  31740. /**
  31741. * Gets the step Id used by deterministic lock step
  31742. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31743. * @returns the step Id
  31744. */
  31745. getStepId(): number;
  31746. /**
  31747. * Gets the internal step used by deterministic lock step
  31748. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31749. * @returns the internal step
  31750. */
  31751. getInternalStep(): number;
  31752. private _fogEnabled;
  31753. /**
  31754. * Gets or sets a boolean indicating if fog is enabled on this scene
  31755. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31756. * (Default is true)
  31757. */
  31758. fogEnabled: boolean;
  31759. private _fogMode;
  31760. /**
  31761. * Gets or sets the fog mode to use
  31762. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31763. * | mode | value |
  31764. * | --- | --- |
  31765. * | FOGMODE_NONE | 0 |
  31766. * | FOGMODE_EXP | 1 |
  31767. * | FOGMODE_EXP2 | 2 |
  31768. * | FOGMODE_LINEAR | 3 |
  31769. */
  31770. fogMode: number;
  31771. /**
  31772. * Gets or sets the fog color to use
  31773. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31774. * (Default is Color3(0.2, 0.2, 0.3))
  31775. */
  31776. fogColor: Color3;
  31777. /**
  31778. * Gets or sets the fog density to use
  31779. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31780. * (Default is 0.1)
  31781. */
  31782. fogDensity: number;
  31783. /**
  31784. * Gets or sets the fog start distance to use
  31785. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31786. * (Default is 0)
  31787. */
  31788. fogStart: number;
  31789. /**
  31790. * Gets or sets the fog end distance to use
  31791. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31792. * (Default is 1000)
  31793. */
  31794. fogEnd: number;
  31795. private _shadowsEnabled;
  31796. /**
  31797. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31798. */
  31799. shadowsEnabled: boolean;
  31800. private _lightsEnabled;
  31801. /**
  31802. * Gets or sets a boolean indicating if lights are enabled on this scene
  31803. */
  31804. lightsEnabled: boolean;
  31805. /** All of the active cameras added to this scene. */
  31806. activeCameras: Camera[];
  31807. /** @hidden */ activeCamera: Nullable<Camera>;
  31808. /** Gets or sets the current active camera */
  31809. activeCamera: Nullable<Camera>;
  31810. private _defaultMaterial;
  31811. /** The default material used on meshes when no material is affected */
  31812. /** The default material used on meshes when no material is affected */
  31813. defaultMaterial: Material;
  31814. private _texturesEnabled;
  31815. /**
  31816. * Gets or sets a boolean indicating if textures are enabled on this scene
  31817. */
  31818. texturesEnabled: boolean;
  31819. /**
  31820. * Gets or sets a boolean indicating if particles are enabled on this scene
  31821. */
  31822. particlesEnabled: boolean;
  31823. /**
  31824. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31825. */
  31826. spritesEnabled: boolean;
  31827. private _skeletonsEnabled;
  31828. /**
  31829. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31830. */
  31831. skeletonsEnabled: boolean;
  31832. /**
  31833. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31834. */
  31835. lensFlaresEnabled: boolean;
  31836. /**
  31837. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31838. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31839. */
  31840. collisionsEnabled: boolean;
  31841. private _collisionCoordinator;
  31842. /** @hidden */
  31843. readonly collisionCoordinator: ICollisionCoordinator;
  31844. /**
  31845. * Defines the gravity applied to this scene (used only for collisions)
  31846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31847. */
  31848. gravity: Vector3;
  31849. /**
  31850. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31851. */
  31852. postProcessesEnabled: boolean;
  31853. /**
  31854. * The list of postprocesses added to the scene
  31855. */
  31856. postProcesses: PostProcess[];
  31857. /**
  31858. * Gets the current postprocess manager
  31859. */
  31860. postProcessManager: PostProcessManager;
  31861. /**
  31862. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31863. */
  31864. renderTargetsEnabled: boolean;
  31865. /**
  31866. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31867. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31868. */
  31869. dumpNextRenderTargets: boolean;
  31870. /**
  31871. * The list of user defined render targets added to the scene
  31872. */
  31873. customRenderTargets: RenderTargetTexture[];
  31874. /**
  31875. * Defines if texture loading must be delayed
  31876. * If true, textures will only be loaded when they need to be rendered
  31877. */
  31878. useDelayedTextureLoading: boolean;
  31879. /**
  31880. * Gets the list of meshes imported to the scene through SceneLoader
  31881. */
  31882. importedMeshesFiles: String[];
  31883. /**
  31884. * Gets or sets a boolean indicating if probes are enabled on this scene
  31885. */
  31886. probesEnabled: boolean;
  31887. /**
  31888. * Gets or sets the current offline provider to use to store scene data
  31889. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31890. */
  31891. offlineProvider: IOfflineProvider;
  31892. /**
  31893. * Gets or sets the action manager associated with the scene
  31894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31895. */
  31896. actionManager: AbstractActionManager;
  31897. private _meshesForIntersections;
  31898. /**
  31899. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31900. */
  31901. proceduralTexturesEnabled: boolean;
  31902. private _engine;
  31903. private _totalVertices;
  31904. /** @hidden */ activeIndices: PerfCounter;
  31905. /** @hidden */ activeParticles: PerfCounter;
  31906. /** @hidden */ activeBones: PerfCounter;
  31907. private _animationRatio;
  31908. /** @hidden */ animationTimeLast: number;
  31909. /** @hidden */ animationTime: number;
  31910. /**
  31911. * Gets or sets a general scale for animation speed
  31912. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31913. */
  31914. animationTimeScale: number;
  31915. /** @hidden */ cachedMaterial: Nullable<Material>;
  31916. /** @hidden */ cachedEffect: Nullable<Effect>;
  31917. /** @hidden */ cachedVisibility: Nullable<number>;
  31918. private _renderId;
  31919. private _frameId;
  31920. private _executeWhenReadyTimeoutId;
  31921. private _intermediateRendering;
  31922. private _viewUpdateFlag;
  31923. private _projectionUpdateFlag;
  31924. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31925. private _activeRequests;
  31926. /** @hidden */ pendingData: any[];
  31927. private _isDisposed;
  31928. /**
  31929. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31930. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31931. */
  31932. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31933. private _activeMeshes;
  31934. private _processedMaterials;
  31935. private _renderTargets;
  31936. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31937. private _activeSkeletons;
  31938. private _softwareSkinnedMeshes;
  31939. private _renderingManager;
  31940. /** @hidden */ activeAnimatables: Animatable[];
  31941. private _transformMatrix;
  31942. private _sceneUbo;
  31943. /** @hidden */ viewMatrix: Matrix;
  31944. private _projectionMatrix;
  31945. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31946. /** @hidden */ frustumPlanes: Plane[];
  31947. /**
  31948. * Gets the list of frustum planes (built from the active camera)
  31949. */
  31950. readonly frustumPlanes: Plane[];
  31951. /**
  31952. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31953. * This is useful if there are more lights that the maximum simulteanous authorized
  31954. */
  31955. requireLightSorting: boolean;
  31956. /** @hidden */
  31957. readonly useMaterialMeshMap: boolean;
  31958. /** @hidden */
  31959. readonly useClonedMeshhMap: boolean;
  31960. private _externalData;
  31961. private _uid;
  31962. /**
  31963. * @hidden
  31964. * Backing store of defined scene components.
  31965. */ components: ISceneComponent[];
  31966. /**
  31967. * @hidden
  31968. * Backing store of defined scene components.
  31969. */ serializableComponents: ISceneSerializableComponent[];
  31970. /**
  31971. * List of components to register on the next registration step.
  31972. */
  31973. private _transientComponents;
  31974. /**
  31975. * Registers the transient components if needed.
  31976. */
  31977. private _registerTransientComponents;
  31978. /**
  31979. * @hidden
  31980. * Add a component to the scene.
  31981. * Note that the ccomponent could be registered on th next frame if this is called after
  31982. * the register component stage.
  31983. * @param component Defines the component to add to the scene
  31984. */ addComponent(component: ISceneComponent): void;
  31985. /**
  31986. * @hidden
  31987. * Gets a component from the scene.
  31988. * @param name defines the name of the component to retrieve
  31989. * @returns the component or null if not present
  31990. */ getComponent(name: string): Nullable<ISceneComponent>;
  31991. /**
  31992. * @hidden
  31993. * Defines the actions happening before camera updates.
  31994. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31995. /**
  31996. * @hidden
  31997. * Defines the actions happening before clear the canvas.
  31998. */ beforeClearStage: Stage<SimpleStageAction>;
  31999. /**
  32000. * @hidden
  32001. * Defines the actions when collecting render targets for the frame.
  32002. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32003. /**
  32004. * @hidden
  32005. * Defines the actions happening for one camera in the frame.
  32006. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32007. /**
  32008. * @hidden
  32009. * Defines the actions happening during the per mesh ready checks.
  32010. */ isReadyForMeshStage: Stage<MeshStageAction>;
  32011. /**
  32012. * @hidden
  32013. * Defines the actions happening before evaluate active mesh checks.
  32014. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32015. /**
  32016. * @hidden
  32017. * Defines the actions happening during the evaluate sub mesh checks.
  32018. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32019. /**
  32020. * @hidden
  32021. * Defines the actions happening during the active mesh stage.
  32022. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  32023. /**
  32024. * @hidden
  32025. * Defines the actions happening during the per camera render target step.
  32026. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32027. /**
  32028. * @hidden
  32029. * Defines the actions happening just before the active camera is drawing.
  32030. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  32031. /**
  32032. * @hidden
  32033. * Defines the actions happening just before a render target is drawing.
  32034. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32035. /**
  32036. * @hidden
  32037. * Defines the actions happening just before a rendering group is drawing.
  32038. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32039. /**
  32040. * @hidden
  32041. * Defines the actions happening just before a mesh is drawing.
  32042. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32043. /**
  32044. * @hidden
  32045. * Defines the actions happening just after a mesh has been drawn.
  32046. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32047. /**
  32048. * @hidden
  32049. * Defines the actions happening just after a rendering group has been drawn.
  32050. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32051. /**
  32052. * @hidden
  32053. * Defines the actions happening just after the active camera has been drawn.
  32054. */ afterCameraDrawStage: Stage<CameraStageAction>;
  32055. /**
  32056. * @hidden
  32057. * Defines the actions happening just after a render target has been drawn.
  32058. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32059. /**
  32060. * @hidden
  32061. * Defines the actions happening just after rendering all cameras and computing intersections.
  32062. */ afterRenderStage: Stage<SimpleStageAction>;
  32063. /**
  32064. * @hidden
  32065. * Defines the actions happening when a pointer move event happens.
  32066. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  32067. /**
  32068. * @hidden
  32069. * Defines the actions happening when a pointer down event happens.
  32070. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  32071. /**
  32072. * @hidden
  32073. * Defines the actions happening when a pointer up event happens.
  32074. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  32075. /**
  32076. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32077. */
  32078. private geometriesByUniqueId;
  32079. /**
  32080. * Creates a new Scene
  32081. * @param engine defines the engine to use to render this scene
  32082. * @param options defines the scene options
  32083. */
  32084. constructor(engine: Engine, options?: SceneOptions);
  32085. /**
  32086. * Gets a string idenfifying the name of the class
  32087. * @returns "Scene" string
  32088. */
  32089. getClassName(): string;
  32090. private _defaultMeshCandidates;
  32091. /**
  32092. * @hidden
  32093. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32094. private _defaultSubMeshCandidates;
  32095. /**
  32096. * @hidden
  32097. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32098. /**
  32099. * Sets the default candidate providers for the scene.
  32100. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32101. * and getCollidingSubMeshCandidates to their default function
  32102. */
  32103. setDefaultCandidateProviders(): void;
  32104. /**
  32105. * Gets the mesh that is currently under the pointer
  32106. */
  32107. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32108. /**
  32109. * Gets or sets the current on-screen X position of the pointer
  32110. */
  32111. pointerX: number;
  32112. /**
  32113. * Gets or sets the current on-screen Y position of the pointer
  32114. */
  32115. pointerY: number;
  32116. /**
  32117. * Gets the cached material (ie. the latest rendered one)
  32118. * @returns the cached material
  32119. */
  32120. getCachedMaterial(): Nullable<Material>;
  32121. /**
  32122. * Gets the cached effect (ie. the latest rendered one)
  32123. * @returns the cached effect
  32124. */
  32125. getCachedEffect(): Nullable<Effect>;
  32126. /**
  32127. * Gets the cached visibility state (ie. the latest rendered one)
  32128. * @returns the cached visibility state
  32129. */
  32130. getCachedVisibility(): Nullable<number>;
  32131. /**
  32132. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32133. * @param material defines the current material
  32134. * @param effect defines the current effect
  32135. * @param visibility defines the current visibility state
  32136. * @returns true if one parameter is not cached
  32137. */
  32138. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32139. /**
  32140. * Gets the engine associated with the scene
  32141. * @returns an Engine
  32142. */
  32143. getEngine(): Engine;
  32144. /**
  32145. * Gets the total number of vertices rendered per frame
  32146. * @returns the total number of vertices rendered per frame
  32147. */
  32148. getTotalVertices(): number;
  32149. /**
  32150. * Gets the performance counter for total vertices
  32151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32152. */
  32153. readonly totalVerticesPerfCounter: PerfCounter;
  32154. /**
  32155. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32156. * @returns the total number of active indices rendered per frame
  32157. */
  32158. getActiveIndices(): number;
  32159. /**
  32160. * Gets the performance counter for active indices
  32161. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32162. */
  32163. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32164. /**
  32165. * Gets the total number of active particles rendered per frame
  32166. * @returns the total number of active particles rendered per frame
  32167. */
  32168. getActiveParticles(): number;
  32169. /**
  32170. * Gets the performance counter for active particles
  32171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32172. */
  32173. readonly activeParticlesPerfCounter: PerfCounter;
  32174. /**
  32175. * Gets the total number of active bones rendered per frame
  32176. * @returns the total number of active bones rendered per frame
  32177. */
  32178. getActiveBones(): number;
  32179. /**
  32180. * Gets the performance counter for active bones
  32181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32182. */
  32183. readonly activeBonesPerfCounter: PerfCounter;
  32184. /**
  32185. * Gets the array of active meshes
  32186. * @returns an array of AbstractMesh
  32187. */
  32188. getActiveMeshes(): SmartArray<AbstractMesh>;
  32189. /**
  32190. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32191. * @returns a number
  32192. */
  32193. getAnimationRatio(): number;
  32194. /**
  32195. * Gets an unique Id for the current render phase
  32196. * @returns a number
  32197. */
  32198. getRenderId(): number;
  32199. /**
  32200. * Gets an unique Id for the current frame
  32201. * @returns a number
  32202. */
  32203. getFrameId(): number;
  32204. /** Call this function if you want to manually increment the render Id*/
  32205. incrementRenderId(): void;
  32206. private _createUbo;
  32207. /**
  32208. * Use this method to simulate a pointer move on a mesh
  32209. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32210. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32211. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32212. * @returns the current scene
  32213. */
  32214. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32215. /**
  32216. * Use this method to simulate a pointer down on a mesh
  32217. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32218. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32219. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32220. * @returns the current scene
  32221. */
  32222. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32223. /**
  32224. * Use this method to simulate a pointer up on a mesh
  32225. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32226. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32227. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32228. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32229. * @returns the current scene
  32230. */
  32231. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32232. /**
  32233. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32234. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32235. * @returns true if the pointer was captured
  32236. */
  32237. isPointerCaptured(pointerId?: number): boolean;
  32238. /**
  32239. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32240. * @param attachUp defines if you want to attach events to pointerup
  32241. * @param attachDown defines if you want to attach events to pointerdown
  32242. * @param attachMove defines if you want to attach events to pointermove
  32243. */
  32244. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32245. /** Detaches all event handlers*/
  32246. detachControl(): void;
  32247. /**
  32248. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32249. * Delay loaded resources are not taking in account
  32250. * @return true if all required resources are ready
  32251. */
  32252. isReady(): boolean;
  32253. /** Resets all cached information relative to material (including effect and visibility) */
  32254. resetCachedMaterial(): void;
  32255. /**
  32256. * Registers a function to be called before every frame render
  32257. * @param func defines the function to register
  32258. */
  32259. registerBeforeRender(func: () => void): void;
  32260. /**
  32261. * Unregisters a function called before every frame render
  32262. * @param func defines the function to unregister
  32263. */
  32264. unregisterBeforeRender(func: () => void): void;
  32265. /**
  32266. * Registers a function to be called after every frame render
  32267. * @param func defines the function to register
  32268. */
  32269. registerAfterRender(func: () => void): void;
  32270. /**
  32271. * Unregisters a function called after every frame render
  32272. * @param func defines the function to unregister
  32273. */
  32274. unregisterAfterRender(func: () => void): void;
  32275. private _executeOnceBeforeRender;
  32276. /**
  32277. * The provided function will run before render once and will be disposed afterwards.
  32278. * A timeout delay can be provided so that the function will be executed in N ms.
  32279. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32280. * @param func The function to be executed.
  32281. * @param timeout optional delay in ms
  32282. */
  32283. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32284. /** @hidden */ addPendingData(data: any): void;
  32285. /** @hidden */ removePendingData(data: any): void;
  32286. /**
  32287. * Returns the number of items waiting to be loaded
  32288. * @returns the number of items waiting to be loaded
  32289. */
  32290. getWaitingItemsCount(): number;
  32291. /**
  32292. * Returns a boolean indicating if the scene is still loading data
  32293. */
  32294. readonly isLoading: boolean;
  32295. /**
  32296. * Registers a function to be executed when the scene is ready
  32297. * @param {Function} func - the function to be executed
  32298. */
  32299. executeWhenReady(func: () => void): void;
  32300. /**
  32301. * Returns a promise that resolves when the scene is ready
  32302. * @returns A promise that resolves when the scene is ready
  32303. */
  32304. whenReadyAsync(): Promise<void>;
  32305. /** @hidden */ checkIsReady(): void;
  32306. /**
  32307. * Gets all animatable attached to the scene
  32308. */
  32309. readonly animatables: Animatable[];
  32310. /**
  32311. * Resets the last animation time frame.
  32312. * Useful to override when animations start running when loading a scene for the first time.
  32313. */
  32314. resetLastAnimationTimeFrame(): void;
  32315. /**
  32316. * Gets the current view matrix
  32317. * @returns a Matrix
  32318. */
  32319. getViewMatrix(): Matrix;
  32320. /**
  32321. * Gets the current projection matrix
  32322. * @returns a Matrix
  32323. */
  32324. getProjectionMatrix(): Matrix;
  32325. /**
  32326. * Gets the current transform matrix
  32327. * @returns a Matrix made of View * Projection
  32328. */
  32329. getTransformMatrix(): Matrix;
  32330. /**
  32331. * Sets the current transform matrix
  32332. * @param viewL defines the View matrix to use
  32333. * @param projectionL defines the Projection matrix to use
  32334. * @param viewR defines the right View matrix to use (if provided)
  32335. * @param projectionR defines the right Projection matrix to use (if provided)
  32336. */
  32337. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32338. /**
  32339. * Gets the uniform buffer used to store scene data
  32340. * @returns a UniformBuffer
  32341. */
  32342. getSceneUniformBuffer(): UniformBuffer;
  32343. /**
  32344. * Gets an unique (relatively to the current scene) Id
  32345. * @returns an unique number for the scene
  32346. */
  32347. getUniqueId(): number;
  32348. /**
  32349. * Add a mesh to the list of scene's meshes
  32350. * @param newMesh defines the mesh to add
  32351. * @param recursive if all child meshes should also be added to the scene
  32352. */
  32353. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32354. /**
  32355. * Remove a mesh for the list of scene's meshes
  32356. * @param toRemove defines the mesh to remove
  32357. * @param recursive if all child meshes should also be removed from the scene
  32358. * @returns the index where the mesh was in the mesh list
  32359. */
  32360. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32361. /**
  32362. * Add a transform node to the list of scene's transform nodes
  32363. * @param newTransformNode defines the transform node to add
  32364. */
  32365. addTransformNode(newTransformNode: TransformNode): void;
  32366. /**
  32367. * Remove a transform node for the list of scene's transform nodes
  32368. * @param toRemove defines the transform node to remove
  32369. * @returns the index where the transform node was in the transform node list
  32370. */
  32371. removeTransformNode(toRemove: TransformNode): number;
  32372. /**
  32373. * Remove a skeleton for the list of scene's skeletons
  32374. * @param toRemove defines the skeleton to remove
  32375. * @returns the index where the skeleton was in the skeleton list
  32376. */
  32377. removeSkeleton(toRemove: Skeleton): number;
  32378. /**
  32379. * Remove a morph target for the list of scene's morph targets
  32380. * @param toRemove defines the morph target to remove
  32381. * @returns the index where the morph target was in the morph target list
  32382. */
  32383. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32384. /**
  32385. * Remove a light for the list of scene's lights
  32386. * @param toRemove defines the light to remove
  32387. * @returns the index where the light was in the light list
  32388. */
  32389. removeLight(toRemove: Light): number;
  32390. /**
  32391. * Remove a camera for the list of scene's cameras
  32392. * @param toRemove defines the camera to remove
  32393. * @returns the index where the camera was in the camera list
  32394. */
  32395. removeCamera(toRemove: Camera): number;
  32396. /**
  32397. * Remove a particle system for the list of scene's particle systems
  32398. * @param toRemove defines the particle system to remove
  32399. * @returns the index where the particle system was in the particle system list
  32400. */
  32401. removeParticleSystem(toRemove: IParticleSystem): number;
  32402. /**
  32403. * Remove a animation for the list of scene's animations
  32404. * @param toRemove defines the animation to remove
  32405. * @returns the index where the animation was in the animation list
  32406. */
  32407. removeAnimation(toRemove: Animation): number;
  32408. /**
  32409. * Will stop the animation of the given target
  32410. * @param target - the target
  32411. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32412. * @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)
  32413. */
  32414. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32415. /**
  32416. * Removes the given animation group from this scene.
  32417. * @param toRemove The animation group to remove
  32418. * @returns The index of the removed animation group
  32419. */
  32420. removeAnimationGroup(toRemove: AnimationGroup): number;
  32421. /**
  32422. * Removes the given multi-material from this scene.
  32423. * @param toRemove The multi-material to remove
  32424. * @returns The index of the removed multi-material
  32425. */
  32426. removeMultiMaterial(toRemove: MultiMaterial): number;
  32427. /**
  32428. * Removes the given material from this scene.
  32429. * @param toRemove The material to remove
  32430. * @returns The index of the removed material
  32431. */
  32432. removeMaterial(toRemove: Material): number;
  32433. /**
  32434. * Removes the given action manager from this scene.
  32435. * @param toRemove The action manager to remove
  32436. * @returns The index of the removed action manager
  32437. */
  32438. removeActionManager(toRemove: AbstractActionManager): number;
  32439. /**
  32440. * Removes the given texture from this scene.
  32441. * @param toRemove The texture to remove
  32442. * @returns The index of the removed texture
  32443. */
  32444. removeTexture(toRemove: BaseTexture): number;
  32445. /**
  32446. * Adds the given light to this scene
  32447. * @param newLight The light to add
  32448. */
  32449. addLight(newLight: Light): void;
  32450. /**
  32451. * Sorts the list list based on light priorities
  32452. */
  32453. sortLightsByPriority(): void;
  32454. /**
  32455. * Adds the given camera to this scene
  32456. * @param newCamera The camera to add
  32457. */
  32458. addCamera(newCamera: Camera): void;
  32459. /**
  32460. * Adds the given skeleton to this scene
  32461. * @param newSkeleton The skeleton to add
  32462. */
  32463. addSkeleton(newSkeleton: Skeleton): void;
  32464. /**
  32465. * Adds the given particle system to this scene
  32466. * @param newParticleSystem The particle system to add
  32467. */
  32468. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32469. /**
  32470. * Adds the given animation to this scene
  32471. * @param newAnimation The animation to add
  32472. */
  32473. addAnimation(newAnimation: Animation): void;
  32474. /**
  32475. * Adds the given animation group to this scene.
  32476. * @param newAnimationGroup The animation group to add
  32477. */
  32478. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32479. /**
  32480. * Adds the given multi-material to this scene
  32481. * @param newMultiMaterial The multi-material to add
  32482. */
  32483. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32484. /**
  32485. * Adds the given material to this scene
  32486. * @param newMaterial The material to add
  32487. */
  32488. addMaterial(newMaterial: Material): void;
  32489. /**
  32490. * Adds the given morph target to this scene
  32491. * @param newMorphTargetManager The morph target to add
  32492. */
  32493. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32494. /**
  32495. * Adds the given geometry to this scene
  32496. * @param newGeometry The geometry to add
  32497. */
  32498. addGeometry(newGeometry: Geometry): void;
  32499. /**
  32500. * Adds the given action manager to this scene
  32501. * @param newActionManager The action manager to add
  32502. */
  32503. addActionManager(newActionManager: AbstractActionManager): void;
  32504. /**
  32505. * Adds the given texture to this scene.
  32506. * @param newTexture The texture to add
  32507. */
  32508. addTexture(newTexture: BaseTexture): void;
  32509. /**
  32510. * Switch active camera
  32511. * @param newCamera defines the new active camera
  32512. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32513. */
  32514. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32515. /**
  32516. * sets the active camera of the scene using its ID
  32517. * @param id defines the camera's ID
  32518. * @return the new active camera or null if none found.
  32519. */
  32520. setActiveCameraByID(id: string): Nullable<Camera>;
  32521. /**
  32522. * sets the active camera of the scene using its name
  32523. * @param name defines the camera's name
  32524. * @returns the new active camera or null if none found.
  32525. */
  32526. setActiveCameraByName(name: string): Nullable<Camera>;
  32527. /**
  32528. * get an animation group using its name
  32529. * @param name defines the material's name
  32530. * @return the animation group or null if none found.
  32531. */
  32532. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32533. /**
  32534. * Get a material using its unique id
  32535. * @param uniqueId defines the material's unique id
  32536. * @return the material or null if none found.
  32537. */
  32538. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32539. /**
  32540. * get a material using its id
  32541. * @param id defines the material's ID
  32542. * @return the material or null if none found.
  32543. */
  32544. getMaterialByID(id: string): Nullable<Material>;
  32545. /**
  32546. * Gets a material using its name
  32547. * @param name defines the material's name
  32548. * @return the material or null if none found.
  32549. */
  32550. getMaterialByName(name: string): Nullable<Material>;
  32551. /**
  32552. * Gets a camera using its id
  32553. * @param id defines the id to look for
  32554. * @returns the camera or null if not found
  32555. */
  32556. getCameraByID(id: string): Nullable<Camera>;
  32557. /**
  32558. * Gets a camera using its unique id
  32559. * @param uniqueId defines the unique id to look for
  32560. * @returns the camera or null if not found
  32561. */
  32562. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32563. /**
  32564. * Gets a camera using its name
  32565. * @param name defines the camera's name
  32566. * @return the camera or null if none found.
  32567. */
  32568. getCameraByName(name: string): Nullable<Camera>;
  32569. /**
  32570. * Gets a bone using its id
  32571. * @param id defines the bone's id
  32572. * @return the bone or null if not found
  32573. */
  32574. getBoneByID(id: string): Nullable<Bone>;
  32575. /**
  32576. * Gets a bone using its id
  32577. * @param name defines the bone's name
  32578. * @return the bone or null if not found
  32579. */
  32580. getBoneByName(name: string): Nullable<Bone>;
  32581. /**
  32582. * Gets a light node using its name
  32583. * @param name defines the the light's name
  32584. * @return the light or null if none found.
  32585. */
  32586. getLightByName(name: string): Nullable<Light>;
  32587. /**
  32588. * Gets a light node using its id
  32589. * @param id defines the light's id
  32590. * @return the light or null if none found.
  32591. */
  32592. getLightByID(id: string): Nullable<Light>;
  32593. /**
  32594. * Gets a light node using its scene-generated unique ID
  32595. * @param uniqueId defines the light's unique id
  32596. * @return the light or null if none found.
  32597. */
  32598. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32599. /**
  32600. * Gets a particle system by id
  32601. * @param id defines the particle system id
  32602. * @return the corresponding system or null if none found
  32603. */
  32604. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32605. /**
  32606. * Gets a geometry using its ID
  32607. * @param id defines the geometry's id
  32608. * @return the geometry or null if none found.
  32609. */
  32610. getGeometryByID(id: string): Nullable<Geometry>;
  32611. private _getGeometryByUniqueID;
  32612. /**
  32613. * Add a new geometry to this scene
  32614. * @param geometry defines the geometry to be added to the scene.
  32615. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32616. * @return a boolean defining if the geometry was added or not
  32617. */
  32618. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32619. /**
  32620. * Removes an existing geometry
  32621. * @param geometry defines the geometry to be removed from the scene
  32622. * @return a boolean defining if the geometry was removed or not
  32623. */
  32624. removeGeometry(geometry: Geometry): boolean;
  32625. /**
  32626. * Gets the list of geometries attached to the scene
  32627. * @returns an array of Geometry
  32628. */
  32629. getGeometries(): Geometry[];
  32630. /**
  32631. * Gets the first added mesh found of a given ID
  32632. * @param id defines the id to search for
  32633. * @return the mesh found or null if not found at all
  32634. */
  32635. getMeshByID(id: string): Nullable<AbstractMesh>;
  32636. /**
  32637. * Gets a list of meshes using their id
  32638. * @param id defines the id to search for
  32639. * @returns a list of meshes
  32640. */
  32641. getMeshesByID(id: string): Array<AbstractMesh>;
  32642. /**
  32643. * Gets the first added transform node found of a given ID
  32644. * @param id defines the id to search for
  32645. * @return the found transform node or null if not found at all.
  32646. */
  32647. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32648. /**
  32649. * Gets a transform node with its auto-generated unique id
  32650. * @param uniqueId efines the unique id to search for
  32651. * @return the found transform node or null if not found at all.
  32652. */
  32653. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32654. /**
  32655. * Gets a list of transform nodes using their id
  32656. * @param id defines the id to search for
  32657. * @returns a list of transform nodes
  32658. */
  32659. getTransformNodesByID(id: string): Array<TransformNode>;
  32660. /**
  32661. * Gets a mesh with its auto-generated unique id
  32662. * @param uniqueId defines the unique id to search for
  32663. * @return the found mesh or null if not found at all.
  32664. */
  32665. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32666. /**
  32667. * Gets a the last added mesh using a given id
  32668. * @param id defines the id to search for
  32669. * @return the found mesh or null if not found at all.
  32670. */
  32671. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32672. /**
  32673. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32674. * @param id defines the id to search for
  32675. * @return the found node or null if not found at all
  32676. */
  32677. getLastEntryByID(id: string): Nullable<Node>;
  32678. /**
  32679. * Gets a node (Mesh, Camera, Light) using a given id
  32680. * @param id defines the id to search for
  32681. * @return the found node or null if not found at all
  32682. */
  32683. getNodeByID(id: string): Nullable<Node>;
  32684. /**
  32685. * Gets a node (Mesh, Camera, Light) using a given name
  32686. * @param name defines the name to search for
  32687. * @return the found node or null if not found at all.
  32688. */
  32689. getNodeByName(name: string): Nullable<Node>;
  32690. /**
  32691. * Gets a mesh using a given name
  32692. * @param name defines the name to search for
  32693. * @return the found mesh or null if not found at all.
  32694. */
  32695. getMeshByName(name: string): Nullable<AbstractMesh>;
  32696. /**
  32697. * Gets a transform node using a given name
  32698. * @param name defines the name to search for
  32699. * @return the found transform node or null if not found at all.
  32700. */
  32701. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32702. /**
  32703. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32704. * @param id defines the id to search for
  32705. * @return the found skeleton or null if not found at all.
  32706. */
  32707. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32708. /**
  32709. * Gets a skeleton using a given auto generated unique id
  32710. * @param uniqueId defines the unique id to search for
  32711. * @return the found skeleton or null if not found at all.
  32712. */
  32713. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32714. /**
  32715. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32716. * @param id defines the id to search for
  32717. * @return the found skeleton or null if not found at all.
  32718. */
  32719. getSkeletonById(id: string): Nullable<Skeleton>;
  32720. /**
  32721. * Gets a skeleton using a given name
  32722. * @param name defines the name to search for
  32723. * @return the found skeleton or null if not found at all.
  32724. */
  32725. getSkeletonByName(name: string): Nullable<Skeleton>;
  32726. /**
  32727. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32728. * @param id defines the id to search for
  32729. * @return the found morph target manager or null if not found at all.
  32730. */
  32731. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32732. /**
  32733. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32734. * @param id defines the id to search for
  32735. * @return the found morph target or null if not found at all.
  32736. */
  32737. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32738. /**
  32739. * Gets a boolean indicating if the given mesh is active
  32740. * @param mesh defines the mesh to look for
  32741. * @returns true if the mesh is in the active list
  32742. */
  32743. isActiveMesh(mesh: AbstractMesh): boolean;
  32744. /**
  32745. * Return a unique id as a string which can serve as an identifier for the scene
  32746. */
  32747. readonly uid: string;
  32748. /**
  32749. * Add an externaly attached data from its key.
  32750. * This method call will fail and return false, if such key already exists.
  32751. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32752. * @param key the unique key that identifies the data
  32753. * @param data the data object to associate to the key for this Engine instance
  32754. * @return true if no such key were already present and the data was added successfully, false otherwise
  32755. */
  32756. addExternalData<T>(key: string, data: T): boolean;
  32757. /**
  32758. * Get an externaly attached data from its key
  32759. * @param key the unique key that identifies the data
  32760. * @return the associated data, if present (can be null), or undefined if not present
  32761. */
  32762. getExternalData<T>(key: string): Nullable<T>;
  32763. /**
  32764. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32765. * @param key the unique key that identifies the data
  32766. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32767. * @return the associated data, can be null if the factory returned null.
  32768. */
  32769. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32770. /**
  32771. * Remove an externaly attached data from the Engine instance
  32772. * @param key the unique key that identifies the data
  32773. * @return true if the data was successfully removed, false if it doesn't exist
  32774. */
  32775. removeExternalData(key: string): boolean;
  32776. private _evaluateSubMesh;
  32777. /**
  32778. * Clear the processed materials smart array preventing retention point in material dispose.
  32779. */
  32780. freeProcessedMaterials(): void;
  32781. private _preventFreeActiveMeshesAndRenderingGroups;
  32782. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32783. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32784. * when disposing several meshes in a row or a hierarchy of meshes.
  32785. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32786. */
  32787. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32788. /**
  32789. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32790. */
  32791. freeActiveMeshes(): void;
  32792. /**
  32793. * Clear the info related to rendering groups preventing retention points during dispose.
  32794. */
  32795. freeRenderingGroups(): void;
  32796. /** @hidden */ isInIntermediateRendering(): boolean;
  32797. /**
  32798. * Lambda returning the list of potentially active meshes.
  32799. */
  32800. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32801. /**
  32802. * Lambda returning the list of potentially active sub meshes.
  32803. */
  32804. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32805. /**
  32806. * Lambda returning the list of potentially intersecting sub meshes.
  32807. */
  32808. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32809. /**
  32810. * Lambda returning the list of potentially colliding sub meshes.
  32811. */
  32812. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32813. private _activeMeshesFrozen;
  32814. /**
  32815. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32816. * @returns the current scene
  32817. */
  32818. freezeActiveMeshes(): Scene;
  32819. /**
  32820. * Use this function to restart evaluating active meshes on every frame
  32821. * @returns the current scene
  32822. */
  32823. unfreezeActiveMeshes(): Scene;
  32824. private _evaluateActiveMeshes;
  32825. private _activeMesh;
  32826. /**
  32827. * Update the transform matrix to update from the current active camera
  32828. * @param force defines a boolean used to force the update even if cache is up to date
  32829. */
  32830. updateTransformMatrix(force?: boolean): void;
  32831. private _bindFrameBuffer;
  32832. /** @hidden */ allowPostProcessClearColor: boolean;
  32833. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32834. private _processSubCameras;
  32835. private _checkIntersections;
  32836. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32837. /**
  32838. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32839. */
  32840. getDeterministicFrameTime: () => number;
  32841. /** @hidden */ animate(): void;
  32842. /** Execute all animations (for a frame) */
  32843. animate(): void;
  32844. /**
  32845. * Render the scene
  32846. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32847. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32848. */
  32849. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32850. /**
  32851. * Freeze all materials
  32852. * A frozen material will not be updatable but should be faster to render
  32853. */
  32854. freezeMaterials(): void;
  32855. /**
  32856. * Unfreeze all materials
  32857. * A frozen material will not be updatable but should be faster to render
  32858. */
  32859. unfreezeMaterials(): void;
  32860. /**
  32861. * Releases all held ressources
  32862. */
  32863. dispose(): void;
  32864. /**
  32865. * Gets if the scene is already disposed
  32866. */
  32867. readonly isDisposed: boolean;
  32868. /**
  32869. * Call this function to reduce memory footprint of the scene.
  32870. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32871. */
  32872. clearCachedVertexData(): void;
  32873. /**
  32874. * This function will remove the local cached buffer data from texture.
  32875. * It will save memory but will prevent the texture from being rebuilt
  32876. */
  32877. cleanCachedTextureBuffer(): void;
  32878. /**
  32879. * Get the world extend vectors with an optional filter
  32880. *
  32881. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32882. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32883. */
  32884. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32885. min: Vector3;
  32886. max: Vector3;
  32887. };
  32888. /**
  32889. * Creates a ray that can be used to pick in the scene
  32890. * @param x defines the x coordinate of the origin (on-screen)
  32891. * @param y defines the y coordinate of the origin (on-screen)
  32892. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32893. * @param camera defines the camera to use for the picking
  32894. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32895. * @returns a Ray
  32896. */
  32897. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32898. /**
  32899. * Creates a ray that can be used to pick in the scene
  32900. * @param x defines the x coordinate of the origin (on-screen)
  32901. * @param y defines the y coordinate of the origin (on-screen)
  32902. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32903. * @param result defines the ray where to store the picking ray
  32904. * @param camera defines the camera to use for the picking
  32905. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32906. * @returns the current scene
  32907. */
  32908. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32909. /**
  32910. * Creates a ray that can be used to pick in the scene
  32911. * @param x defines the x coordinate of the origin (on-screen)
  32912. * @param y defines the y coordinate of the origin (on-screen)
  32913. * @param camera defines the camera to use for the picking
  32914. * @returns a Ray
  32915. */
  32916. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32917. /**
  32918. * Creates a ray that can be used to pick in the scene
  32919. * @param x defines the x coordinate of the origin (on-screen)
  32920. * @param y defines the y coordinate of the origin (on-screen)
  32921. * @param result defines the ray where to store the picking ray
  32922. * @param camera defines the camera to use for the picking
  32923. * @returns the current scene
  32924. */
  32925. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32926. /** Launch a ray to try to pick a mesh in the scene
  32927. * @param x position on screen
  32928. * @param y position on screen
  32929. * @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
  32930. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32931. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32932. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32933. * @returns a PickingInfo
  32934. */
  32935. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32936. /** Use the given ray to pick a mesh in the scene
  32937. * @param ray The ray to use to pick meshes
  32938. * @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
  32939. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32940. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32941. * @returns a PickingInfo
  32942. */
  32943. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32944. /**
  32945. * Launch a ray to try to pick a mesh in the scene
  32946. * @param x X position on screen
  32947. * @param y Y position on screen
  32948. * @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
  32949. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32950. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32951. * @returns an array of PickingInfo
  32952. */
  32953. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32954. /**
  32955. * Launch a ray to try to pick a mesh in the scene
  32956. * @param ray Ray to use
  32957. * @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
  32958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32959. * @returns an array of PickingInfo
  32960. */
  32961. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32962. /**
  32963. * Force the value of meshUnderPointer
  32964. * @param mesh defines the mesh to use
  32965. */
  32966. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32967. /**
  32968. * Gets the mesh under the pointer
  32969. * @returns a Mesh or null if no mesh is under the pointer
  32970. */
  32971. getPointerOverMesh(): Nullable<AbstractMesh>;
  32972. /** @hidden */ rebuildGeometries(): void;
  32973. /** @hidden */ rebuildTextures(): void;
  32974. private _getByTags;
  32975. /**
  32976. * Get a list of meshes by tags
  32977. * @param tagsQuery defines the tags query to use
  32978. * @param forEach defines a predicate used to filter results
  32979. * @returns an array of Mesh
  32980. */
  32981. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32982. /**
  32983. * Get a list of cameras by tags
  32984. * @param tagsQuery defines the tags query to use
  32985. * @param forEach defines a predicate used to filter results
  32986. * @returns an array of Camera
  32987. */
  32988. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32989. /**
  32990. * Get a list of lights by tags
  32991. * @param tagsQuery defines the tags query to use
  32992. * @param forEach defines a predicate used to filter results
  32993. * @returns an array of Light
  32994. */
  32995. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32996. /**
  32997. * Get a list of materials by tags
  32998. * @param tagsQuery defines the tags query to use
  32999. * @param forEach defines a predicate used to filter results
  33000. * @returns an array of Material
  33001. */
  33002. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33003. /**
  33004. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33005. * This allowed control for front to back rendering or reversly depending of the special needs.
  33006. *
  33007. * @param renderingGroupId The rendering group id corresponding to its index
  33008. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33009. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33010. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33011. */
  33012. 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;
  33013. /**
  33014. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33015. *
  33016. * @param renderingGroupId The rendering group id corresponding to its index
  33017. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33018. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33019. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33020. */
  33021. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33022. /**
  33023. * Gets the current auto clear configuration for one rendering group of the rendering
  33024. * manager.
  33025. * @param index the rendering group index to get the information for
  33026. * @returns The auto clear setup for the requested rendering group
  33027. */
  33028. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33029. private _blockMaterialDirtyMechanism;
  33030. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33031. blockMaterialDirtyMechanism: boolean;
  33032. /**
  33033. * Will flag all materials as dirty to trigger new shader compilation
  33034. * @param flag defines the flag used to specify which material part must be marked as dirty
  33035. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33036. */
  33037. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33038. /** @hidden */ 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;
  33039. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33040. }
  33041. }
  33042. declare module BABYLON {
  33043. /**
  33044. * Set of assets to keep when moving a scene into an asset container.
  33045. */
  33046. export class KeepAssets extends AbstractScene {
  33047. }
  33048. /**
  33049. * Container with a set of assets that can be added or removed from a scene.
  33050. */
  33051. export class AssetContainer extends AbstractScene {
  33052. /**
  33053. * The scene the AssetContainer belongs to.
  33054. */
  33055. scene: Scene;
  33056. /**
  33057. * Instantiates an AssetContainer.
  33058. * @param scene The scene the AssetContainer belongs to.
  33059. */
  33060. constructor(scene: Scene);
  33061. /**
  33062. * Adds all the assets from the container to the scene.
  33063. */
  33064. addAllToScene(): void;
  33065. /**
  33066. * Removes all the assets in the container from the scene
  33067. */
  33068. removeAllFromScene(): void;
  33069. /**
  33070. * Disposes all the assets in the container
  33071. */
  33072. dispose(): void;
  33073. private _moveAssets;
  33074. /**
  33075. * Removes all the assets contained in the scene and adds them to the container.
  33076. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33077. */
  33078. moveAllFromScene(keepAssets?: KeepAssets): void;
  33079. /**
  33080. * 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.
  33081. * @returns the root mesh
  33082. */
  33083. createRootMesh(): Mesh;
  33084. }
  33085. }
  33086. declare module BABYLON {
  33087. /**
  33088. * Defines how the parser contract is defined.
  33089. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33090. */
  33091. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33092. /**
  33093. * Defines how the individual parser contract is defined.
  33094. * These parser can parse an individual asset
  33095. */
  33096. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33097. /**
  33098. * Base class of the scene acting as a container for the different elements composing a scene.
  33099. * This class is dynamically extended by the different components of the scene increasing
  33100. * flexibility and reducing coupling
  33101. */
  33102. export abstract class AbstractScene {
  33103. /**
  33104. * Stores the list of available parsers in the application.
  33105. */
  33106. private static _BabylonFileParsers;
  33107. /**
  33108. * Stores the list of available individual parsers in the application.
  33109. */
  33110. private static _IndividualBabylonFileParsers;
  33111. /**
  33112. * Adds a parser in the list of available ones
  33113. * @param name Defines the name of the parser
  33114. * @param parser Defines the parser to add
  33115. */
  33116. static AddParser(name: string, parser: BabylonFileParser): void;
  33117. /**
  33118. * Gets a general parser from the list of avaialble ones
  33119. * @param name Defines the name of the parser
  33120. * @returns the requested parser or null
  33121. */
  33122. static GetParser(name: string): Nullable<BabylonFileParser>;
  33123. /**
  33124. * Adds n individual parser in the list of available ones
  33125. * @param name Defines the name of the parser
  33126. * @param parser Defines the parser to add
  33127. */
  33128. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33129. /**
  33130. * Gets an individual parser from the list of avaialble ones
  33131. * @param name Defines the name of the parser
  33132. * @returns the requested parser or null
  33133. */
  33134. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33135. /**
  33136. * Parser json data and populate both a scene and its associated container object
  33137. * @param jsonData Defines the data to parse
  33138. * @param scene Defines the scene to parse the data for
  33139. * @param container Defines the container attached to the parsing sequence
  33140. * @param rootUrl Defines the root url of the data
  33141. */
  33142. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33143. /**
  33144. * Gets the list of root nodes (ie. nodes with no parent)
  33145. */
  33146. rootNodes: Node[];
  33147. /** All of the cameras added to this scene
  33148. * @see http://doc.babylonjs.com/babylon101/cameras
  33149. */
  33150. cameras: Camera[];
  33151. /**
  33152. * All of the lights added to this scene
  33153. * @see http://doc.babylonjs.com/babylon101/lights
  33154. */
  33155. lights: Light[];
  33156. /**
  33157. * All of the (abstract) meshes added to this scene
  33158. */
  33159. meshes: AbstractMesh[];
  33160. /**
  33161. * The list of skeletons added to the scene
  33162. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33163. */
  33164. skeletons: Skeleton[];
  33165. /**
  33166. * All of the particle systems added to this scene
  33167. * @see http://doc.babylonjs.com/babylon101/particles
  33168. */
  33169. particleSystems: IParticleSystem[];
  33170. /**
  33171. * Gets a list of Animations associated with the scene
  33172. */
  33173. animations: Animation[];
  33174. /**
  33175. * All of the animation groups added to this scene
  33176. * @see http://doc.babylonjs.com/how_to/group
  33177. */
  33178. animationGroups: AnimationGroup[];
  33179. /**
  33180. * All of the multi-materials added to this scene
  33181. * @see http://doc.babylonjs.com/how_to/multi_materials
  33182. */
  33183. multiMaterials: MultiMaterial[];
  33184. /**
  33185. * All of the materials added to this scene
  33186. * In the context of a Scene, it is not supposed to be modified manually.
  33187. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33188. * Note also that the order of the Material wihin the array is not significant and might change.
  33189. * @see http://doc.babylonjs.com/babylon101/materials
  33190. */
  33191. materials: Material[];
  33192. /**
  33193. * The list of morph target managers added to the scene
  33194. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33195. */
  33196. morphTargetManagers: MorphTargetManager[];
  33197. /**
  33198. * The list of geometries used in the scene.
  33199. */
  33200. geometries: Geometry[];
  33201. /**
  33202. * All of the tranform nodes added to this scene
  33203. * In the context of a Scene, it is not supposed to be modified manually.
  33204. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33205. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33206. * @see http://doc.babylonjs.com/how_to/transformnode
  33207. */
  33208. transformNodes: TransformNode[];
  33209. /**
  33210. * ActionManagers available on the scene.
  33211. */
  33212. actionManagers: AbstractActionManager[];
  33213. /**
  33214. * Textures to keep.
  33215. */
  33216. textures: BaseTexture[];
  33217. /**
  33218. * Environment texture for the scene
  33219. */
  33220. environmentTexture: Nullable<BaseTexture>;
  33221. }
  33222. }
  33223. declare module BABYLON {
  33224. /**
  33225. * Defines a sound that can be played in the application.
  33226. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33228. */
  33229. export class Sound {
  33230. /**
  33231. * The name of the sound in the scene.
  33232. */
  33233. name: string;
  33234. /**
  33235. * Does the sound autoplay once loaded.
  33236. */
  33237. autoplay: boolean;
  33238. /**
  33239. * Does the sound loop after it finishes playing once.
  33240. */
  33241. loop: boolean;
  33242. /**
  33243. * Does the sound use a custom attenuation curve to simulate the falloff
  33244. * happening when the source gets further away from the camera.
  33245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33246. */
  33247. useCustomAttenuation: boolean;
  33248. /**
  33249. * The sound track id this sound belongs to.
  33250. */
  33251. soundTrackId: number;
  33252. /**
  33253. * Is this sound currently played.
  33254. */
  33255. isPlaying: boolean;
  33256. /**
  33257. * Is this sound currently paused.
  33258. */
  33259. isPaused: boolean;
  33260. /**
  33261. * Does this sound enables spatial sound.
  33262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33263. */
  33264. spatialSound: boolean;
  33265. /**
  33266. * Define the reference distance the sound should be heard perfectly.
  33267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33268. */
  33269. refDistance: number;
  33270. /**
  33271. * Define the roll off factor of spatial sounds.
  33272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33273. */
  33274. rolloffFactor: number;
  33275. /**
  33276. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33278. */
  33279. maxDistance: number;
  33280. /**
  33281. * Define the distance attenuation model the sound will follow.
  33282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33283. */
  33284. distanceModel: string;
  33285. /**
  33286. * @hidden
  33287. * Back Compat
  33288. **/
  33289. onended: () => any;
  33290. /**
  33291. * Observable event when the current playing sound finishes.
  33292. */
  33293. onEndedObservable: Observable<Sound>;
  33294. private _panningModel;
  33295. private _playbackRate;
  33296. private _streaming;
  33297. private _startTime;
  33298. private _startOffset;
  33299. private _position;
  33300. /** @hidden */ positionInEmitterSpace: boolean;
  33301. private _localDirection;
  33302. private _volume;
  33303. private _isReadyToPlay;
  33304. private _isDirectional;
  33305. private _readyToPlayCallback;
  33306. private _audioBuffer;
  33307. private _soundSource;
  33308. private _streamingSource;
  33309. private _soundPanner;
  33310. private _soundGain;
  33311. private _inputAudioNode;
  33312. private _outputAudioNode;
  33313. private _coneInnerAngle;
  33314. private _coneOuterAngle;
  33315. private _coneOuterGain;
  33316. private _scene;
  33317. private _connectedTransformNode;
  33318. private _customAttenuationFunction;
  33319. private _registerFunc;
  33320. private _isOutputConnected;
  33321. private _htmlAudioElement;
  33322. private _urlType;
  33323. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33324. /**
  33325. * Create a sound and attach it to a scene
  33326. * @param name Name of your sound
  33327. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33328. * @param scene defines the scene the sound belongs to
  33329. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33330. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33331. */
  33332. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33333. /**
  33334. * Release the sound and its associated resources
  33335. */
  33336. dispose(): void;
  33337. /**
  33338. * Gets if the sounds is ready to be played or not.
  33339. * @returns true if ready, otherwise false
  33340. */
  33341. isReady(): boolean;
  33342. private _soundLoaded;
  33343. /**
  33344. * Sets the data of the sound from an audiobuffer
  33345. * @param audioBuffer The audioBuffer containing the data
  33346. */
  33347. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33348. /**
  33349. * Updates the current sounds options such as maxdistance, loop...
  33350. * @param options A JSON object containing values named as the object properties
  33351. */
  33352. updateOptions(options: any): void;
  33353. private _createSpatialParameters;
  33354. private _updateSpatialParameters;
  33355. /**
  33356. * Switch the panning model to HRTF:
  33357. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33359. */
  33360. switchPanningModelToHRTF(): void;
  33361. /**
  33362. * Switch the panning model to Equal Power:
  33363. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33365. */
  33366. switchPanningModelToEqualPower(): void;
  33367. private _switchPanningModel;
  33368. /**
  33369. * Connect this sound to a sound track audio node like gain...
  33370. * @param soundTrackAudioNode the sound track audio node to connect to
  33371. */
  33372. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33373. /**
  33374. * Transform this sound into a directional source
  33375. * @param coneInnerAngle Size of the inner cone in degree
  33376. * @param coneOuterAngle Size of the outer cone in degree
  33377. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33378. */
  33379. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33380. /**
  33381. * Gets or sets the inner angle for the directional cone.
  33382. */
  33383. /**
  33384. * Gets or sets the inner angle for the directional cone.
  33385. */
  33386. directionalConeInnerAngle: number;
  33387. /**
  33388. * Gets or sets the outer angle for the directional cone.
  33389. */
  33390. /**
  33391. * Gets or sets the outer angle for the directional cone.
  33392. */
  33393. directionalConeOuterAngle: number;
  33394. /**
  33395. * Sets the position of the emitter if spatial sound is enabled
  33396. * @param newPosition Defines the new posisiton
  33397. */
  33398. setPosition(newPosition: Vector3): void;
  33399. /**
  33400. * Sets the local direction of the emitter if spatial sound is enabled
  33401. * @param newLocalDirection Defines the new local direction
  33402. */
  33403. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33404. private _updateDirection;
  33405. /** @hidden */
  33406. updateDistanceFromListener(): void;
  33407. /**
  33408. * Sets a new custom attenuation function for the sound.
  33409. * @param callback Defines the function used for the attenuation
  33410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33411. */
  33412. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33413. /**
  33414. * Play the sound
  33415. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33416. * @param offset (optional) Start the sound setting it at a specific time
  33417. */
  33418. play(time?: number, offset?: number): void;
  33419. private _onended;
  33420. /**
  33421. * Stop the sound
  33422. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33423. */
  33424. stop(time?: number): void;
  33425. /**
  33426. * Put the sound in pause
  33427. */
  33428. pause(): void;
  33429. /**
  33430. * Sets a dedicated volume for this sounds
  33431. * @param newVolume Define the new volume of the sound
  33432. * @param time Define in how long the sound should be at this value
  33433. */
  33434. setVolume(newVolume: number, time?: number): void;
  33435. /**
  33436. * Set the sound play back rate
  33437. * @param newPlaybackRate Define the playback rate the sound should be played at
  33438. */
  33439. setPlaybackRate(newPlaybackRate: number): void;
  33440. /**
  33441. * Gets the volume of the sound.
  33442. * @returns the volume of the sound
  33443. */
  33444. getVolume(): number;
  33445. /**
  33446. * Attach the sound to a dedicated mesh
  33447. * @param transformNode The transform node to connect the sound with
  33448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33449. */
  33450. attachToMesh(transformNode: TransformNode): void;
  33451. /**
  33452. * Detach the sound from the previously attached mesh
  33453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33454. */
  33455. detachFromMesh(): void;
  33456. private _onRegisterAfterWorldMatrixUpdate;
  33457. /**
  33458. * Clone the current sound in the scene.
  33459. * @returns the new sound clone
  33460. */
  33461. clone(): Nullable<Sound>;
  33462. /**
  33463. * Gets the current underlying audio buffer containing the data
  33464. * @returns the audio buffer
  33465. */
  33466. getAudioBuffer(): Nullable<AudioBuffer>;
  33467. /**
  33468. * Serializes the Sound in a JSON representation
  33469. * @returns the JSON representation of the sound
  33470. */
  33471. serialize(): any;
  33472. /**
  33473. * Parse a JSON representation of a sound to innstantiate in a given scene
  33474. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33475. * @param scene Define the scene the new parsed sound should be created in
  33476. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33477. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33478. * @returns the newly parsed sound
  33479. */
  33480. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33481. }
  33482. }
  33483. declare module BABYLON {
  33484. /**
  33485. * This defines an action helpful to play a defined sound on a triggered action.
  33486. */
  33487. export class PlaySoundAction extends Action {
  33488. private _sound;
  33489. /**
  33490. * Instantiate the action
  33491. * @param triggerOptions defines the trigger options
  33492. * @param sound defines the sound to play
  33493. * @param condition defines the trigger related conditions
  33494. */
  33495. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33496. /** @hidden */ prepare(): void;
  33497. /**
  33498. * Execute the action and play the sound.
  33499. */
  33500. execute(): void;
  33501. /**
  33502. * Serializes the actions and its related information.
  33503. * @param parent defines the object to serialize in
  33504. * @returns the serialized object
  33505. */
  33506. serialize(parent: any): any;
  33507. }
  33508. /**
  33509. * This defines an action helpful to stop a defined sound on a triggered action.
  33510. */
  33511. export class StopSoundAction extends Action {
  33512. private _sound;
  33513. /**
  33514. * Instantiate the action
  33515. * @param triggerOptions defines the trigger options
  33516. * @param sound defines the sound to stop
  33517. * @param condition defines the trigger related conditions
  33518. */
  33519. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33520. /** @hidden */ prepare(): void;
  33521. /**
  33522. * Execute the action and stop the sound.
  33523. */
  33524. execute(): void;
  33525. /**
  33526. * Serializes the actions and its related information.
  33527. * @param parent defines the object to serialize in
  33528. * @returns the serialized object
  33529. */
  33530. serialize(parent: any): any;
  33531. }
  33532. }
  33533. declare module BABYLON {
  33534. /**
  33535. * This defines an action responsible to change the value of a property
  33536. * by interpolating between its current value and the newly set one once triggered.
  33537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33538. */
  33539. export class InterpolateValueAction extends Action {
  33540. /**
  33541. * Defines the path of the property where the value should be interpolated
  33542. */
  33543. propertyPath: string;
  33544. /**
  33545. * Defines the target value at the end of the interpolation.
  33546. */
  33547. value: any;
  33548. /**
  33549. * Defines the time it will take for the property to interpolate to the value.
  33550. */
  33551. duration: number;
  33552. /**
  33553. * Defines if the other scene animations should be stopped when the action has been triggered
  33554. */
  33555. stopOtherAnimations?: boolean;
  33556. /**
  33557. * Defines a callback raised once the interpolation animation has been done.
  33558. */
  33559. onInterpolationDone?: () => void;
  33560. /**
  33561. * Observable triggered once the interpolation animation has been done.
  33562. */
  33563. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33564. private _target;
  33565. private _effectiveTarget;
  33566. private _property;
  33567. /**
  33568. * Instantiate the action
  33569. * @param triggerOptions defines the trigger options
  33570. * @param target defines the object containing the value to interpolate
  33571. * @param propertyPath defines the path to the property in the target object
  33572. * @param value defines the target value at the end of the interpolation
  33573. * @param duration deines the time it will take for the property to interpolate to the value.
  33574. * @param condition defines the trigger related conditions
  33575. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33576. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33577. */
  33578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33579. /** @hidden */ prepare(): void;
  33580. /**
  33581. * Execute the action starts the value interpolation.
  33582. */
  33583. execute(): void;
  33584. /**
  33585. * Serializes the actions and its related information.
  33586. * @param parent defines the object to serialize in
  33587. * @returns the serialized object
  33588. */
  33589. serialize(parent: any): any;
  33590. }
  33591. }
  33592. declare module BABYLON {
  33593. /**
  33594. * Options allowed during the creation of a sound track.
  33595. */
  33596. export interface ISoundTrackOptions {
  33597. /**
  33598. * The volume the sound track should take during creation
  33599. */
  33600. volume?: number;
  33601. /**
  33602. * Define if the sound track is the main sound track of the scene
  33603. */
  33604. mainTrack?: boolean;
  33605. }
  33606. /**
  33607. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33608. * It will be also used in a future release to apply effects on a specific track.
  33609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33610. */
  33611. export class SoundTrack {
  33612. /**
  33613. * The unique identifier of the sound track in the scene.
  33614. */
  33615. id: number;
  33616. /**
  33617. * The list of sounds included in the sound track.
  33618. */
  33619. soundCollection: Array<Sound>;
  33620. private _outputAudioNode;
  33621. private _scene;
  33622. private _isMainTrack;
  33623. private _connectedAnalyser;
  33624. private _options;
  33625. private _isInitialized;
  33626. /**
  33627. * Creates a new sound track.
  33628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33629. * @param scene Define the scene the sound track belongs to
  33630. * @param options
  33631. */
  33632. constructor(scene: Scene, options?: ISoundTrackOptions);
  33633. private _initializeSoundTrackAudioGraph;
  33634. /**
  33635. * Release the sound track and its associated resources
  33636. */
  33637. dispose(): void;
  33638. /**
  33639. * Adds a sound to this sound track
  33640. * @param sound define the cound to add
  33641. * @ignoreNaming
  33642. */
  33643. AddSound(sound: Sound): void;
  33644. /**
  33645. * Removes a sound to this sound track
  33646. * @param sound define the cound to remove
  33647. * @ignoreNaming
  33648. */
  33649. RemoveSound(sound: Sound): void;
  33650. /**
  33651. * Set a global volume for the full sound track.
  33652. * @param newVolume Define the new volume of the sound track
  33653. */
  33654. setVolume(newVolume: number): void;
  33655. /**
  33656. * Switch the panning model to HRTF:
  33657. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33659. */
  33660. switchPanningModelToHRTF(): void;
  33661. /**
  33662. * Switch the panning model to Equal Power:
  33663. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33665. */
  33666. switchPanningModelToEqualPower(): void;
  33667. /**
  33668. * Connect the sound track to an audio analyser allowing some amazing
  33669. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33671. * @param analyser The analyser to connect to the engine
  33672. */
  33673. connectToAnalyser(analyser: Analyser): void;
  33674. }
  33675. }
  33676. declare module BABYLON {
  33677. interface AbstractScene {
  33678. /**
  33679. * The list of sounds used in the scene.
  33680. */
  33681. sounds: Nullable<Array<Sound>>;
  33682. }
  33683. interface Scene {
  33684. /**
  33685. * @hidden
  33686. * Backing field
  33687. */ mainSoundTrack: SoundTrack;
  33688. /**
  33689. * The main sound track played by the scene.
  33690. * It cotains your primary collection of sounds.
  33691. */
  33692. mainSoundTrack: SoundTrack;
  33693. /**
  33694. * The list of sound tracks added to the scene
  33695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33696. */
  33697. soundTracks: Nullable<Array<SoundTrack>>;
  33698. /**
  33699. * Gets a sound using a given name
  33700. * @param name defines the name to search for
  33701. * @return the found sound or null if not found at all.
  33702. */
  33703. getSoundByName(name: string): Nullable<Sound>;
  33704. /**
  33705. * Gets or sets if audio support is enabled
  33706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33707. */
  33708. audioEnabled: boolean;
  33709. /**
  33710. * Gets or sets if audio will be output to headphones
  33711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33712. */
  33713. headphone: boolean;
  33714. }
  33715. /**
  33716. * Defines the sound scene component responsible to manage any sounds
  33717. * in a given scene.
  33718. */
  33719. export class AudioSceneComponent implements ISceneSerializableComponent {
  33720. /**
  33721. * The component name helpfull to identify the component in the list of scene components.
  33722. */
  33723. readonly name: string;
  33724. /**
  33725. * The scene the component belongs to.
  33726. */
  33727. scene: Scene;
  33728. private _audioEnabled;
  33729. /**
  33730. * Gets whether audio is enabled or not.
  33731. * Please use related enable/disable method to switch state.
  33732. */
  33733. readonly audioEnabled: boolean;
  33734. private _headphone;
  33735. /**
  33736. * Gets whether audio is outputing to headphone or not.
  33737. * Please use the according Switch methods to change output.
  33738. */
  33739. readonly headphone: boolean;
  33740. /**
  33741. * Creates a new instance of the component for the given scene
  33742. * @param scene Defines the scene to register the component in
  33743. */
  33744. constructor(scene: Scene);
  33745. /**
  33746. * Registers the component in a given scene
  33747. */
  33748. register(): void;
  33749. /**
  33750. * Rebuilds the elements related to this component in case of
  33751. * context lost for instance.
  33752. */
  33753. rebuild(): void;
  33754. /**
  33755. * Serializes the component data to the specified json object
  33756. * @param serializationObject The object to serialize to
  33757. */
  33758. serialize(serializationObject: any): void;
  33759. /**
  33760. * Adds all the element from the container to the scene
  33761. * @param container the container holding the elements
  33762. */
  33763. addFromContainer(container: AbstractScene): void;
  33764. /**
  33765. * Removes all the elements in the container from the scene
  33766. * @param container contains the elements to remove
  33767. * @param dispose if the removed element should be disposed (default: false)
  33768. */
  33769. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33770. /**
  33771. * Disposes the component and the associated ressources.
  33772. */
  33773. dispose(): void;
  33774. /**
  33775. * Disables audio in the associated scene.
  33776. */
  33777. disableAudio(): void;
  33778. /**
  33779. * Enables audio in the associated scene.
  33780. */
  33781. enableAudio(): void;
  33782. /**
  33783. * Switch audio to headphone output.
  33784. */
  33785. switchAudioModeForHeadphones(): void;
  33786. /**
  33787. * Switch audio to normal speakers.
  33788. */
  33789. switchAudioModeForNormalSpeakers(): void;
  33790. private _afterRender;
  33791. }
  33792. }
  33793. declare module BABYLON {
  33794. /**
  33795. * Wraps one or more Sound objects and selects one with random weight for playback.
  33796. */
  33797. export class WeightedSound {
  33798. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33799. loop: boolean;
  33800. private _coneInnerAngle;
  33801. private _coneOuterAngle;
  33802. private _volume;
  33803. /** A Sound is currently playing. */
  33804. isPlaying: boolean;
  33805. /** A Sound is currently paused. */
  33806. isPaused: boolean;
  33807. private _sounds;
  33808. private _weights;
  33809. private _currentIndex?;
  33810. /**
  33811. * Creates a new WeightedSound from the list of sounds given.
  33812. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33813. * @param sounds Array of Sounds that will be selected from.
  33814. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33815. */
  33816. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33817. /**
  33818. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33819. */
  33820. /**
  33821. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33822. */
  33823. directionalConeInnerAngle: number;
  33824. /**
  33825. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33826. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33827. */
  33828. /**
  33829. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33830. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33831. */
  33832. directionalConeOuterAngle: number;
  33833. /**
  33834. * Playback volume.
  33835. */
  33836. /**
  33837. * Playback volume.
  33838. */
  33839. volume: number;
  33840. private _onended;
  33841. /**
  33842. * Suspend playback
  33843. */
  33844. pause(): void;
  33845. /**
  33846. * Stop playback
  33847. */
  33848. stop(): void;
  33849. /**
  33850. * Start playback.
  33851. * @param startOffset Position the clip head at a specific time in seconds.
  33852. */
  33853. play(startOffset?: number): void;
  33854. }
  33855. }
  33856. declare module BABYLON {
  33857. /**
  33858. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33859. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33860. */
  33861. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33862. /**
  33863. * Gets the name of the behavior.
  33864. */
  33865. readonly name: string;
  33866. /**
  33867. * The easing function used by animations
  33868. */
  33869. static EasingFunction: BackEase;
  33870. /**
  33871. * The easing mode used by animations
  33872. */
  33873. static EasingMode: number;
  33874. /**
  33875. * The duration of the animation, in milliseconds
  33876. */
  33877. transitionDuration: number;
  33878. /**
  33879. * Length of the distance animated by the transition when lower radius is reached
  33880. */
  33881. lowerRadiusTransitionRange: number;
  33882. /**
  33883. * Length of the distance animated by the transition when upper radius is reached
  33884. */
  33885. upperRadiusTransitionRange: number;
  33886. private _autoTransitionRange;
  33887. /**
  33888. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33889. */
  33890. /**
  33891. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33892. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33893. */
  33894. autoTransitionRange: boolean;
  33895. private _attachedCamera;
  33896. private _onAfterCheckInputsObserver;
  33897. private _onMeshTargetChangedObserver;
  33898. /**
  33899. * Initializes the behavior.
  33900. */
  33901. init(): void;
  33902. /**
  33903. * Attaches the behavior to its arc rotate camera.
  33904. * @param camera Defines the camera to attach the behavior to
  33905. */
  33906. attach(camera: ArcRotateCamera): void;
  33907. /**
  33908. * Detaches the behavior from its current arc rotate camera.
  33909. */
  33910. detach(): void;
  33911. private _radiusIsAnimating;
  33912. private _radiusBounceTransition;
  33913. private _animatables;
  33914. private _cachedWheelPrecision;
  33915. /**
  33916. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33917. * @param radiusLimit The limit to check against.
  33918. * @return Bool to indicate if at limit.
  33919. */
  33920. private _isRadiusAtLimit;
  33921. /**
  33922. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33923. * @param radiusDelta The delta by which to animate to. Can be negative.
  33924. */
  33925. private _applyBoundRadiusAnimation;
  33926. /**
  33927. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33928. */
  33929. protected _clearAnimationLocks(): void;
  33930. /**
  33931. * Stops and removes all animations that have been applied to the camera
  33932. */
  33933. stopAllAnimations(): void;
  33934. }
  33935. }
  33936. declare module BABYLON {
  33937. /**
  33938. * 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.
  33939. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33940. */
  33941. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33942. /**
  33943. * Gets the name of the behavior.
  33944. */
  33945. readonly name: string;
  33946. private _mode;
  33947. private _radiusScale;
  33948. private _positionScale;
  33949. private _defaultElevation;
  33950. private _elevationReturnTime;
  33951. private _elevationReturnWaitTime;
  33952. private _zoomStopsAnimation;
  33953. private _framingTime;
  33954. /**
  33955. * The easing function used by animations
  33956. */
  33957. static EasingFunction: ExponentialEase;
  33958. /**
  33959. * The easing mode used by animations
  33960. */
  33961. static EasingMode: number;
  33962. /**
  33963. * Sets the current mode used by the behavior
  33964. */
  33965. /**
  33966. * Gets current mode used by the behavior.
  33967. */
  33968. mode: number;
  33969. /**
  33970. * Sets the scale applied to the radius (1 by default)
  33971. */
  33972. /**
  33973. * Gets the scale applied to the radius
  33974. */
  33975. radiusScale: number;
  33976. /**
  33977. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33978. */
  33979. /**
  33980. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33981. */
  33982. positionScale: number;
  33983. /**
  33984. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33985. * behaviour is triggered, in radians.
  33986. */
  33987. /**
  33988. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33989. * behaviour is triggered, in radians.
  33990. */
  33991. defaultElevation: number;
  33992. /**
  33993. * Sets the time (in milliseconds) taken to return to the default beta position.
  33994. * Negative value indicates camera should not return to default.
  33995. */
  33996. /**
  33997. * Gets the time (in milliseconds) taken to return to the default beta position.
  33998. * Negative value indicates camera should not return to default.
  33999. */
  34000. elevationReturnTime: number;
  34001. /**
  34002. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34003. */
  34004. /**
  34005. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34006. */
  34007. elevationReturnWaitTime: number;
  34008. /**
  34009. * Sets the flag that indicates if user zooming should stop animation.
  34010. */
  34011. /**
  34012. * Gets the flag that indicates if user zooming should stop animation.
  34013. */
  34014. zoomStopsAnimation: boolean;
  34015. /**
  34016. * Sets the transition time when framing the mesh, in milliseconds
  34017. */
  34018. /**
  34019. * Gets the transition time when framing the mesh, in milliseconds
  34020. */
  34021. framingTime: number;
  34022. /**
  34023. * Define if the behavior should automatically change the configured
  34024. * camera limits and sensibilities.
  34025. */
  34026. autoCorrectCameraLimitsAndSensibility: boolean;
  34027. private _onPrePointerObservableObserver;
  34028. private _onAfterCheckInputsObserver;
  34029. private _onMeshTargetChangedObserver;
  34030. private _attachedCamera;
  34031. private _isPointerDown;
  34032. private _lastInteractionTime;
  34033. /**
  34034. * Initializes the behavior.
  34035. */
  34036. init(): void;
  34037. /**
  34038. * Attaches the behavior to its arc rotate camera.
  34039. * @param camera Defines the camera to attach the behavior to
  34040. */
  34041. attach(camera: ArcRotateCamera): void;
  34042. /**
  34043. * Detaches the behavior from its current arc rotate camera.
  34044. */
  34045. detach(): void;
  34046. private _animatables;
  34047. private _betaIsAnimating;
  34048. private _betaTransition;
  34049. private _radiusTransition;
  34050. private _vectorTransition;
  34051. /**
  34052. * Targets the given mesh and updates zoom level accordingly.
  34053. * @param mesh The mesh to target.
  34054. * @param radius Optional. If a cached radius position already exists, overrides default.
  34055. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34056. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34057. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34058. */
  34059. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34060. /**
  34061. * Targets the given mesh with its children and updates zoom level accordingly.
  34062. * @param mesh The mesh to target.
  34063. * @param radius Optional. If a cached radius position already exists, overrides default.
  34064. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34065. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34066. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34067. */
  34068. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34069. /**
  34070. * Targets the given meshes with their children and updates zoom level accordingly.
  34071. * @param meshes The mesh to target.
  34072. * @param radius Optional. If a cached radius position already exists, overrides default.
  34073. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34074. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34075. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34076. */
  34077. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34078. /**
  34079. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34080. * @param minimumWorld Determines the smaller position of the bounding box extend
  34081. * @param maximumWorld Determines the bigger position of the bounding box extend
  34082. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34083. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34084. */
  34085. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34086. /**
  34087. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34088. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34089. * frustum width.
  34090. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34091. * to fully enclose the mesh in the viewing frustum.
  34092. */
  34093. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34094. /**
  34095. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34096. * is automatically returned to its default position (expected to be above ground plane).
  34097. */
  34098. private _maintainCameraAboveGround;
  34099. /**
  34100. * Returns the frustum slope based on the canvas ratio and camera FOV
  34101. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34102. */
  34103. private _getFrustumSlope;
  34104. /**
  34105. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34106. */
  34107. private _clearAnimationLocks;
  34108. /**
  34109. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34110. */
  34111. private _applyUserInteraction;
  34112. /**
  34113. * Stops and removes all animations that have been applied to the camera
  34114. */
  34115. stopAllAnimations(): void;
  34116. /**
  34117. * Gets a value indicating if the user is moving the camera
  34118. */
  34119. readonly isUserIsMoving: boolean;
  34120. /**
  34121. * The camera can move all the way towards the mesh.
  34122. */
  34123. static IgnoreBoundsSizeMode: number;
  34124. /**
  34125. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34126. */
  34127. static FitFrustumSidesMode: number;
  34128. }
  34129. }
  34130. declare module BABYLON {
  34131. /**
  34132. * Base class for Camera Pointer Inputs.
  34133. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34134. * for example usage.
  34135. */
  34136. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34137. /**
  34138. * Defines the camera the input is attached to.
  34139. */
  34140. abstract camera: Camera;
  34141. /**
  34142. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34143. */
  34144. protected _altKey: boolean;
  34145. protected _ctrlKey: boolean;
  34146. protected _metaKey: boolean;
  34147. protected _shiftKey: boolean;
  34148. /**
  34149. * Which mouse buttons were pressed at time of last mouse event.
  34150. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34151. */
  34152. protected _buttonsPressed: number;
  34153. /**
  34154. * Defines the buttons associated with the input to handle camera move.
  34155. */
  34156. buttons: number[];
  34157. /**
  34158. * Attach the input controls to a specific dom element to get the input from.
  34159. * @param element Defines the element the controls should be listened from
  34160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34161. */
  34162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34163. /**
  34164. * Detach the current controls from the specified dom element.
  34165. * @param element Defines the element to stop listening the inputs from
  34166. */
  34167. detachControl(element: Nullable<HTMLElement>): void;
  34168. /**
  34169. * Gets the class name of the current input.
  34170. * @returns the class name
  34171. */
  34172. getClassName(): string;
  34173. /**
  34174. * Get the friendly name associated with the input class.
  34175. * @returns the input friendly name
  34176. */
  34177. getSimpleName(): string;
  34178. /**
  34179. * Called on pointer POINTERDOUBLETAP event.
  34180. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34181. */
  34182. protected onDoubleTap(type: string): void;
  34183. /**
  34184. * Called on pointer POINTERMOVE event if only a single touch is active.
  34185. * Override this method to provide functionality.
  34186. */
  34187. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34188. /**
  34189. * Called on pointer POINTERMOVE event if multiple touches are active.
  34190. * Override this method to provide functionality.
  34191. */
  34192. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34193. /**
  34194. * Called on JS contextmenu event.
  34195. * Override this method to provide functionality.
  34196. */
  34197. protected onContextMenu(evt: PointerEvent): void;
  34198. /**
  34199. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34200. * press.
  34201. * Override this method to provide functionality.
  34202. */
  34203. protected onButtonDown(evt: PointerEvent): void;
  34204. /**
  34205. * Called each time a new POINTERUP event occurs. Ie, for each button
  34206. * release.
  34207. * Override this method to provide functionality.
  34208. */
  34209. protected onButtonUp(evt: PointerEvent): void;
  34210. /**
  34211. * Called when window becomes inactive.
  34212. * Override this method to provide functionality.
  34213. */
  34214. protected onLostFocus(): void;
  34215. private _pointerInput;
  34216. private _observer;
  34217. private _onLostFocus;
  34218. private pointA;
  34219. private pointB;
  34220. }
  34221. }
  34222. declare module BABYLON {
  34223. /**
  34224. * Manage the pointers inputs to control an arc rotate camera.
  34225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34226. */
  34227. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34228. /**
  34229. * Defines the camera the input is attached to.
  34230. */
  34231. camera: ArcRotateCamera;
  34232. /**
  34233. * Gets the class name of the current input.
  34234. * @returns the class name
  34235. */
  34236. getClassName(): string;
  34237. /**
  34238. * Defines the buttons associated with the input to handle camera move.
  34239. */
  34240. buttons: number[];
  34241. /**
  34242. * Defines the pointer angular sensibility along the X axis or how fast is
  34243. * the camera rotating.
  34244. */
  34245. angularSensibilityX: number;
  34246. /**
  34247. * Defines the pointer angular sensibility along the Y axis or how fast is
  34248. * the camera rotating.
  34249. */
  34250. angularSensibilityY: number;
  34251. /**
  34252. * Defines the pointer pinch precision or how fast is the camera zooming.
  34253. */
  34254. pinchPrecision: number;
  34255. /**
  34256. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34257. * from 0.
  34258. * It defines the percentage of current camera.radius to use as delta when
  34259. * pinch zoom is used.
  34260. */
  34261. pinchDeltaPercentage: number;
  34262. /**
  34263. * Defines the pointer panning sensibility or how fast is the camera moving.
  34264. */
  34265. panningSensibility: number;
  34266. /**
  34267. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34268. */
  34269. multiTouchPanning: boolean;
  34270. /**
  34271. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34272. * zoom (pinch) through multitouch.
  34273. */
  34274. multiTouchPanAndZoom: boolean;
  34275. /**
  34276. * Revers pinch action direction.
  34277. */
  34278. pinchInwards: boolean;
  34279. private _isPanClick;
  34280. private _twoFingerActivityCount;
  34281. private _isPinching;
  34282. /**
  34283. * Called on pointer POINTERMOVE event if only a single touch is active.
  34284. */
  34285. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34286. /**
  34287. * Called on pointer POINTERDOUBLETAP event.
  34288. */
  34289. protected onDoubleTap(type: string): void;
  34290. /**
  34291. * Called on pointer POINTERMOVE event if multiple touches are active.
  34292. */
  34293. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34294. /**
  34295. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34296. * press.
  34297. */
  34298. protected onButtonDown(evt: PointerEvent): void;
  34299. /**
  34300. * Called each time a new POINTERUP event occurs. Ie, for each button
  34301. * release.
  34302. */
  34303. protected onButtonUp(evt: PointerEvent): void;
  34304. /**
  34305. * Called when window becomes inactive.
  34306. */
  34307. protected onLostFocus(): void;
  34308. }
  34309. }
  34310. declare module BABYLON {
  34311. /**
  34312. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34314. */
  34315. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34316. /**
  34317. * Defines the camera the input is attached to.
  34318. */
  34319. camera: ArcRotateCamera;
  34320. /**
  34321. * Defines the list of key codes associated with the up action (increase alpha)
  34322. */
  34323. keysUp: number[];
  34324. /**
  34325. * Defines the list of key codes associated with the down action (decrease alpha)
  34326. */
  34327. keysDown: number[];
  34328. /**
  34329. * Defines the list of key codes associated with the left action (increase beta)
  34330. */
  34331. keysLeft: number[];
  34332. /**
  34333. * Defines the list of key codes associated with the right action (decrease beta)
  34334. */
  34335. keysRight: number[];
  34336. /**
  34337. * Defines the list of key codes associated with the reset action.
  34338. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34339. */
  34340. keysReset: number[];
  34341. /**
  34342. * Defines the panning sensibility of the inputs.
  34343. * (How fast is the camera paning)
  34344. */
  34345. panningSensibility: number;
  34346. /**
  34347. * Defines the zooming sensibility of the inputs.
  34348. * (How fast is the camera zooming)
  34349. */
  34350. zoomingSensibility: number;
  34351. /**
  34352. * Defines wether maintaining the alt key down switch the movement mode from
  34353. * orientation to zoom.
  34354. */
  34355. useAltToZoom: boolean;
  34356. /**
  34357. * Rotation speed of the camera
  34358. */
  34359. angularSpeed: number;
  34360. private _keys;
  34361. private _ctrlPressed;
  34362. private _altPressed;
  34363. private _onCanvasBlurObserver;
  34364. private _onKeyboardObserver;
  34365. private _engine;
  34366. private _scene;
  34367. /**
  34368. * Attach the input controls to a specific dom element to get the input from.
  34369. * @param element Defines the element the controls should be listened from
  34370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34371. */
  34372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34373. /**
  34374. * Detach the current controls from the specified dom element.
  34375. * @param element Defines the element to stop listening the inputs from
  34376. */
  34377. detachControl(element: Nullable<HTMLElement>): void;
  34378. /**
  34379. * Update the current camera state depending on the inputs that have been used this frame.
  34380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34381. */
  34382. checkInputs(): void;
  34383. /**
  34384. * Gets the class name of the current intput.
  34385. * @returns the class name
  34386. */
  34387. getClassName(): string;
  34388. /**
  34389. * Get the friendly name associated with the input class.
  34390. * @returns the input friendly name
  34391. */
  34392. getSimpleName(): string;
  34393. }
  34394. }
  34395. declare module BABYLON {
  34396. /**
  34397. * Manage the mouse wheel inputs to control an arc rotate camera.
  34398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34399. */
  34400. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34401. /**
  34402. * Defines the camera the input is attached to.
  34403. */
  34404. camera: ArcRotateCamera;
  34405. /**
  34406. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34407. */
  34408. wheelPrecision: number;
  34409. /**
  34410. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34411. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34412. */
  34413. wheelDeltaPercentage: number;
  34414. private _wheel;
  34415. private _observer;
  34416. private computeDeltaFromMouseWheelLegacyEvent;
  34417. /**
  34418. * Attach the input controls to a specific dom element to get the input from.
  34419. * @param element Defines the element the controls should be listened from
  34420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34421. */
  34422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34423. /**
  34424. * Detach the current controls from the specified dom element.
  34425. * @param element Defines the element to stop listening the inputs from
  34426. */
  34427. detachControl(element: Nullable<HTMLElement>): void;
  34428. /**
  34429. * Gets the class name of the current intput.
  34430. * @returns the class name
  34431. */
  34432. getClassName(): string;
  34433. /**
  34434. * Get the friendly name associated with the input class.
  34435. * @returns the input friendly name
  34436. */
  34437. getSimpleName(): string;
  34438. }
  34439. }
  34440. declare module BABYLON {
  34441. /**
  34442. * Default Inputs manager for the ArcRotateCamera.
  34443. * It groups all the default supported inputs for ease of use.
  34444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34445. */
  34446. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34447. /**
  34448. * Instantiates a new ArcRotateCameraInputsManager.
  34449. * @param camera Defines the camera the inputs belong to
  34450. */
  34451. constructor(camera: ArcRotateCamera);
  34452. /**
  34453. * Add mouse wheel input support to the input manager.
  34454. * @returns the current input manager
  34455. */
  34456. addMouseWheel(): ArcRotateCameraInputsManager;
  34457. /**
  34458. * Add pointers input support to the input manager.
  34459. * @returns the current input manager
  34460. */
  34461. addPointers(): ArcRotateCameraInputsManager;
  34462. /**
  34463. * Add keyboard input support to the input manager.
  34464. * @returns the current input manager
  34465. */
  34466. addKeyboard(): ArcRotateCameraInputsManager;
  34467. }
  34468. }
  34469. declare module BABYLON {
  34470. /**
  34471. * This represents an orbital type of camera.
  34472. *
  34473. * 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.
  34474. * 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.
  34475. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34476. */
  34477. export class ArcRotateCamera extends TargetCamera {
  34478. /**
  34479. * Defines the rotation angle of the camera along the longitudinal axis.
  34480. */
  34481. alpha: number;
  34482. /**
  34483. * Defines the rotation angle of the camera along the latitudinal axis.
  34484. */
  34485. beta: number;
  34486. /**
  34487. * Defines the radius of the camera from it s target point.
  34488. */
  34489. radius: number;
  34490. protected _target: Vector3;
  34491. protected _targetHost: Nullable<AbstractMesh>;
  34492. /**
  34493. * Defines the target point of the camera.
  34494. * The camera looks towards it form the radius distance.
  34495. */
  34496. target: Vector3;
  34497. /**
  34498. * Define the current local position of the camera in the scene
  34499. */
  34500. position: Vector3;
  34501. protected _upVector: Vector3;
  34502. protected _upToYMatrix: Matrix;
  34503. protected _YToUpMatrix: Matrix;
  34504. /**
  34505. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34506. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34507. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34508. */
  34509. upVector: Vector3;
  34510. /**
  34511. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34512. */
  34513. setMatUp(): void;
  34514. /**
  34515. * Current inertia value on the longitudinal axis.
  34516. * The bigger this number the longer it will take for the camera to stop.
  34517. */
  34518. inertialAlphaOffset: number;
  34519. /**
  34520. * Current inertia value on the latitudinal axis.
  34521. * The bigger this number the longer it will take for the camera to stop.
  34522. */
  34523. inertialBetaOffset: number;
  34524. /**
  34525. * Current inertia value on the radius axis.
  34526. * The bigger this number the longer it will take for the camera to stop.
  34527. */
  34528. inertialRadiusOffset: number;
  34529. /**
  34530. * Minimum allowed angle on the longitudinal axis.
  34531. * This can help limiting how the Camera is able to move in the scene.
  34532. */
  34533. lowerAlphaLimit: Nullable<number>;
  34534. /**
  34535. * Maximum allowed angle on the longitudinal axis.
  34536. * This can help limiting how the Camera is able to move in the scene.
  34537. */
  34538. upperAlphaLimit: Nullable<number>;
  34539. /**
  34540. * Minimum allowed angle on the latitudinal axis.
  34541. * This can help limiting how the Camera is able to move in the scene.
  34542. */
  34543. lowerBetaLimit: number;
  34544. /**
  34545. * Maximum allowed angle on the latitudinal axis.
  34546. * This can help limiting how the Camera is able to move in the scene.
  34547. */
  34548. upperBetaLimit: number;
  34549. /**
  34550. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34551. * This can help limiting how the Camera is able to move in the scene.
  34552. */
  34553. lowerRadiusLimit: Nullable<number>;
  34554. /**
  34555. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34556. * This can help limiting how the Camera is able to move in the scene.
  34557. */
  34558. upperRadiusLimit: Nullable<number>;
  34559. /**
  34560. * Defines the current inertia value used during panning of the camera along the X axis.
  34561. */
  34562. inertialPanningX: number;
  34563. /**
  34564. * Defines the current inertia value used during panning of the camera along the Y axis.
  34565. */
  34566. inertialPanningY: number;
  34567. /**
  34568. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34569. * Basically if your fingers moves away from more than this distance you will be considered
  34570. * in pinch mode.
  34571. */
  34572. pinchToPanMaxDistance: number;
  34573. /**
  34574. * Defines the maximum distance the camera can pan.
  34575. * This could help keeping the cammera always in your scene.
  34576. */
  34577. panningDistanceLimit: Nullable<number>;
  34578. /**
  34579. * Defines the target of the camera before paning.
  34580. */
  34581. panningOriginTarget: Vector3;
  34582. /**
  34583. * Defines the value of the inertia used during panning.
  34584. * 0 would mean stop inertia and one would mean no decelleration at all.
  34585. */
  34586. panningInertia: number;
  34587. /**
  34588. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34589. */
  34590. angularSensibilityX: number;
  34591. /**
  34592. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34593. */
  34594. angularSensibilityY: number;
  34595. /**
  34596. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34597. */
  34598. pinchPrecision: number;
  34599. /**
  34600. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34601. * It will be used instead of pinchDeltaPrecision if different from 0.
  34602. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34603. */
  34604. pinchDeltaPercentage: number;
  34605. /**
  34606. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34607. */
  34608. panningSensibility: number;
  34609. /**
  34610. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34611. */
  34612. keysUp: number[];
  34613. /**
  34614. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34615. */
  34616. keysDown: number[];
  34617. /**
  34618. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34619. */
  34620. keysLeft: number[];
  34621. /**
  34622. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34623. */
  34624. keysRight: number[];
  34625. /**
  34626. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34627. */
  34628. wheelPrecision: number;
  34629. /**
  34630. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34631. * It will be used instead of pinchDeltaPrecision if different from 0.
  34632. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34633. */
  34634. wheelDeltaPercentage: number;
  34635. /**
  34636. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34637. */
  34638. zoomOnFactor: number;
  34639. /**
  34640. * Defines a screen offset for the camera position.
  34641. */
  34642. targetScreenOffset: Vector2;
  34643. /**
  34644. * Allows the camera to be completely reversed.
  34645. * If false the camera can not arrive upside down.
  34646. */
  34647. allowUpsideDown: boolean;
  34648. /**
  34649. * Define if double tap/click is used to restore the previously saved state of the camera.
  34650. */
  34651. useInputToRestoreState: boolean;
  34652. /** @hidden */ viewMatrix: Matrix;
  34653. /** @hidden */ useCtrlForPanning: boolean;
  34654. /** @hidden */ panningMouseButton: number;
  34655. /**
  34656. * Defines the input associated to the camera.
  34657. */
  34658. inputs: ArcRotateCameraInputsManager;
  34659. /** @hidden */ reset: () => void;
  34660. /**
  34661. * Defines the allowed panning axis.
  34662. */
  34663. panningAxis: Vector3;
  34664. protected _localDirection: Vector3;
  34665. protected _transformedDirection: Vector3;
  34666. private _bouncingBehavior;
  34667. /**
  34668. * Gets the bouncing behavior of the camera if it has been enabled.
  34669. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34670. */
  34671. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34672. /**
  34673. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34674. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34675. */
  34676. useBouncingBehavior: boolean;
  34677. private _framingBehavior;
  34678. /**
  34679. * Gets the framing behavior of the camera if it has been enabled.
  34680. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34681. */
  34682. readonly framingBehavior: Nullable<FramingBehavior>;
  34683. /**
  34684. * Defines if the framing behavior of the camera is enabled on the camera.
  34685. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34686. */
  34687. useFramingBehavior: boolean;
  34688. private _autoRotationBehavior;
  34689. /**
  34690. * Gets the auto rotation behavior of the camera if it has been enabled.
  34691. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34692. */
  34693. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34694. /**
  34695. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34696. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34697. */
  34698. useAutoRotationBehavior: boolean;
  34699. /**
  34700. * Observable triggered when the mesh target has been changed on the camera.
  34701. */
  34702. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34703. /**
  34704. * Event raised when the camera is colliding with a mesh.
  34705. */
  34706. onCollide: (collidedMesh: AbstractMesh) => void;
  34707. /**
  34708. * Defines whether the camera should check collision with the objects oh the scene.
  34709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34710. */
  34711. checkCollisions: boolean;
  34712. /**
  34713. * Defines the collision radius of the camera.
  34714. * This simulates a sphere around the camera.
  34715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34716. */
  34717. collisionRadius: Vector3;
  34718. protected _collider: Collider;
  34719. protected _previousPosition: Vector3;
  34720. protected _collisionVelocity: Vector3;
  34721. protected _newPosition: Vector3;
  34722. protected _previousAlpha: number;
  34723. protected _previousBeta: number;
  34724. protected _previousRadius: number;
  34725. protected _collisionTriggered: boolean;
  34726. protected _targetBoundingCenter: Nullable<Vector3>;
  34727. private _computationVector;
  34728. /**
  34729. * Instantiates a new ArcRotateCamera in a given scene
  34730. * @param name Defines the name of the camera
  34731. * @param alpha Defines the camera rotation along the logitudinal axis
  34732. * @param beta Defines the camera rotation along the latitudinal axis
  34733. * @param radius Defines the camera distance from its target
  34734. * @param target Defines the camera target
  34735. * @param scene Defines the scene the camera belongs to
  34736. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34737. */
  34738. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34739. /** @hidden */ initCache(): void;
  34740. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34741. protected _getTargetPosition(): Vector3;
  34742. private _storedAlpha;
  34743. private _storedBeta;
  34744. private _storedRadius;
  34745. private _storedTarget;
  34746. /**
  34747. * Stores the current state of the camera (alpha, beta, radius and target)
  34748. * @returns the camera itself
  34749. */
  34750. storeState(): Camera;
  34751. /**
  34752. * @hidden
  34753. * Restored camera state. You must call storeState() first
  34754. */ restoreStateValues(): boolean;
  34755. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34756. /**
  34757. * Attached controls to the current camera.
  34758. * @param element Defines the element the controls should be listened from
  34759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34760. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34761. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34762. */
  34763. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34764. /**
  34765. * Detach the current controls from the camera.
  34766. * The camera will stop reacting to inputs.
  34767. * @param element Defines the element to stop listening the inputs from
  34768. */
  34769. detachControl(element: HTMLElement): void;
  34770. /** @hidden */ checkInputs(): void;
  34771. protected _checkLimits(): void;
  34772. /**
  34773. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34774. */
  34775. rebuildAnglesAndRadius(): void;
  34776. /**
  34777. * Use a position to define the current camera related information like aplha, beta and radius
  34778. * @param position Defines the position to set the camera at
  34779. */
  34780. setPosition(position: Vector3): void;
  34781. /**
  34782. * Defines the target the camera should look at.
  34783. * This will automatically adapt alpha beta and radius to fit within the new target.
  34784. * @param target Defines the new target as a Vector or a mesh
  34785. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34786. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34787. */
  34788. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34789. /** @hidden */ getViewMatrix(): Matrix;
  34790. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34791. /**
  34792. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34793. * @param meshes Defines the mesh to zoom on
  34794. * @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)
  34795. */
  34796. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34797. /**
  34798. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34799. * The target will be changed but the radius
  34800. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34801. * @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)
  34802. */
  34803. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34804. min: Vector3;
  34805. max: Vector3;
  34806. distance: number;
  34807. }, doNotUpdateMaxZ?: boolean): void;
  34808. /**
  34809. * @override
  34810. * Override Camera.createRigCamera
  34811. */
  34812. createRigCamera(name: string, cameraIndex: number): Camera;
  34813. /**
  34814. * @hidden
  34815. * @override
  34816. * Override Camera._updateRigCameras
  34817. */ updateRigCameras(): void;
  34818. /**
  34819. * Destroy the camera and release the current resources hold by it.
  34820. */
  34821. dispose(): void;
  34822. /**
  34823. * Gets the current object class name.
  34824. * @return the class name
  34825. */
  34826. getClassName(): string;
  34827. }
  34828. }
  34829. declare module BABYLON {
  34830. /**
  34831. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34832. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34833. */
  34834. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34835. /**
  34836. * Gets the name of the behavior.
  34837. */
  34838. readonly name: string;
  34839. private _zoomStopsAnimation;
  34840. private _idleRotationSpeed;
  34841. private _idleRotationWaitTime;
  34842. private _idleRotationSpinupTime;
  34843. /**
  34844. * Sets the flag that indicates if user zooming should stop animation.
  34845. */
  34846. /**
  34847. * Gets the flag that indicates if user zooming should stop animation.
  34848. */
  34849. zoomStopsAnimation: boolean;
  34850. /**
  34851. * Sets the default speed at which the camera rotates around the model.
  34852. */
  34853. /**
  34854. * Gets the default speed at which the camera rotates around the model.
  34855. */
  34856. idleRotationSpeed: number;
  34857. /**
  34858. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34859. */
  34860. /**
  34861. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34862. */
  34863. idleRotationWaitTime: number;
  34864. /**
  34865. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34866. */
  34867. /**
  34868. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34869. */
  34870. idleRotationSpinupTime: number;
  34871. /**
  34872. * Gets a value indicating if the camera is currently rotating because of this behavior
  34873. */
  34874. readonly rotationInProgress: boolean;
  34875. private _onPrePointerObservableObserver;
  34876. private _onAfterCheckInputsObserver;
  34877. private _attachedCamera;
  34878. private _isPointerDown;
  34879. private _lastFrameTime;
  34880. private _lastInteractionTime;
  34881. private _cameraRotationSpeed;
  34882. /**
  34883. * Initializes the behavior.
  34884. */
  34885. init(): void;
  34886. /**
  34887. * Attaches the behavior to its arc rotate camera.
  34888. * @param camera Defines the camera to attach the behavior to
  34889. */
  34890. attach(camera: ArcRotateCamera): void;
  34891. /**
  34892. * Detaches the behavior from its current arc rotate camera.
  34893. */
  34894. detach(): void;
  34895. /**
  34896. * Returns true if user is scrolling.
  34897. * @return true if user is scrolling.
  34898. */
  34899. private _userIsZooming;
  34900. private _lastFrameRadius;
  34901. private _shouldAnimationStopForInteraction;
  34902. /**
  34903. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34904. */
  34905. private _applyUserInteraction;
  34906. private _userIsMoving;
  34907. }
  34908. }
  34909. declare module BABYLON {
  34910. /**
  34911. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34912. */
  34913. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34914. private ui;
  34915. /**
  34916. * The name of the behavior
  34917. */
  34918. name: string;
  34919. /**
  34920. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34921. */
  34922. distanceAwayFromFace: number;
  34923. /**
  34924. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34925. */
  34926. distanceAwayFromBottomOfFace: number;
  34927. private _faceVectors;
  34928. private _target;
  34929. private _scene;
  34930. private _onRenderObserver;
  34931. private _tmpMatrix;
  34932. private _tmpVector;
  34933. /**
  34934. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34935. * @param ui The transform node that should be attched to the mesh
  34936. */
  34937. constructor(ui: TransformNode);
  34938. /**
  34939. * Initializes the behavior
  34940. */
  34941. init(): void;
  34942. private _closestFace;
  34943. private _zeroVector;
  34944. private _lookAtTmpMatrix;
  34945. private _lookAtToRef;
  34946. /**
  34947. * Attaches the AttachToBoxBehavior to the passed in mesh
  34948. * @param target The mesh that the specified node will be attached to
  34949. */
  34950. attach(target: Mesh): void;
  34951. /**
  34952. * Detaches the behavior from the mesh
  34953. */
  34954. detach(): void;
  34955. }
  34956. }
  34957. declare module BABYLON {
  34958. /**
  34959. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34960. */
  34961. export class FadeInOutBehavior implements Behavior<Mesh> {
  34962. /**
  34963. * Time in milliseconds to delay before fading in (Default: 0)
  34964. */
  34965. delay: number;
  34966. /**
  34967. * Time in milliseconds for the mesh to fade in (Default: 300)
  34968. */
  34969. fadeInTime: number;
  34970. private _millisecondsPerFrame;
  34971. private _hovered;
  34972. private _hoverValue;
  34973. private _ownerNode;
  34974. /**
  34975. * Instatiates the FadeInOutBehavior
  34976. */
  34977. constructor();
  34978. /**
  34979. * The name of the behavior
  34980. */
  34981. readonly name: string;
  34982. /**
  34983. * Initializes the behavior
  34984. */
  34985. init(): void;
  34986. /**
  34987. * Attaches the fade behavior on the passed in mesh
  34988. * @param ownerNode The mesh that will be faded in/out once attached
  34989. */
  34990. attach(ownerNode: Mesh): void;
  34991. /**
  34992. * Detaches the behavior from the mesh
  34993. */
  34994. detach(): void;
  34995. /**
  34996. * Triggers the mesh to begin fading in or out
  34997. * @param value if the object should fade in or out (true to fade in)
  34998. */
  34999. fadeIn(value: boolean): void;
  35000. private _update;
  35001. private _setAllVisibility;
  35002. }
  35003. }
  35004. declare module BABYLON {
  35005. /**
  35006. * Class containing a set of static utilities functions for managing Pivots
  35007. * @hidden
  35008. */
  35009. export class PivotTools {
  35010. private static _PivotCached;
  35011. private static _OldPivotPoint;
  35012. private static _PivotTranslation;
  35013. private static _PivotTmpVector;
  35014. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35015. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35016. }
  35017. }
  35018. declare module BABYLON {
  35019. /**
  35020. * Class containing static functions to help procedurally build meshes
  35021. */
  35022. export class PlaneBuilder {
  35023. /**
  35024. * Creates a plane mesh
  35025. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35026. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35027. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35031. * @param name defines the name of the mesh
  35032. * @param options defines the options used to create the mesh
  35033. * @param scene defines the hosting scene
  35034. * @returns the plane mesh
  35035. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35036. */
  35037. static CreatePlane(name: string, options: {
  35038. size?: number;
  35039. width?: number;
  35040. height?: number;
  35041. sideOrientation?: number;
  35042. frontUVs?: Vector4;
  35043. backUVs?: Vector4;
  35044. updatable?: boolean;
  35045. sourcePlane?: Plane;
  35046. }, scene?: Nullable<Scene>): Mesh;
  35047. }
  35048. }
  35049. declare module BABYLON {
  35050. /**
  35051. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35052. */
  35053. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35054. private static _AnyMouseID;
  35055. private _attachedNode;
  35056. private _dragPlane;
  35057. private _scene;
  35058. private _pointerObserver;
  35059. private _beforeRenderObserver;
  35060. private static _planeScene;
  35061. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35062. /**
  35063. * 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)
  35064. */
  35065. maxDragAngle: number;
  35066. /**
  35067. * @hidden
  35068. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  35069. /**
  35070. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35071. */
  35072. currentDraggingPointerID: number;
  35073. /**
  35074. * The last position where the pointer hit the drag plane in world space
  35075. */
  35076. lastDragPosition: Vector3;
  35077. /**
  35078. * If the behavior is currently in a dragging state
  35079. */
  35080. dragging: boolean;
  35081. /**
  35082. * 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)
  35083. */
  35084. dragDeltaRatio: number;
  35085. /**
  35086. * If the drag plane orientation should be updated during the dragging (Default: true)
  35087. */
  35088. updateDragPlane: boolean;
  35089. private _debugMode;
  35090. private _moving;
  35091. /**
  35092. * Fires each time the attached mesh is dragged with the pointer
  35093. * * delta between last drag position and current drag position in world space
  35094. * * dragDistance along the drag axis
  35095. * * dragPlaneNormal normal of the current drag plane used during the drag
  35096. * * dragPlanePoint in world space where the drag intersects the drag plane
  35097. */
  35098. onDragObservable: Observable<{
  35099. delta: Vector3;
  35100. dragPlanePoint: Vector3;
  35101. dragPlaneNormal: Vector3;
  35102. dragDistance: number;
  35103. pointerId: number;
  35104. }>;
  35105. /**
  35106. * Fires each time a drag begins (eg. mouse down on mesh)
  35107. */
  35108. onDragStartObservable: Observable<{
  35109. dragPlanePoint: Vector3;
  35110. pointerId: number;
  35111. }>;
  35112. /**
  35113. * Fires each time a drag ends (eg. mouse release after drag)
  35114. */
  35115. onDragEndObservable: Observable<{
  35116. dragPlanePoint: Vector3;
  35117. pointerId: number;
  35118. }>;
  35119. /**
  35120. * If the attached mesh should be moved when dragged
  35121. */
  35122. moveAttached: boolean;
  35123. /**
  35124. * If the drag behavior will react to drag events (Default: true)
  35125. */
  35126. enabled: boolean;
  35127. /**
  35128. * If camera controls should be detached during the drag
  35129. */
  35130. detachCameraControls: boolean;
  35131. /**
  35132. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35133. */
  35134. useObjectOrienationForDragging: boolean;
  35135. private _options;
  35136. /**
  35137. * Creates a pointer drag behavior that can be attached to a mesh
  35138. * @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)
  35139. */
  35140. constructor(options?: {
  35141. dragAxis?: Vector3;
  35142. dragPlaneNormal?: Vector3;
  35143. });
  35144. /**
  35145. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35146. */
  35147. validateDrag: (targetPosition: Vector3) => boolean;
  35148. /**
  35149. * The name of the behavior
  35150. */
  35151. readonly name: string;
  35152. /**
  35153. * Initializes the behavior
  35154. */
  35155. init(): void;
  35156. private _tmpVector;
  35157. private _alternatePickedPoint;
  35158. private _worldDragAxis;
  35159. private _targetPosition;
  35160. private _attachedElement;
  35161. /**
  35162. * Attaches the drag behavior the passed in mesh
  35163. * @param ownerNode The mesh that will be dragged around once attached
  35164. */
  35165. attach(ownerNode: AbstractMesh): void;
  35166. /**
  35167. * Force relase the drag action by code.
  35168. */
  35169. releaseDrag(): void;
  35170. private _startDragRay;
  35171. private _lastPointerRay;
  35172. /**
  35173. * Simulates the start of a pointer drag event on the behavior
  35174. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35175. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35176. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35177. */
  35178. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35179. private _startDrag;
  35180. private _dragDelta;
  35181. private _moveDrag;
  35182. private _pickWithRayOnDragPlane;
  35183. private _pointA;
  35184. private _pointB;
  35185. private _pointC;
  35186. private _lineA;
  35187. private _lineB;
  35188. private _localAxis;
  35189. private _lookAt;
  35190. private _updateDragPlanePosition;
  35191. /**
  35192. * Detaches the behavior from the mesh
  35193. */
  35194. detach(): void;
  35195. }
  35196. }
  35197. declare module BABYLON {
  35198. /**
  35199. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35200. */
  35201. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35202. private _dragBehaviorA;
  35203. private _dragBehaviorB;
  35204. private _startDistance;
  35205. private _initialScale;
  35206. private _targetScale;
  35207. private _ownerNode;
  35208. private _sceneRenderObserver;
  35209. /**
  35210. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35211. */
  35212. constructor();
  35213. /**
  35214. * The name of the behavior
  35215. */
  35216. readonly name: string;
  35217. /**
  35218. * Initializes the behavior
  35219. */
  35220. init(): void;
  35221. private _getCurrentDistance;
  35222. /**
  35223. * Attaches the scale behavior the passed in mesh
  35224. * @param ownerNode The mesh that will be scaled around once attached
  35225. */
  35226. attach(ownerNode: Mesh): void;
  35227. /**
  35228. * Detaches the behavior from the mesh
  35229. */
  35230. detach(): void;
  35231. }
  35232. }
  35233. declare module BABYLON {
  35234. /**
  35235. * 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
  35236. */
  35237. export class SixDofDragBehavior implements Behavior<Mesh> {
  35238. private static _virtualScene;
  35239. private _ownerNode;
  35240. private _sceneRenderObserver;
  35241. private _scene;
  35242. private _targetPosition;
  35243. private _virtualOriginMesh;
  35244. private _virtualDragMesh;
  35245. private _pointerObserver;
  35246. private _moving;
  35247. private _startingOrientation;
  35248. /**
  35249. * 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)
  35250. */
  35251. private zDragFactor;
  35252. /**
  35253. * If the object should rotate to face the drag origin
  35254. */
  35255. rotateDraggedObject: boolean;
  35256. /**
  35257. * If the behavior is currently in a dragging state
  35258. */
  35259. dragging: boolean;
  35260. /**
  35261. * 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)
  35262. */
  35263. dragDeltaRatio: number;
  35264. /**
  35265. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35266. */
  35267. currentDraggingPointerID: number;
  35268. /**
  35269. * If camera controls should be detached during the drag
  35270. */
  35271. detachCameraControls: boolean;
  35272. /**
  35273. * Fires each time a drag starts
  35274. */
  35275. onDragStartObservable: Observable<{}>;
  35276. /**
  35277. * Fires each time a drag ends (eg. mouse release after drag)
  35278. */
  35279. onDragEndObservable: Observable<{}>;
  35280. /**
  35281. * 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
  35282. */
  35283. constructor();
  35284. /**
  35285. * The name of the behavior
  35286. */
  35287. readonly name: string;
  35288. /**
  35289. * Initializes the behavior
  35290. */
  35291. init(): void;
  35292. /**
  35293. * Attaches the scale behavior the passed in mesh
  35294. * @param ownerNode The mesh that will be scaled around once attached
  35295. */
  35296. attach(ownerNode: Mesh): void;
  35297. /**
  35298. * Detaches the behavior from the mesh
  35299. */
  35300. detach(): void;
  35301. }
  35302. }
  35303. declare module BABYLON {
  35304. /**
  35305. * Class used to apply inverse kinematics to bones
  35306. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35307. */
  35308. export class BoneIKController {
  35309. private static _tmpVecs;
  35310. private static _tmpQuat;
  35311. private static _tmpMats;
  35312. /**
  35313. * Gets or sets the target mesh
  35314. */
  35315. targetMesh: AbstractMesh;
  35316. /** Gets or sets the mesh used as pole */
  35317. poleTargetMesh: AbstractMesh;
  35318. /**
  35319. * Gets or sets the bone used as pole
  35320. */
  35321. poleTargetBone: Nullable<Bone>;
  35322. /**
  35323. * Gets or sets the target position
  35324. */
  35325. targetPosition: Vector3;
  35326. /**
  35327. * Gets or sets the pole target position
  35328. */
  35329. poleTargetPosition: Vector3;
  35330. /**
  35331. * Gets or sets the pole target local offset
  35332. */
  35333. poleTargetLocalOffset: Vector3;
  35334. /**
  35335. * Gets or sets the pole angle
  35336. */
  35337. poleAngle: number;
  35338. /**
  35339. * Gets or sets the mesh associated with the controller
  35340. */
  35341. mesh: AbstractMesh;
  35342. /**
  35343. * 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)
  35344. */
  35345. slerpAmount: number;
  35346. private _bone1Quat;
  35347. private _bone1Mat;
  35348. private _bone2Ang;
  35349. private _bone1;
  35350. private _bone2;
  35351. private _bone1Length;
  35352. private _bone2Length;
  35353. private _maxAngle;
  35354. private _maxReach;
  35355. private _rightHandedSystem;
  35356. private _bendAxis;
  35357. private _slerping;
  35358. private _adjustRoll;
  35359. /**
  35360. * Gets or sets maximum allowed angle
  35361. */
  35362. maxAngle: number;
  35363. /**
  35364. * Creates a new BoneIKController
  35365. * @param mesh defines the mesh to control
  35366. * @param bone defines the bone to control
  35367. * @param options defines options to set up the controller
  35368. */
  35369. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35370. targetMesh?: AbstractMesh;
  35371. poleTargetMesh?: AbstractMesh;
  35372. poleTargetBone?: Bone;
  35373. poleTargetLocalOffset?: Vector3;
  35374. poleAngle?: number;
  35375. bendAxis?: Vector3;
  35376. maxAngle?: number;
  35377. slerpAmount?: number;
  35378. });
  35379. private _setMaxAngle;
  35380. /**
  35381. * Force the controller to update the bones
  35382. */
  35383. update(): void;
  35384. }
  35385. }
  35386. declare module BABYLON {
  35387. /**
  35388. * Class used to make a bone look toward a point in space
  35389. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35390. */
  35391. export class BoneLookController {
  35392. private static _tmpVecs;
  35393. private static _tmpQuat;
  35394. private static _tmpMats;
  35395. /**
  35396. * The target Vector3 that the bone will look at
  35397. */
  35398. target: Vector3;
  35399. /**
  35400. * The mesh that the bone is attached to
  35401. */
  35402. mesh: AbstractMesh;
  35403. /**
  35404. * The bone that will be looking to the target
  35405. */
  35406. bone: Bone;
  35407. /**
  35408. * The up axis of the coordinate system that is used when the bone is rotated
  35409. */
  35410. upAxis: Vector3;
  35411. /**
  35412. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35413. */
  35414. upAxisSpace: Space;
  35415. /**
  35416. * Used to make an adjustment to the yaw of the bone
  35417. */
  35418. adjustYaw: number;
  35419. /**
  35420. * Used to make an adjustment to the pitch of the bone
  35421. */
  35422. adjustPitch: number;
  35423. /**
  35424. * Used to make an adjustment to the roll of the bone
  35425. */
  35426. adjustRoll: number;
  35427. /**
  35428. * 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)
  35429. */
  35430. slerpAmount: number;
  35431. private _minYaw;
  35432. private _maxYaw;
  35433. private _minPitch;
  35434. private _maxPitch;
  35435. private _minYawSin;
  35436. private _minYawCos;
  35437. private _maxYawSin;
  35438. private _maxYawCos;
  35439. private _midYawConstraint;
  35440. private _minPitchTan;
  35441. private _maxPitchTan;
  35442. private _boneQuat;
  35443. private _slerping;
  35444. private _transformYawPitch;
  35445. private _transformYawPitchInv;
  35446. private _firstFrameSkipped;
  35447. private _yawRange;
  35448. private _fowardAxis;
  35449. /**
  35450. * Gets or sets the minimum yaw angle that the bone can look to
  35451. */
  35452. minYaw: number;
  35453. /**
  35454. * Gets or sets the maximum yaw angle that the bone can look to
  35455. */
  35456. maxYaw: number;
  35457. /**
  35458. * Gets or sets the minimum pitch angle that the bone can look to
  35459. */
  35460. minPitch: number;
  35461. /**
  35462. * Gets or sets the maximum pitch angle that the bone can look to
  35463. */
  35464. maxPitch: number;
  35465. /**
  35466. * Create a BoneLookController
  35467. * @param mesh the mesh that the bone belongs to
  35468. * @param bone the bone that will be looking to the target
  35469. * @param target the target Vector3 to look at
  35470. * @param options optional settings:
  35471. * * maxYaw: the maximum angle the bone will yaw to
  35472. * * minYaw: the minimum angle the bone will yaw to
  35473. * * maxPitch: the maximum angle the bone will pitch to
  35474. * * minPitch: the minimum angle the bone will yaw to
  35475. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35476. * * upAxis: the up axis of the coordinate system
  35477. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35478. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35479. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35480. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35481. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35482. * * adjustRoll: used to make an adjustment to the roll of the bone
  35483. **/
  35484. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35485. maxYaw?: number;
  35486. minYaw?: number;
  35487. maxPitch?: number;
  35488. minPitch?: number;
  35489. slerpAmount?: number;
  35490. upAxis?: Vector3;
  35491. upAxisSpace?: Space;
  35492. yawAxis?: Vector3;
  35493. pitchAxis?: Vector3;
  35494. adjustYaw?: number;
  35495. adjustPitch?: number;
  35496. adjustRoll?: number;
  35497. });
  35498. /**
  35499. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35500. */
  35501. update(): void;
  35502. private _getAngleDiff;
  35503. private _getAngleBetween;
  35504. private _isAngleBetween;
  35505. }
  35506. }
  35507. declare module BABYLON {
  35508. /**
  35509. * Manage the gamepad inputs to control an arc rotate camera.
  35510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35511. */
  35512. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35513. /**
  35514. * Defines the camera the input is attached to.
  35515. */
  35516. camera: ArcRotateCamera;
  35517. /**
  35518. * Defines the gamepad the input is gathering event from.
  35519. */
  35520. gamepad: Nullable<Gamepad>;
  35521. /**
  35522. * Defines the gamepad rotation sensiblity.
  35523. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35524. */
  35525. gamepadRotationSensibility: number;
  35526. /**
  35527. * Defines the gamepad move sensiblity.
  35528. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35529. */
  35530. gamepadMoveSensibility: number;
  35531. private _onGamepadConnectedObserver;
  35532. private _onGamepadDisconnectedObserver;
  35533. /**
  35534. * Attach the input controls to a specific dom element to get the input from.
  35535. * @param element Defines the element the controls should be listened from
  35536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35537. */
  35538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35539. /**
  35540. * Detach the current controls from the specified dom element.
  35541. * @param element Defines the element to stop listening the inputs from
  35542. */
  35543. detachControl(element: Nullable<HTMLElement>): void;
  35544. /**
  35545. * Update the current camera state depending on the inputs that have been used this frame.
  35546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35547. */
  35548. checkInputs(): void;
  35549. /**
  35550. * Gets the class name of the current intput.
  35551. * @returns the class name
  35552. */
  35553. getClassName(): string;
  35554. /**
  35555. * Get the friendly name associated with the input class.
  35556. * @returns the input friendly name
  35557. */
  35558. getSimpleName(): string;
  35559. }
  35560. }
  35561. declare module BABYLON {
  35562. interface ArcRotateCameraInputsManager {
  35563. /**
  35564. * Add orientation input support to the input manager.
  35565. * @returns the current input manager
  35566. */
  35567. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35568. }
  35569. /**
  35570. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35572. */
  35573. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35574. /**
  35575. * Defines the camera the input is attached to.
  35576. */
  35577. camera: ArcRotateCamera;
  35578. /**
  35579. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35580. */
  35581. alphaCorrection: number;
  35582. /**
  35583. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35584. */
  35585. gammaCorrection: number;
  35586. private _alpha;
  35587. private _gamma;
  35588. private _dirty;
  35589. private _deviceOrientationHandler;
  35590. /**
  35591. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35592. */
  35593. constructor();
  35594. /**
  35595. * Attach the input controls to a specific dom element to get the input from.
  35596. * @param element Defines the element the controls should be listened from
  35597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35598. */
  35599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35600. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35601. /**
  35602. * Update the current camera state depending on the inputs that have been used this frame.
  35603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35604. */
  35605. checkInputs(): void;
  35606. /**
  35607. * Detach the current controls from the specified dom element.
  35608. * @param element Defines the element to stop listening the inputs from
  35609. */
  35610. detachControl(element: Nullable<HTMLElement>): void;
  35611. /**
  35612. * Gets the class name of the current intput.
  35613. * @returns the class name
  35614. */
  35615. getClassName(): string;
  35616. /**
  35617. * Get the friendly name associated with the input class.
  35618. * @returns the input friendly name
  35619. */
  35620. getSimpleName(): string;
  35621. }
  35622. }
  35623. declare module BABYLON {
  35624. /**
  35625. * Listen to mouse events to control the camera.
  35626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35627. */
  35628. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35629. /**
  35630. * Defines the camera the input is attached to.
  35631. */
  35632. camera: FlyCamera;
  35633. /**
  35634. * Defines if touch is enabled. (Default is true.)
  35635. */
  35636. touchEnabled: boolean;
  35637. /**
  35638. * Defines the buttons associated with the input to handle camera rotation.
  35639. */
  35640. buttons: number[];
  35641. /**
  35642. * Assign buttons for Yaw control.
  35643. */
  35644. buttonsYaw: number[];
  35645. /**
  35646. * Assign buttons for Pitch control.
  35647. */
  35648. buttonsPitch: number[];
  35649. /**
  35650. * Assign buttons for Roll control.
  35651. */
  35652. buttonsRoll: number[];
  35653. /**
  35654. * Detect if any button is being pressed while mouse is moved.
  35655. * -1 = Mouse locked.
  35656. * 0 = Left button.
  35657. * 1 = Middle Button.
  35658. * 2 = Right Button.
  35659. */
  35660. activeButton: number;
  35661. /**
  35662. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35663. * Higher values reduce its sensitivity.
  35664. */
  35665. angularSensibility: number;
  35666. private _mousemoveCallback;
  35667. private _observer;
  35668. private _rollObserver;
  35669. private previousPosition;
  35670. private noPreventDefault;
  35671. private element;
  35672. /**
  35673. * Listen to mouse events to control the camera.
  35674. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35676. */
  35677. constructor(touchEnabled?: boolean);
  35678. /**
  35679. * Attach the mouse control to the HTML DOM element.
  35680. * @param element Defines the element that listens to the input events.
  35681. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35682. */
  35683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35684. /**
  35685. * Detach the current controls from the specified dom element.
  35686. * @param element Defines the element to stop listening the inputs from
  35687. */
  35688. detachControl(element: Nullable<HTMLElement>): void;
  35689. /**
  35690. * Gets the class name of the current input.
  35691. * @returns the class name.
  35692. */
  35693. getClassName(): string;
  35694. /**
  35695. * Get the friendly name associated with the input class.
  35696. * @returns the input's friendly name.
  35697. */
  35698. getSimpleName(): string;
  35699. private _pointerInput;
  35700. private _onMouseMove;
  35701. /**
  35702. * Rotate camera by mouse offset.
  35703. */
  35704. private rotateCamera;
  35705. }
  35706. }
  35707. declare module BABYLON {
  35708. /**
  35709. * Default Inputs manager for the FlyCamera.
  35710. * It groups all the default supported inputs for ease of use.
  35711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35712. */
  35713. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35714. /**
  35715. * Instantiates a new FlyCameraInputsManager.
  35716. * @param camera Defines the camera the inputs belong to.
  35717. */
  35718. constructor(camera: FlyCamera);
  35719. /**
  35720. * Add keyboard input support to the input manager.
  35721. * @returns the new FlyCameraKeyboardMoveInput().
  35722. */
  35723. addKeyboard(): FlyCameraInputsManager;
  35724. /**
  35725. * Add mouse input support to the input manager.
  35726. * @param touchEnabled Enable touch screen support.
  35727. * @returns the new FlyCameraMouseInput().
  35728. */
  35729. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35730. }
  35731. }
  35732. declare module BABYLON {
  35733. /**
  35734. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35735. * such as in a 3D Space Shooter or a Flight Simulator.
  35736. */
  35737. export class FlyCamera extends TargetCamera {
  35738. /**
  35739. * Define the collision ellipsoid of the camera.
  35740. * This is helpful for simulating a camera body, like a player's body.
  35741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35742. */
  35743. ellipsoid: Vector3;
  35744. /**
  35745. * Define an offset for the position of the ellipsoid around the camera.
  35746. * This can be helpful if the camera is attached away from the player's body center,
  35747. * such as at its head.
  35748. */
  35749. ellipsoidOffset: Vector3;
  35750. /**
  35751. * Enable or disable collisions of the camera with the rest of the scene objects.
  35752. */
  35753. checkCollisions: boolean;
  35754. /**
  35755. * Enable or disable gravity on the camera.
  35756. */
  35757. applyGravity: boolean;
  35758. /**
  35759. * Define the current direction the camera is moving to.
  35760. */
  35761. cameraDirection: Vector3;
  35762. /**
  35763. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35764. * This overrides and empties cameraRotation.
  35765. */
  35766. rotationQuaternion: Quaternion;
  35767. /**
  35768. * Track Roll to maintain the wanted Rolling when looking around.
  35769. */ trackRoll: number;
  35770. /**
  35771. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35772. */
  35773. rollCorrect: number;
  35774. /**
  35775. * Mimic a banked turn, Rolling the camera when Yawing.
  35776. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35777. */
  35778. bankedTurn: boolean;
  35779. /**
  35780. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35781. */
  35782. bankedTurnLimit: number;
  35783. /**
  35784. * Value of 0 disables the banked Roll.
  35785. * Value of 1 is equal to the Yaw angle in radians.
  35786. */
  35787. bankedTurnMultiplier: number;
  35788. /**
  35789. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35790. */
  35791. inputs: FlyCameraInputsManager;
  35792. /**
  35793. * Gets the input sensibility for mouse input.
  35794. * Higher values reduce sensitivity.
  35795. */
  35796. /**
  35797. * Sets the input sensibility for a mouse input.
  35798. * Higher values reduce sensitivity.
  35799. */
  35800. angularSensibility: number;
  35801. /**
  35802. * Get the keys for camera movement forward.
  35803. */
  35804. /**
  35805. * Set the keys for camera movement forward.
  35806. */
  35807. keysForward: number[];
  35808. /**
  35809. * Get the keys for camera movement backward.
  35810. */
  35811. keysBackward: number[];
  35812. /**
  35813. * Get the keys for camera movement up.
  35814. */
  35815. /**
  35816. * Set the keys for camera movement up.
  35817. */
  35818. keysUp: number[];
  35819. /**
  35820. * Get the keys for camera movement down.
  35821. */
  35822. /**
  35823. * Set the keys for camera movement down.
  35824. */
  35825. keysDown: number[];
  35826. /**
  35827. * Get the keys for camera movement left.
  35828. */
  35829. /**
  35830. * Set the keys for camera movement left.
  35831. */
  35832. keysLeft: number[];
  35833. /**
  35834. * Set the keys for camera movement right.
  35835. */
  35836. /**
  35837. * Set the keys for camera movement right.
  35838. */
  35839. keysRight: number[];
  35840. /**
  35841. * Event raised when the camera collides with a mesh in the scene.
  35842. */
  35843. onCollide: (collidedMesh: AbstractMesh) => void;
  35844. private _collider;
  35845. private _needMoveForGravity;
  35846. private _oldPosition;
  35847. private _diffPosition;
  35848. private _newPosition;
  35849. /** @hidden */ localDirection: Vector3;
  35850. /** @hidden */ transformedDirection: Vector3;
  35851. /**
  35852. * Instantiates a FlyCamera.
  35853. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35854. * such as in a 3D Space Shooter or a Flight Simulator.
  35855. * @param name Define the name of the camera in the scene.
  35856. * @param position Define the starting position of the camera in the scene.
  35857. * @param scene Define the scene the camera belongs to.
  35858. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35859. */
  35860. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35861. /**
  35862. * Attach a control to the HTML DOM element.
  35863. * @param element Defines the element that listens to the input events.
  35864. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35865. */
  35866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35867. /**
  35868. * Detach a control from the HTML DOM element.
  35869. * The camera will stop reacting to that input.
  35870. * @param element Defines the element that listens to the input events.
  35871. */
  35872. detachControl(element: HTMLElement): void;
  35873. private _collisionMask;
  35874. /**
  35875. * Get the mask that the camera ignores in collision events.
  35876. */
  35877. /**
  35878. * Set the mask that the camera ignores in collision events.
  35879. */
  35880. collisionMask: number;
  35881. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35882. /** @hidden */
  35883. private _onCollisionPositionChange;
  35884. /** @hidden */ checkInputs(): void;
  35885. /** @hidden */ decideIfNeedsToMove(): boolean;
  35886. /** @hidden */ updatePosition(): void;
  35887. /**
  35888. * Restore the Roll to its target value at the rate specified.
  35889. * @param rate - Higher means slower restoring.
  35890. * @hidden
  35891. */
  35892. restoreRoll(rate: number): void;
  35893. /**
  35894. * Destroy the camera and release the current resources held by it.
  35895. */
  35896. dispose(): void;
  35897. /**
  35898. * Get the current object class name.
  35899. * @returns the class name.
  35900. */
  35901. getClassName(): string;
  35902. }
  35903. }
  35904. declare module BABYLON {
  35905. /**
  35906. * Listen to keyboard events to control the camera.
  35907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35908. */
  35909. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35910. /**
  35911. * Defines the camera the input is attached to.
  35912. */
  35913. camera: FlyCamera;
  35914. /**
  35915. * The list of keyboard keys used to control the forward move of the camera.
  35916. */
  35917. keysForward: number[];
  35918. /**
  35919. * The list of keyboard keys used to control the backward move of the camera.
  35920. */
  35921. keysBackward: number[];
  35922. /**
  35923. * The list of keyboard keys used to control the forward move of the camera.
  35924. */
  35925. keysUp: number[];
  35926. /**
  35927. * The list of keyboard keys used to control the backward move of the camera.
  35928. */
  35929. keysDown: number[];
  35930. /**
  35931. * The list of keyboard keys used to control the right strafe move of the camera.
  35932. */
  35933. keysRight: number[];
  35934. /**
  35935. * The list of keyboard keys used to control the left strafe move of the camera.
  35936. */
  35937. keysLeft: number[];
  35938. private _keys;
  35939. private _onCanvasBlurObserver;
  35940. private _onKeyboardObserver;
  35941. private _engine;
  35942. private _scene;
  35943. /**
  35944. * Attach the input controls to a specific dom element to get the input from.
  35945. * @param element Defines the element the controls should be listened from
  35946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35947. */
  35948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35949. /**
  35950. * Detach the current controls from the specified dom element.
  35951. * @param element Defines the element to stop listening the inputs from
  35952. */
  35953. detachControl(element: Nullable<HTMLElement>): void;
  35954. /**
  35955. * Gets the class name of the current intput.
  35956. * @returns the class name
  35957. */
  35958. getClassName(): string;
  35959. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35960. /**
  35961. * Get the friendly name associated with the input class.
  35962. * @returns the input friendly name
  35963. */
  35964. getSimpleName(): string;
  35965. /**
  35966. * Update the current camera state depending on the inputs that have been used this frame.
  35967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35968. */
  35969. checkInputs(): void;
  35970. }
  35971. }
  35972. declare module BABYLON {
  35973. /**
  35974. * Manage the mouse wheel inputs to control a follow camera.
  35975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35976. */
  35977. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35978. /**
  35979. * Defines the camera the input is attached to.
  35980. */
  35981. camera: FollowCamera;
  35982. /**
  35983. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35984. */
  35985. axisControlRadius: boolean;
  35986. /**
  35987. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35988. */
  35989. axisControlHeight: boolean;
  35990. /**
  35991. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35992. */
  35993. axisControlRotation: boolean;
  35994. /**
  35995. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35996. * relation to mouseWheel events.
  35997. */
  35998. wheelPrecision: number;
  35999. /**
  36000. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36001. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36002. */
  36003. wheelDeltaPercentage: number;
  36004. private _wheel;
  36005. private _observer;
  36006. /**
  36007. * Attach the input controls to a specific dom element to get the input from.
  36008. * @param element Defines the element the controls should be listened from
  36009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36010. */
  36011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36012. /**
  36013. * Detach the current controls from the specified dom element.
  36014. * @param element Defines the element to stop listening the inputs from
  36015. */
  36016. detachControl(element: Nullable<HTMLElement>): void;
  36017. /**
  36018. * Gets the class name of the current intput.
  36019. * @returns the class name
  36020. */
  36021. getClassName(): string;
  36022. /**
  36023. * Get the friendly name associated with the input class.
  36024. * @returns the input friendly name
  36025. */
  36026. getSimpleName(): string;
  36027. }
  36028. }
  36029. declare module BABYLON {
  36030. /**
  36031. * Manage the pointers inputs to control an follow camera.
  36032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36033. */
  36034. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36035. /**
  36036. * Defines the camera the input is attached to.
  36037. */
  36038. camera: FollowCamera;
  36039. /**
  36040. * Gets the class name of the current input.
  36041. * @returns the class name
  36042. */
  36043. getClassName(): string;
  36044. /**
  36045. * Defines the pointer angular sensibility along the X axis or how fast is
  36046. * the camera rotating.
  36047. * A negative number will reverse the axis direction.
  36048. */
  36049. angularSensibilityX: number;
  36050. /**
  36051. * Defines the pointer angular sensibility along the Y axis or how fast is
  36052. * the camera rotating.
  36053. * A negative number will reverse the axis direction.
  36054. */
  36055. angularSensibilityY: number;
  36056. /**
  36057. * Defines the pointer pinch precision or how fast is the camera zooming.
  36058. * A negative number will reverse the axis direction.
  36059. */
  36060. pinchPrecision: number;
  36061. /**
  36062. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36063. * from 0.
  36064. * It defines the percentage of current camera.radius to use as delta when
  36065. * pinch zoom is used.
  36066. */
  36067. pinchDeltaPercentage: number;
  36068. /**
  36069. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36070. */
  36071. axisXControlRadius: boolean;
  36072. /**
  36073. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36074. */
  36075. axisXControlHeight: boolean;
  36076. /**
  36077. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36078. */
  36079. axisXControlRotation: boolean;
  36080. /**
  36081. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36082. */
  36083. axisYControlRadius: boolean;
  36084. /**
  36085. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36086. */
  36087. axisYControlHeight: boolean;
  36088. /**
  36089. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36090. */
  36091. axisYControlRotation: boolean;
  36092. /**
  36093. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36094. */
  36095. axisPinchControlRadius: boolean;
  36096. /**
  36097. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36098. */
  36099. axisPinchControlHeight: boolean;
  36100. /**
  36101. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36102. */
  36103. axisPinchControlRotation: boolean;
  36104. /**
  36105. * Log error messages if basic misconfiguration has occurred.
  36106. */
  36107. warningEnable: boolean;
  36108. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36109. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36110. private _warningCounter;
  36111. private _warning;
  36112. }
  36113. }
  36114. declare module BABYLON {
  36115. /**
  36116. * Default Inputs manager for the FollowCamera.
  36117. * It groups all the default supported inputs for ease of use.
  36118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36119. */
  36120. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36121. /**
  36122. * Instantiates a new FollowCameraInputsManager.
  36123. * @param camera Defines the camera the inputs belong to
  36124. */
  36125. constructor(camera: FollowCamera);
  36126. /**
  36127. * Add keyboard input support to the input manager.
  36128. * @returns the current input manager
  36129. */
  36130. addKeyboard(): FollowCameraInputsManager;
  36131. /**
  36132. * Add mouse wheel input support to the input manager.
  36133. * @returns the current input manager
  36134. */
  36135. addMouseWheel(): FollowCameraInputsManager;
  36136. /**
  36137. * Add pointers input support to the input manager.
  36138. * @returns the current input manager
  36139. */
  36140. addPointers(): FollowCameraInputsManager;
  36141. /**
  36142. * Add orientation input support to the input manager.
  36143. * @returns the current input manager
  36144. */
  36145. addVRDeviceOrientation(): FollowCameraInputsManager;
  36146. }
  36147. }
  36148. declare module BABYLON {
  36149. /**
  36150. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36151. * an arc rotate version arcFollowCamera are available.
  36152. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36153. */
  36154. export class FollowCamera extends TargetCamera {
  36155. /**
  36156. * Distance the follow camera should follow an object at
  36157. */
  36158. radius: number;
  36159. /**
  36160. * Minimum allowed distance of the camera to the axis of rotation
  36161. * (The camera can not get closer).
  36162. * This can help limiting how the Camera is able to move in the scene.
  36163. */
  36164. lowerRadiusLimit: Nullable<number>;
  36165. /**
  36166. * Maximum allowed distance of the camera to the axis of rotation
  36167. * (The camera can not get further).
  36168. * This can help limiting how the Camera is able to move in the scene.
  36169. */
  36170. upperRadiusLimit: Nullable<number>;
  36171. /**
  36172. * Define a rotation offset between the camera and the object it follows
  36173. */
  36174. rotationOffset: number;
  36175. /**
  36176. * Minimum allowed angle to camera position relative to target object.
  36177. * This can help limiting how the Camera is able to move in the scene.
  36178. */
  36179. lowerRotationOffsetLimit: Nullable<number>;
  36180. /**
  36181. * Maximum allowed angle to camera position relative to target object.
  36182. * This can help limiting how the Camera is able to move in the scene.
  36183. */
  36184. upperRotationOffsetLimit: Nullable<number>;
  36185. /**
  36186. * Define a height offset between the camera and the object it follows.
  36187. * It can help following an object from the top (like a car chaing a plane)
  36188. */
  36189. heightOffset: number;
  36190. /**
  36191. * Minimum allowed height of camera position relative to target object.
  36192. * This can help limiting how the Camera is able to move in the scene.
  36193. */
  36194. lowerHeightOffsetLimit: Nullable<number>;
  36195. /**
  36196. * Maximum allowed height of camera position relative to target object.
  36197. * This can help limiting how the Camera is able to move in the scene.
  36198. */
  36199. upperHeightOffsetLimit: Nullable<number>;
  36200. /**
  36201. * Define how fast the camera can accelerate to follow it s target.
  36202. */
  36203. cameraAcceleration: number;
  36204. /**
  36205. * Define the speed limit of the camera following an object.
  36206. */
  36207. maxCameraSpeed: number;
  36208. /**
  36209. * Define the target of the camera.
  36210. */
  36211. lockedTarget: Nullable<AbstractMesh>;
  36212. /**
  36213. * Defines the input associated with the camera.
  36214. */
  36215. inputs: FollowCameraInputsManager;
  36216. /**
  36217. * Instantiates the follow camera.
  36218. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36219. * @param name Define the name of the camera in the scene
  36220. * @param position Define the position of the camera
  36221. * @param scene Define the scene the camera belong to
  36222. * @param lockedTarget Define the target of the camera
  36223. */
  36224. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36225. private _follow;
  36226. /**
  36227. * Attached controls to the current camera.
  36228. * @param element Defines the element the controls should be listened from
  36229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36230. */
  36231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36232. /**
  36233. * Detach the current controls from the camera.
  36234. * The camera will stop reacting to inputs.
  36235. * @param element Defines the element to stop listening the inputs from
  36236. */
  36237. detachControl(element: HTMLElement): void;
  36238. /** @hidden */ checkInputs(): void;
  36239. private _checkLimits;
  36240. /**
  36241. * Gets the camera class name.
  36242. * @returns the class name
  36243. */
  36244. getClassName(): string;
  36245. }
  36246. /**
  36247. * Arc Rotate version of the follow camera.
  36248. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36249. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36250. */
  36251. export class ArcFollowCamera extends TargetCamera {
  36252. /** The longitudinal angle of the camera */
  36253. alpha: number;
  36254. /** The latitudinal angle of the camera */
  36255. beta: number;
  36256. /** The radius of the camera from its target */
  36257. radius: number;
  36258. /** Define the camera target (the messh it should follow) */
  36259. target: Nullable<AbstractMesh>;
  36260. private _cartesianCoordinates;
  36261. /**
  36262. * Instantiates a new ArcFollowCamera
  36263. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36264. * @param name Define the name of the camera
  36265. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36266. * @param beta Define the rotation angle of the camera around the elevation axis
  36267. * @param radius Define the radius of the camera from its target point
  36268. * @param target Define the target of the camera
  36269. * @param scene Define the scene the camera belongs to
  36270. */
  36271. constructor(name: string,
  36272. /** The longitudinal angle of the camera */
  36273. alpha: number,
  36274. /** The latitudinal angle of the camera */
  36275. beta: number,
  36276. /** The radius of the camera from its target */
  36277. radius: number,
  36278. /** Define the camera target (the messh it should follow) */
  36279. target: Nullable<AbstractMesh>, scene: Scene);
  36280. private _follow;
  36281. /** @hidden */ checkInputs(): void;
  36282. /**
  36283. * Returns the class name of the object.
  36284. * It is mostly used internally for serialization purposes.
  36285. */
  36286. getClassName(): string;
  36287. }
  36288. }
  36289. declare module BABYLON {
  36290. /**
  36291. * Manage the keyboard inputs to control the movement of a follow camera.
  36292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36293. */
  36294. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36295. /**
  36296. * Defines the camera the input is attached to.
  36297. */
  36298. camera: FollowCamera;
  36299. /**
  36300. * Defines the list of key codes associated with the up action (increase heightOffset)
  36301. */
  36302. keysHeightOffsetIncr: number[];
  36303. /**
  36304. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36305. */
  36306. keysHeightOffsetDecr: number[];
  36307. /**
  36308. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36309. */
  36310. keysHeightOffsetModifierAlt: boolean;
  36311. /**
  36312. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36313. */
  36314. keysHeightOffsetModifierCtrl: boolean;
  36315. /**
  36316. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36317. */
  36318. keysHeightOffsetModifierShift: boolean;
  36319. /**
  36320. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36321. */
  36322. keysRotationOffsetIncr: number[];
  36323. /**
  36324. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36325. */
  36326. keysRotationOffsetDecr: number[];
  36327. /**
  36328. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36329. */
  36330. keysRotationOffsetModifierAlt: boolean;
  36331. /**
  36332. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36333. */
  36334. keysRotationOffsetModifierCtrl: boolean;
  36335. /**
  36336. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36337. */
  36338. keysRotationOffsetModifierShift: boolean;
  36339. /**
  36340. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36341. */
  36342. keysRadiusIncr: number[];
  36343. /**
  36344. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36345. */
  36346. keysRadiusDecr: number[];
  36347. /**
  36348. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36349. */
  36350. keysRadiusModifierAlt: boolean;
  36351. /**
  36352. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36353. */
  36354. keysRadiusModifierCtrl: boolean;
  36355. /**
  36356. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36357. */
  36358. keysRadiusModifierShift: boolean;
  36359. /**
  36360. * Defines the rate of change of heightOffset.
  36361. */
  36362. heightSensibility: number;
  36363. /**
  36364. * Defines the rate of change of rotationOffset.
  36365. */
  36366. rotationSensibility: number;
  36367. /**
  36368. * Defines the rate of change of radius.
  36369. */
  36370. radiusSensibility: number;
  36371. private _keys;
  36372. private _ctrlPressed;
  36373. private _altPressed;
  36374. private _shiftPressed;
  36375. private _onCanvasBlurObserver;
  36376. private _onKeyboardObserver;
  36377. private _engine;
  36378. private _scene;
  36379. /**
  36380. * Attach the input controls to a specific dom element to get the input from.
  36381. * @param element Defines the element the controls should be listened from
  36382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36383. */
  36384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36385. /**
  36386. * Detach the current controls from the specified dom element.
  36387. * @param element Defines the element to stop listening the inputs from
  36388. */
  36389. detachControl(element: Nullable<HTMLElement>): void;
  36390. /**
  36391. * Update the current camera state depending on the inputs that have been used this frame.
  36392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36393. */
  36394. checkInputs(): void;
  36395. /**
  36396. * Gets the class name of the current input.
  36397. * @returns the class name
  36398. */
  36399. getClassName(): string;
  36400. /**
  36401. * Get the friendly name associated with the input class.
  36402. * @returns the input friendly name
  36403. */
  36404. getSimpleName(): string;
  36405. /**
  36406. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36407. * allow modification of the heightOffset value.
  36408. */
  36409. private _modifierHeightOffset;
  36410. /**
  36411. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36412. * allow modification of the rotationOffset value.
  36413. */
  36414. private _modifierRotationOffset;
  36415. /**
  36416. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36417. * allow modification of the radius value.
  36418. */
  36419. private _modifierRadius;
  36420. }
  36421. }
  36422. declare module BABYLON {
  36423. interface FreeCameraInputsManager {
  36424. /**
  36425. * @hidden
  36426. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36427. /**
  36428. * Add orientation input support to the input manager.
  36429. * @returns the current input manager
  36430. */
  36431. addDeviceOrientation(): FreeCameraInputsManager;
  36432. }
  36433. /**
  36434. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36435. * Screen rotation is taken into account.
  36436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36437. */
  36438. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36439. private _camera;
  36440. private _screenOrientationAngle;
  36441. private _constantTranform;
  36442. private _screenQuaternion;
  36443. private _alpha;
  36444. private _beta;
  36445. private _gamma;
  36446. /**
  36447. * @hidden
  36448. */ onDeviceOrientationChangedObservable: Observable<void>;
  36449. /**
  36450. * Instantiates a new input
  36451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36452. */
  36453. constructor();
  36454. /**
  36455. * Define the camera controlled by the input.
  36456. */
  36457. camera: FreeCamera;
  36458. /**
  36459. * Attach the input controls to a specific dom element to get the input from.
  36460. * @param element Defines the element the controls should be listened from
  36461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36462. */
  36463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36464. private _orientationChanged;
  36465. private _deviceOrientation;
  36466. /**
  36467. * Detach the current controls from the specified dom element.
  36468. * @param element Defines the element to stop listening the inputs from
  36469. */
  36470. detachControl(element: Nullable<HTMLElement>): void;
  36471. /**
  36472. * Update the current camera state depending on the inputs that have been used this frame.
  36473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36474. */
  36475. checkInputs(): void;
  36476. /**
  36477. * Gets the class name of the current intput.
  36478. * @returns the class name
  36479. */
  36480. getClassName(): string;
  36481. /**
  36482. * Get the friendly name associated with the input class.
  36483. * @returns the input friendly name
  36484. */
  36485. getSimpleName(): string;
  36486. }
  36487. }
  36488. declare module BABYLON {
  36489. /**
  36490. * Manage the gamepad inputs to control a free camera.
  36491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36492. */
  36493. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36494. /**
  36495. * Define the camera the input is attached to.
  36496. */
  36497. camera: FreeCamera;
  36498. /**
  36499. * Define the Gamepad controlling the input
  36500. */
  36501. gamepad: Nullable<Gamepad>;
  36502. /**
  36503. * Defines the gamepad rotation sensiblity.
  36504. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36505. */
  36506. gamepadAngularSensibility: number;
  36507. /**
  36508. * Defines the gamepad move sensiblity.
  36509. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36510. */
  36511. gamepadMoveSensibility: number;
  36512. private _onGamepadConnectedObserver;
  36513. private _onGamepadDisconnectedObserver;
  36514. private _cameraTransform;
  36515. private _deltaTransform;
  36516. private _vector3;
  36517. private _vector2;
  36518. /**
  36519. * Attach the input controls to a specific dom element to get the input from.
  36520. * @param element Defines the element the controls should be listened from
  36521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36522. */
  36523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36524. /**
  36525. * Detach the current controls from the specified dom element.
  36526. * @param element Defines the element to stop listening the inputs from
  36527. */
  36528. detachControl(element: Nullable<HTMLElement>): void;
  36529. /**
  36530. * Update the current camera state depending on the inputs that have been used this frame.
  36531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36532. */
  36533. checkInputs(): void;
  36534. /**
  36535. * Gets the class name of the current intput.
  36536. * @returns the class name
  36537. */
  36538. getClassName(): string;
  36539. /**
  36540. * Get the friendly name associated with the input class.
  36541. * @returns the input friendly name
  36542. */
  36543. getSimpleName(): string;
  36544. }
  36545. }
  36546. declare module BABYLON {
  36547. /**
  36548. * Defines the potential axis of a Joystick
  36549. */
  36550. export enum JoystickAxis {
  36551. /** X axis */
  36552. X = 0,
  36553. /** Y axis */
  36554. Y = 1,
  36555. /** Z axis */
  36556. Z = 2
  36557. }
  36558. /**
  36559. * Class used to define virtual joystick (used in touch mode)
  36560. */
  36561. export class VirtualJoystick {
  36562. /**
  36563. * Gets or sets a boolean indicating that left and right values must be inverted
  36564. */
  36565. reverseLeftRight: boolean;
  36566. /**
  36567. * Gets or sets a boolean indicating that up and down values must be inverted
  36568. */
  36569. reverseUpDown: boolean;
  36570. /**
  36571. * Gets the offset value for the position (ie. the change of the position value)
  36572. */
  36573. deltaPosition: Vector3;
  36574. /**
  36575. * Gets a boolean indicating if the virtual joystick was pressed
  36576. */
  36577. pressed: boolean;
  36578. /**
  36579. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36580. */
  36581. static Canvas: Nullable<HTMLCanvasElement>;
  36582. private static _globalJoystickIndex;
  36583. private static vjCanvasContext;
  36584. private static vjCanvasWidth;
  36585. private static vjCanvasHeight;
  36586. private static halfWidth;
  36587. private _action;
  36588. private _axisTargetedByLeftAndRight;
  36589. private _axisTargetedByUpAndDown;
  36590. private _joystickSensibility;
  36591. private _inversedSensibility;
  36592. private _joystickPointerID;
  36593. private _joystickColor;
  36594. private _joystickPointerPos;
  36595. private _joystickPreviousPointerPos;
  36596. private _joystickPointerStartPos;
  36597. private _deltaJoystickVector;
  36598. private _leftJoystick;
  36599. private _touches;
  36600. private _onPointerDownHandlerRef;
  36601. private _onPointerMoveHandlerRef;
  36602. private _onPointerUpHandlerRef;
  36603. private _onResize;
  36604. /**
  36605. * Creates a new virtual joystick
  36606. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36607. */
  36608. constructor(leftJoystick?: boolean);
  36609. /**
  36610. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36611. * @param newJoystickSensibility defines the new sensibility
  36612. */
  36613. setJoystickSensibility(newJoystickSensibility: number): void;
  36614. private _onPointerDown;
  36615. private _onPointerMove;
  36616. private _onPointerUp;
  36617. /**
  36618. * Change the color of the virtual joystick
  36619. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36620. */
  36621. setJoystickColor(newColor: string): void;
  36622. /**
  36623. * Defines a callback to call when the joystick is touched
  36624. * @param action defines the callback
  36625. */
  36626. setActionOnTouch(action: () => any): void;
  36627. /**
  36628. * Defines which axis you'd like to control for left & right
  36629. * @param axis defines the axis to use
  36630. */
  36631. setAxisForLeftRight(axis: JoystickAxis): void;
  36632. /**
  36633. * Defines which axis you'd like to control for up & down
  36634. * @param axis defines the axis to use
  36635. */
  36636. setAxisForUpDown(axis: JoystickAxis): void;
  36637. private _drawVirtualJoystick;
  36638. /**
  36639. * Release internal HTML canvas
  36640. */
  36641. releaseCanvas(): void;
  36642. }
  36643. }
  36644. declare module BABYLON {
  36645. interface FreeCameraInputsManager {
  36646. /**
  36647. * Add virtual joystick input support to the input manager.
  36648. * @returns the current input manager
  36649. */
  36650. addVirtualJoystick(): FreeCameraInputsManager;
  36651. }
  36652. /**
  36653. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36655. */
  36656. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36657. /**
  36658. * Defines the camera the input is attached to.
  36659. */
  36660. camera: FreeCamera;
  36661. private _leftjoystick;
  36662. private _rightjoystick;
  36663. /**
  36664. * Gets the left stick of the virtual joystick.
  36665. * @returns The virtual Joystick
  36666. */
  36667. getLeftJoystick(): VirtualJoystick;
  36668. /**
  36669. * Gets the right stick of the virtual joystick.
  36670. * @returns The virtual Joystick
  36671. */
  36672. getRightJoystick(): VirtualJoystick;
  36673. /**
  36674. * Update the current camera state depending on the inputs that have been used this frame.
  36675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36676. */
  36677. checkInputs(): void;
  36678. /**
  36679. * Attach the input controls to a specific dom element to get the input from.
  36680. * @param element Defines the element the controls should be listened from
  36681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36682. */
  36683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36684. /**
  36685. * Detach the current controls from the specified dom element.
  36686. * @param element Defines the element to stop listening the inputs from
  36687. */
  36688. detachControl(element: Nullable<HTMLElement>): void;
  36689. /**
  36690. * Gets the class name of the current intput.
  36691. * @returns the class name
  36692. */
  36693. getClassName(): string;
  36694. /**
  36695. * Get the friendly name associated with the input class.
  36696. * @returns the input friendly name
  36697. */
  36698. getSimpleName(): string;
  36699. }
  36700. }
  36701. declare module BABYLON {
  36702. /**
  36703. * This represents a FPS type of camera controlled by touch.
  36704. * This is like a universal camera minus the Gamepad controls.
  36705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36706. */
  36707. export class TouchCamera extends FreeCamera {
  36708. /**
  36709. * Defines the touch sensibility for rotation.
  36710. * The higher the faster.
  36711. */
  36712. touchAngularSensibility: number;
  36713. /**
  36714. * Defines the touch sensibility for move.
  36715. * The higher the faster.
  36716. */
  36717. touchMoveSensibility: number;
  36718. /**
  36719. * Instantiates a new touch camera.
  36720. * This represents a FPS type of camera controlled by touch.
  36721. * This is like a universal camera minus the Gamepad controls.
  36722. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36723. * @param name Define the name of the camera in the scene
  36724. * @param position Define the start position of the camera in the scene
  36725. * @param scene Define the scene the camera belongs to
  36726. */
  36727. constructor(name: string, position: Vector3, scene: Scene);
  36728. /**
  36729. * Gets the current object class name.
  36730. * @return the class name
  36731. */
  36732. getClassName(): string;
  36733. /** @hidden */ setupInputs(): void;
  36734. }
  36735. }
  36736. declare module BABYLON {
  36737. /**
  36738. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36739. * being tilted forward or back and left or right.
  36740. */
  36741. export class DeviceOrientationCamera extends FreeCamera {
  36742. private _initialQuaternion;
  36743. private _quaternionCache;
  36744. private _tmpDragQuaternion;
  36745. /**
  36746. * Creates a new device orientation camera
  36747. * @param name The name of the camera
  36748. * @param position The start position camera
  36749. * @param scene The scene the camera belongs to
  36750. */
  36751. constructor(name: string, position: Vector3, scene: Scene);
  36752. /**
  36753. * @hidden
  36754. * Disabled pointer input on first orientation sensor update (Default: true)
  36755. */ disablePointerInputWhenUsingDeviceOrientation: boolean;
  36756. private _dragFactor;
  36757. /**
  36758. * Enabled turning on the y axis when the orientation sensor is active
  36759. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36760. */
  36761. enableHorizontalDragging(dragFactor?: number): void;
  36762. /**
  36763. * Gets the current instance class name ("DeviceOrientationCamera").
  36764. * This helps avoiding instanceof at run time.
  36765. * @returns the class name
  36766. */
  36767. getClassName(): string;
  36768. /**
  36769. * @hidden
  36770. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36771. */ checkInputs(): void;
  36772. /**
  36773. * Reset the camera to its default orientation on the specified axis only.
  36774. * @param axis The axis to reset
  36775. */
  36776. resetToCurrentRotation(axis?: Axis): void;
  36777. }
  36778. }
  36779. declare module BABYLON {
  36780. /**
  36781. * 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,
  36782. * which still works and will still be found in many Playgrounds.
  36783. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36784. */
  36785. export class UniversalCamera extends TouchCamera {
  36786. /**
  36787. * Defines the gamepad rotation sensiblity.
  36788. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36789. */
  36790. gamepadAngularSensibility: number;
  36791. /**
  36792. * Defines the gamepad move sensiblity.
  36793. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36794. */
  36795. gamepadMoveSensibility: number;
  36796. /**
  36797. * 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,
  36798. * which still works and will still be found in many Playgrounds.
  36799. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36800. * @param name Define the name of the camera in the scene
  36801. * @param position Define the start position of the camera in the scene
  36802. * @param scene Define the scene the camera belongs to
  36803. */
  36804. constructor(name: string, position: Vector3, scene: Scene);
  36805. /**
  36806. * Gets the current object class name.
  36807. * @return the class name
  36808. */
  36809. getClassName(): string;
  36810. }
  36811. }
  36812. declare module BABYLON {
  36813. /**
  36814. * This represents a FPS type of camera. This is only here for back compat purpose.
  36815. * Please use the UniversalCamera instead as both are identical.
  36816. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36817. */
  36818. export class GamepadCamera extends UniversalCamera {
  36819. /**
  36820. * Instantiates a new Gamepad Camera
  36821. * This represents a FPS type of camera. This is only here for back compat purpose.
  36822. * Please use the UniversalCamera instead as both are identical.
  36823. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36824. * @param name Define the name of the camera in the scene
  36825. * @param position Define the start position of the camera in the scene
  36826. * @param scene Define the scene the camera belongs to
  36827. */
  36828. constructor(name: string, position: Vector3, scene: Scene);
  36829. /**
  36830. * Gets the current object class name.
  36831. * @return the class name
  36832. */
  36833. getClassName(): string;
  36834. }
  36835. }
  36836. declare module BABYLON {
  36837. /** @hidden */
  36838. export var passPixelShader: {
  36839. name: string;
  36840. shader: string;
  36841. };
  36842. }
  36843. declare module BABYLON {
  36844. /** @hidden */
  36845. export var passCubePixelShader: {
  36846. name: string;
  36847. shader: string;
  36848. };
  36849. }
  36850. declare module BABYLON {
  36851. /**
  36852. * PassPostProcess which produces an output the same as it's input
  36853. */
  36854. export class PassPostProcess extends PostProcess {
  36855. /**
  36856. * Creates the PassPostProcess
  36857. * @param name The name of the effect.
  36858. * @param options The required width/height ratio to downsize to before computing the render pass.
  36859. * @param camera The camera to apply the render pass to.
  36860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36861. * @param engine The engine which the post process will be applied. (default: current engine)
  36862. * @param reusable If the post process can be reused on the same frame. (default: false)
  36863. * @param textureType The type of texture to be used when performing the post processing.
  36864. * @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)
  36865. */
  36866. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36867. }
  36868. /**
  36869. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36870. */
  36871. export class PassCubePostProcess extends PostProcess {
  36872. private _face;
  36873. /**
  36874. * Gets or sets the cube face to display.
  36875. * * 0 is +X
  36876. * * 1 is -X
  36877. * * 2 is +Y
  36878. * * 3 is -Y
  36879. * * 4 is +Z
  36880. * * 5 is -Z
  36881. */
  36882. face: number;
  36883. /**
  36884. * Creates the PassCubePostProcess
  36885. * @param name The name of the effect.
  36886. * @param options The required width/height ratio to downsize to before computing the render pass.
  36887. * @param camera The camera to apply the render pass to.
  36888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36889. * @param engine The engine which the post process will be applied. (default: current engine)
  36890. * @param reusable If the post process can be reused on the same frame. (default: false)
  36891. * @param textureType The type of texture to be used when performing the post processing.
  36892. * @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)
  36893. */
  36894. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36895. }
  36896. }
  36897. declare module BABYLON {
  36898. /** @hidden */
  36899. export var anaglyphPixelShader: {
  36900. name: string;
  36901. shader: string;
  36902. };
  36903. }
  36904. declare module BABYLON {
  36905. /**
  36906. * Postprocess used to generate anaglyphic rendering
  36907. */
  36908. export class AnaglyphPostProcess extends PostProcess {
  36909. private _passedProcess;
  36910. /**
  36911. * Creates a new AnaglyphPostProcess
  36912. * @param name defines postprocess name
  36913. * @param options defines creation options or target ratio scale
  36914. * @param rigCameras defines cameras using this postprocess
  36915. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36916. * @param engine defines hosting engine
  36917. * @param reusable defines if the postprocess will be reused multiple times per frame
  36918. */
  36919. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36920. }
  36921. }
  36922. declare module BABYLON {
  36923. /**
  36924. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36925. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36926. */
  36927. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36928. /**
  36929. * Creates a new AnaglyphArcRotateCamera
  36930. * @param name defines camera name
  36931. * @param alpha defines alpha angle (in radians)
  36932. * @param beta defines beta angle (in radians)
  36933. * @param radius defines radius
  36934. * @param target defines camera target
  36935. * @param interaxialDistance defines distance between each color axis
  36936. * @param scene defines the hosting scene
  36937. */
  36938. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36939. /**
  36940. * Gets camera class name
  36941. * @returns AnaglyphArcRotateCamera
  36942. */
  36943. getClassName(): string;
  36944. }
  36945. }
  36946. declare module BABYLON {
  36947. /**
  36948. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36949. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36950. */
  36951. export class AnaglyphFreeCamera extends FreeCamera {
  36952. /**
  36953. * Creates a new AnaglyphFreeCamera
  36954. * @param name defines camera name
  36955. * @param position defines initial position
  36956. * @param interaxialDistance defines distance between each color axis
  36957. * @param scene defines the hosting scene
  36958. */
  36959. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36960. /**
  36961. * Gets camera class name
  36962. * @returns AnaglyphFreeCamera
  36963. */
  36964. getClassName(): string;
  36965. }
  36966. }
  36967. declare module BABYLON {
  36968. /**
  36969. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36970. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36971. */
  36972. export class AnaglyphGamepadCamera extends GamepadCamera {
  36973. /**
  36974. * Creates a new AnaglyphGamepadCamera
  36975. * @param name defines camera name
  36976. * @param position defines initial position
  36977. * @param interaxialDistance defines distance between each color axis
  36978. * @param scene defines the hosting scene
  36979. */
  36980. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36981. /**
  36982. * Gets camera class name
  36983. * @returns AnaglyphGamepadCamera
  36984. */
  36985. getClassName(): string;
  36986. }
  36987. }
  36988. declare module BABYLON {
  36989. /**
  36990. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36991. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36992. */
  36993. export class AnaglyphUniversalCamera extends UniversalCamera {
  36994. /**
  36995. * Creates a new AnaglyphUniversalCamera
  36996. * @param name defines camera name
  36997. * @param position defines initial position
  36998. * @param interaxialDistance defines distance between each color axis
  36999. * @param scene defines the hosting scene
  37000. */
  37001. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37002. /**
  37003. * Gets camera class name
  37004. * @returns AnaglyphUniversalCamera
  37005. */
  37006. getClassName(): string;
  37007. }
  37008. }
  37009. declare module BABYLON {
  37010. /** @hidden */
  37011. export var stereoscopicInterlacePixelShader: {
  37012. name: string;
  37013. shader: string;
  37014. };
  37015. }
  37016. declare module BABYLON {
  37017. /**
  37018. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37019. */
  37020. export class StereoscopicInterlacePostProcess extends PostProcess {
  37021. private _stepSize;
  37022. private _passedProcess;
  37023. /**
  37024. * Initializes a StereoscopicInterlacePostProcess
  37025. * @param name The name of the effect.
  37026. * @param rigCameras The rig cameras to be appled to the post process
  37027. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37029. * @param engine The engine which the post process will be applied. (default: current engine)
  37030. * @param reusable If the post process can be reused on the same frame. (default: false)
  37031. */
  37032. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37033. }
  37034. }
  37035. declare module BABYLON {
  37036. /**
  37037. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37038. * @see http://doc.babylonjs.com/features/cameras
  37039. */
  37040. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37041. /**
  37042. * Creates a new StereoscopicArcRotateCamera
  37043. * @param name defines camera name
  37044. * @param alpha defines alpha angle (in radians)
  37045. * @param beta defines beta angle (in radians)
  37046. * @param radius defines radius
  37047. * @param target defines camera target
  37048. * @param interaxialDistance defines distance between each color axis
  37049. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37050. * @param scene defines the hosting scene
  37051. */
  37052. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37053. /**
  37054. * Gets camera class name
  37055. * @returns StereoscopicArcRotateCamera
  37056. */
  37057. getClassName(): string;
  37058. }
  37059. }
  37060. declare module BABYLON {
  37061. /**
  37062. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37063. * @see http://doc.babylonjs.com/features/cameras
  37064. */
  37065. export class StereoscopicFreeCamera extends FreeCamera {
  37066. /**
  37067. * Creates a new StereoscopicFreeCamera
  37068. * @param name defines camera name
  37069. * @param position defines initial position
  37070. * @param interaxialDistance defines distance between each color axis
  37071. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37072. * @param scene defines the hosting scene
  37073. */
  37074. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37075. /**
  37076. * Gets camera class name
  37077. * @returns StereoscopicFreeCamera
  37078. */
  37079. getClassName(): string;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. /**
  37084. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37085. * @see http://doc.babylonjs.com/features/cameras
  37086. */
  37087. export class StereoscopicGamepadCamera extends GamepadCamera {
  37088. /**
  37089. * Creates a new StereoscopicGamepadCamera
  37090. * @param name defines camera name
  37091. * @param position defines initial position
  37092. * @param interaxialDistance defines distance between each color axis
  37093. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37094. * @param scene defines the hosting scene
  37095. */
  37096. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37097. /**
  37098. * Gets camera class name
  37099. * @returns StereoscopicGamepadCamera
  37100. */
  37101. getClassName(): string;
  37102. }
  37103. }
  37104. declare module BABYLON {
  37105. /**
  37106. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37107. * @see http://doc.babylonjs.com/features/cameras
  37108. */
  37109. export class StereoscopicUniversalCamera extends UniversalCamera {
  37110. /**
  37111. * Creates a new StereoscopicUniversalCamera
  37112. * @param name defines camera name
  37113. * @param position defines initial position
  37114. * @param interaxialDistance defines distance between each color axis
  37115. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37116. * @param scene defines the hosting scene
  37117. */
  37118. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37119. /**
  37120. * Gets camera class name
  37121. * @returns StereoscopicUniversalCamera
  37122. */
  37123. getClassName(): string;
  37124. }
  37125. }
  37126. declare module BABYLON {
  37127. /**
  37128. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37129. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37130. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37131. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37132. */
  37133. export class VirtualJoysticksCamera extends FreeCamera {
  37134. /**
  37135. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37136. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37137. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37138. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37139. * @param name Define the name of the camera in the scene
  37140. * @param position Define the start position of the camera in the scene
  37141. * @param scene Define the scene the camera belongs to
  37142. */
  37143. constructor(name: string, position: Vector3, scene: Scene);
  37144. /**
  37145. * Gets the current object class name.
  37146. * @return the class name
  37147. */
  37148. getClassName(): string;
  37149. }
  37150. }
  37151. declare module BABYLON {
  37152. /**
  37153. * This represents all the required metrics to create a VR camera.
  37154. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37155. */
  37156. export class VRCameraMetrics {
  37157. /**
  37158. * Define the horizontal resolution off the screen.
  37159. */
  37160. hResolution: number;
  37161. /**
  37162. * Define the vertical resolution off the screen.
  37163. */
  37164. vResolution: number;
  37165. /**
  37166. * Define the horizontal screen size.
  37167. */
  37168. hScreenSize: number;
  37169. /**
  37170. * Define the vertical screen size.
  37171. */
  37172. vScreenSize: number;
  37173. /**
  37174. * Define the vertical screen center position.
  37175. */
  37176. vScreenCenter: number;
  37177. /**
  37178. * Define the distance of the eyes to the screen.
  37179. */
  37180. eyeToScreenDistance: number;
  37181. /**
  37182. * Define the distance between both lenses
  37183. */
  37184. lensSeparationDistance: number;
  37185. /**
  37186. * Define the distance between both viewer's eyes.
  37187. */
  37188. interpupillaryDistance: number;
  37189. /**
  37190. * Define the distortion factor of the VR postprocess.
  37191. * Please, touch with care.
  37192. */
  37193. distortionK: number[];
  37194. /**
  37195. * Define the chromatic aberration correction factors for the VR post process.
  37196. */
  37197. chromaAbCorrection: number[];
  37198. /**
  37199. * Define the scale factor of the post process.
  37200. * The smaller the better but the slower.
  37201. */
  37202. postProcessScaleFactor: number;
  37203. /**
  37204. * Define an offset for the lens center.
  37205. */
  37206. lensCenterOffset: number;
  37207. /**
  37208. * Define if the current vr camera should compensate the distortion of the lense or not.
  37209. */
  37210. compensateDistortion: boolean;
  37211. /**
  37212. * Defines if multiview should be enabled when rendering (Default: false)
  37213. */
  37214. multiviewEnabled: boolean;
  37215. /**
  37216. * Gets the rendering aspect ratio based on the provided resolutions.
  37217. */
  37218. readonly aspectRatio: number;
  37219. /**
  37220. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37221. */
  37222. readonly aspectRatioFov: number;
  37223. /**
  37224. * @hidden
  37225. */
  37226. readonly leftHMatrix: Matrix;
  37227. /**
  37228. * @hidden
  37229. */
  37230. readonly rightHMatrix: Matrix;
  37231. /**
  37232. * @hidden
  37233. */
  37234. readonly leftPreViewMatrix: Matrix;
  37235. /**
  37236. * @hidden
  37237. */
  37238. readonly rightPreViewMatrix: Matrix;
  37239. /**
  37240. * Get the default VRMetrics based on the most generic setup.
  37241. * @returns the default vr metrics
  37242. */
  37243. static GetDefault(): VRCameraMetrics;
  37244. }
  37245. }
  37246. declare module BABYLON {
  37247. /** @hidden */
  37248. export var vrDistortionCorrectionPixelShader: {
  37249. name: string;
  37250. shader: string;
  37251. };
  37252. }
  37253. declare module BABYLON {
  37254. /**
  37255. * VRDistortionCorrectionPostProcess used for mobile VR
  37256. */
  37257. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37258. private _isRightEye;
  37259. private _distortionFactors;
  37260. private _postProcessScaleFactor;
  37261. private _lensCenterOffset;
  37262. private _scaleIn;
  37263. private _scaleFactor;
  37264. private _lensCenter;
  37265. /**
  37266. * Initializes the VRDistortionCorrectionPostProcess
  37267. * @param name The name of the effect.
  37268. * @param camera The camera to apply the render pass to.
  37269. * @param isRightEye If this is for the right eye distortion
  37270. * @param vrMetrics All the required metrics for the VR camera
  37271. */
  37272. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37273. }
  37274. }
  37275. declare module BABYLON {
  37276. /**
  37277. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37278. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37279. */
  37280. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37281. /**
  37282. * Creates a new VRDeviceOrientationArcRotateCamera
  37283. * @param name defines camera name
  37284. * @param alpha defines the camera rotation along the logitudinal axis
  37285. * @param beta defines the camera rotation along the latitudinal axis
  37286. * @param radius defines the camera distance from its target
  37287. * @param target defines the camera target
  37288. * @param scene defines the scene the camera belongs to
  37289. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37290. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37291. */
  37292. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37293. /**
  37294. * Gets camera class name
  37295. * @returns VRDeviceOrientationArcRotateCamera
  37296. */
  37297. getClassName(): string;
  37298. }
  37299. }
  37300. declare module BABYLON {
  37301. /**
  37302. * Camera used to simulate VR rendering (based on FreeCamera)
  37303. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37304. */
  37305. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37306. /**
  37307. * Creates a new VRDeviceOrientationFreeCamera
  37308. * @param name defines camera name
  37309. * @param position defines the start position of the camera
  37310. * @param scene defines the scene the camera belongs to
  37311. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37312. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37313. */
  37314. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37315. /**
  37316. * Gets camera class name
  37317. * @returns VRDeviceOrientationFreeCamera
  37318. */
  37319. getClassName(): string;
  37320. }
  37321. }
  37322. declare module BABYLON {
  37323. /**
  37324. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37325. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37326. */
  37327. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37328. /**
  37329. * Creates a new VRDeviceOrientationGamepadCamera
  37330. * @param name defines camera name
  37331. * @param position defines the start position of the camera
  37332. * @param scene defines the scene the camera belongs to
  37333. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37334. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37335. */
  37336. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37337. /**
  37338. * Gets camera class name
  37339. * @returns VRDeviceOrientationGamepadCamera
  37340. */
  37341. getClassName(): string;
  37342. }
  37343. }
  37344. declare module BABYLON {
  37345. /**
  37346. * Defines supported buttons for XBox360 compatible gamepads
  37347. */
  37348. export enum Xbox360Button {
  37349. /** A */
  37350. A = 0,
  37351. /** B */
  37352. B = 1,
  37353. /** X */
  37354. X = 2,
  37355. /** Y */
  37356. Y = 3,
  37357. /** Start */
  37358. Start = 4,
  37359. /** Back */
  37360. Back = 5,
  37361. /** Left button */
  37362. LB = 6,
  37363. /** Right button */
  37364. RB = 7,
  37365. /** Left stick */
  37366. LeftStick = 8,
  37367. /** Right stick */
  37368. RightStick = 9
  37369. }
  37370. /** Defines values for XBox360 DPad */
  37371. export enum Xbox360Dpad {
  37372. /** Up */
  37373. Up = 0,
  37374. /** Down */
  37375. Down = 1,
  37376. /** Left */
  37377. Left = 2,
  37378. /** Right */
  37379. Right = 3
  37380. }
  37381. /**
  37382. * Defines a XBox360 gamepad
  37383. */
  37384. export class Xbox360Pad extends Gamepad {
  37385. private _leftTrigger;
  37386. private _rightTrigger;
  37387. private _onlefttriggerchanged;
  37388. private _onrighttriggerchanged;
  37389. private _onbuttondown;
  37390. private _onbuttonup;
  37391. private _ondpaddown;
  37392. private _ondpadup;
  37393. /** Observable raised when a button is pressed */
  37394. onButtonDownObservable: Observable<Xbox360Button>;
  37395. /** Observable raised when a button is released */
  37396. onButtonUpObservable: Observable<Xbox360Button>;
  37397. /** Observable raised when a pad is pressed */
  37398. onPadDownObservable: Observable<Xbox360Dpad>;
  37399. /** Observable raised when a pad is released */
  37400. onPadUpObservable: Observable<Xbox360Dpad>;
  37401. private _buttonA;
  37402. private _buttonB;
  37403. private _buttonX;
  37404. private _buttonY;
  37405. private _buttonBack;
  37406. private _buttonStart;
  37407. private _buttonLB;
  37408. private _buttonRB;
  37409. private _buttonLeftStick;
  37410. private _buttonRightStick;
  37411. private _dPadUp;
  37412. private _dPadDown;
  37413. private _dPadLeft;
  37414. private _dPadRight;
  37415. private _isXboxOnePad;
  37416. /**
  37417. * Creates a new XBox360 gamepad object
  37418. * @param id defines the id of this gamepad
  37419. * @param index defines its index
  37420. * @param gamepad defines the internal HTML gamepad object
  37421. * @param xboxOne defines if it is a XBox One gamepad
  37422. */
  37423. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37424. /**
  37425. * Defines the callback to call when left trigger is pressed
  37426. * @param callback defines the callback to use
  37427. */
  37428. onlefttriggerchanged(callback: (value: number) => void): void;
  37429. /**
  37430. * Defines the callback to call when right trigger is pressed
  37431. * @param callback defines the callback to use
  37432. */
  37433. onrighttriggerchanged(callback: (value: number) => void): void;
  37434. /**
  37435. * Gets the left trigger value
  37436. */
  37437. /**
  37438. * Sets the left trigger value
  37439. */
  37440. leftTrigger: number;
  37441. /**
  37442. * Gets the right trigger value
  37443. */
  37444. /**
  37445. * Sets the right trigger value
  37446. */
  37447. rightTrigger: number;
  37448. /**
  37449. * Defines the callback to call when a button is pressed
  37450. * @param callback defines the callback to use
  37451. */
  37452. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37453. /**
  37454. * Defines the callback to call when a button is released
  37455. * @param callback defines the callback to use
  37456. */
  37457. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37458. /**
  37459. * Defines the callback to call when a pad is pressed
  37460. * @param callback defines the callback to use
  37461. */
  37462. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37463. /**
  37464. * Defines the callback to call when a pad is released
  37465. * @param callback defines the callback to use
  37466. */
  37467. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37468. private _setButtonValue;
  37469. private _setDPadValue;
  37470. /**
  37471. * Gets the value of the `A` button
  37472. */
  37473. /**
  37474. * Sets the value of the `A` button
  37475. */
  37476. buttonA: number;
  37477. /**
  37478. * Gets the value of the `B` button
  37479. */
  37480. /**
  37481. * Sets the value of the `B` button
  37482. */
  37483. buttonB: number;
  37484. /**
  37485. * Gets the value of the `X` button
  37486. */
  37487. /**
  37488. * Sets the value of the `X` button
  37489. */
  37490. buttonX: number;
  37491. /**
  37492. * Gets the value of the `Y` button
  37493. */
  37494. /**
  37495. * Sets the value of the `Y` button
  37496. */
  37497. buttonY: number;
  37498. /**
  37499. * Gets the value of the `Start` button
  37500. */
  37501. /**
  37502. * Sets the value of the `Start` button
  37503. */
  37504. buttonStart: number;
  37505. /**
  37506. * Gets the value of the `Back` button
  37507. */
  37508. /**
  37509. * Sets the value of the `Back` button
  37510. */
  37511. buttonBack: number;
  37512. /**
  37513. * Gets the value of the `Left` button
  37514. */
  37515. /**
  37516. * Sets the value of the `Left` button
  37517. */
  37518. buttonLB: number;
  37519. /**
  37520. * Gets the value of the `Right` button
  37521. */
  37522. /**
  37523. * Sets the value of the `Right` button
  37524. */
  37525. buttonRB: number;
  37526. /**
  37527. * Gets the value of the Left joystick
  37528. */
  37529. /**
  37530. * Sets the value of the Left joystick
  37531. */
  37532. buttonLeftStick: number;
  37533. /**
  37534. * Gets the value of the Right joystick
  37535. */
  37536. /**
  37537. * Sets the value of the Right joystick
  37538. */
  37539. buttonRightStick: number;
  37540. /**
  37541. * Gets the value of D-pad up
  37542. */
  37543. /**
  37544. * Sets the value of D-pad up
  37545. */
  37546. dPadUp: number;
  37547. /**
  37548. * Gets the value of D-pad down
  37549. */
  37550. /**
  37551. * Sets the value of D-pad down
  37552. */
  37553. dPadDown: number;
  37554. /**
  37555. * Gets the value of D-pad left
  37556. */
  37557. /**
  37558. * Sets the value of D-pad left
  37559. */
  37560. dPadLeft: number;
  37561. /**
  37562. * Gets the value of D-pad right
  37563. */
  37564. /**
  37565. * Sets the value of D-pad right
  37566. */
  37567. dPadRight: number;
  37568. /**
  37569. * Force the gamepad to synchronize with device values
  37570. */
  37571. update(): void;
  37572. /**
  37573. * Disposes the gamepad
  37574. */
  37575. dispose(): void;
  37576. }
  37577. }
  37578. declare module BABYLON {
  37579. /**
  37580. * Base class of materials working in push mode in babylon JS
  37581. * @hidden
  37582. */
  37583. export class PushMaterial extends Material {
  37584. protected _activeEffect: Effect;
  37585. protected _normalMatrix: Matrix;
  37586. /**
  37587. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37588. * This means that the material can keep using a previous shader while a new one is being compiled.
  37589. * This is mostly used when shader parallel compilation is supported (true by default)
  37590. */
  37591. allowShaderHotSwapping: boolean;
  37592. constructor(name: string, scene: Scene);
  37593. getEffect(): Effect;
  37594. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37595. /**
  37596. * Binds the given world matrix to the active effect
  37597. *
  37598. * @param world the matrix to bind
  37599. */
  37600. bindOnlyWorldMatrix(world: Matrix): void;
  37601. /**
  37602. * Binds the given normal matrix to the active effect
  37603. *
  37604. * @param normalMatrix the matrix to bind
  37605. */
  37606. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37607. bind(world: Matrix, mesh?: Mesh): void;
  37608. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37609. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37610. }
  37611. }
  37612. declare module BABYLON {
  37613. /**
  37614. * This groups all the flags used to control the materials channel.
  37615. */
  37616. export class MaterialFlags {
  37617. private static _DiffuseTextureEnabled;
  37618. /**
  37619. * Are diffuse textures enabled in the application.
  37620. */
  37621. static DiffuseTextureEnabled: boolean;
  37622. private static _AmbientTextureEnabled;
  37623. /**
  37624. * Are ambient textures enabled in the application.
  37625. */
  37626. static AmbientTextureEnabled: boolean;
  37627. private static _OpacityTextureEnabled;
  37628. /**
  37629. * Are opacity textures enabled in the application.
  37630. */
  37631. static OpacityTextureEnabled: boolean;
  37632. private static _ReflectionTextureEnabled;
  37633. /**
  37634. * Are reflection textures enabled in the application.
  37635. */
  37636. static ReflectionTextureEnabled: boolean;
  37637. private static _EmissiveTextureEnabled;
  37638. /**
  37639. * Are emissive textures enabled in the application.
  37640. */
  37641. static EmissiveTextureEnabled: boolean;
  37642. private static _SpecularTextureEnabled;
  37643. /**
  37644. * Are specular textures enabled in the application.
  37645. */
  37646. static SpecularTextureEnabled: boolean;
  37647. private static _BumpTextureEnabled;
  37648. /**
  37649. * Are bump textures enabled in the application.
  37650. */
  37651. static BumpTextureEnabled: boolean;
  37652. private static _LightmapTextureEnabled;
  37653. /**
  37654. * Are lightmap textures enabled in the application.
  37655. */
  37656. static LightmapTextureEnabled: boolean;
  37657. private static _RefractionTextureEnabled;
  37658. /**
  37659. * Are refraction textures enabled in the application.
  37660. */
  37661. static RefractionTextureEnabled: boolean;
  37662. private static _ColorGradingTextureEnabled;
  37663. /**
  37664. * Are color grading textures enabled in the application.
  37665. */
  37666. static ColorGradingTextureEnabled: boolean;
  37667. private static _FresnelEnabled;
  37668. /**
  37669. * Are fresnels enabled in the application.
  37670. */
  37671. static FresnelEnabled: boolean;
  37672. private static _ClearCoatTextureEnabled;
  37673. /**
  37674. * Are clear coat textures enabled in the application.
  37675. */
  37676. static ClearCoatTextureEnabled: boolean;
  37677. private static _ClearCoatBumpTextureEnabled;
  37678. /**
  37679. * Are clear coat bump textures enabled in the application.
  37680. */
  37681. static ClearCoatBumpTextureEnabled: boolean;
  37682. private static _ClearCoatTintTextureEnabled;
  37683. /**
  37684. * Are clear coat tint textures enabled in the application.
  37685. */
  37686. static ClearCoatTintTextureEnabled: boolean;
  37687. private static _SheenTextureEnabled;
  37688. /**
  37689. * Are sheen textures enabled in the application.
  37690. */
  37691. static SheenTextureEnabled: boolean;
  37692. private static _AnisotropicTextureEnabled;
  37693. /**
  37694. * Are anisotropic textures enabled in the application.
  37695. */
  37696. static AnisotropicTextureEnabled: boolean;
  37697. private static _ThicknessTextureEnabled;
  37698. /**
  37699. * Are thickness textures enabled in the application.
  37700. */
  37701. static ThicknessTextureEnabled: boolean;
  37702. }
  37703. }
  37704. declare module BABYLON {
  37705. /** @hidden */
  37706. export var defaultFragmentDeclaration: {
  37707. name: string;
  37708. shader: string;
  37709. };
  37710. }
  37711. declare module BABYLON {
  37712. /** @hidden */
  37713. export var defaultUboDeclaration: {
  37714. name: string;
  37715. shader: string;
  37716. };
  37717. }
  37718. declare module BABYLON {
  37719. /** @hidden */
  37720. export var lightFragmentDeclaration: {
  37721. name: string;
  37722. shader: string;
  37723. };
  37724. }
  37725. declare module BABYLON {
  37726. /** @hidden */
  37727. export var lightUboDeclaration: {
  37728. name: string;
  37729. shader: string;
  37730. };
  37731. }
  37732. declare module BABYLON {
  37733. /** @hidden */
  37734. export var lightsFragmentFunctions: {
  37735. name: string;
  37736. shader: string;
  37737. };
  37738. }
  37739. declare module BABYLON {
  37740. /** @hidden */
  37741. export var shadowsFragmentFunctions: {
  37742. name: string;
  37743. shader: string;
  37744. };
  37745. }
  37746. declare module BABYLON {
  37747. /** @hidden */
  37748. export var fresnelFunction: {
  37749. name: string;
  37750. shader: string;
  37751. };
  37752. }
  37753. declare module BABYLON {
  37754. /** @hidden */
  37755. export var reflectionFunction: {
  37756. name: string;
  37757. shader: string;
  37758. };
  37759. }
  37760. declare module BABYLON {
  37761. /** @hidden */
  37762. export var bumpFragmentFunctions: {
  37763. name: string;
  37764. shader: string;
  37765. };
  37766. }
  37767. declare module BABYLON {
  37768. /** @hidden */
  37769. export var logDepthDeclaration: {
  37770. name: string;
  37771. shader: string;
  37772. };
  37773. }
  37774. declare module BABYLON {
  37775. /** @hidden */
  37776. export var bumpFragment: {
  37777. name: string;
  37778. shader: string;
  37779. };
  37780. }
  37781. declare module BABYLON {
  37782. /** @hidden */
  37783. export var depthPrePass: {
  37784. name: string;
  37785. shader: string;
  37786. };
  37787. }
  37788. declare module BABYLON {
  37789. /** @hidden */
  37790. export var lightFragment: {
  37791. name: string;
  37792. shader: string;
  37793. };
  37794. }
  37795. declare module BABYLON {
  37796. /** @hidden */
  37797. export var logDepthFragment: {
  37798. name: string;
  37799. shader: string;
  37800. };
  37801. }
  37802. declare module BABYLON {
  37803. /** @hidden */
  37804. export var defaultPixelShader: {
  37805. name: string;
  37806. shader: string;
  37807. };
  37808. }
  37809. declare module BABYLON {
  37810. /** @hidden */
  37811. export var defaultVertexDeclaration: {
  37812. name: string;
  37813. shader: string;
  37814. };
  37815. }
  37816. declare module BABYLON {
  37817. /** @hidden */
  37818. export var bumpVertexDeclaration: {
  37819. name: string;
  37820. shader: string;
  37821. };
  37822. }
  37823. declare module BABYLON {
  37824. /** @hidden */
  37825. export var bumpVertex: {
  37826. name: string;
  37827. shader: string;
  37828. };
  37829. }
  37830. declare module BABYLON {
  37831. /** @hidden */
  37832. export var fogVertex: {
  37833. name: string;
  37834. shader: string;
  37835. };
  37836. }
  37837. declare module BABYLON {
  37838. /** @hidden */
  37839. export var shadowsVertex: {
  37840. name: string;
  37841. shader: string;
  37842. };
  37843. }
  37844. declare module BABYLON {
  37845. /** @hidden */
  37846. export var pointCloudVertex: {
  37847. name: string;
  37848. shader: string;
  37849. };
  37850. }
  37851. declare module BABYLON {
  37852. /** @hidden */
  37853. export var logDepthVertex: {
  37854. name: string;
  37855. shader: string;
  37856. };
  37857. }
  37858. declare module BABYLON {
  37859. /** @hidden */
  37860. export var defaultVertexShader: {
  37861. name: string;
  37862. shader: string;
  37863. };
  37864. }
  37865. declare module BABYLON {
  37866. /** @hidden */
  37867. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37868. MAINUV1: boolean;
  37869. MAINUV2: boolean;
  37870. DIFFUSE: boolean;
  37871. DIFFUSEDIRECTUV: number;
  37872. AMBIENT: boolean;
  37873. AMBIENTDIRECTUV: number;
  37874. OPACITY: boolean;
  37875. OPACITYDIRECTUV: number;
  37876. OPACITYRGB: boolean;
  37877. REFLECTION: boolean;
  37878. EMISSIVE: boolean;
  37879. EMISSIVEDIRECTUV: number;
  37880. SPECULAR: boolean;
  37881. SPECULARDIRECTUV: number;
  37882. BUMP: boolean;
  37883. BUMPDIRECTUV: number;
  37884. PARALLAX: boolean;
  37885. PARALLAXOCCLUSION: boolean;
  37886. SPECULAROVERALPHA: boolean;
  37887. CLIPPLANE: boolean;
  37888. CLIPPLANE2: boolean;
  37889. CLIPPLANE3: boolean;
  37890. CLIPPLANE4: boolean;
  37891. ALPHATEST: boolean;
  37892. DEPTHPREPASS: boolean;
  37893. ALPHAFROMDIFFUSE: boolean;
  37894. POINTSIZE: boolean;
  37895. FOG: boolean;
  37896. SPECULARTERM: boolean;
  37897. DIFFUSEFRESNEL: boolean;
  37898. OPACITYFRESNEL: boolean;
  37899. REFLECTIONFRESNEL: boolean;
  37900. REFRACTIONFRESNEL: boolean;
  37901. EMISSIVEFRESNEL: boolean;
  37902. FRESNEL: boolean;
  37903. NORMAL: boolean;
  37904. UV1: boolean;
  37905. UV2: boolean;
  37906. VERTEXCOLOR: boolean;
  37907. VERTEXALPHA: boolean;
  37908. NUM_BONE_INFLUENCERS: number;
  37909. BonesPerMesh: number;
  37910. BONETEXTURE: boolean;
  37911. INSTANCES: boolean;
  37912. GLOSSINESS: boolean;
  37913. ROUGHNESS: boolean;
  37914. EMISSIVEASILLUMINATION: boolean;
  37915. LINKEMISSIVEWITHDIFFUSE: boolean;
  37916. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37917. LIGHTMAP: boolean;
  37918. LIGHTMAPDIRECTUV: number;
  37919. OBJECTSPACE_NORMALMAP: boolean;
  37920. USELIGHTMAPASSHADOWMAP: boolean;
  37921. REFLECTIONMAP_3D: boolean;
  37922. REFLECTIONMAP_SPHERICAL: boolean;
  37923. REFLECTIONMAP_PLANAR: boolean;
  37924. REFLECTIONMAP_CUBIC: boolean;
  37925. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37926. REFLECTIONMAP_PROJECTION: boolean;
  37927. REFLECTIONMAP_SKYBOX: boolean;
  37928. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37929. REFLECTIONMAP_EXPLICIT: boolean;
  37930. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37931. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37932. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37933. INVERTCUBICMAP: boolean;
  37934. LOGARITHMICDEPTH: boolean;
  37935. REFRACTION: boolean;
  37936. REFRACTIONMAP_3D: boolean;
  37937. REFLECTIONOVERALPHA: boolean;
  37938. TWOSIDEDLIGHTING: boolean;
  37939. SHADOWFLOAT: boolean;
  37940. MORPHTARGETS: boolean;
  37941. MORPHTARGETS_NORMAL: boolean;
  37942. MORPHTARGETS_TANGENT: boolean;
  37943. NUM_MORPH_INFLUENCERS: number;
  37944. NONUNIFORMSCALING: boolean;
  37945. PREMULTIPLYALPHA: boolean;
  37946. IMAGEPROCESSING: boolean;
  37947. VIGNETTE: boolean;
  37948. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37949. VIGNETTEBLENDMODEOPAQUE: boolean;
  37950. TONEMAPPING: boolean;
  37951. TONEMAPPING_ACES: boolean;
  37952. CONTRAST: boolean;
  37953. COLORCURVES: boolean;
  37954. COLORGRADING: boolean;
  37955. COLORGRADING3D: boolean;
  37956. SAMPLER3DGREENDEPTH: boolean;
  37957. SAMPLER3DBGRMAP: boolean;
  37958. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37959. MULTIVIEW: boolean;
  37960. /**
  37961. * If the reflection texture on this material is in linear color space
  37962. * @hidden
  37963. */
  37964. IS_REFLECTION_LINEAR: boolean;
  37965. /**
  37966. * If the refraction texture on this material is in linear color space
  37967. * @hidden
  37968. */
  37969. IS_REFRACTION_LINEAR: boolean;
  37970. EXPOSURE: boolean;
  37971. constructor();
  37972. setReflectionMode(modeToEnable: string): void;
  37973. }
  37974. /**
  37975. * This is the default material used in Babylon. It is the best trade off between quality
  37976. * and performances.
  37977. * @see http://doc.babylonjs.com/babylon101/materials
  37978. */
  37979. export class StandardMaterial extends PushMaterial {
  37980. private _diffuseTexture;
  37981. /**
  37982. * The basic texture of the material as viewed under a light.
  37983. */
  37984. diffuseTexture: Nullable<BaseTexture>;
  37985. private _ambientTexture;
  37986. /**
  37987. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37988. */
  37989. ambientTexture: Nullable<BaseTexture>;
  37990. private _opacityTexture;
  37991. /**
  37992. * Define the transparency of the material from a texture.
  37993. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37994. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37995. */
  37996. opacityTexture: Nullable<BaseTexture>;
  37997. private _reflectionTexture;
  37998. /**
  37999. * Define the texture used to display the reflection.
  38000. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38001. */
  38002. reflectionTexture: Nullable<BaseTexture>;
  38003. private _emissiveTexture;
  38004. /**
  38005. * Define texture of the material as if self lit.
  38006. * This will be mixed in the final result even in the absence of light.
  38007. */
  38008. emissiveTexture: Nullable<BaseTexture>;
  38009. private _specularTexture;
  38010. /**
  38011. * Define how the color and intensity of the highlight given by the light in the material.
  38012. */
  38013. specularTexture: Nullable<BaseTexture>;
  38014. private _bumpTexture;
  38015. /**
  38016. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38017. * 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.
  38018. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38019. */
  38020. bumpTexture: Nullable<BaseTexture>;
  38021. private _lightmapTexture;
  38022. /**
  38023. * Complex lighting can be computationally expensive to compute at runtime.
  38024. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38025. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38026. */
  38027. lightmapTexture: Nullable<BaseTexture>;
  38028. private _refractionTexture;
  38029. /**
  38030. * Define the texture used to display the refraction.
  38031. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38032. */
  38033. refractionTexture: Nullable<BaseTexture>;
  38034. /**
  38035. * The color of the material lit by the environmental background lighting.
  38036. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38037. */
  38038. ambientColor: Color3;
  38039. /**
  38040. * The basic color of the material as viewed under a light.
  38041. */
  38042. diffuseColor: Color3;
  38043. /**
  38044. * Define how the color and intensity of the highlight given by the light in the material.
  38045. */
  38046. specularColor: Color3;
  38047. /**
  38048. * Define the color of the material as if self lit.
  38049. * This will be mixed in the final result even in the absence of light.
  38050. */
  38051. emissiveColor: Color3;
  38052. /**
  38053. * Defines how sharp are the highlights in the material.
  38054. * The bigger the value the sharper giving a more glossy feeling to the result.
  38055. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38056. */
  38057. specularPower: number;
  38058. private _useAlphaFromDiffuseTexture;
  38059. /**
  38060. * Does the transparency come from the diffuse texture alpha channel.
  38061. */
  38062. useAlphaFromDiffuseTexture: boolean;
  38063. private _useEmissiveAsIllumination;
  38064. /**
  38065. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38066. */
  38067. useEmissiveAsIllumination: boolean;
  38068. private _linkEmissiveWithDiffuse;
  38069. /**
  38070. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38071. * the emissive level when the final color is close to one.
  38072. */
  38073. linkEmissiveWithDiffuse: boolean;
  38074. private _useSpecularOverAlpha;
  38075. /**
  38076. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38078. */
  38079. useSpecularOverAlpha: boolean;
  38080. private _useReflectionOverAlpha;
  38081. /**
  38082. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38083. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38084. */
  38085. useReflectionOverAlpha: boolean;
  38086. private _disableLighting;
  38087. /**
  38088. * Does lights from the scene impacts this material.
  38089. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38090. */
  38091. disableLighting: boolean;
  38092. private _useObjectSpaceNormalMap;
  38093. /**
  38094. * Allows using an object space normal map (instead of tangent space).
  38095. */
  38096. useObjectSpaceNormalMap: boolean;
  38097. private _useParallax;
  38098. /**
  38099. * Is parallax enabled or not.
  38100. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38101. */
  38102. useParallax: boolean;
  38103. private _useParallaxOcclusion;
  38104. /**
  38105. * Is parallax occlusion enabled or not.
  38106. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38107. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38108. */
  38109. useParallaxOcclusion: boolean;
  38110. /**
  38111. * 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.
  38112. */
  38113. parallaxScaleBias: number;
  38114. private _roughness;
  38115. /**
  38116. * Helps to define how blurry the reflections should appears in the material.
  38117. */
  38118. roughness: number;
  38119. /**
  38120. * In case of refraction, define the value of the indice of refraction.
  38121. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38122. */
  38123. indexOfRefraction: number;
  38124. /**
  38125. * Invert the refraction texture alongside the y axis.
  38126. * It can be useful with procedural textures or probe for instance.
  38127. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38128. */
  38129. invertRefractionY: boolean;
  38130. /**
  38131. * Defines the alpha limits in alpha test mode.
  38132. */
  38133. alphaCutOff: number;
  38134. private _useLightmapAsShadowmap;
  38135. /**
  38136. * In case of light mapping, define whether the map contains light or shadow informations.
  38137. */
  38138. useLightmapAsShadowmap: boolean;
  38139. private _diffuseFresnelParameters;
  38140. /**
  38141. * Define the diffuse fresnel parameters of the material.
  38142. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38143. */
  38144. diffuseFresnelParameters: FresnelParameters;
  38145. private _opacityFresnelParameters;
  38146. /**
  38147. * Define the opacity fresnel parameters of the material.
  38148. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38149. */
  38150. opacityFresnelParameters: FresnelParameters;
  38151. private _reflectionFresnelParameters;
  38152. /**
  38153. * Define the reflection fresnel parameters of the material.
  38154. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38155. */
  38156. reflectionFresnelParameters: FresnelParameters;
  38157. private _refractionFresnelParameters;
  38158. /**
  38159. * Define the refraction fresnel parameters of the material.
  38160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38161. */
  38162. refractionFresnelParameters: FresnelParameters;
  38163. private _emissiveFresnelParameters;
  38164. /**
  38165. * Define the emissive fresnel parameters of the material.
  38166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38167. */
  38168. emissiveFresnelParameters: FresnelParameters;
  38169. private _useReflectionFresnelFromSpecular;
  38170. /**
  38171. * If true automatically deducts the fresnels values from the material specularity.
  38172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38173. */
  38174. useReflectionFresnelFromSpecular: boolean;
  38175. private _useGlossinessFromSpecularMapAlpha;
  38176. /**
  38177. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38178. */
  38179. useGlossinessFromSpecularMapAlpha: boolean;
  38180. private _maxSimultaneousLights;
  38181. /**
  38182. * Defines the maximum number of lights that can be used in the material
  38183. */
  38184. maxSimultaneousLights: number;
  38185. private _invertNormalMapX;
  38186. /**
  38187. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38188. */
  38189. invertNormalMapX: boolean;
  38190. private _invertNormalMapY;
  38191. /**
  38192. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38193. */
  38194. invertNormalMapY: boolean;
  38195. private _twoSidedLighting;
  38196. /**
  38197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38198. */
  38199. twoSidedLighting: boolean;
  38200. /**
  38201. * Default configuration related to image processing available in the standard Material.
  38202. */
  38203. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38204. /**
  38205. * Gets the image processing configuration used either in this material.
  38206. */
  38207. /**
  38208. * Sets the Default image processing configuration used either in the this material.
  38209. *
  38210. * If sets to null, the scene one is in use.
  38211. */
  38212. imageProcessingConfiguration: ImageProcessingConfiguration;
  38213. /**
  38214. * Keep track of the image processing observer to allow dispose and replace.
  38215. */
  38216. private _imageProcessingObserver;
  38217. /**
  38218. * Attaches a new image processing configuration to the Standard Material.
  38219. * @param configuration
  38220. */
  38221. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38222. /**
  38223. * Gets wether the color curves effect is enabled.
  38224. */
  38225. /**
  38226. * Sets wether the color curves effect is enabled.
  38227. */
  38228. cameraColorCurvesEnabled: boolean;
  38229. /**
  38230. * Gets wether the color grading effect is enabled.
  38231. */
  38232. /**
  38233. * Gets wether the color grading effect is enabled.
  38234. */
  38235. cameraColorGradingEnabled: boolean;
  38236. /**
  38237. * Gets wether tonemapping is enabled or not.
  38238. */
  38239. /**
  38240. * Sets wether tonemapping is enabled or not
  38241. */
  38242. cameraToneMappingEnabled: boolean;
  38243. /**
  38244. * The camera exposure used on this material.
  38245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38246. * This corresponds to a photographic exposure.
  38247. */
  38248. /**
  38249. * The camera exposure used on this material.
  38250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38251. * This corresponds to a photographic exposure.
  38252. */
  38253. cameraExposure: number;
  38254. /**
  38255. * Gets The camera contrast used on this material.
  38256. */
  38257. /**
  38258. * Sets The camera contrast used on this material.
  38259. */
  38260. cameraContrast: number;
  38261. /**
  38262. * Gets the Color Grading 2D Lookup Texture.
  38263. */
  38264. /**
  38265. * Sets the Color Grading 2D Lookup Texture.
  38266. */
  38267. cameraColorGradingTexture: Nullable<BaseTexture>;
  38268. /**
  38269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38271. * 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;
  38272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38273. */
  38274. /**
  38275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38277. * 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;
  38278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38279. */
  38280. cameraColorCurves: Nullable<ColorCurves>;
  38281. /**
  38282. * Custom callback helping to override the default shader used in the material.
  38283. */
  38284. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38285. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38286. protected _worldViewProjectionMatrix: Matrix;
  38287. protected _globalAmbientColor: Color3;
  38288. protected _useLogarithmicDepth: boolean;
  38289. /**
  38290. * Instantiates a new standard material.
  38291. * This is the default material used in Babylon. It is the best trade off between quality
  38292. * and performances.
  38293. * @see http://doc.babylonjs.com/babylon101/materials
  38294. * @param name Define the name of the material in the scene
  38295. * @param scene Define the scene the material belong to
  38296. */
  38297. constructor(name: string, scene: Scene);
  38298. /**
  38299. * Gets a boolean indicating that current material needs to register RTT
  38300. */
  38301. readonly hasRenderTargetTextures: boolean;
  38302. /**
  38303. * Gets the current class name of the material e.g. "StandardMaterial"
  38304. * Mainly use in serialization.
  38305. * @returns the class name
  38306. */
  38307. getClassName(): string;
  38308. /**
  38309. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38310. * You can try switching to logarithmic depth.
  38311. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38312. */
  38313. useLogarithmicDepth: boolean;
  38314. /**
  38315. * Specifies if the material will require alpha blending
  38316. * @returns a boolean specifying if alpha blending is needed
  38317. */
  38318. needAlphaBlending(): boolean;
  38319. /**
  38320. * Specifies if this material should be rendered in alpha test mode
  38321. * @returns a boolean specifying if an alpha test is needed.
  38322. */
  38323. needAlphaTesting(): boolean;
  38324. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38325. /**
  38326. * Get the texture used for alpha test purpose.
  38327. * @returns the diffuse texture in case of the standard material.
  38328. */
  38329. getAlphaTestTexture(): Nullable<BaseTexture>;
  38330. /**
  38331. * Get if the submesh is ready to be used and all its information available.
  38332. * Child classes can use it to update shaders
  38333. * @param mesh defines the mesh to check
  38334. * @param subMesh defines which submesh to check
  38335. * @param useInstances specifies that instances should be used
  38336. * @returns a boolean indicating that the submesh is ready or not
  38337. */
  38338. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38339. /**
  38340. * Builds the material UBO layouts.
  38341. * Used internally during the effect preparation.
  38342. */
  38343. buildUniformLayout(): void;
  38344. /**
  38345. * Unbinds the material from the mesh
  38346. */
  38347. unbind(): void;
  38348. /**
  38349. * Binds the submesh to this material by preparing the effect and shader to draw
  38350. * @param world defines the world transformation matrix
  38351. * @param mesh defines the mesh containing the submesh
  38352. * @param subMesh defines the submesh to bind the material to
  38353. */
  38354. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38355. /**
  38356. * Get the list of animatables in the material.
  38357. * @returns the list of animatables object used in the material
  38358. */
  38359. getAnimatables(): IAnimatable[];
  38360. /**
  38361. * Gets the active textures from the material
  38362. * @returns an array of textures
  38363. */
  38364. getActiveTextures(): BaseTexture[];
  38365. /**
  38366. * Specifies if the material uses a texture
  38367. * @param texture defines the texture to check against the material
  38368. * @returns a boolean specifying if the material uses the texture
  38369. */
  38370. hasTexture(texture: BaseTexture): boolean;
  38371. /**
  38372. * Disposes the material
  38373. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38374. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38375. */
  38376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38377. /**
  38378. * Makes a duplicate of the material, and gives it a new name
  38379. * @param name defines the new name for the duplicated material
  38380. * @returns the cloned material
  38381. */
  38382. clone(name: string): StandardMaterial;
  38383. /**
  38384. * Serializes this material in a JSON representation
  38385. * @returns the serialized material object
  38386. */
  38387. serialize(): any;
  38388. /**
  38389. * Creates a standard material from parsed material data
  38390. * @param source defines the JSON representation of the material
  38391. * @param scene defines the hosting scene
  38392. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38393. * @returns a new standard material
  38394. */
  38395. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38396. /**
  38397. * Are diffuse textures enabled in the application.
  38398. */
  38399. static DiffuseTextureEnabled: boolean;
  38400. /**
  38401. * Are ambient textures enabled in the application.
  38402. */
  38403. static AmbientTextureEnabled: boolean;
  38404. /**
  38405. * Are opacity textures enabled in the application.
  38406. */
  38407. static OpacityTextureEnabled: boolean;
  38408. /**
  38409. * Are reflection textures enabled in the application.
  38410. */
  38411. static ReflectionTextureEnabled: boolean;
  38412. /**
  38413. * Are emissive textures enabled in the application.
  38414. */
  38415. static EmissiveTextureEnabled: boolean;
  38416. /**
  38417. * Are specular textures enabled in the application.
  38418. */
  38419. static SpecularTextureEnabled: boolean;
  38420. /**
  38421. * Are bump textures enabled in the application.
  38422. */
  38423. static BumpTextureEnabled: boolean;
  38424. /**
  38425. * Are lightmap textures enabled in the application.
  38426. */
  38427. static LightmapTextureEnabled: boolean;
  38428. /**
  38429. * Are refraction textures enabled in the application.
  38430. */
  38431. static RefractionTextureEnabled: boolean;
  38432. /**
  38433. * Are color grading textures enabled in the application.
  38434. */
  38435. static ColorGradingTextureEnabled: boolean;
  38436. /**
  38437. * Are fresnels enabled in the application.
  38438. */
  38439. static FresnelEnabled: boolean;
  38440. }
  38441. }
  38442. declare module BABYLON {
  38443. /**
  38444. * A class extending Texture allowing drawing on a texture
  38445. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38446. */
  38447. export class DynamicTexture extends Texture {
  38448. private _generateMipMaps;
  38449. private _canvas;
  38450. private _context;
  38451. private _engine;
  38452. /**
  38453. * Creates a DynamicTexture
  38454. * @param name defines the name of the texture
  38455. * @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
  38456. * @param scene defines the scene where you want the texture
  38457. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38458. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38459. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38460. */
  38461. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38462. /**
  38463. * Get the current class name of the texture useful for serialization or dynamic coding.
  38464. * @returns "DynamicTexture"
  38465. */
  38466. getClassName(): string;
  38467. /**
  38468. * Gets the current state of canRescale
  38469. */
  38470. readonly canRescale: boolean;
  38471. private _recreate;
  38472. /**
  38473. * Scales the texture
  38474. * @param ratio the scale factor to apply to both width and height
  38475. */
  38476. scale(ratio: number): void;
  38477. /**
  38478. * Resizes the texture
  38479. * @param width the new width
  38480. * @param height the new height
  38481. */
  38482. scaleTo(width: number, height: number): void;
  38483. /**
  38484. * Gets the context of the canvas used by the texture
  38485. * @returns the canvas context of the dynamic texture
  38486. */
  38487. getContext(): CanvasRenderingContext2D;
  38488. /**
  38489. * Clears the texture
  38490. */
  38491. clear(): void;
  38492. /**
  38493. * Updates the texture
  38494. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38495. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38496. */
  38497. update(invertY?: boolean, premulAlpha?: boolean): void;
  38498. /**
  38499. * Draws text onto the texture
  38500. * @param text defines the text to be drawn
  38501. * @param x defines the placement of the text from the left
  38502. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38503. * @param font defines the font to be used with font-style, font-size, font-name
  38504. * @param color defines the color used for the text
  38505. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38506. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38507. * @param update defines whether texture is immediately update (default is true)
  38508. */
  38509. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38510. /**
  38511. * Clones the texture
  38512. * @returns the clone of the texture.
  38513. */
  38514. clone(): DynamicTexture;
  38515. /**
  38516. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38517. * @returns a serialized dynamic texture object
  38518. */
  38519. serialize(): any;
  38520. /** @hidden */ rebuild(): void;
  38521. }
  38522. }
  38523. declare module BABYLON {
  38524. /** @hidden */
  38525. export var imageProcessingPixelShader: {
  38526. name: string;
  38527. shader: string;
  38528. };
  38529. }
  38530. declare module BABYLON {
  38531. /**
  38532. * ImageProcessingPostProcess
  38533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38534. */
  38535. export class ImageProcessingPostProcess extends PostProcess {
  38536. /**
  38537. * Default configuration related to image processing available in the PBR Material.
  38538. */
  38539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38540. /**
  38541. * Gets the image processing configuration used either in this material.
  38542. */
  38543. /**
  38544. * Sets the Default image processing configuration used either in the this material.
  38545. *
  38546. * If sets to null, the scene one is in use.
  38547. */
  38548. imageProcessingConfiguration: ImageProcessingConfiguration;
  38549. /**
  38550. * Keep track of the image processing observer to allow dispose and replace.
  38551. */
  38552. private _imageProcessingObserver;
  38553. /**
  38554. * Attaches a new image processing configuration to the PBR Material.
  38555. * @param configuration
  38556. */
  38557. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38558. /**
  38559. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38560. */
  38561. /**
  38562. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38563. */
  38564. colorCurves: Nullable<ColorCurves>;
  38565. /**
  38566. * Gets wether the color curves effect is enabled.
  38567. */
  38568. /**
  38569. * Sets wether the color curves effect is enabled.
  38570. */
  38571. colorCurvesEnabled: boolean;
  38572. /**
  38573. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38574. */
  38575. /**
  38576. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38577. */
  38578. colorGradingTexture: Nullable<BaseTexture>;
  38579. /**
  38580. * Gets wether the color grading effect is enabled.
  38581. */
  38582. /**
  38583. * Gets wether the color grading effect is enabled.
  38584. */
  38585. colorGradingEnabled: boolean;
  38586. /**
  38587. * Gets exposure used in the effect.
  38588. */
  38589. /**
  38590. * Sets exposure used in the effect.
  38591. */
  38592. exposure: number;
  38593. /**
  38594. * Gets wether tonemapping is enabled or not.
  38595. */
  38596. /**
  38597. * Sets wether tonemapping is enabled or not
  38598. */
  38599. toneMappingEnabled: boolean;
  38600. /**
  38601. * Gets the type of tone mapping effect.
  38602. */
  38603. /**
  38604. * Sets the type of tone mapping effect.
  38605. */
  38606. toneMappingType: number;
  38607. /**
  38608. * Gets contrast used in the effect.
  38609. */
  38610. /**
  38611. * Sets contrast used in the effect.
  38612. */
  38613. contrast: number;
  38614. /**
  38615. * Gets Vignette stretch size.
  38616. */
  38617. /**
  38618. * Sets Vignette stretch size.
  38619. */
  38620. vignetteStretch: number;
  38621. /**
  38622. * Gets Vignette centre X Offset.
  38623. */
  38624. /**
  38625. * Sets Vignette centre X Offset.
  38626. */
  38627. vignetteCentreX: number;
  38628. /**
  38629. * Gets Vignette centre Y Offset.
  38630. */
  38631. /**
  38632. * Sets Vignette centre Y Offset.
  38633. */
  38634. vignetteCentreY: number;
  38635. /**
  38636. * Gets Vignette weight or intensity of the vignette effect.
  38637. */
  38638. /**
  38639. * Sets Vignette weight or intensity of the vignette effect.
  38640. */
  38641. vignetteWeight: number;
  38642. /**
  38643. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38644. * if vignetteEnabled is set to true.
  38645. */
  38646. /**
  38647. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38648. * if vignetteEnabled is set to true.
  38649. */
  38650. vignetteColor: Color4;
  38651. /**
  38652. * Gets Camera field of view used by the Vignette effect.
  38653. */
  38654. /**
  38655. * Sets Camera field of view used by the Vignette effect.
  38656. */
  38657. vignetteCameraFov: number;
  38658. /**
  38659. * Gets the vignette blend mode allowing different kind of effect.
  38660. */
  38661. /**
  38662. * Sets the vignette blend mode allowing different kind of effect.
  38663. */
  38664. vignetteBlendMode: number;
  38665. /**
  38666. * Gets wether the vignette effect is enabled.
  38667. */
  38668. /**
  38669. * Sets wether the vignette effect is enabled.
  38670. */
  38671. vignetteEnabled: boolean;
  38672. private _fromLinearSpace;
  38673. /**
  38674. * Gets wether the input of the processing is in Gamma or Linear Space.
  38675. */
  38676. /**
  38677. * Sets wether the input of the processing is in Gamma or Linear Space.
  38678. */
  38679. fromLinearSpace: boolean;
  38680. /**
  38681. * Defines cache preventing GC.
  38682. */
  38683. private _defines;
  38684. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38685. /**
  38686. * "ImageProcessingPostProcess"
  38687. * @returns "ImageProcessingPostProcess"
  38688. */
  38689. getClassName(): string;
  38690. protected _updateParameters(): void;
  38691. dispose(camera?: Camera): void;
  38692. }
  38693. }
  38694. declare module BABYLON {
  38695. /**
  38696. * Class containing static functions to help procedurally build meshes
  38697. */
  38698. export class GroundBuilder {
  38699. /**
  38700. * Creates a ground mesh
  38701. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38702. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38704. * @param name defines the name of the mesh
  38705. * @param options defines the options used to create the mesh
  38706. * @param scene defines the hosting scene
  38707. * @returns the ground mesh
  38708. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38709. */
  38710. static CreateGround(name: string, options: {
  38711. width?: number;
  38712. height?: number;
  38713. subdivisions?: number;
  38714. subdivisionsX?: number;
  38715. subdivisionsY?: number;
  38716. updatable?: boolean;
  38717. }, scene: any): Mesh;
  38718. /**
  38719. * Creates a tiled ground mesh
  38720. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38721. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38722. * * 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
  38723. * * 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
  38724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38725. * @param name defines the name of the mesh
  38726. * @param options defines the options used to create the mesh
  38727. * @param scene defines the hosting scene
  38728. * @returns the tiled ground mesh
  38729. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38730. */
  38731. static CreateTiledGround(name: string, options: {
  38732. xmin: number;
  38733. zmin: number;
  38734. xmax: number;
  38735. zmax: number;
  38736. subdivisions?: {
  38737. w: number;
  38738. h: number;
  38739. };
  38740. precision?: {
  38741. w: number;
  38742. h: number;
  38743. };
  38744. updatable?: boolean;
  38745. }, scene?: Nullable<Scene>): Mesh;
  38746. /**
  38747. * Creates a ground mesh from a height map
  38748. * * The parameter `url` sets the URL of the height map image resource.
  38749. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38750. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38751. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38752. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38753. * * 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.
  38754. * * 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).
  38755. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38757. * @param name defines the name of the mesh
  38758. * @param url defines the url to the height map
  38759. * @param options defines the options used to create the mesh
  38760. * @param scene defines the hosting scene
  38761. * @returns the ground mesh
  38762. * @see https://doc.babylonjs.com/babylon101/height_map
  38763. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38764. */
  38765. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38766. width?: number;
  38767. height?: number;
  38768. subdivisions?: number;
  38769. minHeight?: number;
  38770. maxHeight?: number;
  38771. colorFilter?: Color3;
  38772. alphaFilter?: number;
  38773. updatable?: boolean;
  38774. onReady?: (mesh: GroundMesh) => void;
  38775. }, scene?: Nullable<Scene>): GroundMesh;
  38776. }
  38777. }
  38778. declare module BABYLON {
  38779. /**
  38780. * Class containing static functions to help procedurally build meshes
  38781. */
  38782. export class TorusBuilder {
  38783. /**
  38784. * Creates a torus mesh
  38785. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38786. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38787. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38791. * @param name defines the name of the mesh
  38792. * @param options defines the options used to create the mesh
  38793. * @param scene defines the hosting scene
  38794. * @returns the torus mesh
  38795. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38796. */
  38797. static CreateTorus(name: string, options: {
  38798. diameter?: number;
  38799. thickness?: number;
  38800. tessellation?: number;
  38801. updatable?: boolean;
  38802. sideOrientation?: number;
  38803. frontUVs?: Vector4;
  38804. backUVs?: Vector4;
  38805. }, scene: any): Mesh;
  38806. }
  38807. }
  38808. declare module BABYLON {
  38809. /**
  38810. * Class containing static functions to help procedurally build meshes
  38811. */
  38812. export class CylinderBuilder {
  38813. /**
  38814. * Creates a cylinder or a cone mesh
  38815. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38816. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38817. * * 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.
  38818. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38819. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38820. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38821. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38822. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38823. * * 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).
  38824. * * 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
  38825. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38826. * * 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
  38827. * * 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.
  38828. * * If `enclose` is false, a ring surface is one element.
  38829. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38830. * * 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
  38831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38834. * @param name defines the name of the mesh
  38835. * @param options defines the options used to create the mesh
  38836. * @param scene defines the hosting scene
  38837. * @returns the cylinder mesh
  38838. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38839. */
  38840. static CreateCylinder(name: string, options: {
  38841. height?: number;
  38842. diameterTop?: number;
  38843. diameterBottom?: number;
  38844. diameter?: number;
  38845. tessellation?: number;
  38846. subdivisions?: number;
  38847. arc?: number;
  38848. faceColors?: Color4[];
  38849. faceUV?: Vector4[];
  38850. updatable?: boolean;
  38851. hasRings?: boolean;
  38852. enclose?: boolean;
  38853. sideOrientation?: number;
  38854. frontUVs?: Vector4;
  38855. backUVs?: Vector4;
  38856. }, scene: any): Mesh;
  38857. }
  38858. }
  38859. declare module BABYLON {
  38860. /**
  38861. * Manager for handling gamepads
  38862. */
  38863. export class GamepadManager {
  38864. private _scene?;
  38865. private _babylonGamepads;
  38866. private _oneGamepadConnected;
  38867. /** @hidden */ isMonitoring: boolean;
  38868. private _gamepadEventSupported;
  38869. private _gamepadSupport;
  38870. /**
  38871. * observable to be triggered when the gamepad controller has been connected
  38872. */
  38873. onGamepadConnectedObservable: Observable<Gamepad>;
  38874. /**
  38875. * observable to be triggered when the gamepad controller has been disconnected
  38876. */
  38877. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38878. private _onGamepadConnectedEvent;
  38879. private _onGamepadDisconnectedEvent;
  38880. /**
  38881. * Initializes the gamepad manager
  38882. * @param _scene BabylonJS scene
  38883. */
  38884. constructor(_scene?: Scene | undefined);
  38885. /**
  38886. * The gamepads in the game pad manager
  38887. */
  38888. readonly gamepads: Gamepad[];
  38889. /**
  38890. * Get the gamepad controllers based on type
  38891. * @param type The type of gamepad controller
  38892. * @returns Nullable gamepad
  38893. */
  38894. getGamepadByType(type?: number): Nullable<Gamepad>;
  38895. /**
  38896. * Disposes the gamepad manager
  38897. */
  38898. dispose(): void;
  38899. private _addNewGamepad;
  38900. private _startMonitoringGamepads;
  38901. private _stopMonitoringGamepads;
  38902. /** @hidden */ checkGamepadsStatus(): void;
  38903. private _updateGamepadObjects;
  38904. }
  38905. }
  38906. declare module BABYLON {
  38907. interface Scene {
  38908. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38909. /**
  38910. * Gets the gamepad manager associated with the scene
  38911. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38912. */
  38913. gamepadManager: GamepadManager;
  38914. }
  38915. /**
  38916. * Interface representing a free camera inputs manager
  38917. */
  38918. interface FreeCameraInputsManager {
  38919. /**
  38920. * Adds gamepad input support to the FreeCameraInputsManager.
  38921. * @returns the FreeCameraInputsManager
  38922. */
  38923. addGamepad(): FreeCameraInputsManager;
  38924. }
  38925. /**
  38926. * Interface representing an arc rotate camera inputs manager
  38927. */
  38928. interface ArcRotateCameraInputsManager {
  38929. /**
  38930. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38931. * @returns the camera inputs manager
  38932. */
  38933. addGamepad(): ArcRotateCameraInputsManager;
  38934. }
  38935. /**
  38936. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38937. */
  38938. export class GamepadSystemSceneComponent implements ISceneComponent {
  38939. /**
  38940. * The component name helpfull to identify the component in the list of scene components.
  38941. */
  38942. readonly name: string;
  38943. /**
  38944. * The scene the component belongs to.
  38945. */
  38946. scene: Scene;
  38947. /**
  38948. * Creates a new instance of the component for the given scene
  38949. * @param scene Defines the scene to register the component in
  38950. */
  38951. constructor(scene: Scene);
  38952. /**
  38953. * Registers the component in a given scene
  38954. */
  38955. register(): void;
  38956. /**
  38957. * Rebuilds the elements related to this component in case of
  38958. * context lost for instance.
  38959. */
  38960. rebuild(): void;
  38961. /**
  38962. * Disposes the component and the associated ressources
  38963. */
  38964. dispose(): void;
  38965. private _beforeCameraUpdate;
  38966. }
  38967. }
  38968. declare module BABYLON {
  38969. /**
  38970. * Options to modify the vr teleportation behavior.
  38971. */
  38972. export interface VRTeleportationOptions {
  38973. /**
  38974. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38975. */
  38976. floorMeshName?: string;
  38977. /**
  38978. * A list of meshes to be used as the teleportation floor. (default: empty)
  38979. */
  38980. floorMeshes?: Mesh[];
  38981. }
  38982. /**
  38983. * Options to modify the vr experience helper's behavior.
  38984. */
  38985. export interface VRExperienceHelperOptions extends WebVROptions {
  38986. /**
  38987. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38988. */
  38989. createDeviceOrientationCamera?: boolean;
  38990. /**
  38991. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38992. */
  38993. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38994. /**
  38995. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38996. */
  38997. laserToggle?: boolean;
  38998. /**
  38999. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39000. */
  39001. floorMeshes?: Mesh[];
  39002. /**
  39003. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39004. */
  39005. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39006. }
  39007. /**
  39008. * Event containing information after VR has been entered
  39009. */
  39010. export class OnAfterEnteringVRObservableEvent {
  39011. /**
  39012. * If entering vr was successful
  39013. */
  39014. success: boolean;
  39015. }
  39016. /**
  39017. * Helps to quickly add VR support to an existing scene.
  39018. * See http://doc.babylonjs.com/how_to/webvr_helper
  39019. */
  39020. export class VRExperienceHelper {
  39021. /** Options to modify the vr experience helper's behavior. */
  39022. webVROptions: VRExperienceHelperOptions;
  39023. private _scene;
  39024. private _position;
  39025. private _btnVR;
  39026. private _btnVRDisplayed;
  39027. private _webVRsupported;
  39028. private _webVRready;
  39029. private _webVRrequesting;
  39030. private _webVRpresenting;
  39031. private _hasEnteredVR;
  39032. private _fullscreenVRpresenting;
  39033. private _canvas;
  39034. private _webVRCamera;
  39035. private _vrDeviceOrientationCamera;
  39036. private _deviceOrientationCamera;
  39037. private _existingCamera;
  39038. private _onKeyDown;
  39039. private _onVrDisplayPresentChange;
  39040. private _onVRDisplayChanged;
  39041. private _onVRRequestPresentStart;
  39042. private _onVRRequestPresentComplete;
  39043. /**
  39044. * Observable raised right before entering VR.
  39045. */
  39046. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39047. /**
  39048. * Observable raised when entering VR has completed.
  39049. */
  39050. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39051. /**
  39052. * Observable raised when exiting VR.
  39053. */
  39054. onExitingVRObservable: Observable<VRExperienceHelper>;
  39055. /**
  39056. * Observable raised when controller mesh is loaded.
  39057. */
  39058. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39059. /** Return this.onEnteringVRObservable
  39060. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39061. */
  39062. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39063. /** Return this.onExitingVRObservable
  39064. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39065. */
  39066. readonly onExitingVR: Observable<VRExperienceHelper>;
  39067. /** Return this.onControllerMeshLoadedObservable
  39068. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39069. */
  39070. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39071. private _rayLength;
  39072. private _useCustomVRButton;
  39073. private _teleportationRequested;
  39074. private _teleportActive;
  39075. private _floorMeshName;
  39076. private _floorMeshesCollection;
  39077. private _rotationAllowed;
  39078. private _teleportBackwardsVector;
  39079. private _teleportationTarget;
  39080. private _isDefaultTeleportationTarget;
  39081. private _postProcessMove;
  39082. private _teleportationFillColor;
  39083. private _teleportationBorderColor;
  39084. private _rotationAngle;
  39085. private _haloCenter;
  39086. private _cameraGazer;
  39087. private _padSensibilityUp;
  39088. private _padSensibilityDown;
  39089. private _leftController;
  39090. private _rightController;
  39091. /**
  39092. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39093. */
  39094. onNewMeshSelected: Observable<AbstractMesh>;
  39095. /**
  39096. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39097. */
  39098. onNewMeshPicked: Observable<PickingInfo>;
  39099. private _circleEase;
  39100. /**
  39101. * Observable raised before camera teleportation
  39102. */
  39103. onBeforeCameraTeleport: Observable<Vector3>;
  39104. /**
  39105. * Observable raised after camera teleportation
  39106. */
  39107. onAfterCameraTeleport: Observable<Vector3>;
  39108. /**
  39109. * Observable raised when current selected mesh gets unselected
  39110. */
  39111. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39112. private _raySelectionPredicate;
  39113. /**
  39114. * To be optionaly changed by user to define custom ray selection
  39115. */
  39116. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39117. /**
  39118. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39119. */
  39120. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39121. /**
  39122. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39123. */
  39124. teleportationEnabled: boolean;
  39125. private _defaultHeight;
  39126. private _teleportationInitialized;
  39127. private _interactionsEnabled;
  39128. private _interactionsRequested;
  39129. private _displayGaze;
  39130. private _displayLaserPointer;
  39131. /**
  39132. * The mesh used to display where the user is going to teleport.
  39133. */
  39134. /**
  39135. * Sets the mesh to be used to display where the user is going to teleport.
  39136. */
  39137. teleportationTarget: Mesh;
  39138. /**
  39139. * 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
  39140. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39141. * See http://doc.babylonjs.com/resources/baking_transformations
  39142. */
  39143. gazeTrackerMesh: Mesh;
  39144. /**
  39145. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39146. */
  39147. updateGazeTrackerScale: boolean;
  39148. /**
  39149. * If the gaze trackers color should be updated when selecting meshes
  39150. */
  39151. updateGazeTrackerColor: boolean;
  39152. /**
  39153. * The gaze tracking mesh corresponding to the left controller
  39154. */
  39155. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39156. /**
  39157. * The gaze tracking mesh corresponding to the right controller
  39158. */
  39159. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39160. /**
  39161. * If the ray of the gaze should be displayed.
  39162. */
  39163. /**
  39164. * Sets if the ray of the gaze should be displayed.
  39165. */
  39166. displayGaze: boolean;
  39167. /**
  39168. * If the ray of the LaserPointer should be displayed.
  39169. */
  39170. /**
  39171. * Sets if the ray of the LaserPointer should be displayed.
  39172. */
  39173. displayLaserPointer: boolean;
  39174. /**
  39175. * The deviceOrientationCamera used as the camera when not in VR.
  39176. */
  39177. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39178. /**
  39179. * Based on the current WebVR support, returns the current VR camera used.
  39180. */
  39181. readonly currentVRCamera: Nullable<Camera>;
  39182. /**
  39183. * The webVRCamera which is used when in VR.
  39184. */
  39185. readonly webVRCamera: WebVRFreeCamera;
  39186. /**
  39187. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39188. */
  39189. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39190. private readonly _teleportationRequestInitiated;
  39191. /**
  39192. * Defines wether or not Pointer lock should be requested when switching to
  39193. * full screen.
  39194. */
  39195. requestPointerLockOnFullScreen: boolean;
  39196. /**
  39197. * Instantiates a VRExperienceHelper.
  39198. * Helps to quickly add VR support to an existing scene.
  39199. * @param scene The scene the VRExperienceHelper belongs to.
  39200. * @param webVROptions Options to modify the vr experience helper's behavior.
  39201. */
  39202. constructor(scene: Scene,
  39203. /** Options to modify the vr experience helper's behavior. */
  39204. webVROptions?: VRExperienceHelperOptions);
  39205. private _onDefaultMeshLoaded;
  39206. private _onResize;
  39207. private _onFullscreenChange;
  39208. /**
  39209. * Gets a value indicating if we are currently in VR mode.
  39210. */
  39211. readonly isInVRMode: boolean;
  39212. private onVrDisplayPresentChange;
  39213. private onVRDisplayChanged;
  39214. private moveButtonToBottomRight;
  39215. private displayVRButton;
  39216. private updateButtonVisibility;
  39217. private _cachedAngularSensibility;
  39218. /**
  39219. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39220. * Otherwise, will use the fullscreen API.
  39221. */
  39222. enterVR(): void;
  39223. /**
  39224. * Attempt to exit VR, or fullscreen.
  39225. */
  39226. exitVR(): void;
  39227. /**
  39228. * The position of the vr experience helper.
  39229. */
  39230. /**
  39231. * Sets the position of the vr experience helper.
  39232. */
  39233. position: Vector3;
  39234. /**
  39235. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39236. */
  39237. enableInteractions(): void;
  39238. private readonly _noControllerIsActive;
  39239. private beforeRender;
  39240. private _isTeleportationFloor;
  39241. /**
  39242. * Adds a floor mesh to be used for teleportation.
  39243. * @param floorMesh the mesh to be used for teleportation.
  39244. */
  39245. addFloorMesh(floorMesh: Mesh): void;
  39246. /**
  39247. * Removes a floor mesh from being used for teleportation.
  39248. * @param floorMesh the mesh to be removed.
  39249. */
  39250. removeFloorMesh(floorMesh: Mesh): void;
  39251. /**
  39252. * Enables interactions and teleportation using the VR controllers and gaze.
  39253. * @param vrTeleportationOptions options to modify teleportation behavior.
  39254. */
  39255. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39256. private _onNewGamepadConnected;
  39257. private _tryEnableInteractionOnController;
  39258. private _onNewGamepadDisconnected;
  39259. private _enableInteractionOnController;
  39260. private _checkTeleportWithRay;
  39261. private _checkRotate;
  39262. private _checkTeleportBackwards;
  39263. private _enableTeleportationOnController;
  39264. private _createTeleportationCircles;
  39265. private _displayTeleportationTarget;
  39266. private _hideTeleportationTarget;
  39267. private _rotateCamera;
  39268. private _moveTeleportationSelectorTo;
  39269. private _workingVector;
  39270. private _workingQuaternion;
  39271. private _workingMatrix;
  39272. /**
  39273. * Teleports the users feet to the desired location
  39274. * @param location The location where the user's feet should be placed
  39275. */
  39276. teleportCamera(location: Vector3): void;
  39277. private _convertNormalToDirectionOfRay;
  39278. private _castRayAndSelectObject;
  39279. private _notifySelectedMeshUnselected;
  39280. /**
  39281. * Sets the color of the laser ray from the vr controllers.
  39282. * @param color new color for the ray.
  39283. */
  39284. changeLaserColor(color: Color3): void;
  39285. /**
  39286. * Sets the color of the ray from the vr headsets gaze.
  39287. * @param color new color for the ray.
  39288. */
  39289. changeGazeColor(color: Color3): void;
  39290. /**
  39291. * Exits VR and disposes of the vr experience helper
  39292. */
  39293. dispose(): void;
  39294. /**
  39295. * Gets the name of the VRExperienceHelper class
  39296. * @returns "VRExperienceHelper"
  39297. */
  39298. getClassName(): string;
  39299. }
  39300. }
  39301. declare module BABYLON {
  39302. /**
  39303. * Manages an XRSession
  39304. * @see https://doc.babylonjs.com/how_to/webxr
  39305. */
  39306. export class WebXRSessionManager implements IDisposable {
  39307. private scene;
  39308. /**
  39309. * Fires every time a new xrFrame arrives which can be used to update the camera
  39310. */
  39311. onXRFrameObservable: Observable<any>;
  39312. /**
  39313. * Fires when the xr session is ended either by the device or manually done
  39314. */
  39315. onXRSessionEnded: Observable<any>;
  39316. /** @hidden */ xrSession: XRSession;
  39317. /** @hidden */ frameOfReference: XRFrameOfReference;
  39318. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39319. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39320. private _xrNavigator;
  39321. private _xrDevice;
  39322. private _tmpMatrix;
  39323. /**
  39324. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39325. * @param scene The scene which the session should be created for
  39326. */
  39327. constructor(scene: Scene);
  39328. /**
  39329. * Initializes the manager
  39330. * After initialization enterXR can be called to start an XR session
  39331. * @returns Promise which resolves after it is initialized
  39332. */
  39333. initializeAsync(): Promise<void>;
  39334. /**
  39335. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39336. * @param sessionCreationOptions xr options to create the session with
  39337. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39338. * @returns Promise which resolves after it enters XR
  39339. */
  39340. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39341. /**
  39342. * Stops the xrSession and restores the renderloop
  39343. * @returns Promise which resolves after it exits XR
  39344. */
  39345. exitXRAsync(): Promise<void>;
  39346. /**
  39347. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39348. * @param ray ray to cast into the environment
  39349. * @returns Promise which resolves with a collision point in the environment if it exists
  39350. */
  39351. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39352. /**
  39353. * Checks if a session would be supported for the creation options specified
  39354. * @param options creation options to check if they are supported
  39355. * @returns true if supported
  39356. */
  39357. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39358. /**
  39359. * @hidden
  39360. * Converts the render layer of xrSession to a render target
  39361. * @param session session to create render target for
  39362. * @param scene scene the new render target should be created for
  39363. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39364. /**
  39365. * Disposes of the session manager
  39366. */
  39367. dispose(): void;
  39368. }
  39369. }
  39370. declare module BABYLON {
  39371. /**
  39372. * WebXR Camera which holds the views for the xrSession
  39373. * @see https://doc.babylonjs.com/how_to/webxr
  39374. */
  39375. export class WebXRCamera extends FreeCamera {
  39376. private static _TmpMatrix;
  39377. /**
  39378. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39379. * @param name the name of the camera
  39380. * @param scene the scene to add the camera to
  39381. */
  39382. constructor(name: string, scene: Scene);
  39383. private _updateNumberOfRigCameras;
  39384. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39385. /**
  39386. * Updates the cameras position from the current pose information of the XR session
  39387. * @param xrSessionManager the session containing pose information
  39388. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39389. */
  39390. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39391. }
  39392. }
  39393. declare module BABYLON {
  39394. /**
  39395. * States of the webXR experience
  39396. */
  39397. export enum WebXRState {
  39398. /**
  39399. * Transitioning to being in XR mode
  39400. */
  39401. ENTERING_XR = 0,
  39402. /**
  39403. * Transitioning to non XR mode
  39404. */
  39405. EXITING_XR = 1,
  39406. /**
  39407. * In XR mode and presenting
  39408. */
  39409. IN_XR = 2,
  39410. /**
  39411. * Not entered XR mode
  39412. */
  39413. NOT_IN_XR = 3
  39414. }
  39415. /**
  39416. * Helper class used to enable XR
  39417. * @see https://doc.babylonjs.com/how_to/webxr
  39418. */
  39419. export class WebXRExperienceHelper implements IDisposable {
  39420. private scene;
  39421. /**
  39422. * 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
  39423. */
  39424. container: AbstractMesh;
  39425. /**
  39426. * Camera used to render xr content
  39427. */
  39428. camera: WebXRCamera;
  39429. /**
  39430. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39431. */
  39432. state: WebXRState;
  39433. private _setState;
  39434. private static _TmpVector;
  39435. /**
  39436. * Fires when the state of the experience helper has changed
  39437. */
  39438. onStateChangedObservable: Observable<WebXRState>;
  39439. /** @hidden */ sessionManager: WebXRSessionManager;
  39440. private _nonVRCamera;
  39441. private _originalSceneAutoClear;
  39442. private _supported;
  39443. /**
  39444. * Creates the experience helper
  39445. * @param scene the scene to attach the experience helper to
  39446. * @returns a promise for the experience helper
  39447. */
  39448. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39449. /**
  39450. * Creates a WebXRExperienceHelper
  39451. * @param scene The scene the helper should be created in
  39452. */
  39453. private constructor();
  39454. /**
  39455. * Exits XR mode and returns the scene to its original state
  39456. * @returns promise that resolves after xr mode has exited
  39457. */
  39458. exitXRAsync(): Promise<void>;
  39459. /**
  39460. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39461. * @param sessionCreationOptions options for the XR session
  39462. * @param frameOfReference frame of reference of the XR session
  39463. * @returns promise that resolves after xr mode has entered
  39464. */
  39465. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39466. /**
  39467. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39468. * @param ray ray to cast into the environment
  39469. * @returns Promise which resolves with a collision point in the environment if it exists
  39470. */
  39471. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39472. /**
  39473. * Updates the global position of the camera by moving the camera's container
  39474. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39475. * @param position The desired global position of the camera
  39476. */
  39477. setPositionOfCameraUsingContainer(position: Vector3): void;
  39478. /**
  39479. * Rotates the xr camera by rotating the camera's container around the camera's position
  39480. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39481. * @param rotation the desired quaternion rotation to apply to the camera
  39482. */
  39483. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39484. /**
  39485. * Checks if the creation options are supported by the xr session
  39486. * @param options creation options
  39487. * @returns true if supported
  39488. */
  39489. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39490. /**
  39491. * Disposes of the experience helper
  39492. */
  39493. dispose(): void;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * Button which can be used to enter a different mode of XR
  39499. */
  39500. export class WebXREnterExitUIButton {
  39501. /** button element */
  39502. element: HTMLElement;
  39503. /** XR initialization options for the button */
  39504. initializationOptions: XRSessionCreationOptions;
  39505. /**
  39506. * Creates a WebXREnterExitUIButton
  39507. * @param element button element
  39508. * @param initializationOptions XR initialization options for the button
  39509. */
  39510. constructor(
  39511. /** button element */
  39512. element: HTMLElement,
  39513. /** XR initialization options for the button */
  39514. initializationOptions: XRSessionCreationOptions);
  39515. /**
  39516. * Overwritable function which can be used to update the button's visuals when the state changes
  39517. * @param activeButton the current active button in the UI
  39518. */
  39519. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39520. }
  39521. /**
  39522. * Options to create the webXR UI
  39523. */
  39524. export class WebXREnterExitUIOptions {
  39525. /**
  39526. * Context to enter xr with
  39527. */
  39528. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39529. /**
  39530. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39531. */
  39532. customButtons?: Array<WebXREnterExitUIButton>;
  39533. }
  39534. /**
  39535. * UI to allow the user to enter/exit XR mode
  39536. */
  39537. export class WebXREnterExitUI implements IDisposable {
  39538. private scene;
  39539. private _overlay;
  39540. private _buttons;
  39541. private _activeButton;
  39542. /**
  39543. * Fired every time the active button is changed.
  39544. *
  39545. * When xr is entered via a button that launches xr that button will be the callback parameter
  39546. *
  39547. * When exiting xr the callback parameter will be null)
  39548. */
  39549. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39550. /**
  39551. * Creates UI to allow the user to enter/exit XR mode
  39552. * @param scene the scene to add the ui to
  39553. * @param helper the xr experience helper to enter/exit xr with
  39554. * @param options options to configure the UI
  39555. * @returns the created ui
  39556. */
  39557. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39558. private constructor();
  39559. private _updateButtons;
  39560. /**
  39561. * Disposes of the object
  39562. */
  39563. dispose(): void;
  39564. }
  39565. }
  39566. declare module BABYLON {
  39567. /**
  39568. * Represents an XR input
  39569. */
  39570. export class WebXRController {
  39571. /**
  39572. * 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
  39573. */
  39574. grip?: AbstractMesh;
  39575. /**
  39576. * Pointer which can be used to select objects or attach a visible laser to
  39577. */
  39578. pointer: AbstractMesh;
  39579. /**
  39580. * Creates the controller
  39581. * @see https://doc.babylonjs.com/how_to/webxr
  39582. * @param scene the scene which the controller should be associated to
  39583. */
  39584. constructor(scene: Scene);
  39585. /**
  39586. * Disposes of the object
  39587. */
  39588. dispose(): void;
  39589. }
  39590. /**
  39591. * XR input used to track XR inputs such as controllers/rays
  39592. */
  39593. export class WebXRInput implements IDisposable {
  39594. private helper;
  39595. /**
  39596. * XR controllers being tracked
  39597. */
  39598. controllers: Array<WebXRController>;
  39599. private _tmpMatrix;
  39600. private _frameObserver;
  39601. /**
  39602. * Initializes the WebXRInput
  39603. * @param helper experience helper which the input should be created for
  39604. */
  39605. constructor(helper: WebXRExperienceHelper);
  39606. /**
  39607. * Disposes of the object
  39608. */
  39609. dispose(): void;
  39610. }
  39611. }
  39612. declare module BABYLON {
  39613. /**
  39614. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39615. */
  39616. export class WebXRManagedOutputCanvas implements IDisposable {
  39617. private _canvas;
  39618. /**
  39619. * xrpresent context of the canvas which can be used to display/mirror xr content
  39620. */
  39621. canvasContext: Nullable<WebGLRenderingContext>;
  39622. /**
  39623. * Initializes the canvas to be added/removed upon entering/exiting xr
  39624. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39625. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39626. */
  39627. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39628. /**
  39629. * Disposes of the object
  39630. */
  39631. dispose(): void;
  39632. private _setManagedOutputCanvas;
  39633. private _addCanvas;
  39634. private _removeCanvas;
  39635. }
  39636. }
  39637. declare module BABYLON {
  39638. /**
  39639. * Contains an array of blocks representing the octree
  39640. */
  39641. export interface IOctreeContainer<T> {
  39642. /**
  39643. * Blocks within the octree
  39644. */
  39645. blocks: Array<OctreeBlock<T>>;
  39646. }
  39647. /**
  39648. * Class used to store a cell in an octree
  39649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39650. */
  39651. export class OctreeBlock<T> {
  39652. /**
  39653. * Gets the content of the current block
  39654. */
  39655. entries: T[];
  39656. /**
  39657. * Gets the list of block children
  39658. */
  39659. blocks: Array<OctreeBlock<T>>;
  39660. private _depth;
  39661. private _maxDepth;
  39662. private _capacity;
  39663. private _minPoint;
  39664. private _maxPoint;
  39665. private _boundingVectors;
  39666. private _creationFunc;
  39667. /**
  39668. * Creates a new block
  39669. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39670. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39671. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39672. * @param depth defines the current depth of this block in the octree
  39673. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39674. * @param creationFunc defines a callback to call when an element is added to the block
  39675. */
  39676. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39677. /**
  39678. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39679. */
  39680. readonly capacity: number;
  39681. /**
  39682. * Gets the minimum vector (in world space) of the block's bounding box
  39683. */
  39684. readonly minPoint: Vector3;
  39685. /**
  39686. * Gets the maximum vector (in world space) of the block's bounding box
  39687. */
  39688. readonly maxPoint: Vector3;
  39689. /**
  39690. * Add a new element to this block
  39691. * @param entry defines the element to add
  39692. */
  39693. addEntry(entry: T): void;
  39694. /**
  39695. * Remove an element from this block
  39696. * @param entry defines the element to remove
  39697. */
  39698. removeEntry(entry: T): void;
  39699. /**
  39700. * Add an array of elements to this block
  39701. * @param entries defines the array of elements to add
  39702. */
  39703. addEntries(entries: T[]): void;
  39704. /**
  39705. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39706. * @param frustumPlanes defines the frustum planes to test
  39707. * @param selection defines the array to store current content if selection is positive
  39708. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39709. */
  39710. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39711. /**
  39712. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39713. * @param sphereCenter defines the bounding sphere center
  39714. * @param sphereRadius defines the bounding sphere radius
  39715. * @param selection defines the array to store current content if selection is positive
  39716. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39717. */
  39718. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39719. /**
  39720. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39721. * @param ray defines the ray to test with
  39722. * @param selection defines the array to store current content if selection is positive
  39723. */
  39724. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39725. /**
  39726. * Subdivide the content into child blocks (this block will then be empty)
  39727. */
  39728. createInnerBlocks(): void;
  39729. /**
  39730. * @hidden
  39731. */ 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;
  39732. }
  39733. }
  39734. declare module BABYLON {
  39735. /**
  39736. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39737. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39738. */
  39739. export class Octree<T> {
  39740. /** 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.) */
  39741. maxDepth: number;
  39742. /**
  39743. * Blocks within the octree containing objects
  39744. */
  39745. blocks: Array<OctreeBlock<T>>;
  39746. /**
  39747. * Content stored in the octree
  39748. */
  39749. dynamicContent: T[];
  39750. private _maxBlockCapacity;
  39751. private _selectionContent;
  39752. private _creationFunc;
  39753. /**
  39754. * Creates a octree
  39755. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39756. * @param creationFunc function to be used to instatiate the octree
  39757. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39758. * @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.)
  39759. */
  39760. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39761. /** 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.) */
  39762. maxDepth?: number);
  39763. /**
  39764. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39765. * @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);
  39766. * @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);
  39767. * @param entries meshes to be added to the octree blocks
  39768. */
  39769. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39770. /**
  39771. * Adds a mesh to the octree
  39772. * @param entry Mesh to add to the octree
  39773. */
  39774. addMesh(entry: T): void;
  39775. /**
  39776. * Remove an element from the octree
  39777. * @param entry defines the element to remove
  39778. */
  39779. removeMesh(entry: T): void;
  39780. /**
  39781. * Selects an array of meshes within the frustum
  39782. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39783. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39784. * @returns array of meshes within the frustum
  39785. */
  39786. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39787. /**
  39788. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39789. * @param sphereCenter defines the bounding sphere center
  39790. * @param sphereRadius defines the bounding sphere radius
  39791. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39792. * @returns an array of objects that intersect the sphere
  39793. */
  39794. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39795. /**
  39796. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39797. * @param ray defines the ray to test with
  39798. * @returns array of intersected objects
  39799. */
  39800. intersectsRay(ray: Ray): SmartArray<T>;
  39801. /**
  39802. * Adds a mesh into the octree block if it intersects the block
  39803. */
  39804. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39805. /**
  39806. * Adds a submesh into the octree block if it intersects the block
  39807. */
  39808. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39809. }
  39810. }
  39811. declare module BABYLON {
  39812. interface Scene {
  39813. /**
  39814. * @hidden
  39815. * Backing Filed
  39816. */ selectionOctree: Octree<AbstractMesh>;
  39817. /**
  39818. * Gets the octree used to boost mesh selection (picking)
  39819. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39820. */
  39821. selectionOctree: Octree<AbstractMesh>;
  39822. /**
  39823. * Creates or updates the octree used to boost selection (picking)
  39824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39825. * @param maxCapacity defines the maximum capacity per leaf
  39826. * @param maxDepth defines the maximum depth of the octree
  39827. * @returns an octree of AbstractMesh
  39828. */
  39829. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39830. }
  39831. interface AbstractMesh {
  39832. /**
  39833. * @hidden
  39834. * Backing Field
  39835. */ submeshesOctree: Octree<SubMesh>;
  39836. /**
  39837. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39838. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39839. * @param maxCapacity defines the maximum size of each block (64 by default)
  39840. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39841. * @returns the new octree
  39842. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39843. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39844. */
  39845. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39846. }
  39847. /**
  39848. * Defines the octree scene component responsible to manage any octrees
  39849. * in a given scene.
  39850. */
  39851. export class OctreeSceneComponent {
  39852. /**
  39853. * The component name help to identify the component in the list of scene components.
  39854. */
  39855. readonly name: string;
  39856. /**
  39857. * The scene the component belongs to.
  39858. */
  39859. scene: Scene;
  39860. /**
  39861. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39862. */
  39863. readonly checksIsEnabled: boolean;
  39864. /**
  39865. * Creates a new instance of the component for the given scene
  39866. * @param scene Defines the scene to register the component in
  39867. */
  39868. constructor(scene: Scene);
  39869. /**
  39870. * Registers the component in a given scene
  39871. */
  39872. register(): void;
  39873. /**
  39874. * Return the list of active meshes
  39875. * @returns the list of active meshes
  39876. */
  39877. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39878. /**
  39879. * Return the list of active sub meshes
  39880. * @param mesh The mesh to get the candidates sub meshes from
  39881. * @returns the list of active sub meshes
  39882. */
  39883. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39884. private _tempRay;
  39885. /**
  39886. * Return the list of sub meshes intersecting with a given local ray
  39887. * @param mesh defines the mesh to find the submesh for
  39888. * @param localRay defines the ray in local space
  39889. * @returns the list of intersecting sub meshes
  39890. */
  39891. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39892. /**
  39893. * Return the list of sub meshes colliding with a collider
  39894. * @param mesh defines the mesh to find the submesh for
  39895. * @param collider defines the collider to evaluate the collision against
  39896. * @returns the list of colliding sub meshes
  39897. */
  39898. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39899. /**
  39900. * Rebuilds the elements related to this component in case of
  39901. * context lost for instance.
  39902. */
  39903. rebuild(): void;
  39904. /**
  39905. * Disposes the component and the associated ressources.
  39906. */
  39907. dispose(): void;
  39908. }
  39909. }
  39910. declare module BABYLON {
  39911. /**
  39912. * Renders a layer on top of an existing scene
  39913. */
  39914. export class UtilityLayerRenderer implements IDisposable {
  39915. /** the original scene that will be rendered on top of */
  39916. originalScene: Scene;
  39917. private _pointerCaptures;
  39918. private _lastPointerEvents;
  39919. private static _DefaultUtilityLayer;
  39920. private static _DefaultKeepDepthUtilityLayer;
  39921. private _sharedGizmoLight;
  39922. /**
  39923. * @hidden
  39924. * Light which used by gizmos to get light shading
  39925. */ getSharedGizmoLight(): HemisphericLight;
  39926. /**
  39927. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39928. */
  39929. pickUtilitySceneFirst: boolean;
  39930. /**
  39931. * 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)
  39932. */
  39933. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39934. /**
  39935. * 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)
  39936. */
  39937. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39938. /**
  39939. * The scene that is rendered on top of the original scene
  39940. */
  39941. utilityLayerScene: Scene;
  39942. /**
  39943. * If the utility layer should automatically be rendered on top of existing scene
  39944. */
  39945. shouldRender: boolean;
  39946. /**
  39947. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39948. */
  39949. onlyCheckPointerDownEvents: boolean;
  39950. /**
  39951. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39952. */
  39953. processAllEvents: boolean;
  39954. /**
  39955. * Observable raised when the pointer move from the utility layer scene to the main scene
  39956. */
  39957. onPointerOutObservable: Observable<number>;
  39958. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39959. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39960. private _afterRenderObserver;
  39961. private _sceneDisposeObserver;
  39962. private _originalPointerObserver;
  39963. /**
  39964. * Instantiates a UtilityLayerRenderer
  39965. * @param originalScene the original scene that will be rendered on top of
  39966. * @param handleEvents boolean indicating if the utility layer should handle events
  39967. */
  39968. constructor(
  39969. /** the original scene that will be rendered on top of */
  39970. originalScene: Scene, handleEvents?: boolean);
  39971. private _notifyObservers;
  39972. /**
  39973. * Renders the utility layers scene on top of the original scene
  39974. */
  39975. render(): void;
  39976. /**
  39977. * Disposes of the renderer
  39978. */
  39979. dispose(): void;
  39980. private _updateCamera;
  39981. }
  39982. }
  39983. declare module BABYLON {
  39984. /**
  39985. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39986. */
  39987. export class Gizmo implements IDisposable {
  39988. /** The utility layer the gizmo will be added to */
  39989. gizmoLayer: UtilityLayerRenderer;
  39990. /**
  39991. * The root mesh of the gizmo
  39992. */ rootMesh: Mesh;
  39993. private _attachedMesh;
  39994. /**
  39995. * Ratio for the scale of the gizmo (Default: 1)
  39996. */
  39997. scaleRatio: number;
  39998. /**
  39999. * If a custom mesh has been set (Default: false)
  40000. */
  40001. protected _customMeshSet: boolean;
  40002. /**
  40003. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40004. * * When set, interactions will be enabled
  40005. */
  40006. attachedMesh: Nullable<AbstractMesh>;
  40007. /**
  40008. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40009. * @param mesh The mesh to replace the default mesh of the gizmo
  40010. */
  40011. setCustomMesh(mesh: Mesh): void;
  40012. /**
  40013. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40014. */
  40015. updateGizmoRotationToMatchAttachedMesh: boolean;
  40016. /**
  40017. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40018. */
  40019. updateGizmoPositionToMatchAttachedMesh: boolean;
  40020. /**
  40021. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40022. */
  40023. protected _updateScale: boolean;
  40024. protected _interactionsEnabled: boolean;
  40025. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40026. private _beforeRenderObserver;
  40027. private _tempVector;
  40028. /**
  40029. * Creates a gizmo
  40030. * @param gizmoLayer The utility layer the gizmo will be added to
  40031. */
  40032. constructor(
  40033. /** The utility layer the gizmo will be added to */
  40034. gizmoLayer?: UtilityLayerRenderer);
  40035. /**
  40036. * Updates the gizmo to match the attached mesh's position/rotation
  40037. */
  40038. protected _update(): void;
  40039. /**
  40040. * Disposes of the gizmo
  40041. */
  40042. dispose(): void;
  40043. }
  40044. }
  40045. declare module BABYLON {
  40046. /**
  40047. * Single axis drag gizmo
  40048. */
  40049. export class AxisDragGizmo extends Gizmo {
  40050. /**
  40051. * Drag behavior responsible for the gizmos dragging interactions
  40052. */
  40053. dragBehavior: PointerDragBehavior;
  40054. private _pointerObserver;
  40055. /**
  40056. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40057. */
  40058. snapDistance: number;
  40059. /**
  40060. * Event that fires each time the gizmo snaps to a new location.
  40061. * * snapDistance is the the change in distance
  40062. */
  40063. onSnapObservable: Observable<{
  40064. snapDistance: number;
  40065. }>;
  40066. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40067. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40068. /**
  40069. * Creates an AxisDragGizmo
  40070. * @param gizmoLayer The utility layer the gizmo will be added to
  40071. * @param dragAxis The axis which the gizmo will be able to drag on
  40072. * @param color The color of the gizmo
  40073. */
  40074. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40076. /**
  40077. * Disposes of the gizmo
  40078. */
  40079. dispose(): void;
  40080. }
  40081. }
  40082. declare module BABYLON.Debug {
  40083. /**
  40084. * The Axes viewer will show 3 axes in a specific point in space
  40085. */
  40086. export class AxesViewer {
  40087. private _xAxis;
  40088. private _yAxis;
  40089. private _zAxis;
  40090. private _scaleLinesFactor;
  40091. private _instanced;
  40092. /**
  40093. * Gets the hosting scene
  40094. */
  40095. scene: Scene;
  40096. /**
  40097. * Gets or sets a number used to scale line length
  40098. */
  40099. scaleLines: number;
  40100. /** Gets the node hierarchy used to render x-axis */
  40101. readonly xAxis: TransformNode;
  40102. /** Gets the node hierarchy used to render y-axis */
  40103. readonly yAxis: TransformNode;
  40104. /** Gets the node hierarchy used to render z-axis */
  40105. readonly zAxis: TransformNode;
  40106. /**
  40107. * Creates a new AxesViewer
  40108. * @param scene defines the hosting scene
  40109. * @param scaleLines defines a number used to scale line length (1 by default)
  40110. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40111. * @param xAxis defines the node hierarchy used to render the x-axis
  40112. * @param yAxis defines the node hierarchy used to render the y-axis
  40113. * @param zAxis defines the node hierarchy used to render the z-axis
  40114. */
  40115. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40116. /**
  40117. * Force the viewer to update
  40118. * @param position defines the position of the viewer
  40119. * @param xaxis defines the x axis of the viewer
  40120. * @param yaxis defines the y axis of the viewer
  40121. * @param zaxis defines the z axis of the viewer
  40122. */
  40123. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40124. /**
  40125. * Creates an instance of this axes viewer.
  40126. * @returns a new axes viewer with instanced meshes
  40127. */
  40128. createInstance(): AxesViewer;
  40129. /** Releases resources */
  40130. dispose(): void;
  40131. private static _SetRenderingGroupId;
  40132. }
  40133. }
  40134. declare module BABYLON.Debug {
  40135. /**
  40136. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40137. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40138. */
  40139. export class BoneAxesViewer extends AxesViewer {
  40140. /**
  40141. * Gets or sets the target mesh where to display the axes viewer
  40142. */
  40143. mesh: Nullable<Mesh>;
  40144. /**
  40145. * Gets or sets the target bone where to display the axes viewer
  40146. */
  40147. bone: Nullable<Bone>;
  40148. /** Gets current position */
  40149. pos: Vector3;
  40150. /** Gets direction of X axis */
  40151. xaxis: Vector3;
  40152. /** Gets direction of Y axis */
  40153. yaxis: Vector3;
  40154. /** Gets direction of Z axis */
  40155. zaxis: Vector3;
  40156. /**
  40157. * Creates a new BoneAxesViewer
  40158. * @param scene defines the hosting scene
  40159. * @param bone defines the target bone
  40160. * @param mesh defines the target mesh
  40161. * @param scaleLines defines a scaling factor for line length (1 by default)
  40162. */
  40163. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40164. /**
  40165. * Force the viewer to update
  40166. */
  40167. update(): void;
  40168. /** Releases resources */
  40169. dispose(): void;
  40170. }
  40171. }
  40172. declare module BABYLON {
  40173. /**
  40174. * Interface used to define scene explorer extensibility option
  40175. */
  40176. export interface IExplorerExtensibilityOption {
  40177. /**
  40178. * Define the option label
  40179. */
  40180. label: string;
  40181. /**
  40182. * Defines the action to execute on click
  40183. */
  40184. action: (entity: any) => void;
  40185. }
  40186. /**
  40187. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40188. */
  40189. export interface IExplorerExtensibilityGroup {
  40190. /**
  40191. * Defines a predicate to test if a given type mut be extended
  40192. */
  40193. predicate: (entity: any) => boolean;
  40194. /**
  40195. * Gets the list of options added to a type
  40196. */
  40197. entries: IExplorerExtensibilityOption[];
  40198. }
  40199. /**
  40200. * Interface used to define the options to use to create the Inspector
  40201. */
  40202. export interface IInspectorOptions {
  40203. /**
  40204. * Display in overlay mode (default: false)
  40205. */
  40206. overlay?: boolean;
  40207. /**
  40208. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40209. */
  40210. globalRoot?: HTMLElement;
  40211. /**
  40212. * Display the Scene explorer
  40213. */
  40214. showExplorer?: boolean;
  40215. /**
  40216. * Display the property inspector
  40217. */
  40218. showInspector?: boolean;
  40219. /**
  40220. * Display in embed mode (both panes on the right)
  40221. */
  40222. embedMode?: boolean;
  40223. /**
  40224. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40225. */
  40226. handleResize?: boolean;
  40227. /**
  40228. * Allow the panes to popup (default: true)
  40229. */
  40230. enablePopup?: boolean;
  40231. /**
  40232. * Allow the panes to be closed by users (default: true)
  40233. */
  40234. enableClose?: boolean;
  40235. /**
  40236. * Optional list of extensibility entries
  40237. */
  40238. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40239. /**
  40240. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40241. */
  40242. inspectorURL?: string;
  40243. }
  40244. interface Scene {
  40245. /**
  40246. * @hidden
  40247. * Backing field
  40248. */ debugLayer: DebugLayer;
  40249. /**
  40250. * Gets the debug layer (aka Inspector) associated with the scene
  40251. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40252. */
  40253. debugLayer: DebugLayer;
  40254. }
  40255. /**
  40256. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40257. * what is happening in your scene
  40258. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40259. */
  40260. export class DebugLayer {
  40261. /**
  40262. * Define the url to get the inspector script from.
  40263. * By default it uses the babylonjs CDN.
  40264. * @ignoreNaming
  40265. */
  40266. static InspectorURL: string;
  40267. private _scene;
  40268. private BJSINSPECTOR;
  40269. /**
  40270. * Observable triggered when a property is changed through the inspector.
  40271. */
  40272. onPropertyChangedObservable: Observable<{
  40273. object: any;
  40274. property: string;
  40275. value: any;
  40276. initialValue: any;
  40277. }>;
  40278. /**
  40279. * Instantiates a new debug layer.
  40280. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40281. * what is happening in your scene
  40282. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40283. * @param scene Defines the scene to inspect
  40284. */
  40285. constructor(scene: Scene);
  40286. /** Creates the inspector window. */
  40287. private _createInspector;
  40288. /**
  40289. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40290. * @param entity defines the entity to select
  40291. * @param lineContainerTitle defines the specific block to highlight
  40292. */
  40293. select(entity: any, lineContainerTitle?: string): void;
  40294. /** Get the inspector from bundle or global */
  40295. private _getGlobalInspector;
  40296. /**
  40297. * Get if the inspector is visible or not.
  40298. * @returns true if visible otherwise, false
  40299. */
  40300. isVisible(): boolean;
  40301. /**
  40302. * Hide the inspector and close its window.
  40303. */
  40304. hide(): void;
  40305. /**
  40306. * Launch the debugLayer.
  40307. * @param config Define the configuration of the inspector
  40308. * @return a promise fulfilled when the debug layer is visible
  40309. */
  40310. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40311. }
  40312. }
  40313. declare module BABYLON {
  40314. /**
  40315. * Class containing static functions to help procedurally build meshes
  40316. */
  40317. export class BoxBuilder {
  40318. /**
  40319. * Creates a box mesh
  40320. * * The parameter `size` sets the size (float) of each box side (default 1)
  40321. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40322. * * 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)
  40323. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40327. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40328. * @param name defines the name of the mesh
  40329. * @param options defines the options used to create the mesh
  40330. * @param scene defines the hosting scene
  40331. * @returns the box mesh
  40332. */
  40333. static CreateBox(name: string, options: {
  40334. size?: number;
  40335. width?: number;
  40336. height?: number;
  40337. depth?: number;
  40338. faceUV?: Vector4[];
  40339. faceColors?: Color4[];
  40340. sideOrientation?: number;
  40341. frontUVs?: Vector4;
  40342. backUVs?: Vector4;
  40343. wrap?: boolean;
  40344. topBaseAt?: number;
  40345. bottomBaseAt?: number;
  40346. updatable?: boolean;
  40347. }, scene?: Nullable<Scene>): Mesh;
  40348. }
  40349. }
  40350. declare module BABYLON {
  40351. /**
  40352. * Class containing static functions to help procedurally build meshes
  40353. */
  40354. export class SphereBuilder {
  40355. /**
  40356. * Creates a sphere mesh
  40357. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40358. * * 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`)
  40359. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40360. * * 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
  40361. * * 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)
  40362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40365. * @param name defines the name of the mesh
  40366. * @param options defines the options used to create the mesh
  40367. * @param scene defines the hosting scene
  40368. * @returns the sphere mesh
  40369. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40370. */
  40371. static CreateSphere(name: string, options: {
  40372. segments?: number;
  40373. diameter?: number;
  40374. diameterX?: number;
  40375. diameterY?: number;
  40376. diameterZ?: number;
  40377. arc?: number;
  40378. slice?: number;
  40379. sideOrientation?: number;
  40380. frontUVs?: Vector4;
  40381. backUVs?: Vector4;
  40382. updatable?: boolean;
  40383. }, scene: any): Mesh;
  40384. }
  40385. }
  40386. declare module BABYLON.Debug {
  40387. /**
  40388. * Used to show the physics impostor around the specific mesh
  40389. */
  40390. export class PhysicsViewer {
  40391. /** @hidden */
  40392. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40393. /** @hidden */
  40394. protected _meshes: Array<Nullable<AbstractMesh>>;
  40395. /** @hidden */
  40396. protected _scene: Nullable<Scene>;
  40397. /** @hidden */
  40398. protected _numMeshes: number;
  40399. /** @hidden */
  40400. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40401. private _renderFunction;
  40402. private _utilityLayer;
  40403. private _debugBoxMesh;
  40404. private _debugSphereMesh;
  40405. private _debugCylinderMesh;
  40406. private _debugMaterial;
  40407. private _debugMeshMeshes;
  40408. /**
  40409. * Creates a new PhysicsViewer
  40410. * @param scene defines the hosting scene
  40411. */
  40412. constructor(scene: Scene);
  40413. /** @hidden */
  40414. protected _updateDebugMeshes(): void;
  40415. /**
  40416. * Renders a specified physic impostor
  40417. * @param impostor defines the impostor to render
  40418. * @param targetMesh defines the mesh represented by the impostor
  40419. * @returns the new debug mesh used to render the impostor
  40420. */
  40421. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40422. /**
  40423. * Hides a specified physic impostor
  40424. * @param impostor defines the impostor to hide
  40425. */
  40426. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40427. private _getDebugMaterial;
  40428. private _getDebugBoxMesh;
  40429. private _getDebugSphereMesh;
  40430. private _getDebugCylinderMesh;
  40431. private _getDebugMeshMesh;
  40432. private _getDebugMesh;
  40433. /** Releases all resources */
  40434. dispose(): void;
  40435. }
  40436. }
  40437. declare module BABYLON {
  40438. /**
  40439. * Class containing static functions to help procedurally build meshes
  40440. */
  40441. export class LinesBuilder {
  40442. /**
  40443. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40444. * * 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
  40445. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40446. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40447. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40448. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40449. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40450. * * 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
  40451. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40454. * @param name defines the name of the new line system
  40455. * @param options defines the options used to create the line system
  40456. * @param scene defines the hosting scene
  40457. * @returns a new line system mesh
  40458. */
  40459. static CreateLineSystem(name: string, options: {
  40460. lines: Vector3[][];
  40461. updatable?: boolean;
  40462. instance?: Nullable<LinesMesh>;
  40463. colors?: Nullable<Color4[][]>;
  40464. useVertexAlpha?: boolean;
  40465. }, scene: Nullable<Scene>): LinesMesh;
  40466. /**
  40467. * Creates a line mesh
  40468. * 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
  40469. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40470. * * The parameter `points` is an array successive Vector3
  40471. * * 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
  40472. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40473. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40474. * * When updating an instance, remember that only point positions can change, not the number of points
  40475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40476. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40477. * @param name defines the name of the new line system
  40478. * @param options defines the options used to create the line system
  40479. * @param scene defines the hosting scene
  40480. * @returns a new line mesh
  40481. */
  40482. static CreateLines(name: string, options: {
  40483. points: Vector3[];
  40484. updatable?: boolean;
  40485. instance?: Nullable<LinesMesh>;
  40486. colors?: Color4[];
  40487. useVertexAlpha?: boolean;
  40488. }, scene?: Nullable<Scene>): LinesMesh;
  40489. /**
  40490. * Creates a dashed line mesh
  40491. * * 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
  40492. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40493. * * The parameter `points` is an array successive Vector3
  40494. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40495. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40496. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40497. * * 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
  40498. * * When updating an instance, remember that only point positions can change, not the number of points
  40499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40500. * @param name defines the name of the mesh
  40501. * @param options defines the options used to create the mesh
  40502. * @param scene defines the hosting scene
  40503. * @returns the dashed line mesh
  40504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40505. */
  40506. static CreateDashedLines(name: string, options: {
  40507. points: Vector3[];
  40508. dashSize?: number;
  40509. gapSize?: number;
  40510. dashNb?: number;
  40511. updatable?: boolean;
  40512. instance?: LinesMesh;
  40513. }, scene?: Nullable<Scene>): LinesMesh;
  40514. }
  40515. }
  40516. declare module BABYLON {
  40517. /**
  40518. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40519. * in order to better appreciate the issue one might have.
  40520. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40521. */
  40522. export class RayHelper {
  40523. /**
  40524. * Defines the ray we are currently tryin to visualize.
  40525. */
  40526. ray: Nullable<Ray>;
  40527. private _renderPoints;
  40528. private _renderLine;
  40529. private _renderFunction;
  40530. private _scene;
  40531. private _updateToMeshFunction;
  40532. private _attachedToMesh;
  40533. private _meshSpaceDirection;
  40534. private _meshSpaceOrigin;
  40535. /**
  40536. * Helper function to create a colored helper in a scene in one line.
  40537. * @param ray Defines the ray we are currently tryin to visualize
  40538. * @param scene Defines the scene the ray is used in
  40539. * @param color Defines the color we want to see the ray in
  40540. * @returns The newly created ray helper.
  40541. */
  40542. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40543. /**
  40544. * Instantiate a new ray helper.
  40545. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40546. * in order to better appreciate the issue one might have.
  40547. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40548. * @param ray Defines the ray we are currently tryin to visualize
  40549. */
  40550. constructor(ray: Ray);
  40551. /**
  40552. * Shows the ray we are willing to debug.
  40553. * @param scene Defines the scene the ray needs to be rendered in
  40554. * @param color Defines the color the ray needs to be rendered in
  40555. */
  40556. show(scene: Scene, color?: Color3): void;
  40557. /**
  40558. * Hides the ray we are debugging.
  40559. */
  40560. hide(): void;
  40561. private _render;
  40562. /**
  40563. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40564. * @param mesh Defines the mesh we want the helper attached to
  40565. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40566. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40567. * @param length Defines the length of the ray
  40568. */
  40569. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40570. /**
  40571. * Detach the ray helper from the mesh it has previously been attached to.
  40572. */
  40573. detachFromMesh(): void;
  40574. private _updateToMesh;
  40575. /**
  40576. * Dispose the helper and release its associated resources.
  40577. */
  40578. dispose(): void;
  40579. }
  40580. }
  40581. declare module BABYLON.Debug {
  40582. /**
  40583. * Class used to render a debug view of a given skeleton
  40584. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40585. */
  40586. export class SkeletonViewer {
  40587. /** defines the skeleton to render */
  40588. skeleton: Skeleton;
  40589. /** defines the mesh attached to the skeleton */
  40590. mesh: AbstractMesh;
  40591. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40592. autoUpdateBonesMatrices: boolean;
  40593. /** defines the rendering group id to use with the viewer */
  40594. renderingGroupId: number;
  40595. /** Gets or sets the color used to render the skeleton */
  40596. color: Color3;
  40597. private _scene;
  40598. private _debugLines;
  40599. private _debugMesh;
  40600. private _isEnabled;
  40601. private _renderFunction;
  40602. private _utilityLayer;
  40603. /**
  40604. * Returns the mesh used to render the bones
  40605. */
  40606. readonly debugMesh: Nullable<LinesMesh>;
  40607. /**
  40608. * Creates a new SkeletonViewer
  40609. * @param skeleton defines the skeleton to render
  40610. * @param mesh defines the mesh attached to the skeleton
  40611. * @param scene defines the hosting scene
  40612. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40613. * @param renderingGroupId defines the rendering group id to use with the viewer
  40614. */
  40615. constructor(
  40616. /** defines the skeleton to render */
  40617. skeleton: Skeleton,
  40618. /** defines the mesh attached to the skeleton */
  40619. mesh: AbstractMesh, scene: Scene,
  40620. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40621. autoUpdateBonesMatrices?: boolean,
  40622. /** defines the rendering group id to use with the viewer */
  40623. renderingGroupId?: number);
  40624. /** Gets or sets a boolean indicating if the viewer is enabled */
  40625. isEnabled: boolean;
  40626. private _getBonePosition;
  40627. private _getLinesForBonesWithLength;
  40628. private _getLinesForBonesNoLength;
  40629. /** Update the viewer to sync with current skeleton state */
  40630. update(): void;
  40631. /** Release associated resources */
  40632. dispose(): void;
  40633. }
  40634. }
  40635. declare module BABYLON {
  40636. /**
  40637. * Options to create the null engine
  40638. */
  40639. export class NullEngineOptions {
  40640. /**
  40641. * Render width (Default: 512)
  40642. */
  40643. renderWidth: number;
  40644. /**
  40645. * Render height (Default: 256)
  40646. */
  40647. renderHeight: number;
  40648. /**
  40649. * Texture size (Default: 512)
  40650. */
  40651. textureSize: number;
  40652. /**
  40653. * If delta time between frames should be constant
  40654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40655. */
  40656. deterministicLockstep: boolean;
  40657. /**
  40658. * Maximum about of steps between frames (Default: 4)
  40659. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40660. */
  40661. lockstepMaxSteps: number;
  40662. }
  40663. /**
  40664. * The null engine class provides support for headless version of babylon.js.
  40665. * This can be used in server side scenario or for testing purposes
  40666. */
  40667. export class NullEngine extends Engine {
  40668. private _options;
  40669. /**
  40670. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40671. */
  40672. isDeterministicLockStep(): boolean;
  40673. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40674. getLockstepMaxSteps(): number;
  40675. /**
  40676. * Sets hardware scaling, used to save performance if needed
  40677. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40678. */
  40679. getHardwareScalingLevel(): number;
  40680. constructor(options?: NullEngineOptions);
  40681. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40682. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40683. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40684. getRenderWidth(useScreen?: boolean): number;
  40685. getRenderHeight(useScreen?: boolean): number;
  40686. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40687. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40688. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40689. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40690. bindSamplers(effect: Effect): void;
  40691. enableEffect(effect: Effect): void;
  40692. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40693. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40694. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40695. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40696. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40697. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40698. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40699. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40700. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40701. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40702. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40703. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40704. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40705. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40706. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40707. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40708. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40709. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40710. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40711. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40712. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40713. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40714. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40715. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40716. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40717. bindBuffers(vertexBuffers: {
  40718. [key: string]: VertexBuffer;
  40719. }, indexBuffer: DataBuffer, effect: Effect): void;
  40720. wipeCaches(bruteForce?: boolean): void;
  40721. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40722. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40723. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40724. /** @hidden */ createTexture(): WebGLTexture;
  40725. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40726. 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;
  40727. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40728. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40729. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40730. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40731. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40732. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40733. areAllEffectsReady(): boolean;
  40734. /**
  40735. * @hidden
  40736. * Get the current error code of the webGL context
  40737. * @returns the error code
  40738. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40739. */
  40740. getError(): number;
  40741. /** @hidden */ getUnpackAlignement(): number;
  40742. /** @hidden */ unpackFlipY(value: boolean): void;
  40743. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40744. /**
  40745. * Updates a dynamic vertex buffer.
  40746. * @param vertexBuffer the vertex buffer to update
  40747. * @param data the data used to update the vertex buffer
  40748. * @param byteOffset the byte offset of the data (optional)
  40749. * @param byteLength the byte length of the data (optional)
  40750. */
  40751. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40752. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40753. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  40754. releaseEffects(): void;
  40755. displayLoadingUI(): void;
  40756. hideLoadingUI(): void;
  40757. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40758. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40759. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40760. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40761. }
  40762. }
  40763. declare module BABYLON {
  40764. /** @hidden */
  40765. export class _OcclusionDataStorage {
  40766. /** @hidden */
  40767. occlusionInternalRetryCounter: number;
  40768. /** @hidden */
  40769. isOcclusionQueryInProgress: boolean;
  40770. /** @hidden */
  40771. isOccluded: boolean;
  40772. /** @hidden */
  40773. occlusionRetryCount: number;
  40774. /** @hidden */
  40775. occlusionType: number;
  40776. /** @hidden */
  40777. occlusionQueryAlgorithmType: number;
  40778. }
  40779. interface Engine {
  40780. /**
  40781. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40782. * @return the new query
  40783. */
  40784. createQuery(): WebGLQuery;
  40785. /**
  40786. * Delete and release a webGL query
  40787. * @param query defines the query to delete
  40788. * @return the current engine
  40789. */
  40790. deleteQuery(query: WebGLQuery): Engine;
  40791. /**
  40792. * Check if a given query has resolved and got its value
  40793. * @param query defines the query to check
  40794. * @returns true if the query got its value
  40795. */
  40796. isQueryResultAvailable(query: WebGLQuery): boolean;
  40797. /**
  40798. * Gets the value of a given query
  40799. * @param query defines the query to check
  40800. * @returns the value of the query
  40801. */
  40802. getQueryResult(query: WebGLQuery): number;
  40803. /**
  40804. * Initiates an occlusion query
  40805. * @param algorithmType defines the algorithm to use
  40806. * @param query defines the query to use
  40807. * @returns the current engine
  40808. * @see http://doc.babylonjs.com/features/occlusionquery
  40809. */
  40810. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40811. /**
  40812. * Ends an occlusion query
  40813. * @see http://doc.babylonjs.com/features/occlusionquery
  40814. * @param algorithmType defines the algorithm to use
  40815. * @returns the current engine
  40816. */
  40817. endOcclusionQuery(algorithmType: number): Engine;
  40818. /**
  40819. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40820. * Please note that only one query can be issued at a time
  40821. * @returns a time token used to track the time span
  40822. */
  40823. startTimeQuery(): Nullable<_TimeToken>;
  40824. /**
  40825. * Ends a time query
  40826. * @param token defines the token used to measure the time span
  40827. * @returns the time spent (in ns)
  40828. */
  40829. endTimeQuery(token: _TimeToken): int;
  40830. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40831. /** @hidden */ createTimeQuery(): WebGLQuery;
  40832. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40833. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40834. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40835. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40836. }
  40837. interface AbstractMesh {
  40838. /**
  40839. * Backing filed
  40840. * @hidden
  40841. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40842. /**
  40843. * Access property
  40844. * @hidden
  40845. */ occlusionDataStorage: _OcclusionDataStorage;
  40846. /**
  40847. * 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.
  40848. * The default value is -1 which means don't break the query and wait till the result
  40849. * @see http://doc.babylonjs.com/features/occlusionquery
  40850. */
  40851. occlusionRetryCount: number;
  40852. /**
  40853. * 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:
  40854. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40855. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40856. * * 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.
  40857. * @see http://doc.babylonjs.com/features/occlusionquery
  40858. */
  40859. occlusionType: number;
  40860. /**
  40861. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40862. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40863. * * 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.
  40864. * @see http://doc.babylonjs.com/features/occlusionquery
  40865. */
  40866. occlusionQueryAlgorithmType: number;
  40867. /**
  40868. * 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
  40869. * @see http://doc.babylonjs.com/features/occlusionquery
  40870. */
  40871. isOccluded: boolean;
  40872. /**
  40873. * Flag to check the progress status of the query
  40874. * @see http://doc.babylonjs.com/features/occlusionquery
  40875. */
  40876. isOcclusionQueryInProgress: boolean;
  40877. }
  40878. }
  40879. declare module BABYLON {
  40880. /** @hidden */
  40881. export var _forceTransformFeedbackToBundle: boolean;
  40882. interface Engine {
  40883. /**
  40884. * Creates a webGL transform feedback object
  40885. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40886. * @returns the webGL transform feedback object
  40887. */
  40888. createTransformFeedback(): WebGLTransformFeedback;
  40889. /**
  40890. * Delete a webGL transform feedback object
  40891. * @param value defines the webGL transform feedback object to delete
  40892. */
  40893. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40894. /**
  40895. * Bind a webGL transform feedback object to the webgl context
  40896. * @param value defines the webGL transform feedback object to bind
  40897. */
  40898. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40899. /**
  40900. * Begins a transform feedback operation
  40901. * @param usePoints defines if points or triangles must be used
  40902. */
  40903. beginTransformFeedback(usePoints: boolean): void;
  40904. /**
  40905. * Ends a transform feedback operation
  40906. */
  40907. endTransformFeedback(): void;
  40908. /**
  40909. * Specify the varyings to use with transform feedback
  40910. * @param program defines the associated webGL program
  40911. * @param value defines the list of strings representing the varying names
  40912. */
  40913. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40914. /**
  40915. * Bind a webGL buffer for a transform feedback operation
  40916. * @param value defines the webGL buffer to bind
  40917. */
  40918. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  40919. }
  40920. }
  40921. declare module BABYLON {
  40922. /**
  40923. * Creation options of the multi render target texture.
  40924. */
  40925. export interface IMultiRenderTargetOptions {
  40926. /**
  40927. * Define if the texture needs to create mip maps after render.
  40928. */
  40929. generateMipMaps?: boolean;
  40930. /**
  40931. * Define the types of all the draw buffers we want to create
  40932. */
  40933. types?: number[];
  40934. /**
  40935. * Define the sampling modes of all the draw buffers we want to create
  40936. */
  40937. samplingModes?: number[];
  40938. /**
  40939. * Define if a depth buffer is required
  40940. */
  40941. generateDepthBuffer?: boolean;
  40942. /**
  40943. * Define if a stencil buffer is required
  40944. */
  40945. generateStencilBuffer?: boolean;
  40946. /**
  40947. * Define if a depth texture is required instead of a depth buffer
  40948. */
  40949. generateDepthTexture?: boolean;
  40950. /**
  40951. * Define the number of desired draw buffers
  40952. */
  40953. textureCount?: number;
  40954. /**
  40955. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40956. */
  40957. doNotChangeAspectRatio?: boolean;
  40958. /**
  40959. * Define the default type of the buffers we are creating
  40960. */
  40961. defaultType?: number;
  40962. }
  40963. /**
  40964. * A multi render target, like a render target provides the ability to render to a texture.
  40965. * Unlike the render target, it can render to several draw buffers in one draw.
  40966. * This is specially interesting in deferred rendering or for any effects requiring more than
  40967. * just one color from a single pass.
  40968. */
  40969. export class MultiRenderTarget extends RenderTargetTexture {
  40970. private _internalTextures;
  40971. private _textures;
  40972. private _multiRenderTargetOptions;
  40973. /**
  40974. * Get if draw buffers are currently supported by the used hardware and browser.
  40975. */
  40976. readonly isSupported: boolean;
  40977. /**
  40978. * Get the list of textures generated by the multi render target.
  40979. */
  40980. readonly textures: Texture[];
  40981. /**
  40982. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  40983. */
  40984. readonly depthTexture: Texture;
  40985. /**
  40986. * Set the wrapping mode on U of all the textures we are rendering to.
  40987. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40988. */
  40989. wrapU: number;
  40990. /**
  40991. * Set the wrapping mode on V of all the textures we are rendering to.
  40992. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40993. */
  40994. wrapV: number;
  40995. /**
  40996. * Instantiate a new multi render target texture.
  40997. * A multi render target, like a render target provides the ability to render to a texture.
  40998. * Unlike the render target, it can render to several draw buffers in one draw.
  40999. * This is specially interesting in deferred rendering or for any effects requiring more than
  41000. * just one color from a single pass.
  41001. * @param name Define the name of the texture
  41002. * @param size Define the size of the buffers to render to
  41003. * @param count Define the number of target we are rendering into
  41004. * @param scene Define the scene the texture belongs to
  41005. * @param options Define the options used to create the multi render target
  41006. */
  41007. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41008. /** @hidden */ rebuild(): void;
  41009. private _createInternalTextures;
  41010. private _createTextures;
  41011. /**
  41012. * Define the number of samples used if MSAA is enabled.
  41013. */
  41014. samples: number;
  41015. /**
  41016. * Resize all the textures in the multi render target.
  41017. * Be carrefull as it will recreate all the data in the new texture.
  41018. * @param size Define the new size
  41019. */
  41020. resize(size: any): void;
  41021. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41022. /**
  41023. * Dispose the render targets and their associated resources
  41024. */
  41025. dispose(): void;
  41026. /**
  41027. * Release all the underlying texture used as draw buffers.
  41028. */
  41029. releaseInternalTextures(): void;
  41030. }
  41031. }
  41032. declare module BABYLON {
  41033. interface Engine {
  41034. /**
  41035. * Unbind a list of render target textures from the webGL context
  41036. * This is used only when drawBuffer extension or webGL2 are active
  41037. * @param textures defines the render target textures to unbind
  41038. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41039. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41040. */
  41041. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41042. /**
  41043. * Create a multi render target texture
  41044. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41045. * @param size defines the size of the texture
  41046. * @param options defines the creation options
  41047. * @returns the cube texture as an InternalTexture
  41048. */
  41049. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41050. /**
  41051. * Update the sample count for a given multiple render target texture
  41052. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41053. * @param textures defines the textures to update
  41054. * @param samples defines the sample count to set
  41055. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41056. */
  41057. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41058. }
  41059. }
  41060. declare module BABYLON {
  41061. /**
  41062. * Gather the list of clipboard event types as constants.
  41063. */
  41064. export class ClipboardEventTypes {
  41065. /**
  41066. * The clipboard event is fired when a copy command is active (pressed).
  41067. */
  41068. static readonly COPY: number;
  41069. /**
  41070. * The clipboard event is fired when a cut command is active (pressed).
  41071. */
  41072. static readonly CUT: number;
  41073. /**
  41074. * The clipboard event is fired when a paste command is active (pressed).
  41075. */
  41076. static readonly PASTE: number;
  41077. }
  41078. /**
  41079. * This class is used to store clipboard related info for the onClipboardObservable event.
  41080. */
  41081. export class ClipboardInfo {
  41082. /**
  41083. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41084. */
  41085. type: number;
  41086. /**
  41087. * Defines the related dom event
  41088. */
  41089. event: ClipboardEvent;
  41090. /**
  41091. *Creates an instance of ClipboardInfo.
  41092. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41093. * @param event Defines the related dom event
  41094. */
  41095. constructor(
  41096. /**
  41097. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41098. */
  41099. type: number,
  41100. /**
  41101. * Defines the related dom event
  41102. */
  41103. event: ClipboardEvent);
  41104. /**
  41105. * Get the clipboard event's type from the keycode.
  41106. * @param keyCode Defines the keyCode for the current keyboard event.
  41107. * @return {number}
  41108. */
  41109. static GetTypeFromCharacter(keyCode: number): number;
  41110. }
  41111. }
  41112. declare module BABYLON {
  41113. /**
  41114. * Class used to represent data loading progression
  41115. */
  41116. export class SceneLoaderProgressEvent {
  41117. /** defines if data length to load can be evaluated */
  41118. readonly lengthComputable: boolean;
  41119. /** defines the loaded data length */
  41120. readonly loaded: number;
  41121. /** defines the data length to load */
  41122. readonly total: number;
  41123. /**
  41124. * Create a new progress event
  41125. * @param lengthComputable defines if data length to load can be evaluated
  41126. * @param loaded defines the loaded data length
  41127. * @param total defines the data length to load
  41128. */
  41129. constructor(
  41130. /** defines if data length to load can be evaluated */
  41131. lengthComputable: boolean,
  41132. /** defines the loaded data length */
  41133. loaded: number,
  41134. /** defines the data length to load */
  41135. total: number);
  41136. /**
  41137. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41138. * @param event defines the source event
  41139. * @returns a new SceneLoaderProgressEvent
  41140. */
  41141. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41142. }
  41143. /**
  41144. * Interface used by SceneLoader plugins to define supported file extensions
  41145. */
  41146. export interface ISceneLoaderPluginExtensions {
  41147. /**
  41148. * Defines the list of supported extensions
  41149. */
  41150. [extension: string]: {
  41151. isBinary: boolean;
  41152. };
  41153. }
  41154. /**
  41155. * Interface used by SceneLoader plugin factory
  41156. */
  41157. export interface ISceneLoaderPluginFactory {
  41158. /**
  41159. * Defines the name of the factory
  41160. */
  41161. name: string;
  41162. /**
  41163. * Function called to create a new plugin
  41164. * @return the new plugin
  41165. */
  41166. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41167. /**
  41168. * Boolean indicating if the plugin can direct load specific data
  41169. */
  41170. canDirectLoad?: (data: string) => boolean;
  41171. }
  41172. /**
  41173. * Interface used to define a SceneLoader plugin
  41174. */
  41175. export interface ISceneLoaderPlugin {
  41176. /**
  41177. * The friendly name of this plugin.
  41178. */
  41179. name: string;
  41180. /**
  41181. * The file extensions supported by this plugin.
  41182. */
  41183. extensions: string | ISceneLoaderPluginExtensions;
  41184. /**
  41185. * Import meshes into a scene.
  41186. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41187. * @param scene The scene to import into
  41188. * @param data The data to import
  41189. * @param rootUrl The root url for scene and resources
  41190. * @param meshes The meshes array to import into
  41191. * @param particleSystems The particle systems array to import into
  41192. * @param skeletons The skeletons array to import into
  41193. * @param onError The callback when import fails
  41194. * @returns True if successful or false otherwise
  41195. */
  41196. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41197. /**
  41198. * Load into a scene.
  41199. * @param scene The scene to load into
  41200. * @param data The data to import
  41201. * @param rootUrl The root url for scene and resources
  41202. * @param onError The callback when import fails
  41203. * @returns true if successful or false otherwise
  41204. */
  41205. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41206. /**
  41207. * The callback that returns true if the data can be directly loaded.
  41208. */
  41209. canDirectLoad?: (data: string) => boolean;
  41210. /**
  41211. * The callback that allows custom handling of the root url based on the response url.
  41212. */
  41213. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41214. /**
  41215. * Load into an asset container.
  41216. * @param scene The scene to load into
  41217. * @param data The data to import
  41218. * @param rootUrl The root url for scene and resources
  41219. * @param onError The callback when import fails
  41220. * @returns The loaded asset container
  41221. */
  41222. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41223. }
  41224. /**
  41225. * Interface used to define an async SceneLoader plugin
  41226. */
  41227. export interface ISceneLoaderPluginAsync {
  41228. /**
  41229. * The friendly name of this plugin.
  41230. */
  41231. name: string;
  41232. /**
  41233. * The file extensions supported by this plugin.
  41234. */
  41235. extensions: string | ISceneLoaderPluginExtensions;
  41236. /**
  41237. * Import meshes into a scene.
  41238. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41239. * @param scene The scene to import into
  41240. * @param data The data to import
  41241. * @param rootUrl The root url for scene and resources
  41242. * @param onProgress The callback when the load progresses
  41243. * @param fileName Defines the name of the file to load
  41244. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41245. */
  41246. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41247. meshes: AbstractMesh[];
  41248. particleSystems: IParticleSystem[];
  41249. skeletons: Skeleton[];
  41250. animationGroups: AnimationGroup[];
  41251. }>;
  41252. /**
  41253. * Load into a scene.
  41254. * @param scene The scene to load into
  41255. * @param data The data to import
  41256. * @param rootUrl The root url for scene and resources
  41257. * @param onProgress The callback when the load progresses
  41258. * @param fileName Defines the name of the file to load
  41259. * @returns Nothing
  41260. */
  41261. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41262. /**
  41263. * The callback that returns true if the data can be directly loaded.
  41264. */
  41265. canDirectLoad?: (data: string) => boolean;
  41266. /**
  41267. * The callback that allows custom handling of the root url based on the response url.
  41268. */
  41269. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41270. /**
  41271. * Load into an asset container.
  41272. * @param scene The scene to load into
  41273. * @param data The data to import
  41274. * @param rootUrl The root url for scene and resources
  41275. * @param onProgress The callback when the load progresses
  41276. * @param fileName Defines the name of the file to load
  41277. * @returns The loaded asset container
  41278. */
  41279. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41280. }
  41281. /**
  41282. * Class used to load scene from various file formats using registered plugins
  41283. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41284. */
  41285. export class SceneLoader {
  41286. /**
  41287. * No logging while loading
  41288. */
  41289. static readonly NO_LOGGING: number;
  41290. /**
  41291. * Minimal logging while loading
  41292. */
  41293. static readonly MINIMAL_LOGGING: number;
  41294. /**
  41295. * Summary logging while loading
  41296. */
  41297. static readonly SUMMARY_LOGGING: number;
  41298. /**
  41299. * Detailled logging while loading
  41300. */
  41301. static readonly DETAILED_LOGGING: number;
  41302. /**
  41303. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41304. */
  41305. static ForceFullSceneLoadingForIncremental: boolean;
  41306. /**
  41307. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41308. */
  41309. static ShowLoadingScreen: boolean;
  41310. /**
  41311. * Defines the current logging level (while loading the scene)
  41312. * @ignorenaming
  41313. */
  41314. static loggingLevel: number;
  41315. /**
  41316. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41317. */
  41318. static CleanBoneMatrixWeights: boolean;
  41319. /**
  41320. * Event raised when a plugin is used to load a scene
  41321. */
  41322. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41323. private static _registeredPlugins;
  41324. private static _getDefaultPlugin;
  41325. private static _getPluginForExtension;
  41326. private static _getPluginForDirectLoad;
  41327. private static _getPluginForFilename;
  41328. private static _getDirectLoad;
  41329. private static _loadData;
  41330. private static _getFileInfo;
  41331. /**
  41332. * Gets a plugin that can load the given extension
  41333. * @param extension defines the extension to load
  41334. * @returns a plugin or null if none works
  41335. */
  41336. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41337. /**
  41338. * Gets a boolean indicating that the given extension can be loaded
  41339. * @param extension defines the extension to load
  41340. * @returns true if the extension is supported
  41341. */
  41342. static IsPluginForExtensionAvailable(extension: string): boolean;
  41343. /**
  41344. * Adds a new plugin to the list of registered plugins
  41345. * @param plugin defines the plugin to add
  41346. */
  41347. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41348. /**
  41349. * Import meshes into a scene
  41350. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41351. * @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)
  41352. * @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)
  41353. * @param scene the instance of BABYLON.Scene to append to
  41354. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41355. * @param onProgress a callback with a progress event for each file being loaded
  41356. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41357. * @param pluginExtension the extension used to determine the plugin
  41358. * @returns The loaded plugin
  41359. */
  41360. 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>;
  41361. /**
  41362. * Import meshes into a scene
  41363. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41364. * @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)
  41365. * @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)
  41366. * @param scene the instance of BABYLON.Scene to append to
  41367. * @param onProgress a callback with a progress event for each file being loaded
  41368. * @param pluginExtension the extension used to determine the plugin
  41369. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41370. */
  41371. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41372. meshes: AbstractMesh[];
  41373. particleSystems: IParticleSystem[];
  41374. skeletons: Skeleton[];
  41375. animationGroups: AnimationGroup[];
  41376. }>;
  41377. /**
  41378. * Load a scene
  41379. * @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)
  41380. * @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)
  41381. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41382. * @param onSuccess a callback with the scene when import succeeds
  41383. * @param onProgress a callback with a progress event for each file being loaded
  41384. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41385. * @param pluginExtension the extension used to determine the plugin
  41386. * @returns The loaded plugin
  41387. */
  41388. 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>;
  41389. /**
  41390. * Load a scene
  41391. * @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)
  41392. * @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)
  41393. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41394. * @param onProgress a callback with a progress event for each file being loaded
  41395. * @param pluginExtension the extension used to determine the plugin
  41396. * @returns The loaded scene
  41397. */
  41398. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41399. /**
  41400. * Append a scene
  41401. * @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)
  41402. * @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)
  41403. * @param scene is the instance of BABYLON.Scene to append to
  41404. * @param onSuccess a callback with the scene when import succeeds
  41405. * @param onProgress a callback with a progress event for each file being loaded
  41406. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41407. * @param pluginExtension the extension used to determine the plugin
  41408. * @returns The loaded plugin
  41409. */
  41410. 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>;
  41411. /**
  41412. * Append a scene
  41413. * @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)
  41414. * @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)
  41415. * @param scene is the instance of BABYLON.Scene to append to
  41416. * @param onProgress a callback with a progress event for each file being loaded
  41417. * @param pluginExtension the extension used to determine the plugin
  41418. * @returns The given scene
  41419. */
  41420. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41421. /**
  41422. * Load a scene into an asset container
  41423. * @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)
  41424. * @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)
  41425. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41426. * @param onSuccess a callback with the scene when import succeeds
  41427. * @param onProgress a callback with a progress event for each file being loaded
  41428. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41429. * @param pluginExtension the extension used to determine the plugin
  41430. * @returns The loaded plugin
  41431. */
  41432. 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>;
  41433. /**
  41434. * Load a scene into an asset container
  41435. * @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)
  41436. * @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)
  41437. * @param scene is the instance of Scene to append to
  41438. * @param onProgress a callback with a progress event for each file being loaded
  41439. * @param pluginExtension the extension used to determine the plugin
  41440. * @returns The loaded asset container
  41441. */
  41442. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41443. }
  41444. }
  41445. declare module BABYLON {
  41446. /**
  41447. * Google Daydream controller
  41448. */
  41449. export class DaydreamController extends WebVRController {
  41450. /**
  41451. * Base Url for the controller model.
  41452. */
  41453. static MODEL_BASE_URL: string;
  41454. /**
  41455. * File name for the controller model.
  41456. */
  41457. static MODEL_FILENAME: string;
  41458. /**
  41459. * Gamepad Id prefix used to identify Daydream Controller.
  41460. */
  41461. static readonly GAMEPAD_ID_PREFIX: string;
  41462. /**
  41463. * Creates a new DaydreamController from a gamepad
  41464. * @param vrGamepad the gamepad that the controller should be created from
  41465. */
  41466. constructor(vrGamepad: any);
  41467. /**
  41468. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41469. * @param scene scene in which to add meshes
  41470. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41471. */
  41472. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41473. /**
  41474. * Called once for each button that changed state since the last frame
  41475. * @param buttonIdx Which button index changed
  41476. * @param state New state of the button
  41477. * @param changes Which properties on the state changed since last frame
  41478. */
  41479. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41480. }
  41481. }
  41482. declare module BABYLON {
  41483. /**
  41484. * Gear VR Controller
  41485. */
  41486. export class GearVRController extends WebVRController {
  41487. /**
  41488. * Base Url for the controller model.
  41489. */
  41490. static MODEL_BASE_URL: string;
  41491. /**
  41492. * File name for the controller model.
  41493. */
  41494. static MODEL_FILENAME: string;
  41495. /**
  41496. * Gamepad Id prefix used to identify this controller.
  41497. */
  41498. static readonly GAMEPAD_ID_PREFIX: string;
  41499. private readonly _buttonIndexToObservableNameMap;
  41500. /**
  41501. * Creates a new GearVRController from a gamepad
  41502. * @param vrGamepad the gamepad that the controller should be created from
  41503. */
  41504. constructor(vrGamepad: any);
  41505. /**
  41506. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41507. * @param scene scene in which to add meshes
  41508. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41509. */
  41510. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41511. /**
  41512. * Called once for each button that changed state since the last frame
  41513. * @param buttonIdx Which button index changed
  41514. * @param state New state of the button
  41515. * @param changes Which properties on the state changed since last frame
  41516. */
  41517. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41518. }
  41519. }
  41520. declare module BABYLON {
  41521. /**
  41522. * Generic Controller
  41523. */
  41524. export class GenericController extends WebVRController {
  41525. /**
  41526. * Base Url for the controller model.
  41527. */
  41528. static readonly MODEL_BASE_URL: string;
  41529. /**
  41530. * File name for the controller model.
  41531. */
  41532. static readonly MODEL_FILENAME: string;
  41533. /**
  41534. * Creates a new GenericController from a gamepad
  41535. * @param vrGamepad the gamepad that the controller should be created from
  41536. */
  41537. constructor(vrGamepad: any);
  41538. /**
  41539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41540. * @param scene scene in which to add meshes
  41541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41542. */
  41543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41544. /**
  41545. * Called once for each button that changed state since the last frame
  41546. * @param buttonIdx Which button index changed
  41547. * @param state New state of the button
  41548. * @param changes Which properties on the state changed since last frame
  41549. */
  41550. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41551. }
  41552. }
  41553. declare module BABYLON {
  41554. /**
  41555. * Oculus Touch Controller
  41556. */
  41557. export class OculusTouchController extends WebVRController {
  41558. /**
  41559. * Base Url for the controller model.
  41560. */
  41561. static MODEL_BASE_URL: string;
  41562. /**
  41563. * File name for the left controller model.
  41564. */
  41565. static MODEL_LEFT_FILENAME: string;
  41566. /**
  41567. * File name for the right controller model.
  41568. */
  41569. static MODEL_RIGHT_FILENAME: string;
  41570. /**
  41571. * Fired when the secondary trigger on this controller is modified
  41572. */
  41573. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41574. /**
  41575. * Fired when the thumb rest on this controller is modified
  41576. */
  41577. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41578. /**
  41579. * Creates a new OculusTouchController from a gamepad
  41580. * @param vrGamepad the gamepad that the controller should be created from
  41581. */
  41582. constructor(vrGamepad: any);
  41583. /**
  41584. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41585. * @param scene scene in which to add meshes
  41586. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41587. */
  41588. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41589. /**
  41590. * Fired when the A button on this controller is modified
  41591. */
  41592. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41593. /**
  41594. * Fired when the B button on this controller is modified
  41595. */
  41596. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41597. /**
  41598. * Fired when the X button on this controller is modified
  41599. */
  41600. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41601. /**
  41602. * Fired when the Y button on this controller is modified
  41603. */
  41604. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41605. /**
  41606. * Called once for each button that changed state since the last frame
  41607. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41608. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41609. * 2) secondary trigger (same)
  41610. * 3) A (right) X (left), touch, pressed = value
  41611. * 4) B / Y
  41612. * 5) thumb rest
  41613. * @param buttonIdx Which button index changed
  41614. * @param state New state of the button
  41615. * @param changes Which properties on the state changed since last frame
  41616. */
  41617. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41618. }
  41619. }
  41620. declare module BABYLON {
  41621. /**
  41622. * Vive Controller
  41623. */
  41624. export class ViveController extends WebVRController {
  41625. /**
  41626. * Base Url for the controller model.
  41627. */
  41628. static MODEL_BASE_URL: string;
  41629. /**
  41630. * File name for the controller model.
  41631. */
  41632. static MODEL_FILENAME: string;
  41633. /**
  41634. * Creates a new ViveController from a gamepad
  41635. * @param vrGamepad the gamepad that the controller should be created from
  41636. */
  41637. constructor(vrGamepad: any);
  41638. /**
  41639. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41640. * @param scene scene in which to add meshes
  41641. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41642. */
  41643. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41644. /**
  41645. * Fired when the left button on this controller is modified
  41646. */
  41647. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41648. /**
  41649. * Fired when the right button on this controller is modified
  41650. */
  41651. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41652. /**
  41653. * Fired when the menu button on this controller is modified
  41654. */
  41655. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41656. /**
  41657. * Called once for each button that changed state since the last frame
  41658. * Vive mapping:
  41659. * 0: touchpad
  41660. * 1: trigger
  41661. * 2: left AND right buttons
  41662. * 3: menu button
  41663. * @param buttonIdx Which button index changed
  41664. * @param state New state of the button
  41665. * @param changes Which properties on the state changed since last frame
  41666. */
  41667. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41668. }
  41669. }
  41670. declare module BABYLON {
  41671. /**
  41672. * Defines the WindowsMotionController object that the state of the windows motion controller
  41673. */
  41674. export class WindowsMotionController extends WebVRController {
  41675. /**
  41676. * The base url used to load the left and right controller models
  41677. */
  41678. static MODEL_BASE_URL: string;
  41679. /**
  41680. * The name of the left controller model file
  41681. */
  41682. static MODEL_LEFT_FILENAME: string;
  41683. /**
  41684. * The name of the right controller model file
  41685. */
  41686. static MODEL_RIGHT_FILENAME: string;
  41687. /**
  41688. * The controller name prefix for this controller type
  41689. */
  41690. static readonly GAMEPAD_ID_PREFIX: string;
  41691. /**
  41692. * The controller id pattern for this controller type
  41693. */
  41694. private static readonly GAMEPAD_ID_PATTERN;
  41695. private _loadedMeshInfo;
  41696. private readonly _mapping;
  41697. /**
  41698. * Fired when the trackpad on this controller is clicked
  41699. */
  41700. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41701. /**
  41702. * Fired when the trackpad on this controller is modified
  41703. */
  41704. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41705. /**
  41706. * The current x and y values of this controller's trackpad
  41707. */
  41708. trackpad: StickValues;
  41709. /**
  41710. * Creates a new WindowsMotionController from a gamepad
  41711. * @param vrGamepad the gamepad that the controller should be created from
  41712. */
  41713. constructor(vrGamepad: any);
  41714. /**
  41715. * Fired when the trigger on this controller is modified
  41716. */
  41717. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41718. /**
  41719. * Fired when the menu button on this controller is modified
  41720. */
  41721. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41722. /**
  41723. * Fired when the grip button on this controller is modified
  41724. */
  41725. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41726. /**
  41727. * Fired when the thumbstick button on this controller is modified
  41728. */
  41729. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41730. /**
  41731. * Fired when the touchpad button on this controller is modified
  41732. */
  41733. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41734. /**
  41735. * Fired when the touchpad values on this controller are modified
  41736. */
  41737. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41738. private _updateTrackpad;
  41739. /**
  41740. * Called once per frame by the engine.
  41741. */
  41742. update(): void;
  41743. /**
  41744. * Called once for each button that changed state since the last frame
  41745. * @param buttonIdx Which button index changed
  41746. * @param state New state of the button
  41747. * @param changes Which properties on the state changed since last frame
  41748. */
  41749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41750. /**
  41751. * Moves the buttons on the controller mesh based on their current state
  41752. * @param buttonName the name of the button to move
  41753. * @param buttonValue the value of the button which determines the buttons new position
  41754. */
  41755. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41756. /**
  41757. * Moves the axis on the controller mesh based on its current state
  41758. * @param axis the index of the axis
  41759. * @param axisValue the value of the axis which determines the meshes new position
  41760. * @hidden
  41761. */
  41762. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41763. /**
  41764. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41765. * @param scene scene in which to add meshes
  41766. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41767. */
  41768. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41769. /**
  41770. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41771. * can be transformed by button presses and axes values, based on this._mapping.
  41772. *
  41773. * @param scene scene in which the meshes exist
  41774. * @param meshes list of meshes that make up the controller model to process
  41775. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41776. */
  41777. private processModel;
  41778. private createMeshInfo;
  41779. /**
  41780. * Gets the ray of the controller in the direction the controller is pointing
  41781. * @param length the length the resulting ray should be
  41782. * @returns a ray in the direction the controller is pointing
  41783. */
  41784. getForwardRay(length?: number): Ray;
  41785. /**
  41786. * Disposes of the controller
  41787. */
  41788. dispose(): void;
  41789. }
  41790. }
  41791. declare module BABYLON {
  41792. /**
  41793. * Single axis scale gizmo
  41794. */
  41795. export class AxisScaleGizmo extends Gizmo {
  41796. private _coloredMaterial;
  41797. /**
  41798. * Drag behavior responsible for the gizmos dragging interactions
  41799. */
  41800. dragBehavior: PointerDragBehavior;
  41801. private _pointerObserver;
  41802. /**
  41803. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41804. */
  41805. snapDistance: number;
  41806. /**
  41807. * Event that fires each time the gizmo snaps to a new location.
  41808. * * snapDistance is the the change in distance
  41809. */
  41810. onSnapObservable: Observable<{
  41811. snapDistance: number;
  41812. }>;
  41813. /**
  41814. * If the scaling operation should be done on all axis (default: false)
  41815. */
  41816. uniformScaling: boolean;
  41817. /**
  41818. * Creates an AxisScaleGizmo
  41819. * @param gizmoLayer The utility layer the gizmo will be added to
  41820. * @param dragAxis The axis which the gizmo will be able to scale on
  41821. * @param color The color of the gizmo
  41822. */
  41823. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41824. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41825. /**
  41826. * Disposes of the gizmo
  41827. */
  41828. dispose(): void;
  41829. /**
  41830. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41831. * @param mesh The mesh to replace the default mesh of the gizmo
  41832. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41833. */
  41834. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41835. }
  41836. }
  41837. declare module BABYLON {
  41838. /**
  41839. * Bounding box gizmo
  41840. */
  41841. export class BoundingBoxGizmo extends Gizmo {
  41842. private _lineBoundingBox;
  41843. private _rotateSpheresParent;
  41844. private _scaleBoxesParent;
  41845. private _boundingDimensions;
  41846. private _renderObserver;
  41847. private _pointerObserver;
  41848. private _scaleDragSpeed;
  41849. private _tmpQuaternion;
  41850. private _tmpVector;
  41851. private _tmpRotationMatrix;
  41852. /**
  41853. * 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)
  41854. */
  41855. ignoreChildren: boolean;
  41856. /**
  41857. * 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)
  41858. */
  41859. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41860. /**
  41861. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41862. */
  41863. rotationSphereSize: number;
  41864. /**
  41865. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41866. */
  41867. scaleBoxSize: number;
  41868. /**
  41869. * 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)
  41870. */
  41871. fixedDragMeshScreenSize: boolean;
  41872. /**
  41873. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41874. */
  41875. fixedDragMeshScreenSizeDistanceFactor: number;
  41876. /**
  41877. * Fired when a rotation sphere or scale box is dragged
  41878. */
  41879. onDragStartObservable: Observable<{}>;
  41880. /**
  41881. * Fired when a scale box is dragged
  41882. */
  41883. onScaleBoxDragObservable: Observable<{}>;
  41884. /**
  41885. * Fired when a scale box drag is ended
  41886. */
  41887. onScaleBoxDragEndObservable: Observable<{}>;
  41888. /**
  41889. * Fired when a rotation sphere is dragged
  41890. */
  41891. onRotationSphereDragObservable: Observable<{}>;
  41892. /**
  41893. * Fired when a rotation sphere drag is ended
  41894. */
  41895. onRotationSphereDragEndObservable: Observable<{}>;
  41896. /**
  41897. * 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)
  41898. */
  41899. scalePivot: Nullable<Vector3>;
  41900. /**
  41901. * Mesh used as a pivot to rotate the attached mesh
  41902. */
  41903. private _anchorMesh;
  41904. private _existingMeshScale;
  41905. private _dragMesh;
  41906. private pointerDragBehavior;
  41907. private coloredMaterial;
  41908. private hoverColoredMaterial;
  41909. /**
  41910. * Sets the color of the bounding box gizmo
  41911. * @param color the color to set
  41912. */
  41913. setColor(color: Color3): void;
  41914. /**
  41915. * Creates an BoundingBoxGizmo
  41916. * @param gizmoLayer The utility layer the gizmo will be added to
  41917. * @param color The color of the gizmo
  41918. */
  41919. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41920. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41921. private _selectNode;
  41922. /**
  41923. * Updates the bounding box information for the Gizmo
  41924. */
  41925. updateBoundingBox(): void;
  41926. private _updateRotationSpheres;
  41927. private _updateScaleBoxes;
  41928. /**
  41929. * Enables rotation on the specified axis and disables rotation on the others
  41930. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41931. */
  41932. setEnabledRotationAxis(axis: string): void;
  41933. /**
  41934. * Enables/disables scaling
  41935. * @param enable if scaling should be enabled
  41936. */
  41937. setEnabledScaling(enable: boolean): void;
  41938. private _updateDummy;
  41939. /**
  41940. * Enables a pointer drag behavior on the bounding box of the gizmo
  41941. */
  41942. enableDragBehavior(): void;
  41943. /**
  41944. * Disposes of the gizmo
  41945. */
  41946. dispose(): void;
  41947. /**
  41948. * 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)
  41949. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41950. * @returns the bounding box mesh with the passed in mesh as a child
  41951. */
  41952. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41953. /**
  41954. * CustomMeshes are not supported by this gizmo
  41955. * @param mesh The mesh to replace the default mesh of the gizmo
  41956. */
  41957. setCustomMesh(mesh: Mesh): void;
  41958. }
  41959. }
  41960. declare module BABYLON {
  41961. /**
  41962. * Single plane rotation gizmo
  41963. */
  41964. export class PlaneRotationGizmo extends Gizmo {
  41965. /**
  41966. * Drag behavior responsible for the gizmos dragging interactions
  41967. */
  41968. dragBehavior: PointerDragBehavior;
  41969. private _pointerObserver;
  41970. /**
  41971. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41972. */
  41973. snapDistance: number;
  41974. /**
  41975. * Event that fires each time the gizmo snaps to a new location.
  41976. * * snapDistance is the the change in distance
  41977. */
  41978. onSnapObservable: Observable<{
  41979. snapDistance: number;
  41980. }>;
  41981. /**
  41982. * Creates a PlaneRotationGizmo
  41983. * @param gizmoLayer The utility layer the gizmo will be added to
  41984. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41985. * @param color The color of the gizmo
  41986. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41987. */
  41988. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41990. /**
  41991. * Disposes of the gizmo
  41992. */
  41993. dispose(): void;
  41994. }
  41995. }
  41996. declare module BABYLON {
  41997. /**
  41998. * Gizmo that enables rotating a mesh along 3 axis
  41999. */
  42000. export class RotationGizmo extends Gizmo {
  42001. /**
  42002. * Internal gizmo used for interactions on the x axis
  42003. */
  42004. xGizmo: PlaneRotationGizmo;
  42005. /**
  42006. * Internal gizmo used for interactions on the y axis
  42007. */
  42008. yGizmo: PlaneRotationGizmo;
  42009. /**
  42010. * Internal gizmo used for interactions on the z axis
  42011. */
  42012. zGizmo: PlaneRotationGizmo;
  42013. /** Fires an event when any of it's sub gizmos are dragged */
  42014. onDragStartObservable: Observable<{}>;
  42015. /** Fires an event when any of it's sub gizmos are released from dragging */
  42016. onDragEndObservable: Observable<{}>;
  42017. attachedMesh: Nullable<AbstractMesh>;
  42018. /**
  42019. * Creates a RotationGizmo
  42020. * @param gizmoLayer The utility layer the gizmo will be added to
  42021. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42022. */
  42023. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42024. updateGizmoRotationToMatchAttachedMesh: boolean;
  42025. /**
  42026. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42027. */
  42028. snapDistance: number;
  42029. /**
  42030. * Ratio for the scale of the gizmo (Default: 1)
  42031. */
  42032. scaleRatio: number;
  42033. /**
  42034. * Disposes of the gizmo
  42035. */
  42036. dispose(): void;
  42037. /**
  42038. * CustomMeshes are not supported by this gizmo
  42039. * @param mesh The mesh to replace the default mesh of the gizmo
  42040. */
  42041. setCustomMesh(mesh: Mesh): void;
  42042. }
  42043. }
  42044. declare module BABYLON {
  42045. /**
  42046. * Gizmo that enables dragging a mesh along 3 axis
  42047. */
  42048. export class PositionGizmo extends Gizmo {
  42049. /**
  42050. * Internal gizmo used for interactions on the x axis
  42051. */
  42052. xGizmo: AxisDragGizmo;
  42053. /**
  42054. * Internal gizmo used for interactions on the y axis
  42055. */
  42056. yGizmo: AxisDragGizmo;
  42057. /**
  42058. * Internal gizmo used for interactions on the z axis
  42059. */
  42060. zGizmo: AxisDragGizmo;
  42061. /** Fires an event when any of it's sub gizmos are dragged */
  42062. onDragStartObservable: Observable<{}>;
  42063. /** Fires an event when any of it's sub gizmos are released from dragging */
  42064. onDragEndObservable: Observable<{}>;
  42065. attachedMesh: Nullable<AbstractMesh>;
  42066. /**
  42067. * Creates a PositionGizmo
  42068. * @param gizmoLayer The utility layer the gizmo will be added to
  42069. */
  42070. constructor(gizmoLayer?: UtilityLayerRenderer);
  42071. updateGizmoRotationToMatchAttachedMesh: boolean;
  42072. /**
  42073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42074. */
  42075. snapDistance: number;
  42076. /**
  42077. * Ratio for the scale of the gizmo (Default: 1)
  42078. */
  42079. scaleRatio: number;
  42080. /**
  42081. * Disposes of the gizmo
  42082. */
  42083. dispose(): void;
  42084. /**
  42085. * CustomMeshes are not supported by this gizmo
  42086. * @param mesh The mesh to replace the default mesh of the gizmo
  42087. */
  42088. setCustomMesh(mesh: Mesh): void;
  42089. }
  42090. }
  42091. declare module BABYLON {
  42092. /**
  42093. * Class containing static functions to help procedurally build meshes
  42094. */
  42095. export class PolyhedronBuilder {
  42096. /**
  42097. * Creates a polyhedron mesh
  42098. * * 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
  42099. * * The parameter `size` (positive float, default 1) sets the polygon size
  42100. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42101. * * 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`
  42102. * * 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
  42103. * * 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)`)
  42104. * * 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
  42105. * * 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
  42106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42109. * @param name defines the name of the mesh
  42110. * @param options defines the options used to create the mesh
  42111. * @param scene defines the hosting scene
  42112. * @returns the polyhedron mesh
  42113. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42114. */
  42115. static CreatePolyhedron(name: string, options: {
  42116. type?: number;
  42117. size?: number;
  42118. sizeX?: number;
  42119. sizeY?: number;
  42120. sizeZ?: number;
  42121. custom?: any;
  42122. faceUV?: Vector4[];
  42123. faceColors?: Color4[];
  42124. flat?: boolean;
  42125. updatable?: boolean;
  42126. sideOrientation?: number;
  42127. frontUVs?: Vector4;
  42128. backUVs?: Vector4;
  42129. }, scene?: Nullable<Scene>): Mesh;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * Gizmo that enables scaling a mesh along 3 axis
  42135. */
  42136. export class ScaleGizmo extends Gizmo {
  42137. /**
  42138. * Internal gizmo used for interactions on the x axis
  42139. */
  42140. xGizmo: AxisScaleGizmo;
  42141. /**
  42142. * Internal gizmo used for interactions on the y axis
  42143. */
  42144. yGizmo: AxisScaleGizmo;
  42145. /**
  42146. * Internal gizmo used for interactions on the z axis
  42147. */
  42148. zGizmo: AxisScaleGizmo;
  42149. /**
  42150. * Internal gizmo used to scale all axis equally
  42151. */
  42152. uniformScaleGizmo: AxisScaleGizmo;
  42153. /** Fires an event when any of it's sub gizmos are dragged */
  42154. onDragStartObservable: Observable<{}>;
  42155. /** Fires an event when any of it's sub gizmos are released from dragging */
  42156. onDragEndObservable: Observable<{}>;
  42157. attachedMesh: Nullable<AbstractMesh>;
  42158. /**
  42159. * Creates a ScaleGizmo
  42160. * @param gizmoLayer The utility layer the gizmo will be added to
  42161. */
  42162. constructor(gizmoLayer?: UtilityLayerRenderer);
  42163. updateGizmoRotationToMatchAttachedMesh: boolean;
  42164. /**
  42165. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42166. */
  42167. snapDistance: number;
  42168. /**
  42169. * Ratio for the scale of the gizmo (Default: 1)
  42170. */
  42171. scaleRatio: number;
  42172. /**
  42173. * Disposes of the gizmo
  42174. */
  42175. dispose(): void;
  42176. }
  42177. }
  42178. declare module BABYLON {
  42179. /**
  42180. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42181. */
  42182. export class GizmoManager implements IDisposable {
  42183. private scene;
  42184. /**
  42185. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42186. */
  42187. gizmos: {
  42188. positionGizmo: Nullable<PositionGizmo>;
  42189. rotationGizmo: Nullable<RotationGizmo>;
  42190. scaleGizmo: Nullable<ScaleGizmo>;
  42191. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42192. };
  42193. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42194. clearGizmoOnEmptyPointerEvent: boolean;
  42195. /** Fires an event when the manager is attached to a mesh */
  42196. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42197. private _gizmosEnabled;
  42198. private _pointerObserver;
  42199. private _attachedMesh;
  42200. private _boundingBoxColor;
  42201. private _defaultUtilityLayer;
  42202. private _defaultKeepDepthUtilityLayer;
  42203. /**
  42204. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42205. */
  42206. boundingBoxDragBehavior: SixDofDragBehavior;
  42207. /**
  42208. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42209. */
  42210. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42211. /**
  42212. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42213. */
  42214. usePointerToAttachGizmos: boolean;
  42215. /**
  42216. * Instatiates a gizmo manager
  42217. * @param scene the scene to overlay the gizmos on top of
  42218. */
  42219. constructor(scene: Scene);
  42220. /**
  42221. * Attaches a set of gizmos to the specified mesh
  42222. * @param mesh The mesh the gizmo's should be attached to
  42223. */
  42224. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42225. /**
  42226. * If the position gizmo is enabled
  42227. */
  42228. positionGizmoEnabled: boolean;
  42229. /**
  42230. * If the rotation gizmo is enabled
  42231. */
  42232. rotationGizmoEnabled: boolean;
  42233. /**
  42234. * If the scale gizmo is enabled
  42235. */
  42236. scaleGizmoEnabled: boolean;
  42237. /**
  42238. * If the boundingBox gizmo is enabled
  42239. */
  42240. boundingBoxGizmoEnabled: boolean;
  42241. /**
  42242. * Disposes of the gizmo manager
  42243. */
  42244. dispose(): void;
  42245. }
  42246. }
  42247. declare module BABYLON {
  42248. /**
  42249. * A directional light is defined by a direction (what a surprise!).
  42250. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42251. * 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.
  42252. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42253. */
  42254. export class DirectionalLight extends ShadowLight {
  42255. private _shadowFrustumSize;
  42256. /**
  42257. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42258. */
  42259. /**
  42260. * Specifies a fix frustum size for the shadow generation.
  42261. */
  42262. shadowFrustumSize: number;
  42263. private _shadowOrthoScale;
  42264. /**
  42265. * Gets the shadow projection scale against the optimal computed one.
  42266. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42267. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42268. */
  42269. /**
  42270. * Sets the shadow projection scale against the optimal computed one.
  42271. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42272. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42273. */
  42274. shadowOrthoScale: number;
  42275. /**
  42276. * Automatically compute the projection matrix to best fit (including all the casters)
  42277. * on each frame.
  42278. */
  42279. autoUpdateExtends: boolean;
  42280. private _orthoLeft;
  42281. private _orthoRight;
  42282. private _orthoTop;
  42283. private _orthoBottom;
  42284. /**
  42285. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42286. * The directional light is emitted from everywhere in the given direction.
  42287. * It can cast shadows.
  42288. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42289. * @param name The friendly name of the light
  42290. * @param direction The direction of the light
  42291. * @param scene The scene the light belongs to
  42292. */
  42293. constructor(name: string, direction: Vector3, scene: Scene);
  42294. /**
  42295. * Returns the string "DirectionalLight".
  42296. * @return The class name
  42297. */
  42298. getClassName(): string;
  42299. /**
  42300. * Returns the integer 1.
  42301. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42302. */
  42303. getTypeID(): number;
  42304. /**
  42305. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42306. * Returns the DirectionalLight Shadow projection matrix.
  42307. */
  42308. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42309. /**
  42310. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42311. * Returns the DirectionalLight Shadow projection matrix.
  42312. */
  42313. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42314. /**
  42315. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42316. * Returns the DirectionalLight Shadow projection matrix.
  42317. */
  42318. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42319. protected _buildUniformLayout(): void;
  42320. /**
  42321. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42322. * @param effect The effect to update
  42323. * @param lightIndex The index of the light in the effect to update
  42324. * @returns The directional light
  42325. */
  42326. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42327. /**
  42328. * Gets the minZ used for shadow according to both the scene and the light.
  42329. *
  42330. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42331. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42332. * @param activeCamera The camera we are returning the min for
  42333. * @returns the depth min z
  42334. */
  42335. getDepthMinZ(activeCamera: Camera): number;
  42336. /**
  42337. * Gets the maxZ used for shadow according to both the scene and the light.
  42338. *
  42339. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42340. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42341. * @param activeCamera The camera we are returning the max for
  42342. * @returns the depth max z
  42343. */
  42344. getDepthMaxZ(activeCamera: Camera): number;
  42345. /**
  42346. * Prepares the list of defines specific to the light type.
  42347. * @param defines the list of defines
  42348. * @param lightIndex defines the index of the light for the effect
  42349. */
  42350. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42351. }
  42352. }
  42353. declare module BABYLON {
  42354. /**
  42355. * Class containing static functions to help procedurally build meshes
  42356. */
  42357. export class HemisphereBuilder {
  42358. /**
  42359. * Creates a hemisphere mesh
  42360. * @param name defines the name of the mesh
  42361. * @param options defines the options used to create the mesh
  42362. * @param scene defines the hosting scene
  42363. * @returns the hemisphere mesh
  42364. */
  42365. static CreateHemisphere(name: string, options: {
  42366. segments?: number;
  42367. diameter?: number;
  42368. sideOrientation?: number;
  42369. }, scene: any): Mesh;
  42370. }
  42371. }
  42372. declare module BABYLON {
  42373. /**
  42374. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42375. * These values define a cone of light starting from the position, emitting toward the direction.
  42376. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42377. * and the exponent defines the speed of the decay of the light with distance (reach).
  42378. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42379. */
  42380. export class SpotLight extends ShadowLight {
  42381. private _angle;
  42382. private _innerAngle;
  42383. private _cosHalfAngle;
  42384. private _lightAngleScale;
  42385. private _lightAngleOffset;
  42386. /**
  42387. * Gets the cone angle of the spot light in Radians.
  42388. */
  42389. /**
  42390. * Sets the cone angle of the spot light in Radians.
  42391. */
  42392. angle: number;
  42393. /**
  42394. * Only used in gltf falloff mode, this defines the angle where
  42395. * the directional falloff will start before cutting at angle which could be seen
  42396. * as outer angle.
  42397. */
  42398. /**
  42399. * Only used in gltf falloff mode, this defines the angle where
  42400. * the directional falloff will start before cutting at angle which could be seen
  42401. * as outer angle.
  42402. */
  42403. innerAngle: number;
  42404. private _shadowAngleScale;
  42405. /**
  42406. * Allows scaling the angle of the light for shadow generation only.
  42407. */
  42408. /**
  42409. * Allows scaling the angle of the light for shadow generation only.
  42410. */
  42411. shadowAngleScale: number;
  42412. /**
  42413. * The light decay speed with the distance from the emission spot.
  42414. */
  42415. exponent: number;
  42416. private _projectionTextureMatrix;
  42417. /**
  42418. * Allows reading the projecton texture
  42419. */
  42420. readonly projectionTextureMatrix: Matrix;
  42421. protected _projectionTextureLightNear: number;
  42422. /**
  42423. * Gets the near clip of the Spotlight for texture projection.
  42424. */
  42425. /**
  42426. * Sets the near clip of the Spotlight for texture projection.
  42427. */
  42428. projectionTextureLightNear: number;
  42429. protected _projectionTextureLightFar: number;
  42430. /**
  42431. * Gets the far clip of the Spotlight for texture projection.
  42432. */
  42433. /**
  42434. * Sets the far clip of the Spotlight for texture projection.
  42435. */
  42436. projectionTextureLightFar: number;
  42437. protected _projectionTextureUpDirection: Vector3;
  42438. /**
  42439. * Gets the Up vector of the Spotlight for texture projection.
  42440. */
  42441. /**
  42442. * Sets the Up vector of the Spotlight for texture projection.
  42443. */
  42444. projectionTextureUpDirection: Vector3;
  42445. private _projectionTexture;
  42446. /**
  42447. * Gets the projection texture of the light.
  42448. */
  42449. /**
  42450. * Sets the projection texture of the light.
  42451. */
  42452. projectionTexture: Nullable<BaseTexture>;
  42453. private _projectionTextureViewLightDirty;
  42454. private _projectionTextureProjectionLightDirty;
  42455. private _projectionTextureDirty;
  42456. private _projectionTextureViewTargetVector;
  42457. private _projectionTextureViewLightMatrix;
  42458. private _projectionTextureProjectionLightMatrix;
  42459. private _projectionTextureScalingMatrix;
  42460. /**
  42461. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42462. * It can cast shadows.
  42463. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42464. * @param name The light friendly name
  42465. * @param position The position of the spot light in the scene
  42466. * @param direction The direction of the light in the scene
  42467. * @param angle The cone angle of the light in Radians
  42468. * @param exponent The light decay speed with the distance from the emission spot
  42469. * @param scene The scene the lights belongs to
  42470. */
  42471. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42472. /**
  42473. * Returns the string "SpotLight".
  42474. * @returns the class name
  42475. */
  42476. getClassName(): string;
  42477. /**
  42478. * Returns the integer 2.
  42479. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42480. */
  42481. getTypeID(): number;
  42482. /**
  42483. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42484. */
  42485. protected _setDirection(value: Vector3): void;
  42486. /**
  42487. * Overrides the position setter to recompute the projection texture view light Matrix.
  42488. */
  42489. protected _setPosition(value: Vector3): void;
  42490. /**
  42491. * 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.
  42492. * Returns the SpotLight.
  42493. */
  42494. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42495. protected _computeProjectionTextureViewLightMatrix(): void;
  42496. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42497. /**
  42498. * Main function for light texture projection matrix computing.
  42499. */
  42500. protected _computeProjectionTextureMatrix(): void;
  42501. protected _buildUniformLayout(): void;
  42502. private _computeAngleValues;
  42503. /**
  42504. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42505. * @param effect The effect to update
  42506. * @param lightIndex The index of the light in the effect to update
  42507. * @returns The spot light
  42508. */
  42509. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42510. /**
  42511. * Disposes the light and the associated resources.
  42512. */
  42513. dispose(): void;
  42514. /**
  42515. * Prepares the list of defines specific to the light type.
  42516. * @param defines the list of defines
  42517. * @param lightIndex defines the index of the light for the effect
  42518. */
  42519. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42520. }
  42521. }
  42522. declare module BABYLON {
  42523. /**
  42524. * Gizmo that enables viewing a light
  42525. */
  42526. export class LightGizmo extends Gizmo {
  42527. private _lightMesh;
  42528. private _material;
  42529. /**
  42530. * Creates a LightGizmo
  42531. * @param gizmoLayer The utility layer the gizmo will be added to
  42532. */
  42533. constructor(gizmoLayer?: UtilityLayerRenderer);
  42534. private _light;
  42535. /**
  42536. * The light that the gizmo is attached to
  42537. */
  42538. light: Nullable<Light>;
  42539. /**
  42540. * @hidden
  42541. * Updates the gizmo to match the attached mesh's position/rotation
  42542. */
  42543. protected _update(): void;
  42544. private static _Scale;
  42545. /**
  42546. * Creates the lines for a light mesh
  42547. */
  42548. private static _createLightLines;
  42549. private static _CreateHemisphericLightMesh;
  42550. private static _CreatePointLightMesh;
  42551. private static _CreateSpotLightMesh;
  42552. private static _CreateDirectionalLightMesh;
  42553. }
  42554. }
  42555. declare module BABYLON {
  42556. /** @hidden */
  42557. export var backgroundFragmentDeclaration: {
  42558. name: string;
  42559. shader: string;
  42560. };
  42561. }
  42562. declare module BABYLON {
  42563. /** @hidden */
  42564. export var backgroundUboDeclaration: {
  42565. name: string;
  42566. shader: string;
  42567. };
  42568. }
  42569. declare module BABYLON {
  42570. /** @hidden */
  42571. export var backgroundPixelShader: {
  42572. name: string;
  42573. shader: string;
  42574. };
  42575. }
  42576. declare module BABYLON {
  42577. /** @hidden */
  42578. export var backgroundVertexDeclaration: {
  42579. name: string;
  42580. shader: string;
  42581. };
  42582. }
  42583. declare module BABYLON {
  42584. /** @hidden */
  42585. export var backgroundVertexShader: {
  42586. name: string;
  42587. shader: string;
  42588. };
  42589. }
  42590. declare module BABYLON {
  42591. /**
  42592. * Background material used to create an efficient environement around your scene.
  42593. */
  42594. export class BackgroundMaterial extends PushMaterial {
  42595. /**
  42596. * Standard reflectance value at parallel view angle.
  42597. */
  42598. static StandardReflectance0: number;
  42599. /**
  42600. * Standard reflectance value at grazing angle.
  42601. */
  42602. static StandardReflectance90: number;
  42603. protected _primaryColor: Color3;
  42604. /**
  42605. * Key light Color (multiply against the environement texture)
  42606. */
  42607. primaryColor: Color3;
  42608. protected __perceptualColor: Nullable<Color3>;
  42609. /**
  42610. * Experimental Internal Use Only.
  42611. *
  42612. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42613. * This acts as a helper to set the primary color to a more "human friendly" value.
  42614. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42615. * output color as close as possible from the chosen value.
  42616. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42617. * part of lighting setup.)
  42618. */ perceptualColor: Nullable<Color3>;
  42619. protected _primaryColorShadowLevel: float;
  42620. /**
  42621. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42622. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42623. */
  42624. primaryColorShadowLevel: float;
  42625. protected _primaryColorHighlightLevel: float;
  42626. /**
  42627. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42628. * The primary color is used at the level chosen to define what the white area would look.
  42629. */
  42630. primaryColorHighlightLevel: float;
  42631. protected _reflectionTexture: Nullable<BaseTexture>;
  42632. /**
  42633. * Reflection Texture used in the material.
  42634. * Should be author in a specific way for the best result (refer to the documentation).
  42635. */
  42636. reflectionTexture: Nullable<BaseTexture>;
  42637. protected _reflectionBlur: float;
  42638. /**
  42639. * Reflection Texture level of blur.
  42640. *
  42641. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42642. * texture twice.
  42643. */
  42644. reflectionBlur: float;
  42645. protected _diffuseTexture: Nullable<BaseTexture>;
  42646. /**
  42647. * Diffuse Texture used in the material.
  42648. * Should be author in a specific way for the best result (refer to the documentation).
  42649. */
  42650. diffuseTexture: Nullable<BaseTexture>;
  42651. protected _shadowLights: Nullable<IShadowLight[]>;
  42652. /**
  42653. * Specify the list of lights casting shadow on the material.
  42654. * All scene shadow lights will be included if null.
  42655. */
  42656. shadowLights: Nullable<IShadowLight[]>;
  42657. protected _shadowLevel: float;
  42658. /**
  42659. * Helps adjusting the shadow to a softer level if required.
  42660. * 0 means black shadows and 1 means no shadows.
  42661. */
  42662. shadowLevel: float;
  42663. protected _sceneCenter: Vector3;
  42664. /**
  42665. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42666. * It is usually zero but might be interesting to modify according to your setup.
  42667. */
  42668. sceneCenter: Vector3;
  42669. protected _opacityFresnel: boolean;
  42670. /**
  42671. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42672. * This helps ensuring a nice transition when the camera goes under the ground.
  42673. */
  42674. opacityFresnel: boolean;
  42675. protected _reflectionFresnel: boolean;
  42676. /**
  42677. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42678. * This helps adding a mirror texture on the ground.
  42679. */
  42680. reflectionFresnel: boolean;
  42681. protected _reflectionFalloffDistance: number;
  42682. /**
  42683. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42684. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42685. */
  42686. reflectionFalloffDistance: number;
  42687. protected _reflectionAmount: number;
  42688. /**
  42689. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42690. */
  42691. reflectionAmount: number;
  42692. protected _reflectionReflectance0: number;
  42693. /**
  42694. * This specifies the weight of the reflection at grazing angle.
  42695. */
  42696. reflectionReflectance0: number;
  42697. protected _reflectionReflectance90: number;
  42698. /**
  42699. * This specifies the weight of the reflection at a perpendicular point of view.
  42700. */
  42701. reflectionReflectance90: number;
  42702. /**
  42703. * Sets the reflection reflectance fresnel values according to the default standard
  42704. * empirically know to work well :-)
  42705. */
  42706. reflectionStandardFresnelWeight: number;
  42707. protected _useRGBColor: boolean;
  42708. /**
  42709. * Helps to directly use the maps channels instead of their level.
  42710. */
  42711. useRGBColor: boolean;
  42712. protected _enableNoise: boolean;
  42713. /**
  42714. * This helps reducing the banding effect that could occur on the background.
  42715. */
  42716. enableNoise: boolean;
  42717. /**
  42718. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42719. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42720. * Recommended to be keep at 1.0 except for special cases.
  42721. */
  42722. fovMultiplier: number;
  42723. private _fovMultiplier;
  42724. /**
  42725. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42726. */
  42727. useEquirectangularFOV: boolean;
  42728. private _maxSimultaneousLights;
  42729. /**
  42730. * Number of Simultaneous lights allowed on the material.
  42731. */
  42732. maxSimultaneousLights: int;
  42733. /**
  42734. * Default configuration related to image processing available in the Background Material.
  42735. */
  42736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42737. /**
  42738. * Keep track of the image processing observer to allow dispose and replace.
  42739. */
  42740. private _imageProcessingObserver;
  42741. /**
  42742. * Attaches a new image processing configuration to the PBR Material.
  42743. * @param configuration (if null the scene configuration will be use)
  42744. */
  42745. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42746. /**
  42747. * Gets the image processing configuration used either in this material.
  42748. */
  42749. /**
  42750. * Sets the Default image processing configuration used either in the this material.
  42751. *
  42752. * If sets to null, the scene one is in use.
  42753. */
  42754. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42755. /**
  42756. * Gets wether the color curves effect is enabled.
  42757. */
  42758. /**
  42759. * Sets wether the color curves effect is enabled.
  42760. */
  42761. cameraColorCurvesEnabled: boolean;
  42762. /**
  42763. * Gets wether the color grading effect is enabled.
  42764. */
  42765. /**
  42766. * Gets wether the color grading effect is enabled.
  42767. */
  42768. cameraColorGradingEnabled: boolean;
  42769. /**
  42770. * Gets wether tonemapping is enabled or not.
  42771. */
  42772. /**
  42773. * Sets wether tonemapping is enabled or not
  42774. */
  42775. cameraToneMappingEnabled: boolean;
  42776. /**
  42777. * The camera exposure used on this material.
  42778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42779. * This corresponds to a photographic exposure.
  42780. */
  42781. /**
  42782. * The camera exposure used on this material.
  42783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42784. * This corresponds to a photographic exposure.
  42785. */
  42786. cameraExposure: float;
  42787. /**
  42788. * Gets The camera contrast used on this material.
  42789. */
  42790. /**
  42791. * Sets The camera contrast used on this material.
  42792. */
  42793. cameraContrast: float;
  42794. /**
  42795. * Gets the Color Grading 2D Lookup Texture.
  42796. */
  42797. /**
  42798. * Sets the Color Grading 2D Lookup Texture.
  42799. */
  42800. cameraColorGradingTexture: Nullable<BaseTexture>;
  42801. /**
  42802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42804. * 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;
  42805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42806. */
  42807. /**
  42808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42810. * 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;
  42811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42812. */
  42813. cameraColorCurves: Nullable<ColorCurves>;
  42814. /**
  42815. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42816. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42817. */
  42818. switchToBGR: boolean;
  42819. private _renderTargets;
  42820. private _reflectionControls;
  42821. private _white;
  42822. private _primaryShadowColor;
  42823. private _primaryHighlightColor;
  42824. /**
  42825. * Instantiates a Background Material in the given scene
  42826. * @param name The friendly name of the material
  42827. * @param scene The scene to add the material to
  42828. */
  42829. constructor(name: string, scene: Scene);
  42830. /**
  42831. * Gets a boolean indicating that current material needs to register RTT
  42832. */
  42833. readonly hasRenderTargetTextures: boolean;
  42834. /**
  42835. * The entire material has been created in order to prevent overdraw.
  42836. * @returns false
  42837. */
  42838. needAlphaTesting(): boolean;
  42839. /**
  42840. * The entire material has been created in order to prevent overdraw.
  42841. * @returns true if blending is enable
  42842. */
  42843. needAlphaBlending(): boolean;
  42844. /**
  42845. * Checks wether the material is ready to be rendered for a given mesh.
  42846. * @param mesh The mesh to render
  42847. * @param subMesh The submesh to check against
  42848. * @param useInstances Specify wether or not the material is used with instances
  42849. * @returns true if all the dependencies are ready (Textures, Effects...)
  42850. */
  42851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42852. /**
  42853. * Compute the primary color according to the chosen perceptual color.
  42854. */
  42855. private _computePrimaryColorFromPerceptualColor;
  42856. /**
  42857. * Compute the highlights and shadow colors according to their chosen levels.
  42858. */
  42859. private _computePrimaryColors;
  42860. /**
  42861. * Build the uniform buffer used in the material.
  42862. */
  42863. buildUniformLayout(): void;
  42864. /**
  42865. * Unbind the material.
  42866. */
  42867. unbind(): void;
  42868. /**
  42869. * Bind only the world matrix to the material.
  42870. * @param world The world matrix to bind.
  42871. */
  42872. bindOnlyWorldMatrix(world: Matrix): void;
  42873. /**
  42874. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42875. * @param world The world matrix to bind.
  42876. * @param subMesh The submesh to bind for.
  42877. */
  42878. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42879. /**
  42880. * Dispose the material.
  42881. * @param forceDisposeEffect Force disposal of the associated effect.
  42882. * @param forceDisposeTextures Force disposal of the associated textures.
  42883. */
  42884. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42885. /**
  42886. * Clones the material.
  42887. * @param name The cloned name.
  42888. * @returns The cloned material.
  42889. */
  42890. clone(name: string): BackgroundMaterial;
  42891. /**
  42892. * Serializes the current material to its JSON representation.
  42893. * @returns The JSON representation.
  42894. */
  42895. serialize(): any;
  42896. /**
  42897. * Gets the class name of the material
  42898. * @returns "BackgroundMaterial"
  42899. */
  42900. getClassName(): string;
  42901. /**
  42902. * Parse a JSON input to create back a background material.
  42903. * @param source The JSON data to parse
  42904. * @param scene The scene to create the parsed material in
  42905. * @param rootUrl The root url of the assets the material depends upon
  42906. * @returns the instantiated BackgroundMaterial.
  42907. */
  42908. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42909. }
  42910. }
  42911. declare module BABYLON {
  42912. /**
  42913. * Represents the different options available during the creation of
  42914. * a Environment helper.
  42915. *
  42916. * This can control the default ground, skybox and image processing setup of your scene.
  42917. */
  42918. export interface IEnvironmentHelperOptions {
  42919. /**
  42920. * Specifies wether or not to create a ground.
  42921. * True by default.
  42922. */
  42923. createGround: boolean;
  42924. /**
  42925. * Specifies the ground size.
  42926. * 15 by default.
  42927. */
  42928. groundSize: number;
  42929. /**
  42930. * The texture used on the ground for the main color.
  42931. * Comes from the BabylonJS CDN by default.
  42932. *
  42933. * Remarks: Can be either a texture or a url.
  42934. */
  42935. groundTexture: string | BaseTexture;
  42936. /**
  42937. * The color mixed in the ground texture by default.
  42938. * BabylonJS clearColor by default.
  42939. */
  42940. groundColor: Color3;
  42941. /**
  42942. * Specifies the ground opacity.
  42943. * 1 by default.
  42944. */
  42945. groundOpacity: number;
  42946. /**
  42947. * Enables the ground to receive shadows.
  42948. * True by default.
  42949. */
  42950. enableGroundShadow: boolean;
  42951. /**
  42952. * Helps preventing the shadow to be fully black on the ground.
  42953. * 0.5 by default.
  42954. */
  42955. groundShadowLevel: number;
  42956. /**
  42957. * Creates a mirror texture attach to the ground.
  42958. * false by default.
  42959. */
  42960. enableGroundMirror: boolean;
  42961. /**
  42962. * Specifies the ground mirror size ratio.
  42963. * 0.3 by default as the default kernel is 64.
  42964. */
  42965. groundMirrorSizeRatio: number;
  42966. /**
  42967. * Specifies the ground mirror blur kernel size.
  42968. * 64 by default.
  42969. */
  42970. groundMirrorBlurKernel: number;
  42971. /**
  42972. * Specifies the ground mirror visibility amount.
  42973. * 1 by default
  42974. */
  42975. groundMirrorAmount: number;
  42976. /**
  42977. * Specifies the ground mirror reflectance weight.
  42978. * This uses the standard weight of the background material to setup the fresnel effect
  42979. * of the mirror.
  42980. * 1 by default.
  42981. */
  42982. groundMirrorFresnelWeight: number;
  42983. /**
  42984. * Specifies the ground mirror Falloff distance.
  42985. * This can helps reducing the size of the reflection.
  42986. * 0 by Default.
  42987. */
  42988. groundMirrorFallOffDistance: number;
  42989. /**
  42990. * Specifies the ground mirror texture type.
  42991. * Unsigned Int by Default.
  42992. */
  42993. groundMirrorTextureType: number;
  42994. /**
  42995. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42996. * the shown objects.
  42997. */
  42998. groundYBias: number;
  42999. /**
  43000. * Specifies wether or not to create a skybox.
  43001. * True by default.
  43002. */
  43003. createSkybox: boolean;
  43004. /**
  43005. * Specifies the skybox size.
  43006. * 20 by default.
  43007. */
  43008. skyboxSize: number;
  43009. /**
  43010. * The texture used on the skybox for the main color.
  43011. * Comes from the BabylonJS CDN by default.
  43012. *
  43013. * Remarks: Can be either a texture or a url.
  43014. */
  43015. skyboxTexture: string | BaseTexture;
  43016. /**
  43017. * The color mixed in the skybox texture by default.
  43018. * BabylonJS clearColor by default.
  43019. */
  43020. skyboxColor: Color3;
  43021. /**
  43022. * The background rotation around the Y axis of the scene.
  43023. * This helps aligning the key lights of your scene with the background.
  43024. * 0 by default.
  43025. */
  43026. backgroundYRotation: number;
  43027. /**
  43028. * Compute automatically the size of the elements to best fit with the scene.
  43029. */
  43030. sizeAuto: boolean;
  43031. /**
  43032. * Default position of the rootMesh if autoSize is not true.
  43033. */
  43034. rootPosition: Vector3;
  43035. /**
  43036. * Sets up the image processing in the scene.
  43037. * true by default.
  43038. */
  43039. setupImageProcessing: boolean;
  43040. /**
  43041. * The texture used as your environment texture in the scene.
  43042. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43043. *
  43044. * Remarks: Can be either a texture or a url.
  43045. */
  43046. environmentTexture: string | BaseTexture;
  43047. /**
  43048. * The value of the exposure to apply to the scene.
  43049. * 0.6 by default if setupImageProcessing is true.
  43050. */
  43051. cameraExposure: number;
  43052. /**
  43053. * The value of the contrast to apply to the scene.
  43054. * 1.6 by default if setupImageProcessing is true.
  43055. */
  43056. cameraContrast: number;
  43057. /**
  43058. * Specifies wether or not tonemapping should be enabled in the scene.
  43059. * true by default if setupImageProcessing is true.
  43060. */
  43061. toneMappingEnabled: boolean;
  43062. }
  43063. /**
  43064. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43065. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43066. * It also helps with the default setup of your imageProcessing configuration.
  43067. */
  43068. export class EnvironmentHelper {
  43069. /**
  43070. * Default ground texture URL.
  43071. */
  43072. private static _groundTextureCDNUrl;
  43073. /**
  43074. * Default skybox texture URL.
  43075. */
  43076. private static _skyboxTextureCDNUrl;
  43077. /**
  43078. * Default environment texture URL.
  43079. */
  43080. private static _environmentTextureCDNUrl;
  43081. /**
  43082. * Creates the default options for the helper.
  43083. */
  43084. private static _getDefaultOptions;
  43085. private _rootMesh;
  43086. /**
  43087. * Gets the root mesh created by the helper.
  43088. */
  43089. readonly rootMesh: Mesh;
  43090. private _skybox;
  43091. /**
  43092. * Gets the skybox created by the helper.
  43093. */
  43094. readonly skybox: Nullable<Mesh>;
  43095. private _skyboxTexture;
  43096. /**
  43097. * Gets the skybox texture created by the helper.
  43098. */
  43099. readonly skyboxTexture: Nullable<BaseTexture>;
  43100. private _skyboxMaterial;
  43101. /**
  43102. * Gets the skybox material created by the helper.
  43103. */
  43104. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43105. private _ground;
  43106. /**
  43107. * Gets the ground mesh created by the helper.
  43108. */
  43109. readonly ground: Nullable<Mesh>;
  43110. private _groundTexture;
  43111. /**
  43112. * Gets the ground texture created by the helper.
  43113. */
  43114. readonly groundTexture: Nullable<BaseTexture>;
  43115. private _groundMirror;
  43116. /**
  43117. * Gets the ground mirror created by the helper.
  43118. */
  43119. readonly groundMirror: Nullable<MirrorTexture>;
  43120. /**
  43121. * Gets the ground mirror render list to helps pushing the meshes
  43122. * you wish in the ground reflection.
  43123. */
  43124. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43125. private _groundMaterial;
  43126. /**
  43127. * Gets the ground material created by the helper.
  43128. */
  43129. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43130. /**
  43131. * Stores the creation options.
  43132. */
  43133. private readonly _scene;
  43134. private _options;
  43135. /**
  43136. * This observable will be notified with any error during the creation of the environment,
  43137. * mainly texture creation errors.
  43138. */
  43139. onErrorObservable: Observable<{
  43140. message?: string;
  43141. exception?: any;
  43142. }>;
  43143. /**
  43144. * constructor
  43145. * @param options Defines the options we want to customize the helper
  43146. * @param scene The scene to add the material to
  43147. */
  43148. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43149. /**
  43150. * Updates the background according to the new options
  43151. * @param options
  43152. */
  43153. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43154. /**
  43155. * Sets the primary color of all the available elements.
  43156. * @param color the main color to affect to the ground and the background
  43157. */
  43158. setMainColor(color: Color3): void;
  43159. /**
  43160. * Setup the image processing according to the specified options.
  43161. */
  43162. private _setupImageProcessing;
  43163. /**
  43164. * Setup the environment texture according to the specified options.
  43165. */
  43166. private _setupEnvironmentTexture;
  43167. /**
  43168. * Setup the background according to the specified options.
  43169. */
  43170. private _setupBackground;
  43171. /**
  43172. * Get the scene sizes according to the setup.
  43173. */
  43174. private _getSceneSize;
  43175. /**
  43176. * Setup the ground according to the specified options.
  43177. */
  43178. private _setupGround;
  43179. /**
  43180. * Setup the ground material according to the specified options.
  43181. */
  43182. private _setupGroundMaterial;
  43183. /**
  43184. * Setup the ground diffuse texture according to the specified options.
  43185. */
  43186. private _setupGroundDiffuseTexture;
  43187. /**
  43188. * Setup the ground mirror texture according to the specified options.
  43189. */
  43190. private _setupGroundMirrorTexture;
  43191. /**
  43192. * Setup the ground to receive the mirror texture.
  43193. */
  43194. private _setupMirrorInGroundMaterial;
  43195. /**
  43196. * Setup the skybox according to the specified options.
  43197. */
  43198. private _setupSkybox;
  43199. /**
  43200. * Setup the skybox material according to the specified options.
  43201. */
  43202. private _setupSkyboxMaterial;
  43203. /**
  43204. * Setup the skybox reflection texture according to the specified options.
  43205. */
  43206. private _setupSkyboxReflectionTexture;
  43207. private _errorHandler;
  43208. /**
  43209. * Dispose all the elements created by the Helper.
  43210. */
  43211. dispose(): void;
  43212. }
  43213. }
  43214. declare module BABYLON {
  43215. /**
  43216. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43217. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43218. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43219. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43220. */
  43221. export class PhotoDome extends TransformNode {
  43222. private _useDirectMapping;
  43223. /**
  43224. * The texture being displayed on the sphere
  43225. */
  43226. protected _photoTexture: Texture;
  43227. /**
  43228. * Gets or sets the texture being displayed on the sphere
  43229. */
  43230. photoTexture: Texture;
  43231. /**
  43232. * Observable raised when an error occured while loading the 360 image
  43233. */
  43234. onLoadErrorObservable: Observable<string>;
  43235. /**
  43236. * The skybox material
  43237. */
  43238. protected _material: BackgroundMaterial;
  43239. /**
  43240. * The surface used for the skybox
  43241. */
  43242. protected _mesh: Mesh;
  43243. /**
  43244. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43245. * Also see the options.resolution property.
  43246. */
  43247. fovMultiplier: number;
  43248. /**
  43249. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43250. * @param name Element's name, child elements will append suffixes for their own names.
  43251. * @param urlsOfPhoto defines the url of the photo to display
  43252. * @param options defines an object containing optional or exposed sub element properties
  43253. * @param onError defines a callback called when an error occured while loading the texture
  43254. */
  43255. constructor(name: string, urlOfPhoto: string, options: {
  43256. resolution?: number;
  43257. size?: number;
  43258. useDirectMapping?: boolean;
  43259. faceForward?: boolean;
  43260. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43261. /**
  43262. * Releases resources associated with this node.
  43263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43265. */
  43266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43267. }
  43268. }
  43269. declare module BABYLON {
  43270. /** @hidden */
  43271. export var rgbdDecodePixelShader: {
  43272. name: string;
  43273. shader: string;
  43274. };
  43275. }
  43276. declare module BABYLON {
  43277. /**
  43278. * Class used to host texture specific utilities
  43279. */
  43280. export class BRDFTextureTools {
  43281. /**
  43282. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43283. * @param texture the texture to expand.
  43284. */
  43285. private static _ExpandDefaultBRDFTexture;
  43286. /**
  43287. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43288. * @param scene defines the hosting scene
  43289. * @returns the environment BRDF texture
  43290. */
  43291. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43292. private static _environmentBRDFBase64Texture;
  43293. }
  43294. }
  43295. declare module BABYLON {
  43296. /**
  43297. * @hidden
  43298. */
  43299. export interface IMaterialClearCoatDefines {
  43300. CLEARCOAT: boolean;
  43301. CLEARCOAT_DEFAULTIOR: boolean;
  43302. CLEARCOAT_TEXTURE: boolean;
  43303. CLEARCOAT_TEXTUREDIRECTUV: number;
  43304. CLEARCOAT_BUMP: boolean;
  43305. CLEARCOAT_BUMPDIRECTUV: number;
  43306. CLEARCOAT_TINT: boolean;
  43307. CLEARCOAT_TINT_TEXTURE: boolean;
  43308. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43309. /** @hidden */ areTexturesDirty: boolean;
  43310. }
  43311. /**
  43312. * Define the code related to the clear coat parameters of the pbr material.
  43313. */
  43314. export class PBRClearCoatConfiguration {
  43315. /**
  43316. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43317. * The default fits with a polyurethane material.
  43318. */
  43319. private static readonly _DefaultIndiceOfRefraction;
  43320. private _isEnabled;
  43321. /**
  43322. * Defines if the clear coat is enabled in the material.
  43323. */
  43324. isEnabled: boolean;
  43325. /**
  43326. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43327. */
  43328. intensity: number;
  43329. /**
  43330. * Defines the clear coat layer roughness.
  43331. */
  43332. roughness: number;
  43333. private _indiceOfRefraction;
  43334. /**
  43335. * Defines the indice of refraction of the clear coat.
  43336. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43337. * The default fits with a polyurethane material.
  43338. * Changing the default value is more performance intensive.
  43339. */
  43340. indiceOfRefraction: number;
  43341. private _texture;
  43342. /**
  43343. * Stores the clear coat values in a texture.
  43344. */
  43345. texture: Nullable<BaseTexture>;
  43346. private _bumpTexture;
  43347. /**
  43348. * Define the clear coat specific bump texture.
  43349. */
  43350. bumpTexture: Nullable<BaseTexture>;
  43351. private _isTintEnabled;
  43352. /**
  43353. * Defines if the clear coat tint is enabled in the material.
  43354. */
  43355. isTintEnabled: boolean;
  43356. /**
  43357. * Defines the clear coat tint of the material.
  43358. * This is only use if tint is enabled
  43359. */
  43360. tintColor: Color3;
  43361. /**
  43362. * Defines the distance at which the tint color should be found in the
  43363. * clear coat media.
  43364. * This is only use if tint is enabled
  43365. */
  43366. tintColorAtDistance: number;
  43367. /**
  43368. * Defines the clear coat layer thickness.
  43369. * This is only use if tint is enabled
  43370. */
  43371. tintThickness: number;
  43372. private _tintTexture;
  43373. /**
  43374. * Stores the clear tint values in a texture.
  43375. * rgb is tint
  43376. * a is a thickness factor
  43377. */
  43378. tintTexture: Nullable<BaseTexture>;
  43379. /** @hidden */
  43380. private _internalMarkAllSubMeshesAsTexturesDirty;
  43381. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43382. /**
  43383. * Instantiate a new istance of clear coat configuration.
  43384. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43385. */
  43386. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43387. /**
  43388. * Gets wehter the submesh is ready to be used or not.
  43389. * @param defines the list of "defines" to update.
  43390. * @param scene defines the scene the material belongs to.
  43391. * @param engine defines the engine the material belongs to.
  43392. * @param disableBumpMap defines wether the material disables bump or not.
  43393. * @returns - boolean indicating that the submesh is ready or not.
  43394. */
  43395. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43396. /**
  43397. * Checks to see if a texture is used in the material.
  43398. * @param defines the list of "defines" to update.
  43399. * @param scene defines the scene to the material belongs to.
  43400. */
  43401. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43402. /**
  43403. * Binds the material data.
  43404. * @param uniformBuffer defines the Uniform buffer to fill in.
  43405. * @param scene defines the scene the material belongs to.
  43406. * @param engine defines the engine the material belongs to.
  43407. * @param disableBumpMap defines wether the material disables bump or not.
  43408. * @param isFrozen defines wether the material is frozen or not.
  43409. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43410. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43411. */
  43412. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43413. /**
  43414. * Checks to see if a texture is used in the material.
  43415. * @param texture - Base texture to use.
  43416. * @returns - Boolean specifying if a texture is used in the material.
  43417. */
  43418. hasTexture(texture: BaseTexture): boolean;
  43419. /**
  43420. * Returns an array of the actively used textures.
  43421. * @param activeTextures Array of BaseTextures
  43422. */
  43423. getActiveTextures(activeTextures: BaseTexture[]): void;
  43424. /**
  43425. * Returns the animatable textures.
  43426. * @param animatables Array of animatable textures.
  43427. */
  43428. getAnimatables(animatables: IAnimatable[]): void;
  43429. /**
  43430. * Disposes the resources of the material.
  43431. * @param forceDisposeTextures - Forces the disposal of all textures.
  43432. */
  43433. dispose(forceDisposeTextures?: boolean): void;
  43434. /**
  43435. * Get the current class name of the texture useful for serialization or dynamic coding.
  43436. * @returns "PBRClearCoatConfiguration"
  43437. */
  43438. getClassName(): string;
  43439. /**
  43440. * Add fallbacks to the effect fallbacks list.
  43441. * @param defines defines the Base texture to use.
  43442. * @param fallbacks defines the current fallback list.
  43443. * @param currentRank defines the current fallback rank.
  43444. * @returns the new fallback rank.
  43445. */
  43446. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43447. /**
  43448. * Add the required uniforms to the current list.
  43449. * @param uniforms defines the current uniform list.
  43450. */
  43451. static AddUniforms(uniforms: string[]): void;
  43452. /**
  43453. * Add the required samplers to the current list.
  43454. * @param samplers defines the current sampler list.
  43455. */
  43456. static AddSamplers(samplers: string[]): void;
  43457. /**
  43458. * Add the required uniforms to the current buffer.
  43459. * @param uniformBuffer defines the current uniform buffer.
  43460. */
  43461. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43462. /**
  43463. * Makes a duplicate of the current configuration into another one.
  43464. * @param clearCoatConfiguration define the config where to copy the info
  43465. */
  43466. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43467. /**
  43468. * Serializes this clear coat configuration.
  43469. * @returns - An object with the serialized config.
  43470. */
  43471. serialize(): any;
  43472. /**
  43473. * Parses a Clear Coat Configuration from a serialized object.
  43474. * @param source - Serialized object.
  43475. */
  43476. parse(source: any): void;
  43477. }
  43478. }
  43479. declare module BABYLON {
  43480. /**
  43481. * @hidden
  43482. */
  43483. export interface IMaterialAnisotropicDefines {
  43484. ANISOTROPIC: boolean;
  43485. ANISOTROPIC_TEXTURE: boolean;
  43486. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43487. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43488. }
  43489. /**
  43490. * Define the code related to the anisotropic parameters of the pbr material.
  43491. */
  43492. export class PBRAnisotropicConfiguration {
  43493. private _isEnabled;
  43494. /**
  43495. * Defines if the anisotropy is enabled in the material.
  43496. */
  43497. isEnabled: boolean;
  43498. /**
  43499. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43500. */
  43501. intensity: number;
  43502. /**
  43503. * Defines if the effect is along the tangents, bitangents or in between.
  43504. * By default, the effect is "strectching" the highlights along the tangents.
  43505. */
  43506. direction: Vector2;
  43507. private _texture;
  43508. /**
  43509. * Stores the anisotropy values in a texture.
  43510. * rg is direction (like normal from -1 to 1)
  43511. * b is a intensity
  43512. */
  43513. texture: Nullable<BaseTexture>;
  43514. /** @hidden */
  43515. private _internalMarkAllSubMeshesAsTexturesDirty;
  43516. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43517. /**
  43518. * Instantiate a new istance of anisotropy configuration.
  43519. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43520. */
  43521. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43522. /**
  43523. * Specifies that the submesh is ready to be used.
  43524. * @param defines the list of "defines" to update.
  43525. * @param scene defines the scene the material belongs to.
  43526. * @returns - boolean indicating that the submesh is ready or not.
  43527. */
  43528. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43529. /**
  43530. * Checks to see if a texture is used in the material.
  43531. * @param defines the list of "defines" to update.
  43532. * @param mesh the mesh we are preparing the defines for.
  43533. * @param scene defines the scene the material belongs to.
  43534. */
  43535. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43536. /**
  43537. * Binds the material data.
  43538. * @param uniformBuffer defines the Uniform buffer to fill in.
  43539. * @param scene defines the scene the material belongs to.
  43540. * @param isFrozen defines wether the material is frozen or not.
  43541. */
  43542. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43543. /**
  43544. * Checks to see if a texture is used in the material.
  43545. * @param texture - Base texture to use.
  43546. * @returns - Boolean specifying if a texture is used in the material.
  43547. */
  43548. hasTexture(texture: BaseTexture): boolean;
  43549. /**
  43550. * Returns an array of the actively used textures.
  43551. * @param activeTextures Array of BaseTextures
  43552. */
  43553. getActiveTextures(activeTextures: BaseTexture[]): void;
  43554. /**
  43555. * Returns the animatable textures.
  43556. * @param animatables Array of animatable textures.
  43557. */
  43558. getAnimatables(animatables: IAnimatable[]): void;
  43559. /**
  43560. * Disposes the resources of the material.
  43561. * @param forceDisposeTextures - Forces the disposal of all textures.
  43562. */
  43563. dispose(forceDisposeTextures?: boolean): void;
  43564. /**
  43565. * Get the current class name of the texture useful for serialization or dynamic coding.
  43566. * @returns "PBRAnisotropicConfiguration"
  43567. */
  43568. getClassName(): string;
  43569. /**
  43570. * Add fallbacks to the effect fallbacks list.
  43571. * @param defines defines the Base texture to use.
  43572. * @param fallbacks defines the current fallback list.
  43573. * @param currentRank defines the current fallback rank.
  43574. * @returns the new fallback rank.
  43575. */
  43576. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43577. /**
  43578. * Add the required uniforms to the current list.
  43579. * @param uniforms defines the current uniform list.
  43580. */
  43581. static AddUniforms(uniforms: string[]): void;
  43582. /**
  43583. * Add the required uniforms to the current buffer.
  43584. * @param uniformBuffer defines the current uniform buffer.
  43585. */
  43586. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43587. /**
  43588. * Add the required samplers to the current list.
  43589. * @param samplers defines the current sampler list.
  43590. */
  43591. static AddSamplers(samplers: string[]): void;
  43592. /**
  43593. * Makes a duplicate of the current configuration into another one.
  43594. * @param anisotropicConfiguration define the config where to copy the info
  43595. */
  43596. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43597. /**
  43598. * Serializes this anisotropy configuration.
  43599. * @returns - An object with the serialized config.
  43600. */
  43601. serialize(): any;
  43602. /**
  43603. * Parses a anisotropy Configuration from a serialized object.
  43604. * @param source - Serialized object.
  43605. */
  43606. parse(source: any): void;
  43607. }
  43608. }
  43609. declare module BABYLON {
  43610. /**
  43611. * @hidden
  43612. */
  43613. export interface IMaterialBRDFDefines {
  43614. BRDF_V_HEIGHT_CORRELATED: boolean;
  43615. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43616. SPHERICAL_HARMONICS: boolean;
  43617. /** @hidden */ areMiscDirty: boolean;
  43618. }
  43619. /**
  43620. * Define the code related to the BRDF parameters of the pbr material.
  43621. */
  43622. export class PBRBRDFConfiguration {
  43623. /**
  43624. * Default value used for the energy conservation.
  43625. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43626. */
  43627. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43628. /**
  43629. * Default value used for the Smith Visibility Height Correlated mode.
  43630. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43631. */
  43632. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43633. /**
  43634. * Default value used for the IBL diffuse part.
  43635. * This can help switching back to the polynomials mode globally which is a tiny bit
  43636. * less GPU intensive at the drawback of a lower quality.
  43637. */
  43638. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  43639. private _useEnergyConservation;
  43640. /**
  43641. * Defines if the material uses energy conservation.
  43642. */
  43643. useEnergyConservation: boolean;
  43644. private _useSmithVisibilityHeightCorrelated;
  43645. /**
  43646. * LEGACY Mode set to false
  43647. * Defines if the material uses height smith correlated visibility term.
  43648. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43649. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43650. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43651. * Not relying on height correlated will also disable energy conservation.
  43652. */
  43653. useSmithVisibilityHeightCorrelated: boolean;
  43654. private _useSphericalHarmonics;
  43655. /**
  43656. * LEGACY Mode set to false
  43657. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  43658. * diffuse part of the IBL.
  43659. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  43660. * to the ground truth.
  43661. */
  43662. useSphericalHarmonics: boolean;
  43663. /** @hidden */
  43664. private _internalMarkAllSubMeshesAsMiscDirty;
  43665. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43666. /**
  43667. * Instantiate a new istance of clear coat configuration.
  43668. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43669. */
  43670. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43671. /**
  43672. * Checks to see if a texture is used in the material.
  43673. * @param defines the list of "defines" to update.
  43674. */
  43675. prepareDefines(defines: IMaterialBRDFDefines): void;
  43676. /**
  43677. * Get the current class name of the texture useful for serialization or dynamic coding.
  43678. * @returns "PBRClearCoatConfiguration"
  43679. */
  43680. getClassName(): string;
  43681. /**
  43682. * Makes a duplicate of the current configuration into another one.
  43683. * @param brdfConfiguration define the config where to copy the info
  43684. */
  43685. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43686. /**
  43687. * Serializes this BRDF configuration.
  43688. * @returns - An object with the serialized config.
  43689. */
  43690. serialize(): any;
  43691. /**
  43692. * Parses a BRDF Configuration from a serialized object.
  43693. * @param source - Serialized object.
  43694. */
  43695. parse(source: any): void;
  43696. }
  43697. }
  43698. declare module BABYLON {
  43699. /**
  43700. * @hidden
  43701. */
  43702. export interface IMaterialSheenDefines {
  43703. SHEEN: boolean;
  43704. SHEEN_TEXTURE: boolean;
  43705. SHEEN_TEXTUREDIRECTUV: number;
  43706. SHEEN_LINKWITHALBEDO: boolean;
  43707. /** @hidden */ areTexturesDirty: boolean;
  43708. }
  43709. /**
  43710. * Define the code related to the Sheen parameters of the pbr material.
  43711. */
  43712. export class PBRSheenConfiguration {
  43713. private _isEnabled;
  43714. /**
  43715. * Defines if the material uses sheen.
  43716. */
  43717. isEnabled: boolean;
  43718. private _linkSheenWithAlbedo;
  43719. /**
  43720. * Defines if the sheen is linked to the sheen color.
  43721. */
  43722. linkSheenWithAlbedo: boolean;
  43723. /**
  43724. * Defines the sheen intensity.
  43725. */
  43726. intensity: number;
  43727. /**
  43728. * Defines the sheen color.
  43729. */
  43730. color: Color3;
  43731. private _texture;
  43732. /**
  43733. * Stores the sheen tint values in a texture.
  43734. * rgb is tint
  43735. * a is a intensity
  43736. */
  43737. texture: Nullable<BaseTexture>;
  43738. /** @hidden */
  43739. private _internalMarkAllSubMeshesAsTexturesDirty;
  43740. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43741. /**
  43742. * Instantiate a new istance of clear coat configuration.
  43743. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43744. */
  43745. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43746. /**
  43747. * Specifies that the submesh is ready to be used.
  43748. * @param defines the list of "defines" to update.
  43749. * @param scene defines the scene the material belongs to.
  43750. * @returns - boolean indicating that the submesh is ready or not.
  43751. */
  43752. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43753. /**
  43754. * Checks to see if a texture is used in the material.
  43755. * @param defines the list of "defines" to update.
  43756. * @param scene defines the scene the material belongs to.
  43757. */
  43758. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43759. /**
  43760. * Binds the material data.
  43761. * @param uniformBuffer defines the Uniform buffer to fill in.
  43762. * @param scene defines the scene the material belongs to.
  43763. * @param isFrozen defines wether the material is frozen or not.
  43764. */
  43765. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43766. /**
  43767. * Checks to see if a texture is used in the material.
  43768. * @param texture - Base texture to use.
  43769. * @returns - Boolean specifying if a texture is used in the material.
  43770. */
  43771. hasTexture(texture: BaseTexture): boolean;
  43772. /**
  43773. * Returns an array of the actively used textures.
  43774. * @param activeTextures Array of BaseTextures
  43775. */
  43776. getActiveTextures(activeTextures: BaseTexture[]): void;
  43777. /**
  43778. * Returns the animatable textures.
  43779. * @param animatables Array of animatable textures.
  43780. */
  43781. getAnimatables(animatables: IAnimatable[]): void;
  43782. /**
  43783. * Disposes the resources of the material.
  43784. * @param forceDisposeTextures - Forces the disposal of all textures.
  43785. */
  43786. dispose(forceDisposeTextures?: boolean): void;
  43787. /**
  43788. * Get the current class name of the texture useful for serialization or dynamic coding.
  43789. * @returns "PBRSheenConfiguration"
  43790. */
  43791. getClassName(): string;
  43792. /**
  43793. * Add fallbacks to the effect fallbacks list.
  43794. * @param defines defines the Base texture to use.
  43795. * @param fallbacks defines the current fallback list.
  43796. * @param currentRank defines the current fallback rank.
  43797. * @returns the new fallback rank.
  43798. */
  43799. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43800. /**
  43801. * Add the required uniforms to the current list.
  43802. * @param uniforms defines the current uniform list.
  43803. */
  43804. static AddUniforms(uniforms: string[]): void;
  43805. /**
  43806. * Add the required uniforms to the current buffer.
  43807. * @param uniformBuffer defines the current uniform buffer.
  43808. */
  43809. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43810. /**
  43811. * Add the required samplers to the current list.
  43812. * @param samplers defines the current sampler list.
  43813. */
  43814. static AddSamplers(samplers: string[]): void;
  43815. /**
  43816. * Makes a duplicate of the current configuration into another one.
  43817. * @param sheenConfiguration define the config where to copy the info
  43818. */
  43819. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43820. /**
  43821. * Serializes this BRDF configuration.
  43822. * @returns - An object with the serialized config.
  43823. */
  43824. serialize(): any;
  43825. /**
  43826. * Parses a Sheen Configuration from a serialized object.
  43827. * @param source - Serialized object.
  43828. */
  43829. parse(source: any): void;
  43830. }
  43831. }
  43832. declare module BABYLON {
  43833. /**
  43834. * @hidden
  43835. */
  43836. export interface IMaterialSubSurfaceDefines {
  43837. SUBSURFACE: boolean;
  43838. SS_REFRACTION: boolean;
  43839. SS_TRANSLUCENCY: boolean;
  43840. SS_SCATERRING: boolean;
  43841. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43842. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43843. SS_REFRACTIONMAP_3D: boolean;
  43844. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43845. SS_LODINREFRACTIONALPHA: boolean;
  43846. SS_GAMMAREFRACTION: boolean;
  43847. SS_RGBDREFRACTION: boolean;
  43848. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43849. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43850. /** @hidden */ areTexturesDirty: boolean;
  43851. }
  43852. /**
  43853. * Define the code related to the sub surface parameters of the pbr material.
  43854. */
  43855. export class PBRSubSurfaceConfiguration {
  43856. private _isRefractionEnabled;
  43857. /**
  43858. * Defines if the refraction is enabled in the material.
  43859. */
  43860. isRefractionEnabled: boolean;
  43861. private _isTranslucencyEnabled;
  43862. /**
  43863. * Defines if the translucency is enabled in the material.
  43864. */
  43865. isTranslucencyEnabled: boolean;
  43866. private _isScatteringEnabled;
  43867. /**
  43868. * Defines the refraction intensity of the material.
  43869. * The refraction when enabled replaces the Diffuse part of the material.
  43870. * The intensity helps transitionning between diffuse and refraction.
  43871. */
  43872. refractionIntensity: number;
  43873. /**
  43874. * Defines the translucency intensity of the material.
  43875. * When translucency has been enabled, this defines how much of the "translucency"
  43876. * is addded to the diffuse part of the material.
  43877. */
  43878. translucencyIntensity: number;
  43879. /**
  43880. * Defines the scattering intensity of the material.
  43881. * When scattering has been enabled, this defines how much of the "scattered light"
  43882. * is addded to the diffuse part of the material.
  43883. */
  43884. scatteringIntensity: number;
  43885. private _thicknessTexture;
  43886. /**
  43887. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43888. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43889. * 0 would mean minimumThickness
  43890. * 1 would mean maximumThickness
  43891. * The other channels might be use as a mask to vary the different effects intensity.
  43892. */
  43893. thicknessTexture: Nullable<BaseTexture>;
  43894. private _refractionTexture;
  43895. /**
  43896. * Defines the texture to use for refraction.
  43897. */
  43898. refractionTexture: Nullable<BaseTexture>;
  43899. private _indexOfRefraction;
  43900. /**
  43901. * Defines the indice of refraction used in the material.
  43902. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43903. */
  43904. indexOfRefraction: number;
  43905. private _invertRefractionY;
  43906. /**
  43907. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43908. */
  43909. invertRefractionY: boolean;
  43910. private _linkRefractionWithTransparency;
  43911. /**
  43912. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43913. * Materials half opaque for instance using refraction could benefit from this control.
  43914. */
  43915. linkRefractionWithTransparency: boolean;
  43916. /**
  43917. * Defines the minimum thickness stored in the thickness map.
  43918. * If no thickness map is defined, this value will be used to simulate thickness.
  43919. */
  43920. minimumThickness: number;
  43921. /**
  43922. * Defines the maximum thickness stored in the thickness map.
  43923. */
  43924. maximumThickness: number;
  43925. /**
  43926. * Defines the volume tint of the material.
  43927. * This is used for both translucency and scattering.
  43928. */
  43929. tintColor: Color3;
  43930. /**
  43931. * Defines the distance at which the tint color should be found in the media.
  43932. * This is used for refraction only.
  43933. */
  43934. tintColorAtDistance: number;
  43935. /**
  43936. * Defines how far each channel transmit through the media.
  43937. * It is defined as a color to simplify it selection.
  43938. */
  43939. diffusionDistance: Color3;
  43940. private _useMaskFromThicknessTexture;
  43941. /**
  43942. * Stores the intensity of the different subsurface effects in the thickness texture.
  43943. * * the green channel is the translucency intensity.
  43944. * * the blue channel is the scattering intensity.
  43945. * * the alpha channel is the refraction intensity.
  43946. */
  43947. useMaskFromThicknessTexture: boolean;
  43948. /** @hidden */
  43949. private _internalMarkAllSubMeshesAsTexturesDirty;
  43950. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43951. /**
  43952. * Instantiate a new istance of sub surface configuration.
  43953. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43954. */
  43955. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43956. /**
  43957. * Gets wehter the submesh is ready to be used or not.
  43958. * @param defines the list of "defines" to update.
  43959. * @param scene defines the scene the material belongs to.
  43960. * @returns - boolean indicating that the submesh is ready or not.
  43961. */
  43962. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43963. /**
  43964. * Checks to see if a texture is used in the material.
  43965. * @param defines the list of "defines" to update.
  43966. * @param scene defines the scene to the material belongs to.
  43967. */
  43968. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43969. /**
  43970. * Binds the material data.
  43971. * @param uniformBuffer defines the Uniform buffer to fill in.
  43972. * @param scene defines the scene the material belongs to.
  43973. * @param engine defines the engine the material belongs to.
  43974. * @param isFrozen defines wether the material is frozen or not.
  43975. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43976. */
  43977. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43978. /**
  43979. * Unbinds the material from the mesh.
  43980. * @param activeEffect defines the effect that should be unbound from.
  43981. * @returns true if unbound, otherwise false
  43982. */
  43983. unbind(activeEffect: Effect): boolean;
  43984. /**
  43985. * Returns the texture used for refraction or null if none is used.
  43986. * @param scene defines the scene the material belongs to.
  43987. * @returns - Refraction texture if present. If no refraction texture and refraction
  43988. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43989. */
  43990. private _getRefractionTexture;
  43991. /**
  43992. * Returns true if alpha blending should be disabled.
  43993. */
  43994. readonly disableAlphaBlending: boolean;
  43995. /**
  43996. * Fills the list of render target textures.
  43997. * @param renderTargets the list of render targets to update
  43998. */
  43999. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44000. /**
  44001. * Checks to see if a texture is used in the material.
  44002. * @param texture - Base texture to use.
  44003. * @returns - Boolean specifying if a texture is used in the material.
  44004. */
  44005. hasTexture(texture: BaseTexture): boolean;
  44006. /**
  44007. * Gets a boolean indicating that current material needs to register RTT
  44008. * @returns true if this uses a render target otherwise false.
  44009. */
  44010. hasRenderTargetTextures(): boolean;
  44011. /**
  44012. * Returns an array of the actively used textures.
  44013. * @param activeTextures Array of BaseTextures
  44014. */
  44015. getActiveTextures(activeTextures: BaseTexture[]): void;
  44016. /**
  44017. * Returns the animatable textures.
  44018. * @param animatables Array of animatable textures.
  44019. */
  44020. getAnimatables(animatables: IAnimatable[]): void;
  44021. /**
  44022. * Disposes the resources of the material.
  44023. * @param forceDisposeTextures - Forces the disposal of all textures.
  44024. */
  44025. dispose(forceDisposeTextures?: boolean): void;
  44026. /**
  44027. * Get the current class name of the texture useful for serialization or dynamic coding.
  44028. * @returns "PBRSubSurfaceConfiguration"
  44029. */
  44030. getClassName(): string;
  44031. /**
  44032. * Add fallbacks to the effect fallbacks list.
  44033. * @param defines defines the Base texture to use.
  44034. * @param fallbacks defines the current fallback list.
  44035. * @param currentRank defines the current fallback rank.
  44036. * @returns the new fallback rank.
  44037. */
  44038. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44039. /**
  44040. * Add the required uniforms to the current list.
  44041. * @param uniforms defines the current uniform list.
  44042. */
  44043. static AddUniforms(uniforms: string[]): void;
  44044. /**
  44045. * Add the required samplers to the current list.
  44046. * @param samplers defines the current sampler list.
  44047. */
  44048. static AddSamplers(samplers: string[]): void;
  44049. /**
  44050. * Add the required uniforms to the current buffer.
  44051. * @param uniformBuffer defines the current uniform buffer.
  44052. */
  44053. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44054. /**
  44055. * Makes a duplicate of the current configuration into another one.
  44056. * @param configuration define the config where to copy the info
  44057. */
  44058. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44059. /**
  44060. * Serializes this Sub Surface configuration.
  44061. * @returns - An object with the serialized config.
  44062. */
  44063. serialize(): any;
  44064. /**
  44065. * Parses a Sub Surface Configuration from a serialized object.
  44066. * @param source - Serialized object.
  44067. */
  44068. parse(source: any): void;
  44069. }
  44070. }
  44071. declare module BABYLON {
  44072. /** @hidden */
  44073. export var pbrFragmentDeclaration: {
  44074. name: string;
  44075. shader: string;
  44076. };
  44077. }
  44078. declare module BABYLON {
  44079. /** @hidden */
  44080. export var pbrUboDeclaration: {
  44081. name: string;
  44082. shader: string;
  44083. };
  44084. }
  44085. declare module BABYLON {
  44086. /** @hidden */
  44087. export var pbrFragmentExtraDeclaration: {
  44088. name: string;
  44089. shader: string;
  44090. };
  44091. }
  44092. declare module BABYLON {
  44093. /** @hidden */
  44094. export var pbrFragmentSamplersDeclaration: {
  44095. name: string;
  44096. shader: string;
  44097. };
  44098. }
  44099. declare module BABYLON {
  44100. /** @hidden */
  44101. export var pbrHelperFunctions: {
  44102. name: string;
  44103. shader: string;
  44104. };
  44105. }
  44106. declare module BABYLON {
  44107. /** @hidden */
  44108. export var harmonicsFunctions: {
  44109. name: string;
  44110. shader: string;
  44111. };
  44112. }
  44113. declare module BABYLON {
  44114. /** @hidden */
  44115. export var pbrDirectLightingSetupFunctions: {
  44116. name: string;
  44117. shader: string;
  44118. };
  44119. }
  44120. declare module BABYLON {
  44121. /** @hidden */
  44122. export var pbrDirectLightingFalloffFunctions: {
  44123. name: string;
  44124. shader: string;
  44125. };
  44126. }
  44127. declare module BABYLON {
  44128. /** @hidden */
  44129. export var pbrBRDFFunctions: {
  44130. name: string;
  44131. shader: string;
  44132. };
  44133. }
  44134. declare module BABYLON {
  44135. /** @hidden */
  44136. export var pbrDirectLightingFunctions: {
  44137. name: string;
  44138. shader: string;
  44139. };
  44140. }
  44141. declare module BABYLON {
  44142. /** @hidden */
  44143. export var pbrIBLFunctions: {
  44144. name: string;
  44145. shader: string;
  44146. };
  44147. }
  44148. declare module BABYLON {
  44149. /** @hidden */
  44150. export var pbrDebug: {
  44151. name: string;
  44152. shader: string;
  44153. };
  44154. }
  44155. declare module BABYLON {
  44156. /** @hidden */
  44157. export var pbrPixelShader: {
  44158. name: string;
  44159. shader: string;
  44160. };
  44161. }
  44162. declare module BABYLON {
  44163. /** @hidden */
  44164. export var pbrVertexDeclaration: {
  44165. name: string;
  44166. shader: string;
  44167. };
  44168. }
  44169. declare module BABYLON {
  44170. /** @hidden */
  44171. export var pbrVertexShader: {
  44172. name: string;
  44173. shader: string;
  44174. };
  44175. }
  44176. declare module BABYLON {
  44177. /**
  44178. * Manages the defines for the PBR Material.
  44179. * @hidden
  44180. */
  44181. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44182. PBR: boolean;
  44183. MAINUV1: boolean;
  44184. MAINUV2: boolean;
  44185. UV1: boolean;
  44186. UV2: boolean;
  44187. ALBEDO: boolean;
  44188. ALBEDODIRECTUV: number;
  44189. VERTEXCOLOR: boolean;
  44190. AMBIENT: boolean;
  44191. AMBIENTDIRECTUV: number;
  44192. AMBIENTINGRAYSCALE: boolean;
  44193. OPACITY: boolean;
  44194. VERTEXALPHA: boolean;
  44195. OPACITYDIRECTUV: number;
  44196. OPACITYRGB: boolean;
  44197. ALPHATEST: boolean;
  44198. DEPTHPREPASS: boolean;
  44199. ALPHABLEND: boolean;
  44200. ALPHAFROMALBEDO: boolean;
  44201. ALPHATESTVALUE: string;
  44202. SPECULAROVERALPHA: boolean;
  44203. RADIANCEOVERALPHA: boolean;
  44204. ALPHAFRESNEL: boolean;
  44205. LINEARALPHAFRESNEL: boolean;
  44206. PREMULTIPLYALPHA: boolean;
  44207. EMISSIVE: boolean;
  44208. EMISSIVEDIRECTUV: number;
  44209. REFLECTIVITY: boolean;
  44210. REFLECTIVITYDIRECTUV: number;
  44211. SPECULARTERM: boolean;
  44212. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44213. MICROSURFACEAUTOMATIC: boolean;
  44214. LODBASEDMICROSFURACE: boolean;
  44215. MICROSURFACEMAP: boolean;
  44216. MICROSURFACEMAPDIRECTUV: number;
  44217. METALLICWORKFLOW: boolean;
  44218. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44219. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44220. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44221. AOSTOREINMETALMAPRED: boolean;
  44222. ENVIRONMENTBRDF: boolean;
  44223. ENVIRONMENTBRDF_RGBD: boolean;
  44224. NORMAL: boolean;
  44225. TANGENT: boolean;
  44226. BUMP: boolean;
  44227. BUMPDIRECTUV: number;
  44228. OBJECTSPACE_NORMALMAP: boolean;
  44229. PARALLAX: boolean;
  44230. PARALLAXOCCLUSION: boolean;
  44231. NORMALXYSCALE: boolean;
  44232. LIGHTMAP: boolean;
  44233. LIGHTMAPDIRECTUV: number;
  44234. USELIGHTMAPASSHADOWMAP: boolean;
  44235. GAMMALIGHTMAP: boolean;
  44236. REFLECTION: boolean;
  44237. REFLECTIONMAP_3D: boolean;
  44238. REFLECTIONMAP_SPHERICAL: boolean;
  44239. REFLECTIONMAP_PLANAR: boolean;
  44240. REFLECTIONMAP_CUBIC: boolean;
  44241. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44242. REFLECTIONMAP_PROJECTION: boolean;
  44243. REFLECTIONMAP_SKYBOX: boolean;
  44244. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44245. REFLECTIONMAP_EXPLICIT: boolean;
  44246. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44247. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44248. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44249. INVERTCUBICMAP: boolean;
  44250. USESPHERICALFROMREFLECTIONMAP: boolean;
  44251. SPHERICAL_HARMONICS: boolean;
  44252. USESPHERICALINVERTEX: boolean;
  44253. REFLECTIONMAP_OPPOSITEZ: boolean;
  44254. LODINREFLECTIONALPHA: boolean;
  44255. GAMMAREFLECTION: boolean;
  44256. RGBDREFLECTION: boolean;
  44257. RADIANCEOCCLUSION: boolean;
  44258. HORIZONOCCLUSION: boolean;
  44259. INSTANCES: boolean;
  44260. NUM_BONE_INFLUENCERS: number;
  44261. BonesPerMesh: number;
  44262. BONETEXTURE: boolean;
  44263. NONUNIFORMSCALING: boolean;
  44264. MORPHTARGETS: boolean;
  44265. MORPHTARGETS_NORMAL: boolean;
  44266. MORPHTARGETS_TANGENT: boolean;
  44267. NUM_MORPH_INFLUENCERS: number;
  44268. IMAGEPROCESSING: boolean;
  44269. VIGNETTE: boolean;
  44270. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44271. VIGNETTEBLENDMODEOPAQUE: boolean;
  44272. TONEMAPPING: boolean;
  44273. TONEMAPPING_ACES: boolean;
  44274. CONTRAST: boolean;
  44275. COLORCURVES: boolean;
  44276. COLORGRADING: boolean;
  44277. COLORGRADING3D: boolean;
  44278. SAMPLER3DGREENDEPTH: boolean;
  44279. SAMPLER3DBGRMAP: boolean;
  44280. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44281. EXPOSURE: boolean;
  44282. MULTIVIEW: boolean;
  44283. USEPHYSICALLIGHTFALLOFF: boolean;
  44284. USEGLTFLIGHTFALLOFF: boolean;
  44285. TWOSIDEDLIGHTING: boolean;
  44286. SHADOWFLOAT: boolean;
  44287. CLIPPLANE: boolean;
  44288. CLIPPLANE2: boolean;
  44289. CLIPPLANE3: boolean;
  44290. CLIPPLANE4: boolean;
  44291. POINTSIZE: boolean;
  44292. FOG: boolean;
  44293. LOGARITHMICDEPTH: boolean;
  44294. FORCENORMALFORWARD: boolean;
  44295. SPECULARAA: boolean;
  44296. CLEARCOAT: boolean;
  44297. CLEARCOAT_DEFAULTIOR: boolean;
  44298. CLEARCOAT_TEXTURE: boolean;
  44299. CLEARCOAT_TEXTUREDIRECTUV: number;
  44300. CLEARCOAT_BUMP: boolean;
  44301. CLEARCOAT_BUMPDIRECTUV: number;
  44302. CLEARCOAT_TINT: boolean;
  44303. CLEARCOAT_TINT_TEXTURE: boolean;
  44304. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44305. ANISOTROPIC: boolean;
  44306. ANISOTROPIC_TEXTURE: boolean;
  44307. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44308. BRDF_V_HEIGHT_CORRELATED: boolean;
  44309. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44310. SHEEN: boolean;
  44311. SHEEN_TEXTURE: boolean;
  44312. SHEEN_TEXTUREDIRECTUV: number;
  44313. SHEEN_LINKWITHALBEDO: boolean;
  44314. SUBSURFACE: boolean;
  44315. SS_REFRACTION: boolean;
  44316. SS_TRANSLUCENCY: boolean;
  44317. SS_SCATERRING: boolean;
  44318. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44319. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44320. SS_REFRACTIONMAP_3D: boolean;
  44321. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44322. SS_LODINREFRACTIONALPHA: boolean;
  44323. SS_GAMMAREFRACTION: boolean;
  44324. SS_RGBDREFRACTION: boolean;
  44325. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44326. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44327. UNLIT: boolean;
  44328. DEBUGMODE: number;
  44329. /**
  44330. * Initializes the PBR Material defines.
  44331. */
  44332. constructor();
  44333. /**
  44334. * Resets the PBR Material defines.
  44335. */
  44336. reset(): void;
  44337. }
  44338. /**
  44339. * The Physically based material base class of BJS.
  44340. *
  44341. * This offers the main features of a standard PBR material.
  44342. * For more information, please refer to the documentation :
  44343. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44344. */
  44345. export abstract class PBRBaseMaterial extends PushMaterial {
  44346. /**
  44347. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44348. */
  44349. static readonly PBRMATERIAL_OPAQUE: number;
  44350. /**
  44351. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44352. */
  44353. static readonly PBRMATERIAL_ALPHATEST: number;
  44354. /**
  44355. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44356. */
  44357. static readonly PBRMATERIAL_ALPHABLEND: number;
  44358. /**
  44359. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44360. * They are also discarded below the alpha cutoff threshold to improve performances.
  44361. */
  44362. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44363. /**
  44364. * Defines the default value of how much AO map is occluding the analytical lights
  44365. * (point spot...).
  44366. */
  44367. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44368. /**
  44369. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44370. */
  44371. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44372. /**
  44373. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44374. * to enhance interoperability with other engines.
  44375. */
  44376. static readonly LIGHTFALLOFF_GLTF: number;
  44377. /**
  44378. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44379. * to enhance interoperability with other materials.
  44380. */
  44381. static readonly LIGHTFALLOFF_STANDARD: number;
  44382. /**
  44383. * Intensity of the direct lights e.g. the four lights available in your scene.
  44384. * This impacts both the direct diffuse and specular highlights.
  44385. */
  44386. protected _directIntensity: number;
  44387. /**
  44388. * Intensity of the emissive part of the material.
  44389. * This helps controlling the emissive effect without modifying the emissive color.
  44390. */
  44391. protected _emissiveIntensity: number;
  44392. /**
  44393. * Intensity of the environment e.g. how much the environment will light the object
  44394. * either through harmonics for rough material or through the refelction for shiny ones.
  44395. */
  44396. protected _environmentIntensity: number;
  44397. /**
  44398. * This is a special control allowing the reduction of the specular highlights coming from the
  44399. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44400. */
  44401. protected _specularIntensity: number;
  44402. /**
  44403. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44404. */
  44405. private _lightingInfos;
  44406. /**
  44407. * Debug Control allowing disabling the bump map on this material.
  44408. */
  44409. protected _disableBumpMap: boolean;
  44410. /**
  44411. * AKA Diffuse Texture in standard nomenclature.
  44412. */
  44413. protected _albedoTexture: Nullable<BaseTexture>;
  44414. /**
  44415. * AKA Occlusion Texture in other nomenclature.
  44416. */
  44417. protected _ambientTexture: Nullable<BaseTexture>;
  44418. /**
  44419. * AKA Occlusion Texture Intensity in other nomenclature.
  44420. */
  44421. protected _ambientTextureStrength: number;
  44422. /**
  44423. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44424. * 1 means it completely occludes it
  44425. * 0 mean it has no impact
  44426. */
  44427. protected _ambientTextureImpactOnAnalyticalLights: number;
  44428. /**
  44429. * Stores the alpha values in a texture.
  44430. */
  44431. protected _opacityTexture: Nullable<BaseTexture>;
  44432. /**
  44433. * Stores the reflection values in a texture.
  44434. */
  44435. protected _reflectionTexture: Nullable<BaseTexture>;
  44436. /**
  44437. * Stores the emissive values in a texture.
  44438. */
  44439. protected _emissiveTexture: Nullable<BaseTexture>;
  44440. /**
  44441. * AKA Specular texture in other nomenclature.
  44442. */
  44443. protected _reflectivityTexture: Nullable<BaseTexture>;
  44444. /**
  44445. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44446. */
  44447. protected _metallicTexture: Nullable<BaseTexture>;
  44448. /**
  44449. * Specifies the metallic scalar of the metallic/roughness workflow.
  44450. * Can also be used to scale the metalness values of the metallic texture.
  44451. */
  44452. protected _metallic: Nullable<number>;
  44453. /**
  44454. * Specifies the roughness scalar of the metallic/roughness workflow.
  44455. * Can also be used to scale the roughness values of the metallic texture.
  44456. */
  44457. protected _roughness: Nullable<number>;
  44458. /**
  44459. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44460. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44461. */
  44462. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44463. /**
  44464. * Stores surface normal data used to displace a mesh in a texture.
  44465. */
  44466. protected _bumpTexture: Nullable<BaseTexture>;
  44467. /**
  44468. * Stores the pre-calculated light information of a mesh in a texture.
  44469. */
  44470. protected _lightmapTexture: Nullable<BaseTexture>;
  44471. /**
  44472. * The color of a material in ambient lighting.
  44473. */
  44474. protected _ambientColor: Color3;
  44475. /**
  44476. * AKA Diffuse Color in other nomenclature.
  44477. */
  44478. protected _albedoColor: Color3;
  44479. /**
  44480. * AKA Specular Color in other nomenclature.
  44481. */
  44482. protected _reflectivityColor: Color3;
  44483. /**
  44484. * The color applied when light is reflected from a material.
  44485. */
  44486. protected _reflectionColor: Color3;
  44487. /**
  44488. * The color applied when light is emitted from a material.
  44489. */
  44490. protected _emissiveColor: Color3;
  44491. /**
  44492. * AKA Glossiness in other nomenclature.
  44493. */
  44494. protected _microSurface: number;
  44495. /**
  44496. * Specifies that the material will use the light map as a show map.
  44497. */
  44498. protected _useLightmapAsShadowmap: boolean;
  44499. /**
  44500. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44501. * makes the reflect vector face the model (under horizon).
  44502. */
  44503. protected _useHorizonOcclusion: boolean;
  44504. /**
  44505. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44506. * too much the area relying on ambient texture to define their ambient occlusion.
  44507. */
  44508. protected _useRadianceOcclusion: boolean;
  44509. /**
  44510. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44511. */
  44512. protected _useAlphaFromAlbedoTexture: boolean;
  44513. /**
  44514. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44515. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44516. */
  44517. protected _useSpecularOverAlpha: boolean;
  44518. /**
  44519. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44520. */
  44521. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44522. /**
  44523. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44524. */
  44525. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44526. /**
  44527. * Specifies if the metallic texture contains the roughness information in its green channel.
  44528. */
  44529. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44530. /**
  44531. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44532. */
  44533. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44534. /**
  44535. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44536. */
  44537. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44538. /**
  44539. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44540. */
  44541. protected _useAmbientInGrayScale: boolean;
  44542. /**
  44543. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44544. * The material will try to infer what glossiness each pixel should be.
  44545. */
  44546. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44547. /**
  44548. * Defines the falloff type used in this material.
  44549. * It by default is Physical.
  44550. */
  44551. protected _lightFalloff: number;
  44552. /**
  44553. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44554. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44555. */
  44556. protected _useRadianceOverAlpha: boolean;
  44557. /**
  44558. * Allows using an object space normal map (instead of tangent space).
  44559. */
  44560. protected _useObjectSpaceNormalMap: boolean;
  44561. /**
  44562. * Allows using the bump map in parallax mode.
  44563. */
  44564. protected _useParallax: boolean;
  44565. /**
  44566. * Allows using the bump map in parallax occlusion mode.
  44567. */
  44568. protected _useParallaxOcclusion: boolean;
  44569. /**
  44570. * Controls the scale bias of the parallax mode.
  44571. */
  44572. protected _parallaxScaleBias: number;
  44573. /**
  44574. * If sets to true, disables all the lights affecting the material.
  44575. */
  44576. protected _disableLighting: boolean;
  44577. /**
  44578. * Number of Simultaneous lights allowed on the material.
  44579. */
  44580. protected _maxSimultaneousLights: number;
  44581. /**
  44582. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44583. */
  44584. protected _invertNormalMapX: boolean;
  44585. /**
  44586. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44587. */
  44588. protected _invertNormalMapY: boolean;
  44589. /**
  44590. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44591. */
  44592. protected _twoSidedLighting: boolean;
  44593. /**
  44594. * Defines the alpha limits in alpha test mode.
  44595. */
  44596. protected _alphaCutOff: number;
  44597. /**
  44598. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44599. */
  44600. protected _forceAlphaTest: boolean;
  44601. /**
  44602. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44603. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44604. */
  44605. protected _useAlphaFresnel: boolean;
  44606. /**
  44607. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44608. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44609. */
  44610. protected _useLinearAlphaFresnel: boolean;
  44611. /**
  44612. * The transparency mode of the material.
  44613. */
  44614. protected _transparencyMode: Nullable<number>;
  44615. /**
  44616. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44617. * from cos thetav and roughness:
  44618. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44619. */
  44620. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44621. /**
  44622. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44623. */
  44624. protected _forceIrradianceInFragment: boolean;
  44625. /**
  44626. * Force normal to face away from face.
  44627. */
  44628. protected _forceNormalForward: boolean;
  44629. /**
  44630. * Enables specular anti aliasing in the PBR shader.
  44631. * It will both interacts on the Geometry for analytical and IBL lighting.
  44632. * It also prefilter the roughness map based on the bump values.
  44633. */
  44634. protected _enableSpecularAntiAliasing: boolean;
  44635. /**
  44636. * Default configuration related to image processing available in the PBR Material.
  44637. */
  44638. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44639. /**
  44640. * Keep track of the image processing observer to allow dispose and replace.
  44641. */
  44642. private _imageProcessingObserver;
  44643. /**
  44644. * Attaches a new image processing configuration to the PBR Material.
  44645. * @param configuration
  44646. */
  44647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44648. /**
  44649. * Stores the available render targets.
  44650. */
  44651. private _renderTargets;
  44652. /**
  44653. * Sets the global ambient color for the material used in lighting calculations.
  44654. */
  44655. private _globalAmbientColor;
  44656. /**
  44657. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44658. */
  44659. private _useLogarithmicDepth;
  44660. /**
  44661. * If set to true, no lighting calculations will be applied.
  44662. */
  44663. private _unlit;
  44664. private _debugMode;
  44665. /**
  44666. * @hidden
  44667. * This is reserved for the inspector.
  44668. * Defines the material debug mode.
  44669. * It helps seeing only some components of the material while troubleshooting.
  44670. */
  44671. debugMode: number;
  44672. /**
  44673. * @hidden
  44674. * This is reserved for the inspector.
  44675. * Specify from where on screen the debug mode should start.
  44676. * The value goes from -1 (full screen) to 1 (not visible)
  44677. * It helps with side by side comparison against the final render
  44678. * This defaults to -1
  44679. */
  44680. private debugLimit;
  44681. /**
  44682. * @hidden
  44683. * This is reserved for the inspector.
  44684. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44685. * You can use the factor to better multiply the final value.
  44686. */
  44687. private debugFactor;
  44688. /**
  44689. * Defines the clear coat layer parameters for the material.
  44690. */
  44691. readonly clearCoat: PBRClearCoatConfiguration;
  44692. /**
  44693. * Defines the anisotropic parameters for the material.
  44694. */
  44695. readonly anisotropy: PBRAnisotropicConfiguration;
  44696. /**
  44697. * Defines the BRDF parameters for the material.
  44698. */
  44699. readonly brdf: PBRBRDFConfiguration;
  44700. /**
  44701. * Defines the Sheen parameters for the material.
  44702. */
  44703. readonly sheen: PBRSheenConfiguration;
  44704. /**
  44705. * Defines the SubSurface parameters for the material.
  44706. */
  44707. readonly subSurface: PBRSubSurfaceConfiguration;
  44708. /**
  44709. * Custom callback helping to override the default shader used in the material.
  44710. */
  44711. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44712. /**
  44713. * Instantiates a new PBRMaterial instance.
  44714. *
  44715. * @param name The material name
  44716. * @param scene The scene the material will be use in.
  44717. */
  44718. constructor(name: string, scene: Scene);
  44719. /**
  44720. * Gets a boolean indicating that current material needs to register RTT
  44721. */
  44722. readonly hasRenderTargetTextures: boolean;
  44723. /**
  44724. * Gets the name of the material class.
  44725. */
  44726. getClassName(): string;
  44727. /**
  44728. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44729. */
  44730. /**
  44731. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44732. */
  44733. useLogarithmicDepth: boolean;
  44734. /**
  44735. * Gets the current transparency mode.
  44736. */
  44737. /**
  44738. * Sets the transparency mode of the material.
  44739. *
  44740. * | Value | Type | Description |
  44741. * | ----- | ----------------------------------- | ----------- |
  44742. * | 0 | OPAQUE | |
  44743. * | 1 | ALPHATEST | |
  44744. * | 2 | ALPHABLEND | |
  44745. * | 3 | ALPHATESTANDBLEND | |
  44746. *
  44747. */
  44748. transparencyMode: Nullable<number>;
  44749. /**
  44750. * Returns true if alpha blending should be disabled.
  44751. */
  44752. private readonly _disableAlphaBlending;
  44753. /**
  44754. * Specifies whether or not this material should be rendered in alpha blend mode.
  44755. */
  44756. needAlphaBlending(): boolean;
  44757. /**
  44758. * Specifies if the mesh will require alpha blending.
  44759. * @param mesh - BJS mesh.
  44760. */
  44761. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44762. /**
  44763. * Specifies whether or not this material should be rendered in alpha test mode.
  44764. */
  44765. needAlphaTesting(): boolean;
  44766. /**
  44767. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44768. */
  44769. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44770. /**
  44771. * Gets the texture used for the alpha test.
  44772. */
  44773. getAlphaTestTexture(): Nullable<BaseTexture>;
  44774. /**
  44775. * Specifies that the submesh is ready to be used.
  44776. * @param mesh - BJS mesh.
  44777. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44778. * @param useInstances - Specifies that instances should be used.
  44779. * @returns - boolean indicating that the submesh is ready or not.
  44780. */
  44781. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44782. /**
  44783. * Specifies if the material uses metallic roughness workflow.
  44784. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44785. */
  44786. isMetallicWorkflow(): boolean;
  44787. private _prepareEffect;
  44788. private _prepareDefines;
  44789. /**
  44790. * Force shader compilation
  44791. */
  44792. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44793. clipPlane: boolean;
  44794. }>): void;
  44795. /**
  44796. * Initializes the uniform buffer layout for the shader.
  44797. */
  44798. buildUniformLayout(): void;
  44799. /**
  44800. * Unbinds the material from the mesh
  44801. */
  44802. unbind(): void;
  44803. /**
  44804. * Binds the submesh data.
  44805. * @param world - The world matrix.
  44806. * @param mesh - The BJS mesh.
  44807. * @param subMesh - A submesh of the BJS mesh.
  44808. */
  44809. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44810. /**
  44811. * Returns the animatable textures.
  44812. * @returns - Array of animatable textures.
  44813. */
  44814. getAnimatables(): IAnimatable[];
  44815. /**
  44816. * Returns the texture used for reflections.
  44817. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44818. */
  44819. private _getReflectionTexture;
  44820. /**
  44821. * Returns an array of the actively used textures.
  44822. * @returns - Array of BaseTextures
  44823. */
  44824. getActiveTextures(): BaseTexture[];
  44825. /**
  44826. * Checks to see if a texture is used in the material.
  44827. * @param texture - Base texture to use.
  44828. * @returns - Boolean specifying if a texture is used in the material.
  44829. */
  44830. hasTexture(texture: BaseTexture): boolean;
  44831. /**
  44832. * Disposes the resources of the material.
  44833. * @param forceDisposeEffect - Forces the disposal of effects.
  44834. * @param forceDisposeTextures - Forces the disposal of all textures.
  44835. */
  44836. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44837. }
  44838. }
  44839. declare module BABYLON {
  44840. /**
  44841. * The Physically based material of BJS.
  44842. *
  44843. * This offers the main features of a standard PBR material.
  44844. * For more information, please refer to the documentation :
  44845. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44846. */
  44847. export class PBRMaterial extends PBRBaseMaterial {
  44848. /**
  44849. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44850. */
  44851. static readonly PBRMATERIAL_OPAQUE: number;
  44852. /**
  44853. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44854. */
  44855. static readonly PBRMATERIAL_ALPHATEST: number;
  44856. /**
  44857. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44858. */
  44859. static readonly PBRMATERIAL_ALPHABLEND: number;
  44860. /**
  44861. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44862. * They are also discarded below the alpha cutoff threshold to improve performances.
  44863. */
  44864. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44865. /**
  44866. * Defines the default value of how much AO map is occluding the analytical lights
  44867. * (point spot...).
  44868. */
  44869. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44870. /**
  44871. * Intensity of the direct lights e.g. the four lights available in your scene.
  44872. * This impacts both the direct diffuse and specular highlights.
  44873. */
  44874. directIntensity: number;
  44875. /**
  44876. * Intensity of the emissive part of the material.
  44877. * This helps controlling the emissive effect without modifying the emissive color.
  44878. */
  44879. emissiveIntensity: number;
  44880. /**
  44881. * Intensity of the environment e.g. how much the environment will light the object
  44882. * either through harmonics for rough material or through the refelction for shiny ones.
  44883. */
  44884. environmentIntensity: number;
  44885. /**
  44886. * This is a special control allowing the reduction of the specular highlights coming from the
  44887. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44888. */
  44889. specularIntensity: number;
  44890. /**
  44891. * Debug Control allowing disabling the bump map on this material.
  44892. */
  44893. disableBumpMap: boolean;
  44894. /**
  44895. * AKA Diffuse Texture in standard nomenclature.
  44896. */
  44897. albedoTexture: BaseTexture;
  44898. /**
  44899. * AKA Occlusion Texture in other nomenclature.
  44900. */
  44901. ambientTexture: BaseTexture;
  44902. /**
  44903. * AKA Occlusion Texture Intensity in other nomenclature.
  44904. */
  44905. ambientTextureStrength: number;
  44906. /**
  44907. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44908. * 1 means it completely occludes it
  44909. * 0 mean it has no impact
  44910. */
  44911. ambientTextureImpactOnAnalyticalLights: number;
  44912. /**
  44913. * Stores the alpha values in a texture.
  44914. */
  44915. opacityTexture: BaseTexture;
  44916. /**
  44917. * Stores the reflection values in a texture.
  44918. */
  44919. reflectionTexture: Nullable<BaseTexture>;
  44920. /**
  44921. * Stores the emissive values in a texture.
  44922. */
  44923. emissiveTexture: BaseTexture;
  44924. /**
  44925. * AKA Specular texture in other nomenclature.
  44926. */
  44927. reflectivityTexture: BaseTexture;
  44928. /**
  44929. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44930. */
  44931. metallicTexture: BaseTexture;
  44932. /**
  44933. * Specifies the metallic scalar of the metallic/roughness workflow.
  44934. * Can also be used to scale the metalness values of the metallic texture.
  44935. */
  44936. metallic: Nullable<number>;
  44937. /**
  44938. * Specifies the roughness scalar of the metallic/roughness workflow.
  44939. * Can also be used to scale the roughness values of the metallic texture.
  44940. */
  44941. roughness: Nullable<number>;
  44942. /**
  44943. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44944. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44945. */
  44946. microSurfaceTexture: BaseTexture;
  44947. /**
  44948. * Stores surface normal data used to displace a mesh in a texture.
  44949. */
  44950. bumpTexture: BaseTexture;
  44951. /**
  44952. * Stores the pre-calculated light information of a mesh in a texture.
  44953. */
  44954. lightmapTexture: BaseTexture;
  44955. /**
  44956. * Stores the refracted light information in a texture.
  44957. */
  44958. refractionTexture: Nullable<BaseTexture>;
  44959. /**
  44960. * The color of a material in ambient lighting.
  44961. */
  44962. ambientColor: Color3;
  44963. /**
  44964. * AKA Diffuse Color in other nomenclature.
  44965. */
  44966. albedoColor: Color3;
  44967. /**
  44968. * AKA Specular Color in other nomenclature.
  44969. */
  44970. reflectivityColor: Color3;
  44971. /**
  44972. * The color reflected from the material.
  44973. */
  44974. reflectionColor: Color3;
  44975. /**
  44976. * The color emitted from the material.
  44977. */
  44978. emissiveColor: Color3;
  44979. /**
  44980. * AKA Glossiness in other nomenclature.
  44981. */
  44982. microSurface: number;
  44983. /**
  44984. * source material index of refraction (IOR)' / 'destination material IOR.
  44985. */
  44986. indexOfRefraction: number;
  44987. /**
  44988. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44989. */
  44990. invertRefractionY: boolean;
  44991. /**
  44992. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44993. * Materials half opaque for instance using refraction could benefit from this control.
  44994. */
  44995. linkRefractionWithTransparency: boolean;
  44996. /**
  44997. * If true, the light map contains occlusion information instead of lighting info.
  44998. */
  44999. useLightmapAsShadowmap: boolean;
  45000. /**
  45001. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45002. */
  45003. useAlphaFromAlbedoTexture: boolean;
  45004. /**
  45005. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45006. */
  45007. forceAlphaTest: boolean;
  45008. /**
  45009. * Defines the alpha limits in alpha test mode.
  45010. */
  45011. alphaCutOff: number;
  45012. /**
  45013. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45014. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45015. */
  45016. useSpecularOverAlpha: boolean;
  45017. /**
  45018. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45019. */
  45020. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45021. /**
  45022. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45023. */
  45024. useRoughnessFromMetallicTextureAlpha: boolean;
  45025. /**
  45026. * Specifies if the metallic texture contains the roughness information in its green channel.
  45027. */
  45028. useRoughnessFromMetallicTextureGreen: boolean;
  45029. /**
  45030. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45031. */
  45032. useMetallnessFromMetallicTextureBlue: boolean;
  45033. /**
  45034. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45035. */
  45036. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45037. /**
  45038. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45039. */
  45040. useAmbientInGrayScale: boolean;
  45041. /**
  45042. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45043. * The material will try to infer what glossiness each pixel should be.
  45044. */
  45045. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45046. /**
  45047. * BJS is using an harcoded light falloff based on a manually sets up range.
  45048. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45049. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45050. */
  45051. /**
  45052. * BJS is using an harcoded light falloff based on a manually sets up range.
  45053. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45054. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45055. */
  45056. usePhysicalLightFalloff: boolean;
  45057. /**
  45058. * In order to support the falloff compatibility with gltf, a special mode has been added
  45059. * to reproduce the gltf light falloff.
  45060. */
  45061. /**
  45062. * In order to support the falloff compatibility with gltf, a special mode has been added
  45063. * to reproduce the gltf light falloff.
  45064. */
  45065. useGLTFLightFalloff: boolean;
  45066. /**
  45067. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45068. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45069. */
  45070. useRadianceOverAlpha: boolean;
  45071. /**
  45072. * Allows using an object space normal map (instead of tangent space).
  45073. */
  45074. useObjectSpaceNormalMap: boolean;
  45075. /**
  45076. * Allows using the bump map in parallax mode.
  45077. */
  45078. useParallax: boolean;
  45079. /**
  45080. * Allows using the bump map in parallax occlusion mode.
  45081. */
  45082. useParallaxOcclusion: boolean;
  45083. /**
  45084. * Controls the scale bias of the parallax mode.
  45085. */
  45086. parallaxScaleBias: number;
  45087. /**
  45088. * If sets to true, disables all the lights affecting the material.
  45089. */
  45090. disableLighting: boolean;
  45091. /**
  45092. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45093. */
  45094. forceIrradianceInFragment: boolean;
  45095. /**
  45096. * Number of Simultaneous lights allowed on the material.
  45097. */
  45098. maxSimultaneousLights: number;
  45099. /**
  45100. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45101. */
  45102. invertNormalMapX: boolean;
  45103. /**
  45104. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45105. */
  45106. invertNormalMapY: boolean;
  45107. /**
  45108. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45109. */
  45110. twoSidedLighting: boolean;
  45111. /**
  45112. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45113. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45114. */
  45115. useAlphaFresnel: boolean;
  45116. /**
  45117. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45118. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45119. */
  45120. useLinearAlphaFresnel: boolean;
  45121. /**
  45122. * Let user defines the brdf lookup texture used for IBL.
  45123. * A default 8bit version is embedded but you could point at :
  45124. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45125. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45126. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45127. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45128. */
  45129. environmentBRDFTexture: Nullable<BaseTexture>;
  45130. /**
  45131. * Force normal to face away from face.
  45132. */
  45133. forceNormalForward: boolean;
  45134. /**
  45135. * Enables specular anti aliasing in the PBR shader.
  45136. * It will both interacts on the Geometry for analytical and IBL lighting.
  45137. * It also prefilter the roughness map based on the bump values.
  45138. */
  45139. enableSpecularAntiAliasing: boolean;
  45140. /**
  45141. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45142. * makes the reflect vector face the model (under horizon).
  45143. */
  45144. useHorizonOcclusion: boolean;
  45145. /**
  45146. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45147. * too much the area relying on ambient texture to define their ambient occlusion.
  45148. */
  45149. useRadianceOcclusion: boolean;
  45150. /**
  45151. * If set to true, no lighting calculations will be applied.
  45152. */
  45153. unlit: boolean;
  45154. /**
  45155. * Gets the image processing configuration used either in this material.
  45156. */
  45157. /**
  45158. * Sets the Default image processing configuration used either in the this material.
  45159. *
  45160. * If sets to null, the scene one is in use.
  45161. */
  45162. imageProcessingConfiguration: ImageProcessingConfiguration;
  45163. /**
  45164. * Gets wether the color curves effect is enabled.
  45165. */
  45166. /**
  45167. * Sets wether the color curves effect is enabled.
  45168. */
  45169. cameraColorCurvesEnabled: boolean;
  45170. /**
  45171. * Gets wether the color grading effect is enabled.
  45172. */
  45173. /**
  45174. * Gets wether the color grading effect is enabled.
  45175. */
  45176. cameraColorGradingEnabled: boolean;
  45177. /**
  45178. * Gets wether tonemapping is enabled or not.
  45179. */
  45180. /**
  45181. * Sets wether tonemapping is enabled or not
  45182. */
  45183. cameraToneMappingEnabled: boolean;
  45184. /**
  45185. * The camera exposure used on this material.
  45186. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45187. * This corresponds to a photographic exposure.
  45188. */
  45189. /**
  45190. * The camera exposure used on this material.
  45191. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45192. * This corresponds to a photographic exposure.
  45193. */
  45194. cameraExposure: number;
  45195. /**
  45196. * Gets The camera contrast used on this material.
  45197. */
  45198. /**
  45199. * Sets The camera contrast used on this material.
  45200. */
  45201. cameraContrast: number;
  45202. /**
  45203. * Gets the Color Grading 2D Lookup Texture.
  45204. */
  45205. /**
  45206. * Sets the Color Grading 2D Lookup Texture.
  45207. */
  45208. cameraColorGradingTexture: Nullable<BaseTexture>;
  45209. /**
  45210. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45211. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45212. * 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;
  45213. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45214. */
  45215. /**
  45216. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45217. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45218. * 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;
  45219. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45220. */
  45221. cameraColorCurves: Nullable<ColorCurves>;
  45222. /**
  45223. * Instantiates a new PBRMaterial instance.
  45224. *
  45225. * @param name The material name
  45226. * @param scene The scene the material will be use in.
  45227. */
  45228. constructor(name: string, scene: Scene);
  45229. /**
  45230. * Returns the name of this material class.
  45231. */
  45232. getClassName(): string;
  45233. /**
  45234. * Makes a duplicate of the current material.
  45235. * @param name - name to use for the new material.
  45236. */
  45237. clone(name: string): PBRMaterial;
  45238. /**
  45239. * Serializes this PBR Material.
  45240. * @returns - An object with the serialized material.
  45241. */
  45242. serialize(): any;
  45243. /**
  45244. * Parses a PBR Material from a serialized object.
  45245. * @param source - Serialized object.
  45246. * @param scene - BJS scene instance.
  45247. * @param rootUrl - url for the scene object
  45248. * @returns - PBRMaterial
  45249. */
  45250. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45251. }
  45252. }
  45253. declare module BABYLON {
  45254. /**
  45255. * Direct draw surface info
  45256. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45257. */
  45258. export interface DDSInfo {
  45259. /**
  45260. * Width of the texture
  45261. */
  45262. width: number;
  45263. /**
  45264. * Width of the texture
  45265. */
  45266. height: number;
  45267. /**
  45268. * Number of Mipmaps for the texture
  45269. * @see https://en.wikipedia.org/wiki/Mipmap
  45270. */
  45271. mipmapCount: number;
  45272. /**
  45273. * If the textures format is a known fourCC format
  45274. * @see https://www.fourcc.org/
  45275. */
  45276. isFourCC: boolean;
  45277. /**
  45278. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45279. */
  45280. isRGB: boolean;
  45281. /**
  45282. * If the texture is a lumincance format
  45283. */
  45284. isLuminance: boolean;
  45285. /**
  45286. * If this is a cube texture
  45287. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45288. */
  45289. isCube: boolean;
  45290. /**
  45291. * If the texture is a compressed format eg. FOURCC_DXT1
  45292. */
  45293. isCompressed: boolean;
  45294. /**
  45295. * The dxgiFormat of the texture
  45296. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45297. */
  45298. dxgiFormat: number;
  45299. /**
  45300. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45301. */
  45302. textureType: number;
  45303. /**
  45304. * Sphericle polynomial created for the dds texture
  45305. */
  45306. sphericalPolynomial?: SphericalPolynomial;
  45307. }
  45308. /**
  45309. * Class used to provide DDS decompression tools
  45310. */
  45311. export class DDSTools {
  45312. /**
  45313. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45314. */
  45315. static StoreLODInAlphaChannel: boolean;
  45316. /**
  45317. * Gets DDS information from an array buffer
  45318. * @param arrayBuffer defines the array buffer to read data from
  45319. * @returns the DDS information
  45320. */
  45321. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45322. private static _FloatView;
  45323. private static _Int32View;
  45324. private static _ToHalfFloat;
  45325. private static _FromHalfFloat;
  45326. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45327. private static _GetHalfFloatRGBAArrayBuffer;
  45328. private static _GetFloatRGBAArrayBuffer;
  45329. private static _GetFloatAsUIntRGBAArrayBuffer;
  45330. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45331. private static _GetRGBAArrayBuffer;
  45332. private static _ExtractLongWordOrder;
  45333. private static _GetRGBArrayBuffer;
  45334. private static _GetLuminanceArrayBuffer;
  45335. /**
  45336. * Uploads DDS Levels to a Babylon Texture
  45337. * @hidden
  45338. */
  45339. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45340. }
  45341. interface Engine {
  45342. /**
  45343. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45344. * @param rootUrl defines the url where the file to load is located
  45345. * @param scene defines the current scene
  45346. * @param lodScale defines scale to apply to the mip map selection
  45347. * @param lodOffset defines offset to apply to the mip map selection
  45348. * @param onLoad defines an optional callback raised when the texture is loaded
  45349. * @param onError defines an optional callback raised if there is an issue to load the texture
  45350. * @param format defines the format of the data
  45351. * @param forcedExtension defines the extension to use to pick the right loader
  45352. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45353. * @returns the cube texture as an InternalTexture
  45354. */
  45355. 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;
  45356. }
  45357. }
  45358. declare module BABYLON {
  45359. /**
  45360. * Implementation of the DDS Texture Loader.
  45361. * @hidden
  45362. */
  45363. export class _DDSTextureLoader implements IInternalTextureLoader {
  45364. /**
  45365. * Defines wether the loader supports cascade loading the different faces.
  45366. */
  45367. readonly supportCascades: boolean;
  45368. /**
  45369. * This returns if the loader support the current file information.
  45370. * @param extension defines the file extension of the file being loaded
  45371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45372. * @param fallback defines the fallback internal texture if any
  45373. * @param isBase64 defines whether the texture is encoded as a base64
  45374. * @param isBuffer defines whether the texture data are stored as a buffer
  45375. * @returns true if the loader can load the specified file
  45376. */
  45377. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45378. /**
  45379. * Transform the url before loading if required.
  45380. * @param rootUrl the url of the texture
  45381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45382. * @returns the transformed texture
  45383. */
  45384. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45385. /**
  45386. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45387. * @param rootUrl the url of the texture
  45388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45389. * @returns the fallback texture
  45390. */
  45391. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45392. /**
  45393. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45394. * @param data contains the texture data
  45395. * @param texture defines the BabylonJS internal texture
  45396. * @param createPolynomials will be true if polynomials have been requested
  45397. * @param onLoad defines the callback to trigger once the texture is ready
  45398. * @param onError defines the callback to trigger in case of error
  45399. */
  45400. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45401. /**
  45402. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45403. * @param data contains the texture data
  45404. * @param texture defines the BabylonJS internal texture
  45405. * @param callback defines the method to call once ready to upload
  45406. */
  45407. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45408. }
  45409. }
  45410. declare module BABYLON {
  45411. /** @hidden */
  45412. export var rgbdEncodePixelShader: {
  45413. name: string;
  45414. shader: string;
  45415. };
  45416. }
  45417. declare module BABYLON {
  45418. /**
  45419. * Raw texture data and descriptor sufficient for WebGL texture upload
  45420. */
  45421. export interface EnvironmentTextureInfo {
  45422. /**
  45423. * Version of the environment map
  45424. */
  45425. version: number;
  45426. /**
  45427. * Width of image
  45428. */
  45429. width: number;
  45430. /**
  45431. * Irradiance information stored in the file.
  45432. */
  45433. irradiance: any;
  45434. /**
  45435. * Specular information stored in the file.
  45436. */
  45437. specular: any;
  45438. }
  45439. /**
  45440. * Sets of helpers addressing the serialization and deserialization of environment texture
  45441. * stored in a BabylonJS env file.
  45442. * Those files are usually stored as .env files.
  45443. */
  45444. export class EnvironmentTextureTools {
  45445. /**
  45446. * Magic number identifying the env file.
  45447. */
  45448. private static _MagicBytes;
  45449. /**
  45450. * Gets the environment info from an env file.
  45451. * @param data The array buffer containing the .env bytes.
  45452. * @returns the environment file info (the json header) if successfully parsed.
  45453. */
  45454. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45455. /**
  45456. * Creates an environment texture from a loaded cube texture.
  45457. * @param texture defines the cube texture to convert in env file
  45458. * @return a promise containing the environment data if succesfull.
  45459. */
  45460. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45461. /**
  45462. * Creates a JSON representation of the spherical data.
  45463. * @param texture defines the texture containing the polynomials
  45464. * @return the JSON representation of the spherical info
  45465. */
  45466. private static _CreateEnvTextureIrradiance;
  45467. /**
  45468. * Uploads the texture info contained in the env file to the GPU.
  45469. * @param texture defines the internal texture to upload to
  45470. * @param arrayBuffer defines the buffer cotaining the data to load
  45471. * @param info defines the texture info retrieved through the GetEnvInfo method
  45472. * @returns a promise
  45473. */
  45474. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45475. /**
  45476. * Uploads the levels of image data to the GPU.
  45477. * @param texture defines the internal texture to upload to
  45478. * @param imageData defines the array buffer views of image data [mipmap][face]
  45479. * @returns a promise
  45480. */
  45481. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45482. /**
  45483. * Uploads spherical polynomials information to the texture.
  45484. * @param texture defines the texture we are trying to upload the information to
  45485. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45486. */
  45487. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45488. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45489. }
  45490. }
  45491. declare module BABYLON {
  45492. /**
  45493. * Implementation of the ENV Texture Loader.
  45494. * @hidden
  45495. */
  45496. export class _ENVTextureLoader implements IInternalTextureLoader {
  45497. /**
  45498. * Defines wether the loader supports cascade loading the different faces.
  45499. */
  45500. readonly supportCascades: boolean;
  45501. /**
  45502. * This returns if the loader support the current file information.
  45503. * @param extension defines the file extension of the file being loaded
  45504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45505. * @param fallback defines the fallback internal texture if any
  45506. * @param isBase64 defines whether the texture is encoded as a base64
  45507. * @param isBuffer defines whether the texture data are stored as a buffer
  45508. * @returns true if the loader can load the specified file
  45509. */
  45510. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45511. /**
  45512. * Transform the url before loading if required.
  45513. * @param rootUrl the url of the texture
  45514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45515. * @returns the transformed texture
  45516. */
  45517. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45518. /**
  45519. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45520. * @param rootUrl the url of the texture
  45521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45522. * @returns the fallback texture
  45523. */
  45524. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45525. /**
  45526. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45527. * @param data contains the texture data
  45528. * @param texture defines the BabylonJS internal texture
  45529. * @param createPolynomials will be true if polynomials have been requested
  45530. * @param onLoad defines the callback to trigger once the texture is ready
  45531. * @param onError defines the callback to trigger in case of error
  45532. */
  45533. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45534. /**
  45535. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45536. * @param data contains the texture data
  45537. * @param texture defines the BabylonJS internal texture
  45538. * @param callback defines the method to call once ready to upload
  45539. */
  45540. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45541. }
  45542. }
  45543. declare module BABYLON {
  45544. /**
  45545. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45546. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45547. */
  45548. export class KhronosTextureContainer {
  45549. /** contents of the KTX container file */
  45550. arrayBuffer: any;
  45551. private static HEADER_LEN;
  45552. private static COMPRESSED_2D;
  45553. private static COMPRESSED_3D;
  45554. private static TEX_2D;
  45555. private static TEX_3D;
  45556. /**
  45557. * Gets the openGL type
  45558. */
  45559. glType: number;
  45560. /**
  45561. * Gets the openGL type size
  45562. */
  45563. glTypeSize: number;
  45564. /**
  45565. * Gets the openGL format
  45566. */
  45567. glFormat: number;
  45568. /**
  45569. * Gets the openGL internal format
  45570. */
  45571. glInternalFormat: number;
  45572. /**
  45573. * Gets the base internal format
  45574. */
  45575. glBaseInternalFormat: number;
  45576. /**
  45577. * Gets image width in pixel
  45578. */
  45579. pixelWidth: number;
  45580. /**
  45581. * Gets image height in pixel
  45582. */
  45583. pixelHeight: number;
  45584. /**
  45585. * Gets image depth in pixels
  45586. */
  45587. pixelDepth: number;
  45588. /**
  45589. * Gets the number of array elements
  45590. */
  45591. numberOfArrayElements: number;
  45592. /**
  45593. * Gets the number of faces
  45594. */
  45595. numberOfFaces: number;
  45596. /**
  45597. * Gets the number of mipmap levels
  45598. */
  45599. numberOfMipmapLevels: number;
  45600. /**
  45601. * Gets the bytes of key value data
  45602. */
  45603. bytesOfKeyValueData: number;
  45604. /**
  45605. * Gets the load type
  45606. */
  45607. loadType: number;
  45608. /**
  45609. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45610. */
  45611. isInvalid: boolean;
  45612. /**
  45613. * Creates a new KhronosTextureContainer
  45614. * @param arrayBuffer contents of the KTX container file
  45615. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45616. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45617. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45618. */
  45619. constructor(
  45620. /** contents of the KTX container file */
  45621. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45622. /**
  45623. * Uploads KTX content to a Babylon Texture.
  45624. * It is assumed that the texture has already been created & is currently bound
  45625. * @hidden
  45626. */
  45627. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45628. private _upload2DCompressedLevels;
  45629. }
  45630. }
  45631. declare module BABYLON {
  45632. /**
  45633. * Implementation of the KTX Texture Loader.
  45634. * @hidden
  45635. */
  45636. export class _KTXTextureLoader implements IInternalTextureLoader {
  45637. /**
  45638. * Defines wether the loader supports cascade loading the different faces.
  45639. */
  45640. readonly supportCascades: boolean;
  45641. /**
  45642. * This returns if the loader support the current file information.
  45643. * @param extension defines the file extension of the file being loaded
  45644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45645. * @param fallback defines the fallback internal texture if any
  45646. * @param isBase64 defines whether the texture is encoded as a base64
  45647. * @param isBuffer defines whether the texture data are stored as a buffer
  45648. * @returns true if the loader can load the specified file
  45649. */
  45650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45651. /**
  45652. * Transform the url before loading if required.
  45653. * @param rootUrl the url of the texture
  45654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45655. * @returns the transformed texture
  45656. */
  45657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45658. /**
  45659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45660. * @param rootUrl the url of the texture
  45661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45662. * @returns the fallback texture
  45663. */
  45664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45665. /**
  45666. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45667. * @param data contains the texture data
  45668. * @param texture defines the BabylonJS internal texture
  45669. * @param createPolynomials will be true if polynomials have been requested
  45670. * @param onLoad defines the callback to trigger once the texture is ready
  45671. * @param onError defines the callback to trigger in case of error
  45672. */
  45673. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45674. /**
  45675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45676. * @param data contains the texture data
  45677. * @param texture defines the BabylonJS internal texture
  45678. * @param callback defines the method to call once ready to upload
  45679. */
  45680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45681. }
  45682. }
  45683. declare module BABYLON {
  45684. /** @hidden */
  45685. export var _forceSceneHelpersToBundle: boolean;
  45686. interface Scene {
  45687. /**
  45688. * Creates a default light for the scene.
  45689. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45690. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45691. */
  45692. createDefaultLight(replace?: boolean): void;
  45693. /**
  45694. * Creates a default camera for the scene.
  45695. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45696. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45697. * @param replace has default false, when true replaces the active camera in the scene
  45698. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45699. */
  45700. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45701. /**
  45702. * Creates a default camera and a default light.
  45703. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45704. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45705. * @param replace has the default false, when true replaces the active camera/light in the scene
  45706. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45707. */
  45708. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45709. /**
  45710. * Creates a new sky box
  45711. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45712. * @param environmentTexture defines the texture to use as environment texture
  45713. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45714. * @param scale defines the overall scale of the skybox
  45715. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45716. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45717. * @returns a new mesh holding the sky box
  45718. */
  45719. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45720. /**
  45721. * Creates a new environment
  45722. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45723. * @param options defines the options you can use to configure the environment
  45724. * @returns the new EnvironmentHelper
  45725. */
  45726. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45727. /**
  45728. * Creates a new VREXperienceHelper
  45729. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45730. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45731. * @returns a new VREXperienceHelper
  45732. */
  45733. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45734. /**
  45735. * Creates a new XREXperienceHelper
  45736. * @see http://doc.babylonjs.com/how_to/webxr
  45737. * @returns a promise for a new XREXperienceHelper
  45738. */
  45739. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45740. }
  45741. }
  45742. declare module BABYLON {
  45743. /**
  45744. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45745. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45746. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45747. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45748. */
  45749. export class VideoDome extends TransformNode {
  45750. /**
  45751. * Define the video source as a Monoscopic panoramic 360 video.
  45752. */
  45753. static readonly MODE_MONOSCOPIC: number;
  45754. /**
  45755. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45756. */
  45757. static readonly MODE_TOPBOTTOM: number;
  45758. /**
  45759. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45760. */
  45761. static readonly MODE_SIDEBYSIDE: number;
  45762. private _useDirectMapping;
  45763. /**
  45764. * The video texture being displayed on the sphere
  45765. */
  45766. protected _videoTexture: VideoTexture;
  45767. /**
  45768. * Gets the video texture being displayed on the sphere
  45769. */
  45770. readonly videoTexture: VideoTexture;
  45771. /**
  45772. * The skybox material
  45773. */
  45774. protected _material: BackgroundMaterial;
  45775. /**
  45776. * The surface used for the skybox
  45777. */
  45778. protected _mesh: Mesh;
  45779. /**
  45780. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45781. * Also see the options.resolution property.
  45782. */
  45783. fovMultiplier: number;
  45784. private _videoMode;
  45785. /**
  45786. * Gets or set the current video mode for the video. It can be:
  45787. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45788. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45789. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45790. */
  45791. videoMode: number;
  45792. /**
  45793. * Oberserver used in Stereoscopic VR Mode.
  45794. */
  45795. private _onBeforeCameraRenderObserver;
  45796. /**
  45797. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45798. * @param name Element's name, child elements will append suffixes for their own names.
  45799. * @param urlsOrVideo defines the url(s) or the video element to use
  45800. * @param options An object containing optional or exposed sub element properties
  45801. */
  45802. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45803. resolution?: number;
  45804. clickToPlay?: boolean;
  45805. autoPlay?: boolean;
  45806. loop?: boolean;
  45807. size?: number;
  45808. poster?: string;
  45809. faceForward?: boolean;
  45810. useDirectMapping?: boolean;
  45811. }, scene: Scene);
  45812. private _changeVideoMode;
  45813. /**
  45814. * Releases resources associated with this node.
  45815. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45816. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45817. */
  45818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45819. }
  45820. }
  45821. declare module BABYLON {
  45822. /**
  45823. * This class can be used to get instrumentation data from a Babylon engine
  45824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45825. */
  45826. export class EngineInstrumentation implements IDisposable {
  45827. /**
  45828. * Define the instrumented engine.
  45829. */
  45830. engine: Engine;
  45831. private _captureGPUFrameTime;
  45832. private _gpuFrameTimeToken;
  45833. private _gpuFrameTime;
  45834. private _captureShaderCompilationTime;
  45835. private _shaderCompilationTime;
  45836. private _onBeginFrameObserver;
  45837. private _onEndFrameObserver;
  45838. private _onBeforeShaderCompilationObserver;
  45839. private _onAfterShaderCompilationObserver;
  45840. /**
  45841. * Gets the perf counter used for GPU frame time
  45842. */
  45843. readonly gpuFrameTimeCounter: PerfCounter;
  45844. /**
  45845. * Gets the GPU frame time capture status
  45846. */
  45847. /**
  45848. * Enable or disable the GPU frame time capture
  45849. */
  45850. captureGPUFrameTime: boolean;
  45851. /**
  45852. * Gets the perf counter used for shader compilation time
  45853. */
  45854. readonly shaderCompilationTimeCounter: PerfCounter;
  45855. /**
  45856. * Gets the shader compilation time capture status
  45857. */
  45858. /**
  45859. * Enable or disable the shader compilation time capture
  45860. */
  45861. captureShaderCompilationTime: boolean;
  45862. /**
  45863. * Instantiates a new engine instrumentation.
  45864. * This class can be used to get instrumentation data from a Babylon engine
  45865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45866. * @param engine Defines the engine to instrument
  45867. */
  45868. constructor(
  45869. /**
  45870. * Define the instrumented engine.
  45871. */
  45872. engine: Engine);
  45873. /**
  45874. * Dispose and release associated resources.
  45875. */
  45876. dispose(): void;
  45877. }
  45878. }
  45879. declare module BABYLON {
  45880. /**
  45881. * This class can be used to get instrumentation data from a Babylon engine
  45882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45883. */
  45884. export class SceneInstrumentation implements IDisposable {
  45885. /**
  45886. * Defines the scene to instrument
  45887. */
  45888. scene: Scene;
  45889. private _captureActiveMeshesEvaluationTime;
  45890. private _activeMeshesEvaluationTime;
  45891. private _captureRenderTargetsRenderTime;
  45892. private _renderTargetsRenderTime;
  45893. private _captureFrameTime;
  45894. private _frameTime;
  45895. private _captureRenderTime;
  45896. private _renderTime;
  45897. private _captureInterFrameTime;
  45898. private _interFrameTime;
  45899. private _captureParticlesRenderTime;
  45900. private _particlesRenderTime;
  45901. private _captureSpritesRenderTime;
  45902. private _spritesRenderTime;
  45903. private _capturePhysicsTime;
  45904. private _physicsTime;
  45905. private _captureAnimationsTime;
  45906. private _animationsTime;
  45907. private _captureCameraRenderTime;
  45908. private _cameraRenderTime;
  45909. private _onBeforeActiveMeshesEvaluationObserver;
  45910. private _onAfterActiveMeshesEvaluationObserver;
  45911. private _onBeforeRenderTargetsRenderObserver;
  45912. private _onAfterRenderTargetsRenderObserver;
  45913. private _onAfterRenderObserver;
  45914. private _onBeforeDrawPhaseObserver;
  45915. private _onAfterDrawPhaseObserver;
  45916. private _onBeforeAnimationsObserver;
  45917. private _onBeforeParticlesRenderingObserver;
  45918. private _onAfterParticlesRenderingObserver;
  45919. private _onBeforeSpritesRenderingObserver;
  45920. private _onAfterSpritesRenderingObserver;
  45921. private _onBeforePhysicsObserver;
  45922. private _onAfterPhysicsObserver;
  45923. private _onAfterAnimationsObserver;
  45924. private _onBeforeCameraRenderObserver;
  45925. private _onAfterCameraRenderObserver;
  45926. /**
  45927. * Gets the perf counter used for active meshes evaluation time
  45928. */
  45929. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45930. /**
  45931. * Gets the active meshes evaluation time capture status
  45932. */
  45933. /**
  45934. * Enable or disable the active meshes evaluation time capture
  45935. */
  45936. captureActiveMeshesEvaluationTime: boolean;
  45937. /**
  45938. * Gets the perf counter used for render targets render time
  45939. */
  45940. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45941. /**
  45942. * Gets the render targets render time capture status
  45943. */
  45944. /**
  45945. * Enable or disable the render targets render time capture
  45946. */
  45947. captureRenderTargetsRenderTime: boolean;
  45948. /**
  45949. * Gets the perf counter used for particles render time
  45950. */
  45951. readonly particlesRenderTimeCounter: PerfCounter;
  45952. /**
  45953. * Gets the particles render time capture status
  45954. */
  45955. /**
  45956. * Enable or disable the particles render time capture
  45957. */
  45958. captureParticlesRenderTime: boolean;
  45959. /**
  45960. * Gets the perf counter used for sprites render time
  45961. */
  45962. readonly spritesRenderTimeCounter: PerfCounter;
  45963. /**
  45964. * Gets the sprites render time capture status
  45965. */
  45966. /**
  45967. * Enable or disable the sprites render time capture
  45968. */
  45969. captureSpritesRenderTime: boolean;
  45970. /**
  45971. * Gets the perf counter used for physics time
  45972. */
  45973. readonly physicsTimeCounter: PerfCounter;
  45974. /**
  45975. * Gets the physics time capture status
  45976. */
  45977. /**
  45978. * Enable or disable the physics time capture
  45979. */
  45980. capturePhysicsTime: boolean;
  45981. /**
  45982. * Gets the perf counter used for animations time
  45983. */
  45984. readonly animationsTimeCounter: PerfCounter;
  45985. /**
  45986. * Gets the animations time capture status
  45987. */
  45988. /**
  45989. * Enable or disable the animations time capture
  45990. */
  45991. captureAnimationsTime: boolean;
  45992. /**
  45993. * Gets the perf counter used for frame time capture
  45994. */
  45995. readonly frameTimeCounter: PerfCounter;
  45996. /**
  45997. * Gets the frame time capture status
  45998. */
  45999. /**
  46000. * Enable or disable the frame time capture
  46001. */
  46002. captureFrameTime: boolean;
  46003. /**
  46004. * Gets the perf counter used for inter-frames time capture
  46005. */
  46006. readonly interFrameTimeCounter: PerfCounter;
  46007. /**
  46008. * Gets the inter-frames time capture status
  46009. */
  46010. /**
  46011. * Enable or disable the inter-frames time capture
  46012. */
  46013. captureInterFrameTime: boolean;
  46014. /**
  46015. * Gets the perf counter used for render time capture
  46016. */
  46017. readonly renderTimeCounter: PerfCounter;
  46018. /**
  46019. * Gets the render time capture status
  46020. */
  46021. /**
  46022. * Enable or disable the render time capture
  46023. */
  46024. captureRenderTime: boolean;
  46025. /**
  46026. * Gets the perf counter used for camera render time capture
  46027. */
  46028. readonly cameraRenderTimeCounter: PerfCounter;
  46029. /**
  46030. * Gets the camera render time capture status
  46031. */
  46032. /**
  46033. * Enable or disable the camera render time capture
  46034. */
  46035. captureCameraRenderTime: boolean;
  46036. /**
  46037. * Gets the perf counter used for draw calls
  46038. */
  46039. readonly drawCallsCounter: PerfCounter;
  46040. /**
  46041. * Instantiates a new scene instrumentation.
  46042. * This class can be used to get instrumentation data from a Babylon engine
  46043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46044. * @param scene Defines the scene to instrument
  46045. */
  46046. constructor(
  46047. /**
  46048. * Defines the scene to instrument
  46049. */
  46050. scene: Scene);
  46051. /**
  46052. * Dispose and release associated resources.
  46053. */
  46054. dispose(): void;
  46055. }
  46056. }
  46057. declare module BABYLON {
  46058. /** @hidden */
  46059. export var glowMapGenerationPixelShader: {
  46060. name: string;
  46061. shader: string;
  46062. };
  46063. }
  46064. declare module BABYLON {
  46065. /** @hidden */
  46066. export var glowMapGenerationVertexShader: {
  46067. name: string;
  46068. shader: string;
  46069. };
  46070. }
  46071. declare module BABYLON {
  46072. /**
  46073. * Effect layer options. This helps customizing the behaviour
  46074. * of the effect layer.
  46075. */
  46076. export interface IEffectLayerOptions {
  46077. /**
  46078. * Multiplication factor apply to the canvas size to compute the render target size
  46079. * used to generated the objects (the smaller the faster).
  46080. */
  46081. mainTextureRatio: number;
  46082. /**
  46083. * Enforces a fixed size texture to ensure effect stability across devices.
  46084. */
  46085. mainTextureFixedSize?: number;
  46086. /**
  46087. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46088. */
  46089. alphaBlendingMode: number;
  46090. /**
  46091. * The camera attached to the layer.
  46092. */
  46093. camera: Nullable<Camera>;
  46094. /**
  46095. * The rendering group to draw the layer in.
  46096. */
  46097. renderingGroupId: number;
  46098. }
  46099. /**
  46100. * The effect layer Helps adding post process effect blended with the main pass.
  46101. *
  46102. * This can be for instance use to generate glow or higlight effects on the scene.
  46103. *
  46104. * The effect layer class can not be used directly and is intented to inherited from to be
  46105. * customized per effects.
  46106. */
  46107. export abstract class EffectLayer {
  46108. private _vertexBuffers;
  46109. private _indexBuffer;
  46110. private _cachedDefines;
  46111. private _effectLayerMapGenerationEffect;
  46112. private _effectLayerOptions;
  46113. private _mergeEffect;
  46114. protected _scene: Scene;
  46115. protected _engine: Engine;
  46116. protected _maxSize: number;
  46117. protected _mainTextureDesiredSize: ISize;
  46118. protected _mainTexture: RenderTargetTexture;
  46119. protected _shouldRender: boolean;
  46120. protected _postProcesses: PostProcess[];
  46121. protected _textures: BaseTexture[];
  46122. protected _emissiveTextureAndColor: {
  46123. texture: Nullable<BaseTexture>;
  46124. color: Color4;
  46125. };
  46126. /**
  46127. * The name of the layer
  46128. */
  46129. name: string;
  46130. /**
  46131. * The clear color of the texture used to generate the glow map.
  46132. */
  46133. neutralColor: Color4;
  46134. /**
  46135. * Specifies wether the highlight layer is enabled or not.
  46136. */
  46137. isEnabled: boolean;
  46138. /**
  46139. * Gets the camera attached to the layer.
  46140. */
  46141. readonly camera: Nullable<Camera>;
  46142. /**
  46143. * Gets the rendering group id the layer should render in.
  46144. */
  46145. readonly renderingGroupId: number;
  46146. /**
  46147. * An event triggered when the effect layer has been disposed.
  46148. */
  46149. onDisposeObservable: Observable<EffectLayer>;
  46150. /**
  46151. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46152. */
  46153. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46154. /**
  46155. * An event triggered when the generated texture is being merged in the scene.
  46156. */
  46157. onBeforeComposeObservable: Observable<EffectLayer>;
  46158. /**
  46159. * An event triggered when the generated texture has been merged in the scene.
  46160. */
  46161. onAfterComposeObservable: Observable<EffectLayer>;
  46162. /**
  46163. * An event triggered when the efffect layer changes its size.
  46164. */
  46165. onSizeChangedObservable: Observable<EffectLayer>;
  46166. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46167. /**
  46168. * Instantiates a new effect Layer and references it in the scene.
  46169. * @param name The name of the layer
  46170. * @param scene The scene to use the layer in
  46171. */
  46172. constructor(
  46173. /** The Friendly of the effect in the scene */
  46174. name: string, scene: Scene);
  46175. /**
  46176. * Get the effect name of the layer.
  46177. * @return The effect name
  46178. */
  46179. abstract getEffectName(): string;
  46180. /**
  46181. * Checks for the readiness of the element composing the layer.
  46182. * @param subMesh the mesh to check for
  46183. * @param useInstances specify wether or not to use instances to render the mesh
  46184. * @return true if ready otherwise, false
  46185. */
  46186. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46187. /**
  46188. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46189. * @returns true if the effect requires stencil during the main canvas render pass.
  46190. */
  46191. abstract needStencil(): boolean;
  46192. /**
  46193. * Create the merge effect. This is the shader use to blit the information back
  46194. * to the main canvas at the end of the scene rendering.
  46195. * @returns The effect containing the shader used to merge the effect on the main canvas
  46196. */
  46197. protected abstract _createMergeEffect(): Effect;
  46198. /**
  46199. * Creates the render target textures and post processes used in the effect layer.
  46200. */
  46201. protected abstract _createTextureAndPostProcesses(): void;
  46202. /**
  46203. * Implementation specific of rendering the generating effect on the main canvas.
  46204. * @param effect The effect used to render through
  46205. */
  46206. protected abstract _internalRender(effect: Effect): void;
  46207. /**
  46208. * Sets the required values for both the emissive texture and and the main color.
  46209. */
  46210. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46211. /**
  46212. * Free any resources and references associated to a mesh.
  46213. * Internal use
  46214. * @param mesh The mesh to free.
  46215. */
  46216. abstract _disposeMesh(mesh: Mesh): void;
  46217. /**
  46218. * Serializes this layer (Glow or Highlight for example)
  46219. * @returns a serialized layer object
  46220. */
  46221. abstract serialize?(): any;
  46222. /**
  46223. * Initializes the effect layer with the required options.
  46224. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46225. */
  46226. protected _init(options: Partial<IEffectLayerOptions>): void;
  46227. /**
  46228. * Generates the index buffer of the full screen quad blending to the main canvas.
  46229. */
  46230. private _generateIndexBuffer;
  46231. /**
  46232. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46233. */
  46234. private _generateVertexBuffer;
  46235. /**
  46236. * Sets the main texture desired size which is the closest power of two
  46237. * of the engine canvas size.
  46238. */
  46239. private _setMainTextureSize;
  46240. /**
  46241. * Creates the main texture for the effect layer.
  46242. */
  46243. protected _createMainTexture(): void;
  46244. /**
  46245. * Adds specific effects defines.
  46246. * @param defines The defines to add specifics to.
  46247. */
  46248. protected _addCustomEffectDefines(defines: string[]): void;
  46249. /**
  46250. * Checks for the readiness of the element composing the layer.
  46251. * @param subMesh the mesh to check for
  46252. * @param useInstances specify wether or not to use instances to render the mesh
  46253. * @param emissiveTexture the associated emissive texture used to generate the glow
  46254. * @return true if ready otherwise, false
  46255. */
  46256. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46257. /**
  46258. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46259. */
  46260. render(): void;
  46261. /**
  46262. * Determine if a given mesh will be used in the current effect.
  46263. * @param mesh mesh to test
  46264. * @returns true if the mesh will be used
  46265. */
  46266. hasMesh(mesh: AbstractMesh): boolean;
  46267. /**
  46268. * Returns true if the layer contains information to display, otherwise false.
  46269. * @returns true if the glow layer should be rendered
  46270. */
  46271. shouldRender(): boolean;
  46272. /**
  46273. * Returns true if the mesh should render, otherwise false.
  46274. * @param mesh The mesh to render
  46275. * @returns true if it should render otherwise false
  46276. */
  46277. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46278. /**
  46279. * Returns true if the mesh can be rendered, otherwise false.
  46280. * @param mesh The mesh to render
  46281. * @param material The material used on the mesh
  46282. * @returns true if it can be rendered otherwise false
  46283. */
  46284. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46285. /**
  46286. * Returns true if the mesh should render, otherwise false.
  46287. * @param mesh The mesh to render
  46288. * @returns true if it should render otherwise false
  46289. */
  46290. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46291. /**
  46292. * Renders the submesh passed in parameter to the generation map.
  46293. */
  46294. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46295. /**
  46296. * Rebuild the required buffers.
  46297. * @hidden Internal use only.
  46298. */ rebuild(): void;
  46299. /**
  46300. * Dispose only the render target textures and post process.
  46301. */
  46302. private _disposeTextureAndPostProcesses;
  46303. /**
  46304. * Dispose the highlight layer and free resources.
  46305. */
  46306. dispose(): void;
  46307. /**
  46308. * Gets the class name of the effect layer
  46309. * @returns the string with the class name of the effect layer
  46310. */
  46311. getClassName(): string;
  46312. /**
  46313. * Creates an effect layer from parsed effect layer data
  46314. * @param parsedEffectLayer defines effect layer data
  46315. * @param scene defines the current scene
  46316. * @param rootUrl defines the root URL containing the effect layer information
  46317. * @returns a parsed effect Layer
  46318. */
  46319. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46320. }
  46321. }
  46322. declare module BABYLON {
  46323. interface AbstractScene {
  46324. /**
  46325. * The list of effect layers (highlights/glow) added to the scene
  46326. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46327. * @see http://doc.babylonjs.com/how_to/glow_layer
  46328. */
  46329. effectLayers: Array<EffectLayer>;
  46330. /**
  46331. * Removes the given effect layer from this scene.
  46332. * @param toRemove defines the effect layer to remove
  46333. * @returns the index of the removed effect layer
  46334. */
  46335. removeEffectLayer(toRemove: EffectLayer): number;
  46336. /**
  46337. * Adds the given effect layer to this scene
  46338. * @param newEffectLayer defines the effect layer to add
  46339. */
  46340. addEffectLayer(newEffectLayer: EffectLayer): void;
  46341. }
  46342. /**
  46343. * Defines the layer scene component responsible to manage any effect layers
  46344. * in a given scene.
  46345. */
  46346. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46347. /**
  46348. * The component name helpfull to identify the component in the list of scene components.
  46349. */
  46350. readonly name: string;
  46351. /**
  46352. * The scene the component belongs to.
  46353. */
  46354. scene: Scene;
  46355. private _engine;
  46356. private _renderEffects;
  46357. private _needStencil;
  46358. private _previousStencilState;
  46359. /**
  46360. * Creates a new instance of the component for the given scene
  46361. * @param scene Defines the scene to register the component in
  46362. */
  46363. constructor(scene: Scene);
  46364. /**
  46365. * Registers the component in a given scene
  46366. */
  46367. register(): void;
  46368. /**
  46369. * Rebuilds the elements related to this component in case of
  46370. * context lost for instance.
  46371. */
  46372. rebuild(): void;
  46373. /**
  46374. * Serializes the component data to the specified json object
  46375. * @param serializationObject The object to serialize to
  46376. */
  46377. serialize(serializationObject: any): void;
  46378. /**
  46379. * Adds all the element from the container to the scene
  46380. * @param container the container holding the elements
  46381. */
  46382. addFromContainer(container: AbstractScene): void;
  46383. /**
  46384. * Removes all the elements in the container from the scene
  46385. * @param container contains the elements to remove
  46386. * @param dispose if the removed element should be disposed (default: false)
  46387. */
  46388. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46389. /**
  46390. * Disposes the component and the associated ressources.
  46391. */
  46392. dispose(): void;
  46393. private _isReadyForMesh;
  46394. private _renderMainTexture;
  46395. private _setStencil;
  46396. private _setStencilBack;
  46397. private _draw;
  46398. private _drawCamera;
  46399. private _drawRenderingGroup;
  46400. }
  46401. }
  46402. declare module BABYLON {
  46403. /** @hidden */
  46404. export var glowMapMergePixelShader: {
  46405. name: string;
  46406. shader: string;
  46407. };
  46408. }
  46409. declare module BABYLON {
  46410. /** @hidden */
  46411. export var glowMapMergeVertexShader: {
  46412. name: string;
  46413. shader: string;
  46414. };
  46415. }
  46416. declare module BABYLON {
  46417. interface AbstractScene {
  46418. /**
  46419. * Return a the first highlight layer of the scene with a given name.
  46420. * @param name The name of the highlight layer to look for.
  46421. * @return The highlight layer if found otherwise null.
  46422. */
  46423. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46424. }
  46425. /**
  46426. * Glow layer options. This helps customizing the behaviour
  46427. * of the glow layer.
  46428. */
  46429. export interface IGlowLayerOptions {
  46430. /**
  46431. * Multiplication factor apply to the canvas size to compute the render target size
  46432. * used to generated the glowing objects (the smaller the faster).
  46433. */
  46434. mainTextureRatio: number;
  46435. /**
  46436. * Enforces a fixed size texture to ensure resize independant blur.
  46437. */
  46438. mainTextureFixedSize?: number;
  46439. /**
  46440. * How big is the kernel of the blur texture.
  46441. */
  46442. blurKernelSize: number;
  46443. /**
  46444. * The camera attached to the layer.
  46445. */
  46446. camera: Nullable<Camera>;
  46447. /**
  46448. * Enable MSAA by chosing the number of samples.
  46449. */
  46450. mainTextureSamples?: number;
  46451. /**
  46452. * The rendering group to draw the layer in.
  46453. */
  46454. renderingGroupId: number;
  46455. }
  46456. /**
  46457. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46458. *
  46459. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46460. * glowy meshes to your scene.
  46461. *
  46462. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46463. */
  46464. export class GlowLayer extends EffectLayer {
  46465. /**
  46466. * Effect Name of the layer.
  46467. */
  46468. static readonly EffectName: string;
  46469. /**
  46470. * The default blur kernel size used for the glow.
  46471. */
  46472. static DefaultBlurKernelSize: number;
  46473. /**
  46474. * The default texture size ratio used for the glow.
  46475. */
  46476. static DefaultTextureRatio: number;
  46477. /**
  46478. * Sets the kernel size of the blur.
  46479. */
  46480. /**
  46481. * Gets the kernel size of the blur.
  46482. */
  46483. blurKernelSize: number;
  46484. /**
  46485. * Sets the glow intensity.
  46486. */
  46487. /**
  46488. * Gets the glow intensity.
  46489. */
  46490. intensity: number;
  46491. private _options;
  46492. private _intensity;
  46493. private _horizontalBlurPostprocess1;
  46494. private _verticalBlurPostprocess1;
  46495. private _horizontalBlurPostprocess2;
  46496. private _verticalBlurPostprocess2;
  46497. private _blurTexture1;
  46498. private _blurTexture2;
  46499. private _postProcesses1;
  46500. private _postProcesses2;
  46501. private _includedOnlyMeshes;
  46502. private _excludedMeshes;
  46503. /**
  46504. * Callback used to let the user override the color selection on a per mesh basis
  46505. */
  46506. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46507. /**
  46508. * Callback used to let the user override the texture selection on a per mesh basis
  46509. */
  46510. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46511. /**
  46512. * Instantiates a new glow Layer and references it to the scene.
  46513. * @param name The name of the layer
  46514. * @param scene The scene to use the layer in
  46515. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46516. */
  46517. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46518. /**
  46519. * Get the effect name of the layer.
  46520. * @return The effect name
  46521. */
  46522. getEffectName(): string;
  46523. /**
  46524. * Create the merge effect. This is the shader use to blit the information back
  46525. * to the main canvas at the end of the scene rendering.
  46526. */
  46527. protected _createMergeEffect(): Effect;
  46528. /**
  46529. * Creates the render target textures and post processes used in the glow layer.
  46530. */
  46531. protected _createTextureAndPostProcesses(): void;
  46532. /**
  46533. * Checks for the readiness of the element composing the layer.
  46534. * @param subMesh the mesh to check for
  46535. * @param useInstances specify wether or not to use instances to render the mesh
  46536. * @param emissiveTexture the associated emissive texture used to generate the glow
  46537. * @return true if ready otherwise, false
  46538. */
  46539. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46540. /**
  46541. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46542. */
  46543. needStencil(): boolean;
  46544. /**
  46545. * Returns true if the mesh can be rendered, otherwise false.
  46546. * @param mesh The mesh to render
  46547. * @param material The material used on the mesh
  46548. * @returns true if it can be rendered otherwise false
  46549. */
  46550. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46551. /**
  46552. * Implementation specific of rendering the generating effect on the main canvas.
  46553. * @param effect The effect used to render through
  46554. */
  46555. protected _internalRender(effect: Effect): void;
  46556. /**
  46557. * Sets the required values for both the emissive texture and and the main color.
  46558. */
  46559. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46560. /**
  46561. * Returns true if the mesh should render, otherwise false.
  46562. * @param mesh The mesh to render
  46563. * @returns true if it should render otherwise false
  46564. */
  46565. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46566. /**
  46567. * Adds specific effects defines.
  46568. * @param defines The defines to add specifics to.
  46569. */
  46570. protected _addCustomEffectDefines(defines: string[]): void;
  46571. /**
  46572. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46573. * @param mesh The mesh to exclude from the glow layer
  46574. */
  46575. addExcludedMesh(mesh: Mesh): void;
  46576. /**
  46577. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46578. * @param mesh The mesh to remove
  46579. */
  46580. removeExcludedMesh(mesh: Mesh): void;
  46581. /**
  46582. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46583. * @param mesh The mesh to include in the glow layer
  46584. */
  46585. addIncludedOnlyMesh(mesh: Mesh): void;
  46586. /**
  46587. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46588. * @param mesh The mesh to remove
  46589. */
  46590. removeIncludedOnlyMesh(mesh: Mesh): void;
  46591. /**
  46592. * Determine if a given mesh will be used in the glow layer
  46593. * @param mesh The mesh to test
  46594. * @returns true if the mesh will be highlighted by the current glow layer
  46595. */
  46596. hasMesh(mesh: AbstractMesh): boolean;
  46597. /**
  46598. * Free any resources and references associated to a mesh.
  46599. * Internal use
  46600. * @param mesh The mesh to free.
  46601. * @hidden
  46602. */ disposeMesh(mesh: Mesh): void;
  46603. /**
  46604. * Gets the class name of the effect layer
  46605. * @returns the string with the class name of the effect layer
  46606. */
  46607. getClassName(): string;
  46608. /**
  46609. * Serializes this glow layer
  46610. * @returns a serialized glow layer object
  46611. */
  46612. serialize(): any;
  46613. /**
  46614. * Creates a Glow Layer from parsed glow layer data
  46615. * @param parsedGlowLayer defines glow layer data
  46616. * @param scene defines the current scene
  46617. * @param rootUrl defines the root URL containing the glow layer information
  46618. * @returns a parsed Glow Layer
  46619. */
  46620. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46621. }
  46622. }
  46623. declare module BABYLON {
  46624. /** @hidden */
  46625. export var glowBlurPostProcessPixelShader: {
  46626. name: string;
  46627. shader: string;
  46628. };
  46629. }
  46630. declare module BABYLON {
  46631. interface AbstractScene {
  46632. /**
  46633. * Return a the first highlight layer of the scene with a given name.
  46634. * @param name The name of the highlight layer to look for.
  46635. * @return The highlight layer if found otherwise null.
  46636. */
  46637. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46638. }
  46639. /**
  46640. * Highlight layer options. This helps customizing the behaviour
  46641. * of the highlight layer.
  46642. */
  46643. export interface IHighlightLayerOptions {
  46644. /**
  46645. * Multiplication factor apply to the canvas size to compute the render target size
  46646. * used to generated the glowing objects (the smaller the faster).
  46647. */
  46648. mainTextureRatio: number;
  46649. /**
  46650. * Enforces a fixed size texture to ensure resize independant blur.
  46651. */
  46652. mainTextureFixedSize?: number;
  46653. /**
  46654. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46655. * of the picture to blur (the smaller the faster).
  46656. */
  46657. blurTextureSizeRatio: number;
  46658. /**
  46659. * How big in texel of the blur texture is the vertical blur.
  46660. */
  46661. blurVerticalSize: number;
  46662. /**
  46663. * How big in texel of the blur texture is the horizontal blur.
  46664. */
  46665. blurHorizontalSize: number;
  46666. /**
  46667. * Alpha blending mode used to apply the blur. Default is combine.
  46668. */
  46669. alphaBlendingMode: number;
  46670. /**
  46671. * The camera attached to the layer.
  46672. */
  46673. camera: Nullable<Camera>;
  46674. /**
  46675. * Should we display highlight as a solid stroke?
  46676. */
  46677. isStroke?: boolean;
  46678. /**
  46679. * The rendering group to draw the layer in.
  46680. */
  46681. renderingGroupId: number;
  46682. }
  46683. /**
  46684. * The highlight layer Helps adding a glow effect around a mesh.
  46685. *
  46686. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46687. * glowy meshes to your scene.
  46688. *
  46689. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46690. */
  46691. export class HighlightLayer extends EffectLayer {
  46692. name: string;
  46693. /**
  46694. * Effect Name of the highlight layer.
  46695. */
  46696. static readonly EffectName: string;
  46697. /**
  46698. * The neutral color used during the preparation of the glow effect.
  46699. * This is black by default as the blend operation is a blend operation.
  46700. */
  46701. static NeutralColor: Color4;
  46702. /**
  46703. * Stencil value used for glowing meshes.
  46704. */
  46705. static GlowingMeshStencilReference: number;
  46706. /**
  46707. * Stencil value used for the other meshes in the scene.
  46708. */
  46709. static NormalMeshStencilReference: number;
  46710. /**
  46711. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46712. */
  46713. innerGlow: boolean;
  46714. /**
  46715. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46716. */
  46717. outerGlow: boolean;
  46718. /**
  46719. * Specifies the horizontal size of the blur.
  46720. */
  46721. /**
  46722. * Gets the horizontal size of the blur.
  46723. */
  46724. blurHorizontalSize: number;
  46725. /**
  46726. * Specifies the vertical size of the blur.
  46727. */
  46728. /**
  46729. * Gets the vertical size of the blur.
  46730. */
  46731. blurVerticalSize: number;
  46732. /**
  46733. * An event triggered when the highlight layer is being blurred.
  46734. */
  46735. onBeforeBlurObservable: Observable<HighlightLayer>;
  46736. /**
  46737. * An event triggered when the highlight layer has been blurred.
  46738. */
  46739. onAfterBlurObservable: Observable<HighlightLayer>;
  46740. private _instanceGlowingMeshStencilReference;
  46741. private _options;
  46742. private _downSamplePostprocess;
  46743. private _horizontalBlurPostprocess;
  46744. private _verticalBlurPostprocess;
  46745. private _blurTexture;
  46746. private _meshes;
  46747. private _excludedMeshes;
  46748. /**
  46749. * Instantiates a new highlight Layer and references it to the scene..
  46750. * @param name The name of the layer
  46751. * @param scene The scene to use the layer in
  46752. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46753. */
  46754. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46755. /**
  46756. * Get the effect name of the layer.
  46757. * @return The effect name
  46758. */
  46759. getEffectName(): string;
  46760. /**
  46761. * Create the merge effect. This is the shader use to blit the information back
  46762. * to the main canvas at the end of the scene rendering.
  46763. */
  46764. protected _createMergeEffect(): Effect;
  46765. /**
  46766. * Creates the render target textures and post processes used in the highlight layer.
  46767. */
  46768. protected _createTextureAndPostProcesses(): void;
  46769. /**
  46770. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46771. */
  46772. needStencil(): boolean;
  46773. /**
  46774. * Checks for the readiness of the element composing the layer.
  46775. * @param subMesh the mesh to check for
  46776. * @param useInstances specify wether or not to use instances to render the mesh
  46777. * @param emissiveTexture the associated emissive texture used to generate the glow
  46778. * @return true if ready otherwise, false
  46779. */
  46780. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46781. /**
  46782. * Implementation specific of rendering the generating effect on the main canvas.
  46783. * @param effect The effect used to render through
  46784. */
  46785. protected _internalRender(effect: Effect): void;
  46786. /**
  46787. * Returns true if the layer contains information to display, otherwise false.
  46788. */
  46789. shouldRender(): boolean;
  46790. /**
  46791. * Returns true if the mesh should render, otherwise false.
  46792. * @param mesh The mesh to render
  46793. * @returns true if it should render otherwise false
  46794. */
  46795. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46796. /**
  46797. * Sets the required values for both the emissive texture and and the main color.
  46798. */
  46799. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46800. /**
  46801. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46802. * @param mesh The mesh to exclude from the highlight layer
  46803. */
  46804. addExcludedMesh(mesh: Mesh): void;
  46805. /**
  46806. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46807. * @param mesh The mesh to highlight
  46808. */
  46809. removeExcludedMesh(mesh: Mesh): void;
  46810. /**
  46811. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46812. * @param mesh mesh to test
  46813. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46814. */
  46815. hasMesh(mesh: AbstractMesh): boolean;
  46816. /**
  46817. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46818. * @param mesh The mesh to highlight
  46819. * @param color The color of the highlight
  46820. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46821. */
  46822. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46823. /**
  46824. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46825. * @param mesh The mesh to highlight
  46826. */
  46827. removeMesh(mesh: Mesh): void;
  46828. /**
  46829. * Force the stencil to the normal expected value for none glowing parts
  46830. */
  46831. private _defaultStencilReference;
  46832. /**
  46833. * Free any resources and references associated to a mesh.
  46834. * Internal use
  46835. * @param mesh The mesh to free.
  46836. * @hidden
  46837. */ disposeMesh(mesh: Mesh): void;
  46838. /**
  46839. * Dispose the highlight layer and free resources.
  46840. */
  46841. dispose(): void;
  46842. /**
  46843. * Gets the class name of the effect layer
  46844. * @returns the string with the class name of the effect layer
  46845. */
  46846. getClassName(): string;
  46847. /**
  46848. * Serializes this Highlight layer
  46849. * @returns a serialized Highlight layer object
  46850. */
  46851. serialize(): any;
  46852. /**
  46853. * Creates a Highlight layer from parsed Highlight layer data
  46854. * @param parsedHightlightLayer defines the Highlight layer data
  46855. * @param scene defines the current scene
  46856. * @param rootUrl defines the root URL containing the Highlight layer information
  46857. * @returns a parsed Highlight layer
  46858. */
  46859. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46860. }
  46861. }
  46862. declare module BABYLON {
  46863. /** @hidden */
  46864. export var lensFlarePixelShader: {
  46865. name: string;
  46866. shader: string;
  46867. };
  46868. }
  46869. declare module BABYLON {
  46870. /** @hidden */
  46871. export var lensFlareVertexShader: {
  46872. name: string;
  46873. shader: string;
  46874. };
  46875. }
  46876. declare module BABYLON {
  46877. /**
  46878. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46879. * It is usually composed of several `lensFlare`.
  46880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46881. */
  46882. export class LensFlareSystem {
  46883. /**
  46884. * Define the name of the lens flare system
  46885. */
  46886. name: string;
  46887. /**
  46888. * List of lens flares used in this system.
  46889. */
  46890. lensFlares: LensFlare[];
  46891. /**
  46892. * Define a limit from the border the lens flare can be visible.
  46893. */
  46894. borderLimit: number;
  46895. /**
  46896. * Define a viewport border we do not want to see the lens flare in.
  46897. */
  46898. viewportBorder: number;
  46899. /**
  46900. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46901. */
  46902. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46903. /**
  46904. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46905. */
  46906. layerMask: number;
  46907. /**
  46908. * Define the id of the lens flare system in the scene.
  46909. * (equal to name by default)
  46910. */
  46911. id: string;
  46912. private _scene;
  46913. private _emitter;
  46914. private _vertexBuffers;
  46915. private _indexBuffer;
  46916. private _effect;
  46917. private _positionX;
  46918. private _positionY;
  46919. private _isEnabled;
  46920. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46921. /**
  46922. * Instantiates a lens flare system.
  46923. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46924. * It is usually composed of several `lensFlare`.
  46925. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46926. * @param name Define the name of the lens flare system in the scene
  46927. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46928. * @param scene Define the scene the lens flare system belongs to
  46929. */
  46930. constructor(
  46931. /**
  46932. * Define the name of the lens flare system
  46933. */
  46934. name: string, emitter: any, scene: Scene);
  46935. /**
  46936. * Define if the lens flare system is enabled.
  46937. */
  46938. isEnabled: boolean;
  46939. /**
  46940. * Get the scene the effects belongs to.
  46941. * @returns the scene holding the lens flare system
  46942. */
  46943. getScene(): Scene;
  46944. /**
  46945. * Get the emitter of the lens flare system.
  46946. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46947. * @returns the emitter of the lens flare system
  46948. */
  46949. getEmitter(): any;
  46950. /**
  46951. * Set the emitter of the lens flare system.
  46952. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46953. * @param newEmitter Define the new emitter of the system
  46954. */
  46955. setEmitter(newEmitter: any): void;
  46956. /**
  46957. * Get the lens flare system emitter position.
  46958. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46959. * @returns the position
  46960. */
  46961. getEmitterPosition(): Vector3;
  46962. /**
  46963. * @hidden
  46964. */
  46965. computeEffectivePosition(globalViewport: Viewport): boolean;
  46966. /** @hidden */ isVisible(): boolean;
  46967. /**
  46968. * @hidden
  46969. */
  46970. render(): boolean;
  46971. /**
  46972. * Dispose and release the lens flare with its associated resources.
  46973. */
  46974. dispose(): void;
  46975. /**
  46976. * Parse a lens flare system from a JSON repressentation
  46977. * @param parsedLensFlareSystem Define the JSON to parse
  46978. * @param scene Define the scene the parsed system should be instantiated in
  46979. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46980. * @returns the parsed system
  46981. */
  46982. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46983. /**
  46984. * Serialize the current Lens Flare System into a JSON representation.
  46985. * @returns the serialized JSON
  46986. */
  46987. serialize(): any;
  46988. }
  46989. }
  46990. declare module BABYLON {
  46991. /**
  46992. * This represents one of the lens effect in a `lensFlareSystem`.
  46993. * It controls one of the indiviual texture used in the effect.
  46994. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46995. */
  46996. export class LensFlare {
  46997. /**
  46998. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46999. */
  47000. size: number;
  47001. /**
  47002. * 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.
  47003. */
  47004. position: number;
  47005. /**
  47006. * Define the lens color.
  47007. */
  47008. color: Color3;
  47009. /**
  47010. * Define the lens texture.
  47011. */
  47012. texture: Nullable<Texture>;
  47013. /**
  47014. * Define the alpha mode to render this particular lens.
  47015. */
  47016. alphaMode: number;
  47017. private _system;
  47018. /**
  47019. * Creates a new Lens Flare.
  47020. * This represents one of the lens effect in a `lensFlareSystem`.
  47021. * It controls one of the indiviual texture used in the effect.
  47022. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47023. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47024. * @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.
  47025. * @param color Define the lens color
  47026. * @param imgUrl Define the lens texture url
  47027. * @param system Define the `lensFlareSystem` this flare is part of
  47028. * @returns The newly created Lens Flare
  47029. */
  47030. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47031. /**
  47032. * Instantiates a new Lens Flare.
  47033. * This represents one of the lens effect in a `lensFlareSystem`.
  47034. * It controls one of the indiviual texture used in the effect.
  47035. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47036. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47037. * @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.
  47038. * @param color Define the lens color
  47039. * @param imgUrl Define the lens texture url
  47040. * @param system Define the `lensFlareSystem` this flare is part of
  47041. */
  47042. constructor(
  47043. /**
  47044. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47045. */
  47046. size: number,
  47047. /**
  47048. * 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.
  47049. */
  47050. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47051. /**
  47052. * Dispose and release the lens flare with its associated resources.
  47053. */
  47054. dispose(): void;
  47055. }
  47056. }
  47057. declare module BABYLON {
  47058. interface AbstractScene {
  47059. /**
  47060. * The list of lens flare system added to the scene
  47061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47062. */
  47063. lensFlareSystems: Array<LensFlareSystem>;
  47064. /**
  47065. * Removes the given lens flare system from this scene.
  47066. * @param toRemove The lens flare system to remove
  47067. * @returns The index of the removed lens flare system
  47068. */
  47069. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47070. /**
  47071. * Adds the given lens flare system to this scene
  47072. * @param newLensFlareSystem The lens flare system to add
  47073. */
  47074. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47075. /**
  47076. * Gets a lens flare system using its name
  47077. * @param name defines the name to look for
  47078. * @returns the lens flare system or null if not found
  47079. */
  47080. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47081. /**
  47082. * Gets a lens flare system using its id
  47083. * @param id defines the id to look for
  47084. * @returns the lens flare system or null if not found
  47085. */
  47086. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47087. }
  47088. /**
  47089. * Defines the lens flare scene component responsible to manage any lens flares
  47090. * in a given scene.
  47091. */
  47092. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47093. /**
  47094. * The component name helpfull to identify the component in the list of scene components.
  47095. */
  47096. readonly name: string;
  47097. /**
  47098. * The scene the component belongs to.
  47099. */
  47100. scene: Scene;
  47101. /**
  47102. * Creates a new instance of the component for the given scene
  47103. * @param scene Defines the scene to register the component in
  47104. */
  47105. constructor(scene: Scene);
  47106. /**
  47107. * Registers the component in a given scene
  47108. */
  47109. register(): void;
  47110. /**
  47111. * Rebuilds the elements related to this component in case of
  47112. * context lost for instance.
  47113. */
  47114. rebuild(): void;
  47115. /**
  47116. * Adds all the element from the container to the scene
  47117. * @param container the container holding the elements
  47118. */
  47119. addFromContainer(container: AbstractScene): void;
  47120. /**
  47121. * Removes all the elements in the container from the scene
  47122. * @param container contains the elements to remove
  47123. * @param dispose if the removed element should be disposed (default: false)
  47124. */
  47125. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47126. /**
  47127. * Serializes the component data to the specified json object
  47128. * @param serializationObject The object to serialize to
  47129. */
  47130. serialize(serializationObject: any): void;
  47131. /**
  47132. * Disposes the component and the associated ressources.
  47133. */
  47134. dispose(): void;
  47135. private _draw;
  47136. }
  47137. }
  47138. declare module BABYLON {
  47139. /**
  47140. * Defines the shadow generator component responsible to manage any shadow generators
  47141. * in a given scene.
  47142. */
  47143. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47144. /**
  47145. * The component name helpfull to identify the component in the list of scene components.
  47146. */
  47147. readonly name: string;
  47148. /**
  47149. * The scene the component belongs to.
  47150. */
  47151. scene: Scene;
  47152. /**
  47153. * Creates a new instance of the component for the given scene
  47154. * @param scene Defines the scene to register the component in
  47155. */
  47156. constructor(scene: Scene);
  47157. /**
  47158. * Registers the component in a given scene
  47159. */
  47160. register(): void;
  47161. /**
  47162. * Rebuilds the elements related to this component in case of
  47163. * context lost for instance.
  47164. */
  47165. rebuild(): void;
  47166. /**
  47167. * Serializes the component data to the specified json object
  47168. * @param serializationObject The object to serialize to
  47169. */
  47170. serialize(serializationObject: any): void;
  47171. /**
  47172. * Adds all the element from the container to the scene
  47173. * @param container the container holding the elements
  47174. */
  47175. addFromContainer(container: AbstractScene): void;
  47176. /**
  47177. * Removes all the elements in the container from the scene
  47178. * @param container contains the elements to remove
  47179. * @param dispose if the removed element should be disposed (default: false)
  47180. */
  47181. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47182. /**
  47183. * Rebuilds the elements related to this component in case of
  47184. * context lost for instance.
  47185. */
  47186. dispose(): void;
  47187. private _gatherRenderTargets;
  47188. }
  47189. }
  47190. declare module BABYLON {
  47191. /**
  47192. * A point light is a light defined by an unique point in world space.
  47193. * The light is emitted in every direction from this point.
  47194. * A good example of a point light is a standard light bulb.
  47195. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47196. */
  47197. export class PointLight extends ShadowLight {
  47198. private _shadowAngle;
  47199. /**
  47200. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47201. * This specifies what angle the shadow will use to be created.
  47202. *
  47203. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47204. */
  47205. /**
  47206. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47207. * This specifies what angle the shadow will use to be created.
  47208. *
  47209. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47210. */
  47211. shadowAngle: number;
  47212. /**
  47213. * Gets the direction if it has been set.
  47214. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47215. */
  47216. /**
  47217. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47218. */
  47219. direction: Vector3;
  47220. /**
  47221. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47222. * A PointLight emits the light in every direction.
  47223. * It can cast shadows.
  47224. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47225. * ```javascript
  47226. * var pointLight = new PointLight("pl", camera.position, scene);
  47227. * ```
  47228. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47229. * @param name The light friendly name
  47230. * @param position The position of the point light in the scene
  47231. * @param scene The scene the lights belongs to
  47232. */
  47233. constructor(name: string, position: Vector3, scene: Scene);
  47234. /**
  47235. * Returns the string "PointLight"
  47236. * @returns the class name
  47237. */
  47238. getClassName(): string;
  47239. /**
  47240. * Returns the integer 0.
  47241. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47242. */
  47243. getTypeID(): number;
  47244. /**
  47245. * Specifies wether or not the shadowmap should be a cube texture.
  47246. * @returns true if the shadowmap needs to be a cube texture.
  47247. */
  47248. needCube(): boolean;
  47249. /**
  47250. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47251. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47252. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47253. */
  47254. getShadowDirection(faceIndex?: number): Vector3;
  47255. /**
  47256. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47257. * - fov = PI / 2
  47258. * - aspect ratio : 1.0
  47259. * - z-near and far equal to the active camera minZ and maxZ.
  47260. * Returns the PointLight.
  47261. */
  47262. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47263. protected _buildUniformLayout(): void;
  47264. /**
  47265. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47266. * @param effect The effect to update
  47267. * @param lightIndex The index of the light in the effect to update
  47268. * @returns The point light
  47269. */
  47270. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47271. /**
  47272. * Prepares the list of defines specific to the light type.
  47273. * @param defines the list of defines
  47274. * @param lightIndex defines the index of the light for the effect
  47275. */
  47276. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47277. }
  47278. }
  47279. declare module BABYLON {
  47280. /**
  47281. * Header information of HDR texture files.
  47282. */
  47283. export interface HDRInfo {
  47284. /**
  47285. * The height of the texture in pixels.
  47286. */
  47287. height: number;
  47288. /**
  47289. * The width of the texture in pixels.
  47290. */
  47291. width: number;
  47292. /**
  47293. * The index of the beginning of the data in the binary file.
  47294. */
  47295. dataPosition: number;
  47296. }
  47297. /**
  47298. * This groups tools to convert HDR texture to native colors array.
  47299. */
  47300. export class HDRTools {
  47301. private static Ldexp;
  47302. private static Rgbe2float;
  47303. private static readStringLine;
  47304. /**
  47305. * Reads header information from an RGBE texture stored in a native array.
  47306. * More information on this format are available here:
  47307. * https://en.wikipedia.org/wiki/RGBE_image_format
  47308. *
  47309. * @param uint8array The binary file stored in native array.
  47310. * @return The header information.
  47311. */
  47312. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47313. /**
  47314. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47315. * This RGBE texture needs to store the information as a panorama.
  47316. *
  47317. * More information on this format are available here:
  47318. * https://en.wikipedia.org/wiki/RGBE_image_format
  47319. *
  47320. * @param buffer The binary file stored in an array buffer.
  47321. * @param size The expected size of the extracted cubemap.
  47322. * @return The Cube Map information.
  47323. */
  47324. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47325. /**
  47326. * Returns the pixels data extracted from an RGBE texture.
  47327. * This pixels will be stored left to right up to down in the R G B order in one array.
  47328. *
  47329. * More information on this format are available here:
  47330. * https://en.wikipedia.org/wiki/RGBE_image_format
  47331. *
  47332. * @param uint8array The binary file stored in an array buffer.
  47333. * @param hdrInfo The header information of the file.
  47334. * @return The pixels data in RGB right to left up to down order.
  47335. */
  47336. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47337. private static RGBE_ReadPixels_RLE;
  47338. }
  47339. }
  47340. declare module BABYLON {
  47341. /**
  47342. * This represents a texture coming from an HDR input.
  47343. *
  47344. * The only supported format is currently panorama picture stored in RGBE format.
  47345. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47346. */
  47347. export class HDRCubeTexture extends BaseTexture {
  47348. private static _facesMapping;
  47349. private _generateHarmonics;
  47350. private _noMipmap;
  47351. private _textureMatrix;
  47352. private _size;
  47353. private _onLoad;
  47354. private _onError;
  47355. /**
  47356. * The texture URL.
  47357. */
  47358. url: string;
  47359. /**
  47360. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47361. */
  47362. coordinatesMode: number;
  47363. protected _isBlocking: boolean;
  47364. /**
  47365. * Sets wether or not the texture is blocking during loading.
  47366. */
  47367. /**
  47368. * Gets wether or not the texture is blocking during loading.
  47369. */
  47370. isBlocking: boolean;
  47371. protected _rotationY: number;
  47372. /**
  47373. * Sets texture matrix rotation angle around Y axis in radians.
  47374. */
  47375. /**
  47376. * Gets texture matrix rotation angle around Y axis radians.
  47377. */
  47378. rotationY: number;
  47379. /**
  47380. * Gets or sets the center of the bounding box associated with the cube texture
  47381. * It must define where the camera used to render the texture was set
  47382. */
  47383. boundingBoxPosition: Vector3;
  47384. private _boundingBoxSize;
  47385. /**
  47386. * Gets or sets the size of the bounding box associated with the cube texture
  47387. * When defined, the cubemap will switch to local mode
  47388. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47389. * @example https://www.babylonjs-playground.com/#RNASML
  47390. */
  47391. boundingBoxSize: Vector3;
  47392. /**
  47393. * Instantiates an HDRTexture from the following parameters.
  47394. *
  47395. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47396. * @param scene The scene the texture will be used in
  47397. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47398. * @param noMipmap Forces to not generate the mipmap if true
  47399. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47400. * @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)
  47401. * @param reserved Reserved flag for internal use.
  47402. */
  47403. 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>);
  47404. /**
  47405. * Get the current class name of the texture useful for serialization or dynamic coding.
  47406. * @returns "HDRCubeTexture"
  47407. */
  47408. getClassName(): string;
  47409. /**
  47410. * Occurs when the file is raw .hdr file.
  47411. */
  47412. private loadTexture;
  47413. clone(): HDRCubeTexture;
  47414. delayLoad(): void;
  47415. /**
  47416. * Get the texture reflection matrix used to rotate/transform the reflection.
  47417. * @returns the reflection matrix
  47418. */
  47419. getReflectionTextureMatrix(): Matrix;
  47420. /**
  47421. * Set the texture reflection matrix used to rotate/transform the reflection.
  47422. * @param value Define the reflection matrix to set
  47423. */
  47424. setReflectionTextureMatrix(value: Matrix): void;
  47425. /**
  47426. * Parses a JSON representation of an HDR Texture in order to create the texture
  47427. * @param parsedTexture Define the JSON representation
  47428. * @param scene Define the scene the texture should be created in
  47429. * @param rootUrl Define the root url in case we need to load relative dependencies
  47430. * @returns the newly created texture after parsing
  47431. */
  47432. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47433. serialize(): any;
  47434. }
  47435. }
  47436. declare module BABYLON {
  47437. /**
  47438. * Class used to control physics engine
  47439. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47440. */
  47441. export class PhysicsEngine implements IPhysicsEngine {
  47442. private _physicsPlugin;
  47443. /**
  47444. * Global value used to control the smallest number supported by the simulation
  47445. */
  47446. static Epsilon: number;
  47447. private _impostors;
  47448. private _joints;
  47449. /**
  47450. * Gets the gravity vector used by the simulation
  47451. */
  47452. gravity: Vector3;
  47453. /**
  47454. * Factory used to create the default physics plugin.
  47455. * @returns The default physics plugin
  47456. */
  47457. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47458. /**
  47459. * Creates a new Physics Engine
  47460. * @param gravity defines the gravity vector used by the simulation
  47461. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47462. */
  47463. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47464. /**
  47465. * Sets the gravity vector used by the simulation
  47466. * @param gravity defines the gravity vector to use
  47467. */
  47468. setGravity(gravity: Vector3): void;
  47469. /**
  47470. * Set the time step of the physics engine.
  47471. * Default is 1/60.
  47472. * To slow it down, enter 1/600 for example.
  47473. * To speed it up, 1/30
  47474. * @param newTimeStep defines the new timestep to apply to this world.
  47475. */
  47476. setTimeStep(newTimeStep?: number): void;
  47477. /**
  47478. * Get the time step of the physics engine.
  47479. * @returns the current time step
  47480. */
  47481. getTimeStep(): number;
  47482. /**
  47483. * Release all resources
  47484. */
  47485. dispose(): void;
  47486. /**
  47487. * Gets the name of the current physics plugin
  47488. * @returns the name of the plugin
  47489. */
  47490. getPhysicsPluginName(): string;
  47491. /**
  47492. * Adding a new impostor for the impostor tracking.
  47493. * This will be done by the impostor itself.
  47494. * @param impostor the impostor to add
  47495. */
  47496. addImpostor(impostor: PhysicsImpostor): void;
  47497. /**
  47498. * Remove an impostor from the engine.
  47499. * This impostor and its mesh will not longer be updated by the physics engine.
  47500. * @param impostor the impostor to remove
  47501. */
  47502. removeImpostor(impostor: PhysicsImpostor): void;
  47503. /**
  47504. * Add a joint to the physics engine
  47505. * @param mainImpostor defines the main impostor to which the joint is added.
  47506. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47507. * @param joint defines the joint that will connect both impostors.
  47508. */
  47509. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47510. /**
  47511. * Removes a joint from the simulation
  47512. * @param mainImpostor defines the impostor used with the joint
  47513. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47514. * @param joint defines the joint to remove
  47515. */
  47516. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47517. /**
  47518. * Called by the scene. No need to call it.
  47519. * @param delta defines the timespam between frames
  47520. */ step(delta: number): void;
  47521. /**
  47522. * Gets the current plugin used to run the simulation
  47523. * @returns current plugin
  47524. */
  47525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47526. /**
  47527. * Gets the list of physic impostors
  47528. * @returns an array of PhysicsImpostor
  47529. */
  47530. getImpostors(): Array<PhysicsImpostor>;
  47531. /**
  47532. * Gets the impostor for a physics enabled object
  47533. * @param object defines the object impersonated by the impostor
  47534. * @returns the PhysicsImpostor or null if not found
  47535. */
  47536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47537. /**
  47538. * Gets the impostor for a physics body object
  47539. * @param body defines physics body used by the impostor
  47540. * @returns the PhysicsImpostor or null if not found
  47541. */
  47542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47543. /**
  47544. * Does a raycast in the physics world
  47545. * @param from when should the ray start?
  47546. * @param to when should the ray end?
  47547. * @returns PhysicsRaycastResult
  47548. */
  47549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47550. }
  47551. }
  47552. declare module BABYLON {
  47553. /** @hidden */
  47554. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47555. private _useDeltaForWorldStep;
  47556. world: any;
  47557. name: string;
  47558. private _physicsMaterials;
  47559. private _fixedTimeStep;
  47560. private _cannonRaycastResult;
  47561. private _raycastResult;
  47562. private _removeAfterStep;
  47563. BJSCANNON: any;
  47564. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47565. setGravity(gravity: Vector3): void;
  47566. setTimeStep(timeStep: number): void;
  47567. getTimeStep(): number;
  47568. executeStep(delta: number): void;
  47569. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47570. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47571. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47572. private _processChildMeshes;
  47573. removePhysicsBody(impostor: PhysicsImpostor): void;
  47574. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47575. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47576. private _addMaterial;
  47577. private _checkWithEpsilon;
  47578. private _createShape;
  47579. private _createHeightmap;
  47580. private _minus90X;
  47581. private _plus90X;
  47582. private _tmpPosition;
  47583. private _tmpDeltaPosition;
  47584. private _tmpUnityRotation;
  47585. private _updatePhysicsBodyTransformation;
  47586. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47587. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47588. isSupported(): boolean;
  47589. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47590. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47591. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47592. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47593. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47594. getBodyMass(impostor: PhysicsImpostor): number;
  47595. getBodyFriction(impostor: PhysicsImpostor): number;
  47596. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47597. getBodyRestitution(impostor: PhysicsImpostor): number;
  47598. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47599. sleepBody(impostor: PhysicsImpostor): void;
  47600. wakeUpBody(impostor: PhysicsImpostor): void;
  47601. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47602. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47603. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47604. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47605. getRadius(impostor: PhysicsImpostor): number;
  47606. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47607. dispose(): void;
  47608. private _extendNamespace;
  47609. /**
  47610. * Does a raycast in the physics world
  47611. * @param from when should the ray start?
  47612. * @param to when should the ray end?
  47613. * @returns PhysicsRaycastResult
  47614. */
  47615. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47616. }
  47617. }
  47618. declare module BABYLON {
  47619. /** @hidden */
  47620. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47621. world: any;
  47622. name: string;
  47623. BJSOIMO: any;
  47624. private _raycastResult;
  47625. constructor(iterations?: number, oimoInjection?: any);
  47626. setGravity(gravity: Vector3): void;
  47627. setTimeStep(timeStep: number): void;
  47628. getTimeStep(): number;
  47629. private _tmpImpostorsArray;
  47630. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47631. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47632. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47633. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47634. private _tmpPositionVector;
  47635. removePhysicsBody(impostor: PhysicsImpostor): void;
  47636. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47637. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47638. isSupported(): boolean;
  47639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47643. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47644. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47645. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47646. getBodyMass(impostor: PhysicsImpostor): number;
  47647. getBodyFriction(impostor: PhysicsImpostor): number;
  47648. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47649. getBodyRestitution(impostor: PhysicsImpostor): number;
  47650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47651. sleepBody(impostor: PhysicsImpostor): void;
  47652. wakeUpBody(impostor: PhysicsImpostor): void;
  47653. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47654. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47655. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47656. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47657. getRadius(impostor: PhysicsImpostor): number;
  47658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47659. dispose(): void;
  47660. /**
  47661. * Does a raycast in the physics world
  47662. * @param from when should the ray start?
  47663. * @param to when should the ray end?
  47664. * @returns PhysicsRaycastResult
  47665. */
  47666. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47667. }
  47668. }
  47669. declare module BABYLON {
  47670. /**
  47671. * Class containing static functions to help procedurally build meshes
  47672. */
  47673. export class RibbonBuilder {
  47674. /**
  47675. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47676. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47677. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47678. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47679. * * 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
  47680. * * 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
  47681. * * 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
  47682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47684. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47685. * * 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
  47686. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47687. * * 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
  47688. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47690. * @param name defines the name of the mesh
  47691. * @param options defines the options used to create the mesh
  47692. * @param scene defines the hosting scene
  47693. * @returns the ribbon mesh
  47694. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47696. */
  47697. static CreateRibbon(name: string, options: {
  47698. pathArray: Vector3[][];
  47699. closeArray?: boolean;
  47700. closePath?: boolean;
  47701. offset?: number;
  47702. updatable?: boolean;
  47703. sideOrientation?: number;
  47704. frontUVs?: Vector4;
  47705. backUVs?: Vector4;
  47706. instance?: Mesh;
  47707. invertUV?: boolean;
  47708. uvs?: Vector2[];
  47709. colors?: Color4[];
  47710. }, scene?: Nullable<Scene>): Mesh;
  47711. }
  47712. }
  47713. declare module BABYLON {
  47714. /**
  47715. * Class containing static functions to help procedurally build meshes
  47716. */
  47717. export class ShapeBuilder {
  47718. /**
  47719. * 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.
  47720. * * 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.
  47721. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47722. * * 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.
  47723. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47724. * * 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
  47725. * * 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
  47726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47731. * @param name defines the name of the mesh
  47732. * @param options defines the options used to create the mesh
  47733. * @param scene defines the hosting scene
  47734. * @returns the extruded shape mesh
  47735. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47737. */
  47738. static ExtrudeShape(name: string, options: {
  47739. shape: Vector3[];
  47740. path: Vector3[];
  47741. scale?: number;
  47742. rotation?: number;
  47743. cap?: number;
  47744. updatable?: boolean;
  47745. sideOrientation?: number;
  47746. frontUVs?: Vector4;
  47747. backUVs?: Vector4;
  47748. instance?: Mesh;
  47749. invertUV?: boolean;
  47750. }, scene?: Nullable<Scene>): Mesh;
  47751. /**
  47752. * Creates an custom extruded shape mesh.
  47753. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47754. * * 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.
  47755. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47756. * * 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
  47757. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47758. * * 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
  47759. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47760. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47761. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47762. * * 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
  47763. * * 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
  47764. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47767. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47769. * @param name defines the name of the mesh
  47770. * @param options defines the options used to create the mesh
  47771. * @param scene defines the hosting scene
  47772. * @returns the custom extruded shape mesh
  47773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47776. */
  47777. static ExtrudeShapeCustom(name: string, options: {
  47778. shape: Vector3[];
  47779. path: Vector3[];
  47780. scaleFunction?: any;
  47781. rotationFunction?: any;
  47782. ribbonCloseArray?: boolean;
  47783. ribbonClosePath?: boolean;
  47784. cap?: number;
  47785. updatable?: boolean;
  47786. sideOrientation?: number;
  47787. frontUVs?: Vector4;
  47788. backUVs?: Vector4;
  47789. instance?: Mesh;
  47790. invertUV?: boolean;
  47791. }, scene?: Nullable<Scene>): Mesh;
  47792. private static _ExtrudeShapeGeneric;
  47793. }
  47794. }
  47795. declare module BABYLON {
  47796. /**
  47797. * AmmoJS Physics plugin
  47798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47799. * @see https://github.com/kripken/ammo.js/
  47800. */
  47801. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47802. private _useDeltaForWorldStep;
  47803. /**
  47804. * Reference to the Ammo library
  47805. */
  47806. bjsAMMO: any;
  47807. /**
  47808. * Created ammoJS world which physics bodies are added to
  47809. */
  47810. world: any;
  47811. /**
  47812. * Name of the plugin
  47813. */
  47814. name: string;
  47815. private _timeStep;
  47816. private _fixedTimeStep;
  47817. private _maxSteps;
  47818. private _tmpQuaternion;
  47819. private _tmpAmmoTransform;
  47820. private _tmpAmmoQuaternion;
  47821. private _tmpAmmoConcreteContactResultCallback;
  47822. private _collisionConfiguration;
  47823. private _dispatcher;
  47824. private _overlappingPairCache;
  47825. private _solver;
  47826. private _softBodySolver;
  47827. private _tmpAmmoVectorA;
  47828. private _tmpAmmoVectorB;
  47829. private _tmpAmmoVectorC;
  47830. private _tmpAmmoVectorD;
  47831. private _tmpContactCallbackResult;
  47832. private _tmpAmmoVectorRCA;
  47833. private _tmpAmmoVectorRCB;
  47834. private _raycastResult;
  47835. private static readonly DISABLE_COLLISION_FLAG;
  47836. private static readonly KINEMATIC_FLAG;
  47837. private static readonly DISABLE_DEACTIVATION_FLAG;
  47838. /**
  47839. * Initializes the ammoJS plugin
  47840. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47841. * @param ammoInjection can be used to inject your own ammo reference
  47842. */
  47843. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47844. /**
  47845. * Sets the gravity of the physics world (m/(s^2))
  47846. * @param gravity Gravity to set
  47847. */
  47848. setGravity(gravity: Vector3): void;
  47849. /**
  47850. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47851. * @param timeStep timestep to use in seconds
  47852. */
  47853. setTimeStep(timeStep: number): void;
  47854. /**
  47855. * 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)
  47856. * @param fixedTimeStep fixedTimeStep to use in seconds
  47857. */
  47858. setFixedTimeStep(fixedTimeStep: number): void;
  47859. /**
  47860. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47861. * @param maxSteps the maximum number of steps by the physics engine per frame
  47862. */
  47863. setMaxSteps(maxSteps: number): void;
  47864. /**
  47865. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47866. * @returns the current timestep in seconds
  47867. */
  47868. getTimeStep(): number;
  47869. private _isImpostorInContact;
  47870. private _isImpostorPairInContact;
  47871. private _stepSimulation;
  47872. /**
  47873. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47874. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47875. * After the step the babylon meshes are set to the position of the physics imposters
  47876. * @param delta amount of time to step forward
  47877. * @param impostors array of imposters to update before/after the step
  47878. */
  47879. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47880. /**
  47881. * Update babylon mesh to match physics world object
  47882. * @param impostor imposter to match
  47883. */
  47884. private _afterSoftStep;
  47885. /**
  47886. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47887. * @param impostor imposter to match
  47888. */
  47889. private _ropeStep;
  47890. /**
  47891. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47892. * @param impostor imposter to match
  47893. */
  47894. private _softbodyOrClothStep;
  47895. private _tmpVector;
  47896. private _tmpMatrix;
  47897. /**
  47898. * Applies an impulse on the imposter
  47899. * @param impostor imposter to apply impulse to
  47900. * @param force amount of force to be applied to the imposter
  47901. * @param contactPoint the location to apply the impulse on the imposter
  47902. */
  47903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47904. /**
  47905. * Applies a force on the imposter
  47906. * @param impostor imposter to apply force
  47907. * @param force amount of force to be applied to the imposter
  47908. * @param contactPoint the location to apply the force on the imposter
  47909. */
  47910. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47911. /**
  47912. * Creates a physics body using the plugin
  47913. * @param impostor the imposter to create the physics body on
  47914. */
  47915. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47916. /**
  47917. * Removes the physics body from the imposter and disposes of the body's memory
  47918. * @param impostor imposter to remove the physics body from
  47919. */
  47920. removePhysicsBody(impostor: PhysicsImpostor): void;
  47921. /**
  47922. * Generates a joint
  47923. * @param impostorJoint the imposter joint to create the joint with
  47924. */
  47925. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47926. /**
  47927. * Removes a joint
  47928. * @param impostorJoint the imposter joint to remove the joint from
  47929. */
  47930. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47931. private _addMeshVerts;
  47932. /**
  47933. * Initialise the soft body vertices to match its object's (mesh) vertices
  47934. * Softbody vertices (nodes) are in world space and to match this
  47935. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47936. * @param impostor to create the softbody for
  47937. */
  47938. private _softVertexData;
  47939. /**
  47940. * Create an impostor's soft body
  47941. * @param impostor to create the softbody for
  47942. */
  47943. private _createSoftbody;
  47944. /**
  47945. * Create cloth for an impostor
  47946. * @param impostor to create the softbody for
  47947. */
  47948. private _createCloth;
  47949. /**
  47950. * Create rope for an impostor
  47951. * @param impostor to create the softbody for
  47952. */
  47953. private _createRope;
  47954. private _addHullVerts;
  47955. private _createShape;
  47956. /**
  47957. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47958. * @param impostor imposter containing the physics body and babylon object
  47959. */
  47960. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47961. /**
  47962. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47963. * @param impostor imposter containing the physics body and babylon object
  47964. * @param newPosition new position
  47965. * @param newRotation new rotation
  47966. */
  47967. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47968. /**
  47969. * If this plugin is supported
  47970. * @returns true if its supported
  47971. */
  47972. isSupported(): boolean;
  47973. /**
  47974. * Sets the linear velocity of the physics body
  47975. * @param impostor imposter to set the velocity on
  47976. * @param velocity velocity to set
  47977. */
  47978. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47979. /**
  47980. * Sets the angular velocity of the physics body
  47981. * @param impostor imposter to set the velocity on
  47982. * @param velocity velocity to set
  47983. */
  47984. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47985. /**
  47986. * gets the linear velocity
  47987. * @param impostor imposter to get linear velocity from
  47988. * @returns linear velocity
  47989. */
  47990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47991. /**
  47992. * gets the angular velocity
  47993. * @param impostor imposter to get angular velocity from
  47994. * @returns angular velocity
  47995. */
  47996. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47997. /**
  47998. * Sets the mass of physics body
  47999. * @param impostor imposter to set the mass on
  48000. * @param mass mass to set
  48001. */
  48002. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48003. /**
  48004. * Gets the mass of the physics body
  48005. * @param impostor imposter to get the mass from
  48006. * @returns mass
  48007. */
  48008. getBodyMass(impostor: PhysicsImpostor): number;
  48009. /**
  48010. * Gets friction of the impostor
  48011. * @param impostor impostor to get friction from
  48012. * @returns friction value
  48013. */
  48014. getBodyFriction(impostor: PhysicsImpostor): number;
  48015. /**
  48016. * Sets friction of the impostor
  48017. * @param impostor impostor to set friction on
  48018. * @param friction friction value
  48019. */
  48020. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48021. /**
  48022. * Gets restitution of the impostor
  48023. * @param impostor impostor to get restitution from
  48024. * @returns restitution value
  48025. */
  48026. getBodyRestitution(impostor: PhysicsImpostor): number;
  48027. /**
  48028. * Sets resitution of the impostor
  48029. * @param impostor impostor to set resitution on
  48030. * @param restitution resitution value
  48031. */
  48032. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48033. /**
  48034. * Gets pressure inside the impostor
  48035. * @param impostor impostor to get pressure from
  48036. * @returns pressure value
  48037. */
  48038. getBodyPressure(impostor: PhysicsImpostor): number;
  48039. /**
  48040. * Sets pressure inside a soft body impostor
  48041. * Cloth and rope must remain 0 pressure
  48042. * @param impostor impostor to set pressure on
  48043. * @param pressure pressure value
  48044. */
  48045. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48046. /**
  48047. * Gets stiffness of the impostor
  48048. * @param impostor impostor to get stiffness from
  48049. * @returns pressure value
  48050. */
  48051. getBodyStiffness(impostor: PhysicsImpostor): number;
  48052. /**
  48053. * Sets stiffness of the impostor
  48054. * @param impostor impostor to set stiffness on
  48055. * @param stiffness stiffness value from 0 to 1
  48056. */
  48057. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48058. /**
  48059. * Gets velocityIterations of the impostor
  48060. * @param impostor impostor to get velocity iterations from
  48061. * @returns velocityIterations value
  48062. */
  48063. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48064. /**
  48065. * Sets velocityIterations of the impostor
  48066. * @param impostor impostor to set velocity iterations on
  48067. * @param velocityIterations velocityIterations value
  48068. */
  48069. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48070. /**
  48071. * Gets positionIterations of the impostor
  48072. * @param impostor impostor to get position iterations from
  48073. * @returns positionIterations value
  48074. */
  48075. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48076. /**
  48077. * Sets positionIterations of the impostor
  48078. * @param impostor impostor to set position on
  48079. * @param positionIterations positionIterations value
  48080. */
  48081. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48082. /**
  48083. * Append an anchor to a cloth object
  48084. * @param impostor is the cloth impostor to add anchor to
  48085. * @param otherImpostor is the rigid impostor to anchor to
  48086. * @param width ratio across width from 0 to 1
  48087. * @param height ratio up height from 0 to 1
  48088. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48089. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48090. */
  48091. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48092. /**
  48093. * Append an hook to a rope object
  48094. * @param impostor is the rope impostor to add hook to
  48095. * @param otherImpostor is the rigid impostor to hook to
  48096. * @param length ratio along the rope from 0 to 1
  48097. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48098. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48099. */
  48100. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48101. /**
  48102. * Sleeps the physics body and stops it from being active
  48103. * @param impostor impostor to sleep
  48104. */
  48105. sleepBody(impostor: PhysicsImpostor): void;
  48106. /**
  48107. * Activates the physics body
  48108. * @param impostor impostor to activate
  48109. */
  48110. wakeUpBody(impostor: PhysicsImpostor): void;
  48111. /**
  48112. * Updates the distance parameters of the joint
  48113. * @param joint joint to update
  48114. * @param maxDistance maximum distance of the joint
  48115. * @param minDistance minimum distance of the joint
  48116. */
  48117. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48118. /**
  48119. * Sets a motor on the joint
  48120. * @param joint joint to set motor on
  48121. * @param speed speed of the motor
  48122. * @param maxForce maximum force of the motor
  48123. * @param motorIndex index of the motor
  48124. */
  48125. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48126. /**
  48127. * Sets the motors limit
  48128. * @param joint joint to set limit on
  48129. * @param upperLimit upper limit
  48130. * @param lowerLimit lower limit
  48131. */
  48132. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48133. /**
  48134. * Syncs the position and rotation of a mesh with the impostor
  48135. * @param mesh mesh to sync
  48136. * @param impostor impostor to update the mesh with
  48137. */
  48138. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48139. /**
  48140. * Gets the radius of the impostor
  48141. * @param impostor impostor to get radius from
  48142. * @returns the radius
  48143. */
  48144. getRadius(impostor: PhysicsImpostor): number;
  48145. /**
  48146. * Gets the box size of the impostor
  48147. * @param impostor impostor to get box size from
  48148. * @param result the resulting box size
  48149. */
  48150. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48151. /**
  48152. * Disposes of the impostor
  48153. */
  48154. dispose(): void;
  48155. /**
  48156. * Does a raycast in the physics world
  48157. * @param from when should the ray start?
  48158. * @param to when should the ray end?
  48159. * @returns PhysicsRaycastResult
  48160. */
  48161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48162. }
  48163. }
  48164. declare module BABYLON {
  48165. interface AbstractScene {
  48166. /**
  48167. * The list of reflection probes added to the scene
  48168. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48169. */
  48170. reflectionProbes: Array<ReflectionProbe>;
  48171. /**
  48172. * Removes the given reflection probe from this scene.
  48173. * @param toRemove The reflection probe to remove
  48174. * @returns The index of the removed reflection probe
  48175. */
  48176. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48177. /**
  48178. * Adds the given reflection probe to this scene.
  48179. * @param newReflectionProbe The reflection probe to add
  48180. */
  48181. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48182. }
  48183. /**
  48184. * Class used to generate realtime reflection / refraction cube textures
  48185. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48186. */
  48187. export class ReflectionProbe {
  48188. /** defines the name of the probe */
  48189. name: string;
  48190. private _scene;
  48191. private _renderTargetTexture;
  48192. private _projectionMatrix;
  48193. private _viewMatrix;
  48194. private _target;
  48195. private _add;
  48196. private _attachedMesh;
  48197. private _invertYAxis;
  48198. /** Gets or sets probe position (center of the cube map) */
  48199. position: Vector3;
  48200. /**
  48201. * Creates a new reflection probe
  48202. * @param name defines the name of the probe
  48203. * @param size defines the texture resolution (for each face)
  48204. * @param scene defines the hosting scene
  48205. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48206. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48207. */
  48208. constructor(
  48209. /** defines the name of the probe */
  48210. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48211. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48212. samples: number;
  48213. /** Gets or sets the refresh rate to use (on every frame by default) */
  48214. refreshRate: number;
  48215. /**
  48216. * Gets the hosting scene
  48217. * @returns a Scene
  48218. */
  48219. getScene(): Scene;
  48220. /** Gets the internal CubeTexture used to render to */
  48221. readonly cubeTexture: RenderTargetTexture;
  48222. /** Gets the list of meshes to render */
  48223. readonly renderList: Nullable<AbstractMesh[]>;
  48224. /**
  48225. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48226. * @param mesh defines the mesh to attach to
  48227. */
  48228. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48229. /**
  48230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48231. * @param renderingGroupId The rendering group id corresponding to its index
  48232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48233. */
  48234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48235. /**
  48236. * Clean all associated resources
  48237. */
  48238. dispose(): void;
  48239. /**
  48240. * Converts the reflection probe information to a readable string for debug purpose.
  48241. * @param fullDetails Supports for multiple levels of logging within scene loading
  48242. * @returns the human readable reflection probe info
  48243. */
  48244. toString(fullDetails?: boolean): string;
  48245. /**
  48246. * Get the class name of the relfection probe.
  48247. * @returns "ReflectionProbe"
  48248. */
  48249. getClassName(): string;
  48250. /**
  48251. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48252. * @returns The JSON representation of the texture
  48253. */
  48254. serialize(): any;
  48255. /**
  48256. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48257. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48258. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48259. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48260. * @returns The parsed reflection probe if successful
  48261. */
  48262. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48263. }
  48264. }
  48265. declare module BABYLON {
  48266. /** @hidden */
  48267. export var _BabylonLoaderRegistered: boolean;
  48268. }
  48269. declare module BABYLON {
  48270. /**
  48271. * The Physically based simple base material of BJS.
  48272. *
  48273. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48274. * It is used as the base class for both the specGloss and metalRough conventions.
  48275. */
  48276. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48277. /**
  48278. * Number of Simultaneous lights allowed on the material.
  48279. */
  48280. maxSimultaneousLights: number;
  48281. /**
  48282. * If sets to true, disables all the lights affecting the material.
  48283. */
  48284. disableLighting: boolean;
  48285. /**
  48286. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48287. */
  48288. environmentTexture: BaseTexture;
  48289. /**
  48290. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48291. */
  48292. invertNormalMapX: boolean;
  48293. /**
  48294. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48295. */
  48296. invertNormalMapY: boolean;
  48297. /**
  48298. * Normal map used in the model.
  48299. */
  48300. normalTexture: BaseTexture;
  48301. /**
  48302. * Emissivie color used to self-illuminate the model.
  48303. */
  48304. emissiveColor: Color3;
  48305. /**
  48306. * Emissivie texture used to self-illuminate the model.
  48307. */
  48308. emissiveTexture: BaseTexture;
  48309. /**
  48310. * Occlusion Channel Strenght.
  48311. */
  48312. occlusionStrength: number;
  48313. /**
  48314. * Occlusion Texture of the material (adding extra occlusion effects).
  48315. */
  48316. occlusionTexture: BaseTexture;
  48317. /**
  48318. * Defines the alpha limits in alpha test mode.
  48319. */
  48320. alphaCutOff: number;
  48321. /**
  48322. * Gets the current double sided mode.
  48323. */
  48324. /**
  48325. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48326. */
  48327. doubleSided: boolean;
  48328. /**
  48329. * Stores the pre-calculated light information of a mesh in a texture.
  48330. */
  48331. lightmapTexture: BaseTexture;
  48332. /**
  48333. * If true, the light map contains occlusion information instead of lighting info.
  48334. */
  48335. useLightmapAsShadowmap: boolean;
  48336. /**
  48337. * Instantiates a new PBRMaterial instance.
  48338. *
  48339. * @param name The material name
  48340. * @param scene The scene the material will be use in.
  48341. */
  48342. constructor(name: string, scene: Scene);
  48343. getClassName(): string;
  48344. }
  48345. }
  48346. declare module BABYLON {
  48347. /**
  48348. * The PBR material of BJS following the metal roughness convention.
  48349. *
  48350. * This fits to the PBR convention in the GLTF definition:
  48351. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48352. */
  48353. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48354. /**
  48355. * The base color has two different interpretations depending on the value of metalness.
  48356. * When the material is a metal, the base color is the specific measured reflectance value
  48357. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48358. * of the material.
  48359. */
  48360. baseColor: Color3;
  48361. /**
  48362. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48363. * well as opacity information in the alpha channel.
  48364. */
  48365. baseTexture: BaseTexture;
  48366. /**
  48367. * Specifies the metallic scalar value of the material.
  48368. * Can also be used to scale the metalness values of the metallic texture.
  48369. */
  48370. metallic: number;
  48371. /**
  48372. * Specifies the roughness scalar value of the material.
  48373. * Can also be used to scale the roughness values of the metallic texture.
  48374. */
  48375. roughness: number;
  48376. /**
  48377. * Texture containing both the metallic value in the B channel and the
  48378. * roughness value in the G channel to keep better precision.
  48379. */
  48380. metallicRoughnessTexture: BaseTexture;
  48381. /**
  48382. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48383. *
  48384. * @param name The material name
  48385. * @param scene The scene the material will be use in.
  48386. */
  48387. constructor(name: string, scene: Scene);
  48388. /**
  48389. * Return the currrent class name of the material.
  48390. */
  48391. getClassName(): string;
  48392. /**
  48393. * Makes a duplicate of the current material.
  48394. * @param name - name to use for the new material.
  48395. */
  48396. clone(name: string): PBRMetallicRoughnessMaterial;
  48397. /**
  48398. * Serialize the material to a parsable JSON object.
  48399. */
  48400. serialize(): any;
  48401. /**
  48402. * Parses a JSON object correponding to the serialize function.
  48403. */
  48404. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48405. }
  48406. }
  48407. declare module BABYLON {
  48408. /**
  48409. * The PBR material of BJS following the specular glossiness convention.
  48410. *
  48411. * This fits to the PBR convention in the GLTF definition:
  48412. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48413. */
  48414. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48415. /**
  48416. * Specifies the diffuse color of the material.
  48417. */
  48418. diffuseColor: Color3;
  48419. /**
  48420. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48421. * channel.
  48422. */
  48423. diffuseTexture: BaseTexture;
  48424. /**
  48425. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48426. */
  48427. specularColor: Color3;
  48428. /**
  48429. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48430. */
  48431. glossiness: number;
  48432. /**
  48433. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48434. */
  48435. specularGlossinessTexture: BaseTexture;
  48436. /**
  48437. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48438. *
  48439. * @param name The material name
  48440. * @param scene The scene the material will be use in.
  48441. */
  48442. constructor(name: string, scene: Scene);
  48443. /**
  48444. * Return the currrent class name of the material.
  48445. */
  48446. getClassName(): string;
  48447. /**
  48448. * Makes a duplicate of the current material.
  48449. * @param name - name to use for the new material.
  48450. */
  48451. clone(name: string): PBRSpecularGlossinessMaterial;
  48452. /**
  48453. * Serialize the material to a parsable JSON object.
  48454. */
  48455. serialize(): any;
  48456. /**
  48457. * Parses a JSON object correponding to the serialize function.
  48458. */
  48459. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48460. }
  48461. }
  48462. declare module BABYLON {
  48463. /**
  48464. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48465. * It can help converting any input color in a desired output one. This can then be used to create effects
  48466. * from sepia, black and white to sixties or futuristic rendering...
  48467. *
  48468. * The only supported format is currently 3dl.
  48469. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48470. */
  48471. export class ColorGradingTexture extends BaseTexture {
  48472. /**
  48473. * The current texture matrix. (will always be identity in color grading texture)
  48474. */
  48475. private _textureMatrix;
  48476. /**
  48477. * The texture URL.
  48478. */
  48479. url: string;
  48480. /**
  48481. * Empty line regex stored for GC.
  48482. */
  48483. private static _noneEmptyLineRegex;
  48484. private _engine;
  48485. /**
  48486. * Instantiates a ColorGradingTexture from the following parameters.
  48487. *
  48488. * @param url The location of the color gradind data (currently only supporting 3dl)
  48489. * @param scene The scene the texture will be used in
  48490. */
  48491. constructor(url: string, scene: Scene);
  48492. /**
  48493. * Returns the texture matrix used in most of the material.
  48494. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48495. */
  48496. getTextureMatrix(): Matrix;
  48497. /**
  48498. * Occurs when the file being loaded is a .3dl LUT file.
  48499. */
  48500. private load3dlTexture;
  48501. /**
  48502. * Starts the loading process of the texture.
  48503. */
  48504. private loadTexture;
  48505. /**
  48506. * Clones the color gradind texture.
  48507. */
  48508. clone(): ColorGradingTexture;
  48509. /**
  48510. * Called during delayed load for textures.
  48511. */
  48512. delayLoad(): void;
  48513. /**
  48514. * Parses a color grading texture serialized by Babylon.
  48515. * @param parsedTexture The texture information being parsedTexture
  48516. * @param scene The scene to load the texture in
  48517. * @param rootUrl The root url of the data assets to load
  48518. * @return A color gradind texture
  48519. */
  48520. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48521. /**
  48522. * Serializes the LUT texture to json format.
  48523. */
  48524. serialize(): any;
  48525. }
  48526. }
  48527. declare module BABYLON {
  48528. /**
  48529. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48530. */
  48531. export class EquiRectangularCubeTexture extends BaseTexture {
  48532. /** The six faces of the cube. */
  48533. private static _FacesMapping;
  48534. private _noMipmap;
  48535. private _onLoad;
  48536. private _onError;
  48537. /** The size of the cubemap. */
  48538. private _size;
  48539. /** The buffer of the image. */
  48540. private _buffer;
  48541. /** The width of the input image. */
  48542. private _width;
  48543. /** The height of the input image. */
  48544. private _height;
  48545. /** The URL to the image. */
  48546. url: string;
  48547. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48548. coordinatesMode: number;
  48549. /**
  48550. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48551. * @param url The location of the image
  48552. * @param scene The scene the texture will be used in
  48553. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48554. * @param noMipmap Forces to not generate the mipmap if true
  48555. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48556. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48557. * @param onLoad — defines a callback called when texture is loaded
  48558. * @param onError — defines a callback called if there is an error
  48559. */
  48560. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48561. /**
  48562. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48563. */
  48564. private loadImage;
  48565. /**
  48566. * Convert the image buffer into a cubemap and create a CubeTexture.
  48567. */
  48568. private loadTexture;
  48569. /**
  48570. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48571. * @param buffer The ArrayBuffer that should be converted.
  48572. * @returns The buffer as Float32Array.
  48573. */
  48574. private getFloat32ArrayFromArrayBuffer;
  48575. /**
  48576. * Get the current class name of the texture useful for serialization or dynamic coding.
  48577. * @returns "EquiRectangularCubeTexture"
  48578. */
  48579. getClassName(): string;
  48580. /**
  48581. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48582. * @returns A clone of the current EquiRectangularCubeTexture.
  48583. */
  48584. clone(): EquiRectangularCubeTexture;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Based on jsTGALoader - Javascript loader for TGA file
  48590. * By Vincent Thibault
  48591. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48592. */
  48593. export class TGATools {
  48594. private static _TYPE_INDEXED;
  48595. private static _TYPE_RGB;
  48596. private static _TYPE_GREY;
  48597. private static _TYPE_RLE_INDEXED;
  48598. private static _TYPE_RLE_RGB;
  48599. private static _TYPE_RLE_GREY;
  48600. private static _ORIGIN_MASK;
  48601. private static _ORIGIN_SHIFT;
  48602. private static _ORIGIN_BL;
  48603. private static _ORIGIN_BR;
  48604. private static _ORIGIN_UL;
  48605. private static _ORIGIN_UR;
  48606. /**
  48607. * Gets the header of a TGA file
  48608. * @param data defines the TGA data
  48609. * @returns the header
  48610. */
  48611. static GetTGAHeader(data: Uint8Array): any;
  48612. /**
  48613. * Uploads TGA content to a Babylon Texture
  48614. * @hidden
  48615. */
  48616. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48617. /** @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;
  48618. /** @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;
  48619. /** @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;
  48620. /** @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;
  48621. /** @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;
  48622. /** @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;
  48623. }
  48624. }
  48625. declare module BABYLON {
  48626. /**
  48627. * Implementation of the TGA Texture Loader.
  48628. * @hidden
  48629. */
  48630. export class _TGATextureLoader implements IInternalTextureLoader {
  48631. /**
  48632. * Defines wether the loader supports cascade loading the different faces.
  48633. */
  48634. readonly supportCascades: boolean;
  48635. /**
  48636. * This returns if the loader support the current file information.
  48637. * @param extension defines the file extension of the file being loaded
  48638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48639. * @param fallback defines the fallback internal texture if any
  48640. * @param isBase64 defines whether the texture is encoded as a base64
  48641. * @param isBuffer defines whether the texture data are stored as a buffer
  48642. * @returns true if the loader can load the specified file
  48643. */
  48644. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48645. /**
  48646. * Transform the url before loading if required.
  48647. * @param rootUrl the url of the texture
  48648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48649. * @returns the transformed texture
  48650. */
  48651. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48652. /**
  48653. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48654. * @param rootUrl the url of the texture
  48655. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48656. * @returns the fallback texture
  48657. */
  48658. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48659. /**
  48660. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48661. * @param data contains the texture data
  48662. * @param texture defines the BabylonJS internal texture
  48663. * @param createPolynomials will be true if polynomials have been requested
  48664. * @param onLoad defines the callback to trigger once the texture is ready
  48665. * @param onError defines the callback to trigger in case of error
  48666. */
  48667. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48668. /**
  48669. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48670. * @param data contains the texture data
  48671. * @param texture defines the BabylonJS internal texture
  48672. * @param callback defines the method to call once ready to upload
  48673. */
  48674. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48675. }
  48676. }
  48677. declare module BABYLON {
  48678. /**
  48679. * 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.
  48680. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48681. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48682. */
  48683. export class CustomProceduralTexture extends ProceduralTexture {
  48684. private _animate;
  48685. private _time;
  48686. private _config;
  48687. private _texturePath;
  48688. /**
  48689. * Instantiates a new Custom Procedural Texture.
  48690. * 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.
  48691. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48692. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48693. * @param name Define the name of the texture
  48694. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48695. * @param size Define the size of the texture to create
  48696. * @param scene Define the scene the texture belongs to
  48697. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48698. * @param generateMipMaps Define if the texture should creates mip maps or not
  48699. */
  48700. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48701. private _loadJson;
  48702. /**
  48703. * Is the texture ready to be used ? (rendered at least once)
  48704. * @returns true if ready, otherwise, false.
  48705. */
  48706. isReady(): boolean;
  48707. /**
  48708. * Render the texture to its associated render target.
  48709. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48710. */
  48711. render(useCameraPostProcess?: boolean): void;
  48712. /**
  48713. * Update the list of dependant textures samplers in the shader.
  48714. */
  48715. updateTextures(): void;
  48716. /**
  48717. * Update the uniform values of the procedural texture in the shader.
  48718. */
  48719. updateShaderUniforms(): void;
  48720. /**
  48721. * Define if the texture animates or not.
  48722. */
  48723. animate: boolean;
  48724. }
  48725. }
  48726. declare module BABYLON {
  48727. /** @hidden */
  48728. export var noisePixelShader: {
  48729. name: string;
  48730. shader: string;
  48731. };
  48732. }
  48733. declare module BABYLON {
  48734. /**
  48735. * Class used to generate noise procedural textures
  48736. */
  48737. export class NoiseProceduralTexture extends ProceduralTexture {
  48738. private _time;
  48739. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48740. brightness: number;
  48741. /** Defines the number of octaves to process */
  48742. octaves: number;
  48743. /** Defines the level of persistence (0.8 by default) */
  48744. persistence: number;
  48745. /** Gets or sets animation speed factor (default is 1) */
  48746. animationSpeedFactor: number;
  48747. /**
  48748. * Creates a new NoiseProceduralTexture
  48749. * @param name defines the name fo the texture
  48750. * @param size defines the size of the texture (default is 256)
  48751. * @param scene defines the hosting scene
  48752. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48753. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48754. */
  48755. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48756. private _updateShaderUniforms;
  48757. protected _getDefines(): string;
  48758. /** Generate the current state of the procedural texture */
  48759. render(useCameraPostProcess?: boolean): void;
  48760. /**
  48761. * Serializes this noise procedural texture
  48762. * @returns a serialized noise procedural texture object
  48763. */
  48764. serialize(): any;
  48765. /**
  48766. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48767. * @param parsedTexture defines parsed texture data
  48768. * @param scene defines the current scene
  48769. * @param rootUrl defines the root URL containing noise procedural texture information
  48770. * @returns a parsed NoiseProceduralTexture
  48771. */
  48772. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48773. }
  48774. }
  48775. declare module BABYLON {
  48776. /**
  48777. * Raw cube texture where the raw buffers are passed in
  48778. */
  48779. export class RawCubeTexture extends CubeTexture {
  48780. /**
  48781. * Creates a cube texture where the raw buffers are passed in.
  48782. * @param scene defines the scene the texture is attached to
  48783. * @param data defines the array of data to use to create each face
  48784. * @param size defines the size of the textures
  48785. * @param format defines the format of the data
  48786. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48787. * @param generateMipMaps defines if the engine should generate the mip levels
  48788. * @param invertY defines if data must be stored with Y axis inverted
  48789. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48790. * @param compression defines the compression used (null by default)
  48791. */
  48792. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48793. /**
  48794. * Updates the raw cube texture.
  48795. * @param data defines the data to store
  48796. * @param format defines the data format
  48797. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48798. * @param invertY defines if data must be stored with Y axis inverted
  48799. * @param compression defines the compression used (null by default)
  48800. * @param level defines which level of the texture to update
  48801. */
  48802. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48803. /**
  48804. * Updates a raw cube texture with RGBD encoded data.
  48805. * @param data defines the array of data [mipmap][face] to use to create each face
  48806. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48809. * @returns a promsie that resolves when the operation is complete
  48810. */
  48811. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48812. /**
  48813. * Clones the raw cube texture.
  48814. * @return a new cube texture
  48815. */
  48816. clone(): CubeTexture;
  48817. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48818. }
  48819. }
  48820. declare module BABYLON {
  48821. /**
  48822. * Class used to store 3D textures containing user data
  48823. */
  48824. export class RawTexture3D extends Texture {
  48825. /** Gets or sets the texture format to use */
  48826. format: number;
  48827. private _engine;
  48828. /**
  48829. * Create a new RawTexture3D
  48830. * @param data defines the data of the texture
  48831. * @param width defines the width of the texture
  48832. * @param height defines the height of the texture
  48833. * @param depth defines the depth of the texture
  48834. * @param format defines the texture format to use
  48835. * @param scene defines the hosting scene
  48836. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48837. * @param invertY defines if texture must be stored with Y axis inverted
  48838. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48839. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48840. */
  48841. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48842. /** Gets or sets the texture format to use */
  48843. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48844. /**
  48845. * Update the texture with new data
  48846. * @param data defines the data to store in the texture
  48847. */
  48848. update(data: ArrayBufferView): void;
  48849. }
  48850. }
  48851. declare module BABYLON {
  48852. /**
  48853. * Creates a refraction texture used by refraction channel of the standard material.
  48854. * It is like a mirror but to see through a material.
  48855. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48856. */
  48857. export class RefractionTexture extends RenderTargetTexture {
  48858. /**
  48859. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48860. * 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.
  48861. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48862. */
  48863. refractionPlane: Plane;
  48864. /**
  48865. * Define how deep under the surface we should see.
  48866. */
  48867. depth: number;
  48868. /**
  48869. * Creates a refraction texture used by refraction channel of the standard material.
  48870. * It is like a mirror but to see through a material.
  48871. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48872. * @param name Define the texture name
  48873. * @param size Define the size of the underlying texture
  48874. * @param scene Define the scene the refraction belongs to
  48875. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48876. */
  48877. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48878. /**
  48879. * Clone the refraction texture.
  48880. * @returns the cloned texture
  48881. */
  48882. clone(): RefractionTexture;
  48883. /**
  48884. * Serialize the texture to a JSON representation you could use in Parse later on
  48885. * @returns the serialized JSON representation
  48886. */
  48887. serialize(): any;
  48888. }
  48889. }
  48890. declare module BABYLON {
  48891. /**
  48892. * Defines the options related to the creation of an HtmlElementTexture
  48893. */
  48894. export interface IHtmlElementTextureOptions {
  48895. /**
  48896. * Defines wether mip maps should be created or not.
  48897. */
  48898. generateMipMaps?: boolean;
  48899. /**
  48900. * Defines the sampling mode of the texture.
  48901. */
  48902. samplingMode?: number;
  48903. /**
  48904. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  48905. */
  48906. engine: Nullable<Engine>;
  48907. /**
  48908. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  48909. */
  48910. scene: Nullable<Scene>;
  48911. }
  48912. /**
  48913. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  48914. * To be as efficient as possible depending on your constraints nothing aside the first upload
  48915. * is automatically managed.
  48916. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  48917. * in your application.
  48918. *
  48919. * As the update is not automatic, you need to call them manually.
  48920. */
  48921. export class HtmlElementTexture extends BaseTexture {
  48922. /**
  48923. * The texture URL.
  48924. */
  48925. element: HTMLVideoElement | HTMLCanvasElement;
  48926. private static readonly DefaultOptions;
  48927. private _textureMatrix;
  48928. private _engine;
  48929. private _isVideo;
  48930. private _generateMipMaps;
  48931. private _samplingMode;
  48932. /**
  48933. * Instantiates a HtmlElementTexture from the following parameters.
  48934. *
  48935. * @param name Defines the name of the texture
  48936. * @param element Defines the video or canvas the texture is filled with
  48937. * @param options Defines the other none mandatory texture creation options
  48938. */
  48939. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  48940. private _createInternalTexture;
  48941. /**
  48942. * Returns the texture matrix used in most of the material.
  48943. */
  48944. getTextureMatrix(): Matrix;
  48945. /**
  48946. * Updates the content of the texture.
  48947. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  48948. */
  48949. update(invertY?: Nullable<boolean>): void;
  48950. }
  48951. }
  48952. declare module BABYLON {
  48953. /**
  48954. * Helper class to push actions to a pool of workers.
  48955. */
  48956. export class WorkerPool implements IDisposable {
  48957. private _workerInfos;
  48958. private _pendingActions;
  48959. /**
  48960. * Constructor
  48961. * @param workers Array of workers to use for actions
  48962. */
  48963. constructor(workers: Array<Worker>);
  48964. /**
  48965. * Terminates all workers and clears any pending actions.
  48966. */
  48967. dispose(): void;
  48968. /**
  48969. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48970. * pended until a worker has completed its action.
  48971. * @param action The action to perform. Call onComplete when the action is complete.
  48972. */
  48973. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48974. private _execute;
  48975. }
  48976. }
  48977. declare module BABYLON {
  48978. /**
  48979. * Configuration for Draco compression
  48980. */
  48981. export interface IDracoCompressionConfiguration {
  48982. /**
  48983. * Configuration for the decoder.
  48984. */
  48985. decoder: {
  48986. /**
  48987. * The url to the WebAssembly module.
  48988. */
  48989. wasmUrl?: string;
  48990. /**
  48991. * The url to the WebAssembly binary.
  48992. */
  48993. wasmBinaryUrl?: string;
  48994. /**
  48995. * The url to the fallback JavaScript module.
  48996. */
  48997. fallbackUrl?: string;
  48998. };
  48999. }
  49000. /**
  49001. * Draco compression (https://google.github.io/draco/)
  49002. *
  49003. * This class wraps the Draco module.
  49004. *
  49005. * **Encoder**
  49006. *
  49007. * The encoder is not currently implemented.
  49008. *
  49009. * **Decoder**
  49010. *
  49011. * 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.
  49012. *
  49013. * To update the configuration, use the following code:
  49014. * ```javascript
  49015. * DracoCompression.Configuration = {
  49016. * decoder: {
  49017. * wasmUrl: "<url to the WebAssembly library>",
  49018. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49019. * fallbackUrl: "<url to the fallback JavaScript library>",
  49020. * }
  49021. * };
  49022. * ```
  49023. *
  49024. * 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.
  49025. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49026. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49027. *
  49028. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49029. * ```javascript
  49030. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49031. * ```
  49032. *
  49033. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49034. */
  49035. export class DracoCompression implements IDisposable {
  49036. private _workerPoolPromise?;
  49037. private _decoderModulePromise?;
  49038. /**
  49039. * The configuration. Defaults to the following urls:
  49040. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49041. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49042. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49043. */
  49044. static Configuration: IDracoCompressionConfiguration;
  49045. /**
  49046. * Returns true if the decoder configuration is available.
  49047. */
  49048. static readonly DecoderAvailable: boolean;
  49049. /**
  49050. * Default number of workers to create when creating the draco compression object.
  49051. */
  49052. static DefaultNumWorkers: number;
  49053. private static GetDefaultNumWorkers;
  49054. private static _Default;
  49055. /**
  49056. * Default instance for the draco compression object.
  49057. */
  49058. static readonly Default: DracoCompression;
  49059. /**
  49060. * Constructor
  49061. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49062. */
  49063. constructor(numWorkers?: number);
  49064. /**
  49065. * Stop all async operations and release resources.
  49066. */
  49067. dispose(): void;
  49068. /**
  49069. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49070. * @returns a promise that resolves when ready
  49071. */
  49072. whenReadyAsync(): Promise<void>;
  49073. /**
  49074. * Decode Draco compressed mesh data to vertex data.
  49075. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49076. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49077. * @returns A promise that resolves with the decoded vertex data
  49078. */
  49079. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49080. [kind: string]: number;
  49081. }): Promise<VertexData>;
  49082. }
  49083. }
  49084. declare module BABYLON {
  49085. /**
  49086. * Class for building Constructive Solid Geometry
  49087. */
  49088. export class CSG {
  49089. private polygons;
  49090. /**
  49091. * The world matrix
  49092. */
  49093. matrix: Matrix;
  49094. /**
  49095. * Stores the position
  49096. */
  49097. position: Vector3;
  49098. /**
  49099. * Stores the rotation
  49100. */
  49101. rotation: Vector3;
  49102. /**
  49103. * Stores the rotation quaternion
  49104. */
  49105. rotationQuaternion: Nullable<Quaternion>;
  49106. /**
  49107. * Stores the scaling vector
  49108. */
  49109. scaling: Vector3;
  49110. /**
  49111. * Convert the Mesh to CSG
  49112. * @param mesh The Mesh to convert to CSG
  49113. * @returns A new CSG from the Mesh
  49114. */
  49115. static FromMesh(mesh: Mesh): CSG;
  49116. /**
  49117. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49118. * @param polygons Polygons used to construct a CSG solid
  49119. */
  49120. private static FromPolygons;
  49121. /**
  49122. * Clones, or makes a deep copy, of the CSG
  49123. * @returns A new CSG
  49124. */
  49125. clone(): CSG;
  49126. /**
  49127. * Unions this CSG with another CSG
  49128. * @param csg The CSG to union against this CSG
  49129. * @returns The unioned CSG
  49130. */
  49131. union(csg: CSG): CSG;
  49132. /**
  49133. * Unions this CSG with another CSG in place
  49134. * @param csg The CSG to union against this CSG
  49135. */
  49136. unionInPlace(csg: CSG): void;
  49137. /**
  49138. * Subtracts this CSG with another CSG
  49139. * @param csg The CSG to subtract against this CSG
  49140. * @returns A new CSG
  49141. */
  49142. subtract(csg: CSG): CSG;
  49143. /**
  49144. * Subtracts this CSG with another CSG in place
  49145. * @param csg The CSG to subtact against this CSG
  49146. */
  49147. subtractInPlace(csg: CSG): void;
  49148. /**
  49149. * Intersect this CSG with another CSG
  49150. * @param csg The CSG to intersect against this CSG
  49151. * @returns A new CSG
  49152. */
  49153. intersect(csg: CSG): CSG;
  49154. /**
  49155. * Intersects this CSG with another CSG in place
  49156. * @param csg The CSG to intersect against this CSG
  49157. */
  49158. intersectInPlace(csg: CSG): void;
  49159. /**
  49160. * Return a new CSG solid with solid and empty space switched. This solid is
  49161. * not modified.
  49162. * @returns A new CSG solid with solid and empty space switched
  49163. */
  49164. inverse(): CSG;
  49165. /**
  49166. * Inverses the CSG in place
  49167. */
  49168. inverseInPlace(): void;
  49169. /**
  49170. * This is used to keep meshes transformations so they can be restored
  49171. * when we build back a Babylon Mesh
  49172. * NB : All CSG operations are performed in world coordinates
  49173. * @param csg The CSG to copy the transform attributes from
  49174. * @returns This CSG
  49175. */
  49176. copyTransformAttributes(csg: CSG): CSG;
  49177. /**
  49178. * Build Raw mesh from CSG
  49179. * Coordinates here are in world space
  49180. * @param name The name of the mesh geometry
  49181. * @param scene The Scene
  49182. * @param keepSubMeshes Specifies if the submeshes should be kept
  49183. * @returns A new Mesh
  49184. */
  49185. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49186. /**
  49187. * Build Mesh from CSG taking material and transforms into account
  49188. * @param name The name of the Mesh
  49189. * @param material The material of the Mesh
  49190. * @param scene The Scene
  49191. * @param keepSubMeshes Specifies if submeshes should be kept
  49192. * @returns The new Mesh
  49193. */
  49194. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49195. }
  49196. }
  49197. declare module BABYLON {
  49198. /**
  49199. * Class used to create a trail following a mesh
  49200. */
  49201. export class TrailMesh extends Mesh {
  49202. private _generator;
  49203. private _autoStart;
  49204. private _running;
  49205. private _diameter;
  49206. private _length;
  49207. private _sectionPolygonPointsCount;
  49208. private _sectionVectors;
  49209. private _sectionNormalVectors;
  49210. private _beforeRenderObserver;
  49211. /**
  49212. * @constructor
  49213. * @param name The value used by scene.getMeshByName() to do a lookup.
  49214. * @param generator The mesh to generate a trail.
  49215. * @param scene The scene to add this mesh to.
  49216. * @param diameter Diameter of trailing mesh. Default is 1.
  49217. * @param length Length of trailing mesh. Default is 60.
  49218. * @param autoStart Automatically start trailing mesh. Default true.
  49219. */
  49220. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49221. /**
  49222. * "TrailMesh"
  49223. * @returns "TrailMesh"
  49224. */
  49225. getClassName(): string;
  49226. private _createMesh;
  49227. /**
  49228. * Start trailing mesh.
  49229. */
  49230. start(): void;
  49231. /**
  49232. * Stop trailing mesh.
  49233. */
  49234. stop(): void;
  49235. /**
  49236. * Update trailing mesh geometry.
  49237. */
  49238. update(): void;
  49239. /**
  49240. * Returns a new TrailMesh object.
  49241. * @param name is a string, the name given to the new mesh
  49242. * @param newGenerator use new generator object for cloned trail mesh
  49243. * @returns a new mesh
  49244. */
  49245. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49246. /**
  49247. * Serializes this trail mesh
  49248. * @param serializationObject object to write serialization to
  49249. */
  49250. serialize(serializationObject: any): void;
  49251. /**
  49252. * Parses a serialized trail mesh
  49253. * @param parsedMesh the serialized mesh
  49254. * @param scene the scene to create the trail mesh in
  49255. * @returns the created trail mesh
  49256. */
  49257. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49258. }
  49259. }
  49260. declare module BABYLON {
  49261. /**
  49262. * Class containing static functions to help procedurally build meshes
  49263. */
  49264. export class TorusKnotBuilder {
  49265. /**
  49266. * Creates a torus knot mesh
  49267. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49268. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49269. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49270. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49274. * @param name defines the name of the mesh
  49275. * @param options defines the options used to create the mesh
  49276. * @param scene defines the hosting scene
  49277. * @returns the torus knot mesh
  49278. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49279. */
  49280. static CreateTorusKnot(name: string, options: {
  49281. radius?: number;
  49282. tube?: number;
  49283. radialSegments?: number;
  49284. tubularSegments?: number;
  49285. p?: number;
  49286. q?: number;
  49287. updatable?: boolean;
  49288. sideOrientation?: number;
  49289. frontUVs?: Vector4;
  49290. backUVs?: Vector4;
  49291. }, scene: any): Mesh;
  49292. }
  49293. }
  49294. declare module BABYLON {
  49295. /**
  49296. * Polygon
  49297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49298. */
  49299. export class Polygon {
  49300. /**
  49301. * Creates a rectangle
  49302. * @param xmin bottom X coord
  49303. * @param ymin bottom Y coord
  49304. * @param xmax top X coord
  49305. * @param ymax top Y coord
  49306. * @returns points that make the resulting rectation
  49307. */
  49308. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49309. /**
  49310. * Creates a circle
  49311. * @param radius radius of circle
  49312. * @param cx scale in x
  49313. * @param cy scale in y
  49314. * @param numberOfSides number of sides that make up the circle
  49315. * @returns points that make the resulting circle
  49316. */
  49317. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49318. /**
  49319. * Creates a polygon from input string
  49320. * @param input Input polygon data
  49321. * @returns the parsed points
  49322. */
  49323. static Parse(input: string): Vector2[];
  49324. /**
  49325. * Starts building a polygon from x and y coordinates
  49326. * @param x x coordinate
  49327. * @param y y coordinate
  49328. * @returns the started path2
  49329. */
  49330. static StartingAt(x: number, y: number): Path2;
  49331. }
  49332. /**
  49333. * Builds a polygon
  49334. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49335. */
  49336. export class PolygonMeshBuilder {
  49337. private _points;
  49338. private _outlinepoints;
  49339. private _holes;
  49340. private _name;
  49341. private _scene;
  49342. private _epoints;
  49343. private _eholes;
  49344. private _addToepoint;
  49345. /**
  49346. * Babylon reference to the earcut plugin.
  49347. */
  49348. bjsEarcut: any;
  49349. /**
  49350. * Creates a PolygonMeshBuilder
  49351. * @param name name of the builder
  49352. * @param contours Path of the polygon
  49353. * @param scene scene to add to when creating the mesh
  49354. * @param earcutInjection can be used to inject your own earcut reference
  49355. */
  49356. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49357. /**
  49358. * Adds a whole within the polygon
  49359. * @param hole Array of points defining the hole
  49360. * @returns this
  49361. */
  49362. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49363. /**
  49364. * Creates the polygon
  49365. * @param updatable If the mesh should be updatable
  49366. * @param depth The depth of the mesh created
  49367. * @returns the created mesh
  49368. */
  49369. build(updatable?: boolean, depth?: number): Mesh;
  49370. /**
  49371. * Creates the polygon
  49372. * @param depth The depth of the mesh created
  49373. * @returns the created VertexData
  49374. */
  49375. buildVertexData(depth?: number): VertexData;
  49376. /**
  49377. * Adds a side to the polygon
  49378. * @param positions points that make the polygon
  49379. * @param normals normals of the polygon
  49380. * @param uvs uvs of the polygon
  49381. * @param indices indices of the polygon
  49382. * @param bounds bounds of the polygon
  49383. * @param points points of the polygon
  49384. * @param depth depth of the polygon
  49385. * @param flip flip of the polygon
  49386. */
  49387. private addSide;
  49388. }
  49389. }
  49390. declare module BABYLON {
  49391. /**
  49392. * Class containing static functions to help procedurally build meshes
  49393. */
  49394. export class PolygonBuilder {
  49395. /**
  49396. * Creates a polygon mesh
  49397. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49398. * * 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
  49399. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49402. * * Remember you can only change the shape positions, not their number when updating a polygon
  49403. * @param name defines the name of the mesh
  49404. * @param options defines the options used to create the mesh
  49405. * @param scene defines the hosting scene
  49406. * @param earcutInjection can be used to inject your own earcut reference
  49407. * @returns the polygon mesh
  49408. */
  49409. static CreatePolygon(name: string, options: {
  49410. shape: Vector3[];
  49411. holes?: Vector3[][];
  49412. depth?: number;
  49413. faceUV?: Vector4[];
  49414. faceColors?: Color4[];
  49415. updatable?: boolean;
  49416. sideOrientation?: number;
  49417. frontUVs?: Vector4;
  49418. backUVs?: Vector4;
  49419. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49420. /**
  49421. * Creates an extruded polygon mesh, with depth in the Y direction.
  49422. * * 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)
  49423. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49424. * @param name defines the name of the mesh
  49425. * @param options defines the options used to create the mesh
  49426. * @param scene defines the hosting scene
  49427. * @param earcutInjection can be used to inject your own earcut reference
  49428. * @returns the polygon mesh
  49429. */
  49430. static ExtrudePolygon(name: string, options: {
  49431. shape: Vector3[];
  49432. holes?: Vector3[][];
  49433. depth?: number;
  49434. faceUV?: Vector4[];
  49435. faceColors?: Color4[];
  49436. updatable?: boolean;
  49437. sideOrientation?: number;
  49438. frontUVs?: Vector4;
  49439. backUVs?: Vector4;
  49440. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49441. }
  49442. }
  49443. declare module BABYLON {
  49444. /**
  49445. * Class containing static functions to help procedurally build meshes
  49446. */
  49447. export class LatheBuilder {
  49448. /**
  49449. * Creates lathe mesh.
  49450. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49451. * * 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
  49452. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49453. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49454. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49455. * * 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
  49456. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49457. * * 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
  49458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49462. * @param name defines the name of the mesh
  49463. * @param options defines the options used to create the mesh
  49464. * @param scene defines the hosting scene
  49465. * @returns the lathe mesh
  49466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49467. */
  49468. static CreateLathe(name: string, options: {
  49469. shape: Vector3[];
  49470. radius?: number;
  49471. tessellation?: number;
  49472. clip?: number;
  49473. arc?: number;
  49474. closed?: boolean;
  49475. updatable?: boolean;
  49476. sideOrientation?: number;
  49477. frontUVs?: Vector4;
  49478. backUVs?: Vector4;
  49479. cap?: number;
  49480. invertUV?: boolean;
  49481. }, scene?: Nullable<Scene>): Mesh;
  49482. }
  49483. }
  49484. declare module BABYLON {
  49485. /**
  49486. * Class containing static functions to help procedurally build meshes
  49487. */
  49488. export class TubeBuilder {
  49489. /**
  49490. * Creates a tube mesh.
  49491. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49492. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49493. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49494. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49495. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49496. * * 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)
  49497. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49498. * * 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
  49499. * * 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
  49500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49504. * @param name defines the name of the mesh
  49505. * @param options defines the options used to create the mesh
  49506. * @param scene defines the hosting scene
  49507. * @returns the tube mesh
  49508. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49509. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49510. */
  49511. static CreateTube(name: string, options: {
  49512. path: Vector3[];
  49513. radius?: number;
  49514. tessellation?: number;
  49515. radiusFunction?: {
  49516. (i: number, distance: number): number;
  49517. };
  49518. cap?: number;
  49519. arc?: number;
  49520. updatable?: boolean;
  49521. sideOrientation?: number;
  49522. frontUVs?: Vector4;
  49523. backUVs?: Vector4;
  49524. instance?: Mesh;
  49525. invertUV?: boolean;
  49526. }, scene?: Nullable<Scene>): Mesh;
  49527. }
  49528. }
  49529. declare module BABYLON {
  49530. /**
  49531. * Class containing static functions to help procedurally build meshes
  49532. */
  49533. export class IcoSphereBuilder {
  49534. /**
  49535. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49536. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49537. * * 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`)
  49538. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49539. * * 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
  49540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49543. * @param name defines the name of the mesh
  49544. * @param options defines the options used to create the mesh
  49545. * @param scene defines the hosting scene
  49546. * @returns the icosahedron mesh
  49547. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49548. */
  49549. static CreateIcoSphere(name: string, options: {
  49550. radius?: number;
  49551. radiusX?: number;
  49552. radiusY?: number;
  49553. radiusZ?: number;
  49554. flat?: boolean;
  49555. subdivisions?: number;
  49556. sideOrientation?: number;
  49557. frontUVs?: Vector4;
  49558. backUVs?: Vector4;
  49559. updatable?: boolean;
  49560. }, scene?: Nullable<Scene>): Mesh;
  49561. }
  49562. }
  49563. declare module BABYLON {
  49564. /**
  49565. * Class containing static functions to help procedurally build meshes
  49566. */
  49567. export class DecalBuilder {
  49568. /**
  49569. * Creates a decal mesh.
  49570. * 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
  49571. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49572. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49573. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49574. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49575. * @param name defines the name of the mesh
  49576. * @param sourceMesh defines the mesh where the decal must be applied
  49577. * @param options defines the options used to create the mesh
  49578. * @param scene defines the hosting scene
  49579. * @returns the decal mesh
  49580. * @see https://doc.babylonjs.com/how_to/decals
  49581. */
  49582. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49583. position?: Vector3;
  49584. normal?: Vector3;
  49585. size?: Vector3;
  49586. angle?: number;
  49587. }): Mesh;
  49588. }
  49589. }
  49590. declare module BABYLON {
  49591. /**
  49592. * Class containing static functions to help procedurally build meshes
  49593. */
  49594. export class MeshBuilder {
  49595. /**
  49596. * Creates a box mesh
  49597. * * The parameter `size` sets the size (float) of each box side (default 1)
  49598. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49599. * * 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)
  49600. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49604. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49605. * @param name defines the name of the mesh
  49606. * @param options defines the options used to create the mesh
  49607. * @param scene defines the hosting scene
  49608. * @returns the box mesh
  49609. */
  49610. static CreateBox(name: string, options: {
  49611. size?: number;
  49612. width?: number;
  49613. height?: number;
  49614. depth?: number;
  49615. faceUV?: Vector4[];
  49616. faceColors?: Color4[];
  49617. sideOrientation?: number;
  49618. frontUVs?: Vector4;
  49619. backUVs?: Vector4;
  49620. updatable?: boolean;
  49621. }, scene?: Nullable<Scene>): Mesh;
  49622. /**
  49623. * Creates a sphere mesh
  49624. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49625. * * 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`)
  49626. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49627. * * 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
  49628. * * 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)
  49629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49632. * @param name defines the name of the mesh
  49633. * @param options defines the options used to create the mesh
  49634. * @param scene defines the hosting scene
  49635. * @returns the sphere mesh
  49636. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49637. */
  49638. static CreateSphere(name: string, options: {
  49639. segments?: number;
  49640. diameter?: number;
  49641. diameterX?: number;
  49642. diameterY?: number;
  49643. diameterZ?: number;
  49644. arc?: number;
  49645. slice?: number;
  49646. sideOrientation?: number;
  49647. frontUVs?: Vector4;
  49648. backUVs?: Vector4;
  49649. updatable?: boolean;
  49650. }, scene?: Nullable<Scene>): Mesh;
  49651. /**
  49652. * Creates a plane polygonal mesh. By default, this is a disc
  49653. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49654. * * 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
  49655. * * 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
  49656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49659. * @param name defines the name of the mesh
  49660. * @param options defines the options used to create the mesh
  49661. * @param scene defines the hosting scene
  49662. * @returns the plane polygonal mesh
  49663. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49664. */
  49665. static CreateDisc(name: string, options: {
  49666. radius?: number;
  49667. tessellation?: number;
  49668. arc?: number;
  49669. updatable?: boolean;
  49670. sideOrientation?: number;
  49671. frontUVs?: Vector4;
  49672. backUVs?: Vector4;
  49673. }, scene?: Nullable<Scene>): Mesh;
  49674. /**
  49675. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49676. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49677. * * 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`)
  49678. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49679. * * 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
  49680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49683. * @param name defines the name of the mesh
  49684. * @param options defines the options used to create the mesh
  49685. * @param scene defines the hosting scene
  49686. * @returns the icosahedron mesh
  49687. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49688. */
  49689. static CreateIcoSphere(name: string, options: {
  49690. radius?: number;
  49691. radiusX?: number;
  49692. radiusY?: number;
  49693. radiusZ?: number;
  49694. flat?: boolean;
  49695. subdivisions?: number;
  49696. sideOrientation?: number;
  49697. frontUVs?: Vector4;
  49698. backUVs?: Vector4;
  49699. updatable?: boolean;
  49700. }, scene?: Nullable<Scene>): Mesh;
  49701. /**
  49702. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49703. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49704. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49705. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49706. * * 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
  49707. * * 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
  49708. * * 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
  49709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49712. * * 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
  49713. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49714. * * 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
  49715. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49717. * @param name defines the name of the mesh
  49718. * @param options defines the options used to create the mesh
  49719. * @param scene defines the hosting scene
  49720. * @returns the ribbon mesh
  49721. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49723. */
  49724. static CreateRibbon(name: string, options: {
  49725. pathArray: Vector3[][];
  49726. closeArray?: boolean;
  49727. closePath?: boolean;
  49728. offset?: number;
  49729. updatable?: boolean;
  49730. sideOrientation?: number;
  49731. frontUVs?: Vector4;
  49732. backUVs?: Vector4;
  49733. instance?: Mesh;
  49734. invertUV?: boolean;
  49735. uvs?: Vector2[];
  49736. colors?: Color4[];
  49737. }, scene?: Nullable<Scene>): Mesh;
  49738. /**
  49739. * Creates a cylinder or a cone mesh
  49740. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49741. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49742. * * 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.
  49743. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49744. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49745. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49746. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49747. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49748. * * 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).
  49749. * * 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
  49750. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49751. * * 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
  49752. * * 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.
  49753. * * If `enclose` is false, a ring surface is one element.
  49754. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49755. * * 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
  49756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49759. * @param name defines the name of the mesh
  49760. * @param options defines the options used to create the mesh
  49761. * @param scene defines the hosting scene
  49762. * @returns the cylinder mesh
  49763. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49764. */
  49765. static CreateCylinder(name: string, options: {
  49766. height?: number;
  49767. diameterTop?: number;
  49768. diameterBottom?: number;
  49769. diameter?: number;
  49770. tessellation?: number;
  49771. subdivisions?: number;
  49772. arc?: number;
  49773. faceColors?: Color4[];
  49774. faceUV?: Vector4[];
  49775. updatable?: boolean;
  49776. hasRings?: boolean;
  49777. enclose?: boolean;
  49778. sideOrientation?: number;
  49779. frontUVs?: Vector4;
  49780. backUVs?: Vector4;
  49781. }, scene?: Nullable<Scene>): Mesh;
  49782. /**
  49783. * Creates a torus mesh
  49784. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49785. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49786. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49790. * @param name defines the name of the mesh
  49791. * @param options defines the options used to create the mesh
  49792. * @param scene defines the hosting scene
  49793. * @returns the torus mesh
  49794. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49795. */
  49796. static CreateTorus(name: string, options: {
  49797. diameter?: number;
  49798. thickness?: number;
  49799. tessellation?: number;
  49800. updatable?: boolean;
  49801. sideOrientation?: number;
  49802. frontUVs?: Vector4;
  49803. backUVs?: Vector4;
  49804. }, scene?: Nullable<Scene>): Mesh;
  49805. /**
  49806. * Creates a torus knot mesh
  49807. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49808. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49809. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49810. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49814. * @param name defines the name of the mesh
  49815. * @param options defines the options used to create the mesh
  49816. * @param scene defines the hosting scene
  49817. * @returns the torus knot mesh
  49818. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49819. */
  49820. static CreateTorusKnot(name: string, options: {
  49821. radius?: number;
  49822. tube?: number;
  49823. radialSegments?: number;
  49824. tubularSegments?: number;
  49825. p?: number;
  49826. q?: number;
  49827. updatable?: boolean;
  49828. sideOrientation?: number;
  49829. frontUVs?: Vector4;
  49830. backUVs?: Vector4;
  49831. }, scene?: Nullable<Scene>): Mesh;
  49832. /**
  49833. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49834. * * 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
  49835. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49836. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49837. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49838. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49839. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49840. * * 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
  49841. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49844. * @param name defines the name of the new line system
  49845. * @param options defines the options used to create the line system
  49846. * @param scene defines the hosting scene
  49847. * @returns a new line system mesh
  49848. */
  49849. static CreateLineSystem(name: string, options: {
  49850. lines: Vector3[][];
  49851. updatable?: boolean;
  49852. instance?: Nullable<LinesMesh>;
  49853. colors?: Nullable<Color4[][]>;
  49854. useVertexAlpha?: boolean;
  49855. }, scene: Nullable<Scene>): LinesMesh;
  49856. /**
  49857. * Creates a line mesh
  49858. * 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
  49859. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49860. * * The parameter `points` is an array successive Vector3
  49861. * * 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
  49862. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49863. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49864. * * When updating an instance, remember that only point positions can change, not the number of points
  49865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49867. * @param name defines the name of the new line system
  49868. * @param options defines the options used to create the line system
  49869. * @param scene defines the hosting scene
  49870. * @returns a new line mesh
  49871. */
  49872. static CreateLines(name: string, options: {
  49873. points: Vector3[];
  49874. updatable?: boolean;
  49875. instance?: Nullable<LinesMesh>;
  49876. colors?: Color4[];
  49877. useVertexAlpha?: boolean;
  49878. }, scene?: Nullable<Scene>): LinesMesh;
  49879. /**
  49880. * Creates a dashed line mesh
  49881. * * 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
  49882. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49883. * * The parameter `points` is an array successive Vector3
  49884. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49885. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49886. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49887. * * 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
  49888. * * When updating an instance, remember that only point positions can change, not the number of points
  49889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49890. * @param name defines the name of the mesh
  49891. * @param options defines the options used to create the mesh
  49892. * @param scene defines the hosting scene
  49893. * @returns the dashed line mesh
  49894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49895. */
  49896. static CreateDashedLines(name: string, options: {
  49897. points: Vector3[];
  49898. dashSize?: number;
  49899. gapSize?: number;
  49900. dashNb?: number;
  49901. updatable?: boolean;
  49902. instance?: LinesMesh;
  49903. }, scene?: Nullable<Scene>): LinesMesh;
  49904. /**
  49905. * 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.
  49906. * * 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.
  49907. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49908. * * 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.
  49909. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49910. * * 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
  49911. * * 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
  49912. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49917. * @param name defines the name of the mesh
  49918. * @param options defines the options used to create the mesh
  49919. * @param scene defines the hosting scene
  49920. * @returns the extruded shape mesh
  49921. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49922. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49923. */
  49924. static ExtrudeShape(name: string, options: {
  49925. shape: Vector3[];
  49926. path: Vector3[];
  49927. scale?: number;
  49928. rotation?: number;
  49929. cap?: number;
  49930. updatable?: boolean;
  49931. sideOrientation?: number;
  49932. frontUVs?: Vector4;
  49933. backUVs?: Vector4;
  49934. instance?: Mesh;
  49935. invertUV?: boolean;
  49936. }, scene?: Nullable<Scene>): Mesh;
  49937. /**
  49938. * Creates an custom extruded shape mesh.
  49939. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49940. * * 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.
  49941. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49942. * * 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
  49943. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49944. * * 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
  49945. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49946. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49947. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49948. * * 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
  49949. * * 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
  49950. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49953. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49955. * @param name defines the name of the mesh
  49956. * @param options defines the options used to create the mesh
  49957. * @param scene defines the hosting scene
  49958. * @returns the custom extruded shape mesh
  49959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49960. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49962. */
  49963. static ExtrudeShapeCustom(name: string, options: {
  49964. shape: Vector3[];
  49965. path: Vector3[];
  49966. scaleFunction?: any;
  49967. rotationFunction?: any;
  49968. ribbonCloseArray?: boolean;
  49969. ribbonClosePath?: boolean;
  49970. cap?: number;
  49971. updatable?: boolean;
  49972. sideOrientation?: number;
  49973. frontUVs?: Vector4;
  49974. backUVs?: Vector4;
  49975. instance?: Mesh;
  49976. invertUV?: boolean;
  49977. }, scene?: Nullable<Scene>): Mesh;
  49978. /**
  49979. * Creates lathe mesh.
  49980. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49981. * * 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
  49982. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49983. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49984. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49985. * * 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
  49986. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49987. * * 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
  49988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49992. * @param name defines the name of the mesh
  49993. * @param options defines the options used to create the mesh
  49994. * @param scene defines the hosting scene
  49995. * @returns the lathe mesh
  49996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49997. */
  49998. static CreateLathe(name: string, options: {
  49999. shape: Vector3[];
  50000. radius?: number;
  50001. tessellation?: number;
  50002. clip?: number;
  50003. arc?: number;
  50004. closed?: boolean;
  50005. updatable?: boolean;
  50006. sideOrientation?: number;
  50007. frontUVs?: Vector4;
  50008. backUVs?: Vector4;
  50009. cap?: number;
  50010. invertUV?: boolean;
  50011. }, scene?: Nullable<Scene>): Mesh;
  50012. /**
  50013. * Creates a plane mesh
  50014. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50015. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50016. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50020. * @param name defines the name of the mesh
  50021. * @param options defines the options used to create the mesh
  50022. * @param scene defines the hosting scene
  50023. * @returns the plane mesh
  50024. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50025. */
  50026. static CreatePlane(name: string, options: {
  50027. size?: number;
  50028. width?: number;
  50029. height?: number;
  50030. sideOrientation?: number;
  50031. frontUVs?: Vector4;
  50032. backUVs?: Vector4;
  50033. updatable?: boolean;
  50034. sourcePlane?: Plane;
  50035. }, scene?: Nullable<Scene>): Mesh;
  50036. /**
  50037. * Creates a ground mesh
  50038. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50039. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50041. * @param name defines the name of the mesh
  50042. * @param options defines the options used to create the mesh
  50043. * @param scene defines the hosting scene
  50044. * @returns the ground mesh
  50045. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50046. */
  50047. static CreateGround(name: string, options: {
  50048. width?: number;
  50049. height?: number;
  50050. subdivisions?: number;
  50051. subdivisionsX?: number;
  50052. subdivisionsY?: number;
  50053. updatable?: boolean;
  50054. }, scene?: Nullable<Scene>): Mesh;
  50055. /**
  50056. * Creates a tiled ground mesh
  50057. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50058. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50059. * * 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
  50060. * * 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
  50061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50062. * @param name defines the name of the mesh
  50063. * @param options defines the options used to create the mesh
  50064. * @param scene defines the hosting scene
  50065. * @returns the tiled ground mesh
  50066. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50067. */
  50068. static CreateTiledGround(name: string, options: {
  50069. xmin: number;
  50070. zmin: number;
  50071. xmax: number;
  50072. zmax: number;
  50073. subdivisions?: {
  50074. w: number;
  50075. h: number;
  50076. };
  50077. precision?: {
  50078. w: number;
  50079. h: number;
  50080. };
  50081. updatable?: boolean;
  50082. }, scene?: Nullable<Scene>): Mesh;
  50083. /**
  50084. * Creates a ground mesh from a height map
  50085. * * The parameter `url` sets the URL of the height map image resource.
  50086. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50087. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50088. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50089. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50090. * * 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.
  50091. * * 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).
  50092. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50094. * @param name defines the name of the mesh
  50095. * @param url defines the url to the height map
  50096. * @param options defines the options used to create the mesh
  50097. * @param scene defines the hosting scene
  50098. * @returns the ground mesh
  50099. * @see https://doc.babylonjs.com/babylon101/height_map
  50100. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50101. */
  50102. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50103. width?: number;
  50104. height?: number;
  50105. subdivisions?: number;
  50106. minHeight?: number;
  50107. maxHeight?: number;
  50108. colorFilter?: Color3;
  50109. alphaFilter?: number;
  50110. updatable?: boolean;
  50111. onReady?: (mesh: GroundMesh) => void;
  50112. }, scene?: Nullable<Scene>): GroundMesh;
  50113. /**
  50114. * Creates a polygon mesh
  50115. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50116. * * 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
  50117. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50120. * * Remember you can only change the shape positions, not their number when updating a polygon
  50121. * @param name defines the name of the mesh
  50122. * @param options defines the options used to create the mesh
  50123. * @param scene defines the hosting scene
  50124. * @param earcutInjection can be used to inject your own earcut reference
  50125. * @returns the polygon mesh
  50126. */
  50127. static CreatePolygon(name: string, options: {
  50128. shape: Vector3[];
  50129. holes?: Vector3[][];
  50130. depth?: number;
  50131. faceUV?: Vector4[];
  50132. faceColors?: Color4[];
  50133. updatable?: boolean;
  50134. sideOrientation?: number;
  50135. frontUVs?: Vector4;
  50136. backUVs?: Vector4;
  50137. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50138. /**
  50139. * Creates an extruded polygon mesh, with depth in the Y direction.
  50140. * * 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)
  50141. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50142. * @param name defines the name of the mesh
  50143. * @param options defines the options used to create the mesh
  50144. * @param scene defines the hosting scene
  50145. * @param earcutInjection can be used to inject your own earcut reference
  50146. * @returns the polygon mesh
  50147. */
  50148. static ExtrudePolygon(name: string, options: {
  50149. shape: Vector3[];
  50150. holes?: Vector3[][];
  50151. depth?: number;
  50152. faceUV?: Vector4[];
  50153. faceColors?: Color4[];
  50154. updatable?: boolean;
  50155. sideOrientation?: number;
  50156. frontUVs?: Vector4;
  50157. backUVs?: Vector4;
  50158. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50159. /**
  50160. * Creates a tube mesh.
  50161. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50162. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50163. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50164. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50165. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50166. * * 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)
  50167. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50168. * * 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
  50169. * * 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
  50170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50174. * @param name defines the name of the mesh
  50175. * @param options defines the options used to create the mesh
  50176. * @param scene defines the hosting scene
  50177. * @returns the tube mesh
  50178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50179. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50180. */
  50181. static CreateTube(name: string, options: {
  50182. path: Vector3[];
  50183. radius?: number;
  50184. tessellation?: number;
  50185. radiusFunction?: {
  50186. (i: number, distance: number): number;
  50187. };
  50188. cap?: number;
  50189. arc?: number;
  50190. updatable?: boolean;
  50191. sideOrientation?: number;
  50192. frontUVs?: Vector4;
  50193. backUVs?: Vector4;
  50194. instance?: Mesh;
  50195. invertUV?: boolean;
  50196. }, scene?: Nullable<Scene>): Mesh;
  50197. /**
  50198. * Creates a polyhedron mesh
  50199. * * 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
  50200. * * The parameter `size` (positive float, default 1) sets the polygon size
  50201. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50202. * * 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`
  50203. * * 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
  50204. * * 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)`)
  50205. * * 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
  50206. * * 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
  50207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50210. * @param name defines the name of the mesh
  50211. * @param options defines the options used to create the mesh
  50212. * @param scene defines the hosting scene
  50213. * @returns the polyhedron mesh
  50214. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50215. */
  50216. static CreatePolyhedron(name: string, options: {
  50217. type?: number;
  50218. size?: number;
  50219. sizeX?: number;
  50220. sizeY?: number;
  50221. sizeZ?: number;
  50222. custom?: any;
  50223. faceUV?: Vector4[];
  50224. faceColors?: Color4[];
  50225. flat?: boolean;
  50226. updatable?: boolean;
  50227. sideOrientation?: number;
  50228. frontUVs?: Vector4;
  50229. backUVs?: Vector4;
  50230. }, scene?: Nullable<Scene>): Mesh;
  50231. /**
  50232. * Creates a decal mesh.
  50233. * 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
  50234. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50235. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50236. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50237. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50238. * @param name defines the name of the mesh
  50239. * @param sourceMesh defines the mesh where the decal must be applied
  50240. * @param options defines the options used to create the mesh
  50241. * @param scene defines the hosting scene
  50242. * @returns the decal mesh
  50243. * @see https://doc.babylonjs.com/how_to/decals
  50244. */
  50245. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50246. position?: Vector3;
  50247. normal?: Vector3;
  50248. size?: Vector3;
  50249. angle?: number;
  50250. }): Mesh;
  50251. }
  50252. }
  50253. declare module BABYLON {
  50254. /**
  50255. * A simplifier interface for future simplification implementations
  50256. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50257. */
  50258. export interface ISimplifier {
  50259. /**
  50260. * Simplification of a given mesh according to the given settings.
  50261. * Since this requires computation, it is assumed that the function runs async.
  50262. * @param settings The settings of the simplification, including quality and distance
  50263. * @param successCallback A callback that will be called after the mesh was simplified.
  50264. * @param errorCallback in case of an error, this callback will be called. optional.
  50265. */
  50266. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50267. }
  50268. /**
  50269. * Expected simplification settings.
  50270. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50272. */
  50273. export interface ISimplificationSettings {
  50274. /**
  50275. * Gets or sets the expected quality
  50276. */
  50277. quality: number;
  50278. /**
  50279. * Gets or sets the distance when this optimized version should be used
  50280. */
  50281. distance: number;
  50282. /**
  50283. * Gets an already optimized mesh
  50284. */
  50285. optimizeMesh?: boolean;
  50286. }
  50287. /**
  50288. * Class used to specify simplification options
  50289. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50290. */
  50291. export class SimplificationSettings implements ISimplificationSettings {
  50292. /** expected quality */
  50293. quality: number;
  50294. /** distance when this optimized version should be used */
  50295. distance: number;
  50296. /** already optimized mesh */
  50297. optimizeMesh?: boolean | undefined;
  50298. /**
  50299. * Creates a SimplificationSettings
  50300. * @param quality expected quality
  50301. * @param distance distance when this optimized version should be used
  50302. * @param optimizeMesh already optimized mesh
  50303. */
  50304. constructor(
  50305. /** expected quality */
  50306. quality: number,
  50307. /** distance when this optimized version should be used */
  50308. distance: number,
  50309. /** already optimized mesh */
  50310. optimizeMesh?: boolean | undefined);
  50311. }
  50312. /**
  50313. * Interface used to define a simplification task
  50314. */
  50315. export interface ISimplificationTask {
  50316. /**
  50317. * Array of settings
  50318. */
  50319. settings: Array<ISimplificationSettings>;
  50320. /**
  50321. * Simplification type
  50322. */
  50323. simplificationType: SimplificationType;
  50324. /**
  50325. * Mesh to simplify
  50326. */
  50327. mesh: Mesh;
  50328. /**
  50329. * Callback called on success
  50330. */
  50331. successCallback?: () => void;
  50332. /**
  50333. * Defines if parallel processing can be used
  50334. */
  50335. parallelProcessing: boolean;
  50336. }
  50337. /**
  50338. * Queue used to order the simplification tasks
  50339. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50340. */
  50341. export class SimplificationQueue {
  50342. private _simplificationArray;
  50343. /**
  50344. * Gets a boolean indicating that the process is still running
  50345. */
  50346. running: boolean;
  50347. /**
  50348. * Creates a new queue
  50349. */
  50350. constructor();
  50351. /**
  50352. * Adds a new simplification task
  50353. * @param task defines a task to add
  50354. */
  50355. addTask(task: ISimplificationTask): void;
  50356. /**
  50357. * Execute next task
  50358. */
  50359. executeNext(): void;
  50360. /**
  50361. * Execute a simplification task
  50362. * @param task defines the task to run
  50363. */
  50364. runSimplification(task: ISimplificationTask): void;
  50365. private getSimplifier;
  50366. }
  50367. /**
  50368. * The implemented types of simplification
  50369. * At the moment only Quadratic Error Decimation is implemented
  50370. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50371. */
  50372. export enum SimplificationType {
  50373. /** Quadratic error decimation */
  50374. QUADRATIC = 0
  50375. }
  50376. }
  50377. declare module BABYLON {
  50378. interface Scene {
  50379. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  50380. /**
  50381. * Gets or sets the simplification queue attached to the scene
  50382. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50383. */
  50384. simplificationQueue: SimplificationQueue;
  50385. }
  50386. interface Mesh {
  50387. /**
  50388. * Simplify the mesh according to the given array of settings.
  50389. * Function will return immediately and will simplify async
  50390. * @param settings a collection of simplification settings
  50391. * @param parallelProcessing should all levels calculate parallel or one after the other
  50392. * @param simplificationType the type of simplification to run
  50393. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50394. * @returns the current mesh
  50395. */
  50396. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50397. }
  50398. /**
  50399. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50400. * created in a scene
  50401. */
  50402. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50403. /**
  50404. * The component name helpfull to identify the component in the list of scene components.
  50405. */
  50406. readonly name: string;
  50407. /**
  50408. * The scene the component belongs to.
  50409. */
  50410. scene: Scene;
  50411. /**
  50412. * Creates a new instance of the component for the given scene
  50413. * @param scene Defines the scene to register the component in
  50414. */
  50415. constructor(scene: Scene);
  50416. /**
  50417. * Registers the component in a given scene
  50418. */
  50419. register(): void;
  50420. /**
  50421. * Rebuilds the elements related to this component in case of
  50422. * context lost for instance.
  50423. */
  50424. rebuild(): void;
  50425. /**
  50426. * Disposes the component and the associated ressources
  50427. */
  50428. dispose(): void;
  50429. private _beforeCameraUpdate;
  50430. }
  50431. }
  50432. declare module BABYLON {
  50433. /**
  50434. * Class used to enable access to IndexedDB
  50435. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50436. */
  50437. export class Database implements IOfflineProvider {
  50438. private _callbackManifestChecked;
  50439. private _currentSceneUrl;
  50440. private _db;
  50441. private _enableSceneOffline;
  50442. private _enableTexturesOffline;
  50443. private _manifestVersionFound;
  50444. private _mustUpdateRessources;
  50445. private _hasReachedQuota;
  50446. private _isSupported;
  50447. private _idbFactory;
  50448. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50449. private static IsUASupportingBlobStorage;
  50450. /**
  50451. * Gets a boolean indicating if Database storate is enabled (off by default)
  50452. */
  50453. static IDBStorageEnabled: boolean;
  50454. /**
  50455. * Gets a boolean indicating if scene must be saved in the database
  50456. */
  50457. readonly enableSceneOffline: boolean;
  50458. /**
  50459. * Gets a boolean indicating if textures must be saved in the database
  50460. */
  50461. readonly enableTexturesOffline: boolean;
  50462. /**
  50463. * Creates a new Database
  50464. * @param urlToScene defines the url to load the scene
  50465. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50466. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50467. */
  50468. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50469. private static _ParseURL;
  50470. private static _ReturnFullUrlLocation;
  50471. private _checkManifestFile;
  50472. /**
  50473. * Open the database and make it available
  50474. * @param successCallback defines the callback to call on success
  50475. * @param errorCallback defines the callback to call on error
  50476. */
  50477. open(successCallback: () => void, errorCallback: () => void): void;
  50478. /**
  50479. * Loads an image from the database
  50480. * @param url defines the url to load from
  50481. * @param image defines the target DOM image
  50482. */
  50483. loadImage(url: string, image: HTMLImageElement): void;
  50484. private _loadImageFromDBAsync;
  50485. private _saveImageIntoDBAsync;
  50486. private _checkVersionFromDB;
  50487. private _loadVersionFromDBAsync;
  50488. private _saveVersionIntoDBAsync;
  50489. /**
  50490. * Loads a file from database
  50491. * @param url defines the URL to load from
  50492. * @param sceneLoaded defines a callback to call on success
  50493. * @param progressCallBack defines a callback to call when progress changed
  50494. * @param errorCallback defines a callback to call on error
  50495. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50496. */
  50497. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50498. private _loadFileAsync;
  50499. private _saveFileAsync;
  50500. /**
  50501. * Validates if xhr data is correct
  50502. * @param xhr defines the request to validate
  50503. * @param dataType defines the expected data type
  50504. * @returns true if data is correct
  50505. */
  50506. private static _ValidateXHRData;
  50507. }
  50508. }
  50509. declare module BABYLON {
  50510. /** @hidden */
  50511. export var gpuUpdateParticlesPixelShader: {
  50512. name: string;
  50513. shader: string;
  50514. };
  50515. }
  50516. declare module BABYLON {
  50517. /** @hidden */
  50518. export var gpuUpdateParticlesVertexShader: {
  50519. name: string;
  50520. shader: string;
  50521. };
  50522. }
  50523. declare module BABYLON {
  50524. /** @hidden */
  50525. export var clipPlaneFragmentDeclaration2: {
  50526. name: string;
  50527. shader: string;
  50528. };
  50529. }
  50530. declare module BABYLON {
  50531. /** @hidden */
  50532. export var gpuRenderParticlesPixelShader: {
  50533. name: string;
  50534. shader: string;
  50535. };
  50536. }
  50537. declare module BABYLON {
  50538. /** @hidden */
  50539. export var clipPlaneVertexDeclaration2: {
  50540. name: string;
  50541. shader: string;
  50542. };
  50543. }
  50544. declare module BABYLON {
  50545. /** @hidden */
  50546. export var gpuRenderParticlesVertexShader: {
  50547. name: string;
  50548. shader: string;
  50549. };
  50550. }
  50551. declare module BABYLON {
  50552. /**
  50553. * This represents a GPU particle system in Babylon
  50554. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50555. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50556. */
  50557. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50558. /**
  50559. * The layer mask we are rendering the particles through.
  50560. */
  50561. layerMask: number;
  50562. private _capacity;
  50563. private _activeCount;
  50564. private _currentActiveCount;
  50565. private _accumulatedCount;
  50566. private _renderEffect;
  50567. private _updateEffect;
  50568. private _buffer0;
  50569. private _buffer1;
  50570. private _spriteBuffer;
  50571. private _updateVAO;
  50572. private _renderVAO;
  50573. private _targetIndex;
  50574. private _sourceBuffer;
  50575. private _targetBuffer;
  50576. private _engine;
  50577. private _currentRenderId;
  50578. private _started;
  50579. private _stopped;
  50580. private _timeDelta;
  50581. private _randomTexture;
  50582. private _randomTexture2;
  50583. private _attributesStrideSize;
  50584. private _updateEffectOptions;
  50585. private _randomTextureSize;
  50586. private _actualFrame;
  50587. private readonly _rawTextureWidth;
  50588. /**
  50589. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50590. */
  50591. static readonly IsSupported: boolean;
  50592. /**
  50593. * An event triggered when the system is disposed.
  50594. */
  50595. onDisposeObservable: Observable<GPUParticleSystem>;
  50596. /**
  50597. * Gets the maximum number of particles active at the same time.
  50598. * @returns The max number of active particles.
  50599. */
  50600. getCapacity(): number;
  50601. /**
  50602. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50603. * to override the particles.
  50604. */
  50605. forceDepthWrite: boolean;
  50606. /**
  50607. * Gets or set the number of active particles
  50608. */
  50609. activeParticleCount: number;
  50610. private _preWarmDone;
  50611. /**
  50612. * Is this system ready to be used/rendered
  50613. * @return true if the system is ready
  50614. */
  50615. isReady(): boolean;
  50616. /**
  50617. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50618. * @returns True if it has been started, otherwise false.
  50619. */
  50620. isStarted(): boolean;
  50621. /**
  50622. * Starts the particle system and begins to emit
  50623. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50624. */
  50625. start(delay?: number): void;
  50626. /**
  50627. * Stops the particle system.
  50628. */
  50629. stop(): void;
  50630. /**
  50631. * Remove all active particles
  50632. */
  50633. reset(): void;
  50634. /**
  50635. * Returns the string "GPUParticleSystem"
  50636. * @returns a string containing the class name
  50637. */
  50638. getClassName(): string;
  50639. private _colorGradientsTexture;
  50640. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50641. /**
  50642. * Adds a new color gradient
  50643. * @param gradient defines the gradient to use (between 0 and 1)
  50644. * @param color1 defines the color to affect to the specified gradient
  50645. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50646. * @returns the current particle system
  50647. */
  50648. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50649. /**
  50650. * Remove a specific color gradient
  50651. * @param gradient defines the gradient to remove
  50652. * @returns the current particle system
  50653. */
  50654. removeColorGradient(gradient: number): GPUParticleSystem;
  50655. private _angularSpeedGradientsTexture;
  50656. private _sizeGradientsTexture;
  50657. private _velocityGradientsTexture;
  50658. private _limitVelocityGradientsTexture;
  50659. private _dragGradientsTexture;
  50660. private _addFactorGradient;
  50661. /**
  50662. * Adds a new size gradient
  50663. * @param gradient defines the gradient to use (between 0 and 1)
  50664. * @param factor defines the size factor to affect to the specified gradient
  50665. * @returns the current particle system
  50666. */
  50667. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50668. /**
  50669. * Remove a specific size gradient
  50670. * @param gradient defines the gradient to remove
  50671. * @returns the current particle system
  50672. */
  50673. removeSizeGradient(gradient: number): GPUParticleSystem;
  50674. /**
  50675. * Adds a new angular speed gradient
  50676. * @param gradient defines the gradient to use (between 0 and 1)
  50677. * @param factor defines the angular speed to affect to the specified gradient
  50678. * @returns the current particle system
  50679. */
  50680. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50681. /**
  50682. * Remove a specific angular speed gradient
  50683. * @param gradient defines the gradient to remove
  50684. * @returns the current particle system
  50685. */
  50686. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50687. /**
  50688. * Adds a new velocity gradient
  50689. * @param gradient defines the gradient to use (between 0 and 1)
  50690. * @param factor defines the velocity to affect to the specified gradient
  50691. * @returns the current particle system
  50692. */
  50693. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50694. /**
  50695. * Remove a specific velocity gradient
  50696. * @param gradient defines the gradient to remove
  50697. * @returns the current particle system
  50698. */
  50699. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50700. /**
  50701. * Adds a new limit velocity gradient
  50702. * @param gradient defines the gradient to use (between 0 and 1)
  50703. * @param factor defines the limit velocity value to affect to the specified gradient
  50704. * @returns the current particle system
  50705. */
  50706. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50707. /**
  50708. * Remove a specific limit velocity gradient
  50709. * @param gradient defines the gradient to remove
  50710. * @returns the current particle system
  50711. */
  50712. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50713. /**
  50714. * Adds a new drag gradient
  50715. * @param gradient defines the gradient to use (between 0 and 1)
  50716. * @param factor defines the drag value to affect to the specified gradient
  50717. * @returns the current particle system
  50718. */
  50719. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50720. /**
  50721. * Remove a specific drag gradient
  50722. * @param gradient defines the gradient to remove
  50723. * @returns the current particle system
  50724. */
  50725. removeDragGradient(gradient: number): GPUParticleSystem;
  50726. /**
  50727. * Not supported by GPUParticleSystem
  50728. * @param gradient defines the gradient to use (between 0 and 1)
  50729. * @param factor defines the emit rate value to affect to the specified gradient
  50730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50731. * @returns the current particle system
  50732. */
  50733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50734. /**
  50735. * Not supported by GPUParticleSystem
  50736. * @param gradient defines the gradient to remove
  50737. * @returns the current particle system
  50738. */
  50739. removeEmitRateGradient(gradient: number): IParticleSystem;
  50740. /**
  50741. * Not supported by GPUParticleSystem
  50742. * @param gradient defines the gradient to use (between 0 and 1)
  50743. * @param factor defines the start size value to affect to the specified gradient
  50744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50745. * @returns the current particle system
  50746. */
  50747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50748. /**
  50749. * Not supported by GPUParticleSystem
  50750. * @param gradient defines the gradient to remove
  50751. * @returns the current particle system
  50752. */
  50753. removeStartSizeGradient(gradient: number): IParticleSystem;
  50754. /**
  50755. * Not supported by GPUParticleSystem
  50756. * @param gradient defines the gradient to use (between 0 and 1)
  50757. * @param min defines the color remap minimal range
  50758. * @param max defines the color remap maximal range
  50759. * @returns the current particle system
  50760. */
  50761. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50762. /**
  50763. * Not supported by GPUParticleSystem
  50764. * @param gradient defines the gradient to remove
  50765. * @returns the current particle system
  50766. */
  50767. removeColorRemapGradient(): IParticleSystem;
  50768. /**
  50769. * Not supported by GPUParticleSystem
  50770. * @param gradient defines the gradient to use (between 0 and 1)
  50771. * @param min defines the alpha remap minimal range
  50772. * @param max defines the alpha remap maximal range
  50773. * @returns the current particle system
  50774. */
  50775. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50776. /**
  50777. * Not supported by GPUParticleSystem
  50778. * @param gradient defines the gradient to remove
  50779. * @returns the current particle system
  50780. */
  50781. removeAlphaRemapGradient(): IParticleSystem;
  50782. /**
  50783. * Not supported by GPUParticleSystem
  50784. * @param gradient defines the gradient to use (between 0 and 1)
  50785. * @param color defines the color to affect to the specified gradient
  50786. * @returns the current particle system
  50787. */
  50788. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50789. /**
  50790. * Not supported by GPUParticleSystem
  50791. * @param gradient defines the gradient to remove
  50792. * @returns the current particle system
  50793. */
  50794. removeRampGradient(): IParticleSystem;
  50795. /**
  50796. * Not supported by GPUParticleSystem
  50797. * @returns the list of ramp gradients
  50798. */
  50799. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50800. /**
  50801. * Not supported by GPUParticleSystem
  50802. * Gets or sets a boolean indicating that ramp gradients must be used
  50803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50804. */
  50805. useRampGradients: boolean;
  50806. /**
  50807. * Not supported by GPUParticleSystem
  50808. * @param gradient defines the gradient to use (between 0 and 1)
  50809. * @param factor defines the life time factor to affect to the specified gradient
  50810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50811. * @returns the current particle system
  50812. */
  50813. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50814. /**
  50815. * Not supported by GPUParticleSystem
  50816. * @param gradient defines the gradient to remove
  50817. * @returns the current particle system
  50818. */
  50819. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50820. /**
  50821. * Instantiates a GPU particle system.
  50822. * 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.
  50823. * @param name The name of the particle system
  50824. * @param options The options used to create the system
  50825. * @param scene The scene the particle system belongs to
  50826. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50827. */
  50828. constructor(name: string, options: Partial<{
  50829. capacity: number;
  50830. randomTextureSize: number;
  50831. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50832. protected _reset(): void;
  50833. private _createUpdateVAO;
  50834. private _createRenderVAO;
  50835. private _initialize;
  50836. /** @hidden */ recreateUpdateEffect(): void;
  50837. /** @hidden */ recreateRenderEffect(): void;
  50838. /**
  50839. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50840. * @param preWarm defines if we are in the pre-warmimg phase
  50841. */
  50842. animate(preWarm?: boolean): void;
  50843. private _createFactorGradientTexture;
  50844. private _createSizeGradientTexture;
  50845. private _createAngularSpeedGradientTexture;
  50846. private _createVelocityGradientTexture;
  50847. private _createLimitVelocityGradientTexture;
  50848. private _createDragGradientTexture;
  50849. private _createColorGradientTexture;
  50850. /**
  50851. * Renders the particle system in its current state
  50852. * @param preWarm defines if the system should only update the particles but not render them
  50853. * @returns the current number of particles
  50854. */
  50855. render(preWarm?: boolean): number;
  50856. /**
  50857. * Rebuilds the particle system
  50858. */
  50859. rebuild(): void;
  50860. private _releaseBuffers;
  50861. private _releaseVAOs;
  50862. /**
  50863. * Disposes the particle system and free the associated resources
  50864. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50865. */
  50866. dispose(disposeTexture?: boolean): void;
  50867. /**
  50868. * Clones the particle system.
  50869. * @param name The name of the cloned object
  50870. * @param newEmitter The new emitter to use
  50871. * @returns the cloned particle system
  50872. */
  50873. clone(name: string, newEmitter: any): GPUParticleSystem;
  50874. /**
  50875. * Serializes the particle system to a JSON object.
  50876. * @returns the JSON object
  50877. */
  50878. serialize(): any;
  50879. /**
  50880. * Parses a JSON object to create a GPU particle system.
  50881. * @param parsedParticleSystem The JSON object to parse
  50882. * @param scene The scene to create the particle system in
  50883. * @param rootUrl The root url to use to load external dependencies like texture
  50884. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50885. * @returns the parsed GPU particle system
  50886. */
  50887. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50888. }
  50889. }
  50890. declare module BABYLON {
  50891. /**
  50892. * Represents a set of particle systems working together to create a specific effect
  50893. */
  50894. export class ParticleSystemSet implements IDisposable {
  50895. private _emitterCreationOptions;
  50896. private _emitterNode;
  50897. /**
  50898. * Gets the particle system list
  50899. */
  50900. systems: IParticleSystem[];
  50901. /**
  50902. * Gets the emitter node used with this set
  50903. */
  50904. readonly emitterNode: Nullable<TransformNode>;
  50905. /**
  50906. * Creates a new emitter mesh as a sphere
  50907. * @param options defines the options used to create the sphere
  50908. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50909. * @param scene defines the hosting scene
  50910. */
  50911. setEmitterAsSphere(options: {
  50912. diameter: number;
  50913. segments: number;
  50914. color: Color3;
  50915. }, renderingGroupId: number, scene: Scene): void;
  50916. /**
  50917. * Starts all particle systems of the set
  50918. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50919. */
  50920. start(emitter?: AbstractMesh): void;
  50921. /**
  50922. * Release all associated resources
  50923. */
  50924. dispose(): void;
  50925. /**
  50926. * Serialize the set into a JSON compatible object
  50927. * @returns a JSON compatible representation of the set
  50928. */
  50929. serialize(): any;
  50930. /**
  50931. * Parse a new ParticleSystemSet from a serialized source
  50932. * @param data defines a JSON compatible representation of the set
  50933. * @param scene defines the hosting scene
  50934. * @param gpu defines if we want GPU particles or CPU particles
  50935. * @returns a new ParticleSystemSet
  50936. */
  50937. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50938. }
  50939. }
  50940. declare module BABYLON {
  50941. /**
  50942. * This class is made for on one-liner static method to help creating particle system set.
  50943. */
  50944. export class ParticleHelper {
  50945. /**
  50946. * Gets or sets base Assets URL
  50947. */
  50948. static BaseAssetsUrl: string;
  50949. /**
  50950. * Create a default particle system that you can tweak
  50951. * @param emitter defines the emitter to use
  50952. * @param capacity defines the system capacity (default is 500 particles)
  50953. * @param scene defines the hosting scene
  50954. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50955. * @returns the new Particle system
  50956. */
  50957. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50958. /**
  50959. * This is the main static method (one-liner) of this helper to create different particle systems
  50960. * @param type This string represents the type to the particle system to create
  50961. * @param scene The scene where the particle system should live
  50962. * @param gpu If the system will use gpu
  50963. * @returns the ParticleSystemSet created
  50964. */
  50965. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50966. /**
  50967. * Static function used to export a particle system to a ParticleSystemSet variable.
  50968. * Please note that the emitter shape is not exported
  50969. * @param systems defines the particle systems to export
  50970. * @returns the created particle system set
  50971. */
  50972. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50973. }
  50974. }
  50975. declare module BABYLON {
  50976. interface Engine {
  50977. /**
  50978. * Create an effect to use with particle systems.
  50979. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50980. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50981. * @param uniformsNames defines a list of attribute names
  50982. * @param samplers defines an array of string used to represent textures
  50983. * @param defines defines the string containing the defines to use to compile the shaders
  50984. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50985. * @param onCompiled defines a function to call when the effect creation is successful
  50986. * @param onError defines a function to call when the effect creation has failed
  50987. * @returns the new Effect
  50988. */
  50989. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50990. }
  50991. interface Mesh {
  50992. /**
  50993. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50994. * @returns an array of IParticleSystem
  50995. */
  50996. getEmittedParticleSystems(): IParticleSystem[];
  50997. /**
  50998. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50999. * @returns an array of IParticleSystem
  51000. */
  51001. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51002. }
  51003. /**
  51004. * @hidden
  51005. */
  51006. export var _IDoNeedToBeInTheBuild: number;
  51007. }
  51008. declare module BABYLON {
  51009. interface Scene {
  51010. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  51011. /**
  51012. * Gets the current physics engine
  51013. * @returns a IPhysicsEngine or null if none attached
  51014. */
  51015. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51016. /**
  51017. * Enables physics to the current scene
  51018. * @param gravity defines the scene's gravity for the physics engine
  51019. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51020. * @return a boolean indicating if the physics engine was initialized
  51021. */
  51022. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51023. /**
  51024. * Disables and disposes the physics engine associated with the scene
  51025. */
  51026. disablePhysicsEngine(): void;
  51027. /**
  51028. * Gets a boolean indicating if there is an active physics engine
  51029. * @returns a boolean indicating if there is an active physics engine
  51030. */
  51031. isPhysicsEnabled(): boolean;
  51032. /**
  51033. * Deletes a physics compound impostor
  51034. * @param compound defines the compound to delete
  51035. */
  51036. deleteCompoundImpostor(compound: any): void;
  51037. /**
  51038. * An event triggered when physic simulation is about to be run
  51039. */
  51040. onBeforePhysicsObservable: Observable<Scene>;
  51041. /**
  51042. * An event triggered when physic simulation has been done
  51043. */
  51044. onAfterPhysicsObservable: Observable<Scene>;
  51045. }
  51046. interface AbstractMesh {
  51047. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  51048. /**
  51049. * Gets or sets impostor used for physic simulation
  51050. * @see http://doc.babylonjs.com/features/physics_engine
  51051. */
  51052. physicsImpostor: Nullable<PhysicsImpostor>;
  51053. /**
  51054. * Gets the current physics impostor
  51055. * @see http://doc.babylonjs.com/features/physics_engine
  51056. * @returns a physics impostor or null
  51057. */
  51058. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51059. /** Apply a physic impulse to the mesh
  51060. * @param force defines the force to apply
  51061. * @param contactPoint defines where to apply the force
  51062. * @returns the current mesh
  51063. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51064. */
  51065. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51066. /**
  51067. * Creates a physic joint between two meshes
  51068. * @param otherMesh defines the other mesh to use
  51069. * @param pivot1 defines the pivot to use on this mesh
  51070. * @param pivot2 defines the pivot to use on the other mesh
  51071. * @param options defines additional options (can be plugin dependent)
  51072. * @returns the current mesh
  51073. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51074. */
  51075. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51076. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  51077. }
  51078. /**
  51079. * Defines the physics engine scene component responsible to manage a physics engine
  51080. */
  51081. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51082. /**
  51083. * The component name helpful to identify the component in the list of scene components.
  51084. */
  51085. readonly name: string;
  51086. /**
  51087. * The scene the component belongs to.
  51088. */
  51089. scene: Scene;
  51090. /**
  51091. * Creates a new instance of the component for the given scene
  51092. * @param scene Defines the scene to register the component in
  51093. */
  51094. constructor(scene: Scene);
  51095. /**
  51096. * Registers the component in a given scene
  51097. */
  51098. register(): void;
  51099. /**
  51100. * Rebuilds the elements related to this component in case of
  51101. * context lost for instance.
  51102. */
  51103. rebuild(): void;
  51104. /**
  51105. * Disposes the component and the associated ressources
  51106. */
  51107. dispose(): void;
  51108. }
  51109. }
  51110. declare module BABYLON {
  51111. /**
  51112. * A helper for physics simulations
  51113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51114. */
  51115. export class PhysicsHelper {
  51116. private _scene;
  51117. private _physicsEngine;
  51118. /**
  51119. * Initializes the Physics helper
  51120. * @param scene Babylon.js scene
  51121. */
  51122. constructor(scene: Scene);
  51123. /**
  51124. * Applies a radial explosion impulse
  51125. * @param origin the origin of the explosion
  51126. * @param radiusOrEventOptions the radius or the options of radial explosion
  51127. * @param strength the explosion strength
  51128. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51129. * @returns A physics radial explosion event, or null
  51130. */
  51131. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51132. /**
  51133. * Applies a radial explosion force
  51134. * @param origin the origin of the explosion
  51135. * @param radiusOrEventOptions the radius or the options of radial explosion
  51136. * @param strength the explosion strength
  51137. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51138. * @returns A physics radial explosion event, or null
  51139. */
  51140. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51141. /**
  51142. * Creates a gravitational field
  51143. * @param origin the origin of the explosion
  51144. * @param radiusOrEventOptions the radius or the options of radial explosion
  51145. * @param strength the explosion strength
  51146. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51147. * @returns A physics gravitational field event, or null
  51148. */
  51149. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51150. /**
  51151. * Creates a physics updraft event
  51152. * @param origin the origin of the updraft
  51153. * @param radiusOrEventOptions the radius or the options of the updraft
  51154. * @param strength the strength of the updraft
  51155. * @param height the height of the updraft
  51156. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51157. * @returns A physics updraft event, or null
  51158. */
  51159. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51160. /**
  51161. * Creates a physics vortex event
  51162. * @param origin the of the vortex
  51163. * @param radiusOrEventOptions the radius or the options of the vortex
  51164. * @param strength the strength of the vortex
  51165. * @param height the height of the vortex
  51166. * @returns a Physics vortex event, or null
  51167. * A physics vortex event or null
  51168. */
  51169. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51170. }
  51171. /**
  51172. * Represents a physics radial explosion event
  51173. */
  51174. class PhysicsRadialExplosionEvent {
  51175. private _scene;
  51176. private _options;
  51177. private _sphere;
  51178. private _dataFetched;
  51179. /**
  51180. * Initializes a radial explosioin event
  51181. * @param _scene BabylonJS scene
  51182. * @param _options The options for the vortex event
  51183. */
  51184. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51185. /**
  51186. * Returns the data related to the radial explosion event (sphere).
  51187. * @returns The radial explosion event data
  51188. */
  51189. getData(): PhysicsRadialExplosionEventData;
  51190. /**
  51191. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51192. * @param impostor A physics imposter
  51193. * @param origin the origin of the explosion
  51194. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51195. */
  51196. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51197. /**
  51198. * Triggers affecterd impostors callbacks
  51199. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51200. */
  51201. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51202. /**
  51203. * Disposes the sphere.
  51204. * @param force Specifies if the sphere should be disposed by force
  51205. */
  51206. dispose(force?: boolean): void;
  51207. /*** Helpers ***/
  51208. private _prepareSphere;
  51209. private _intersectsWithSphere;
  51210. }
  51211. /**
  51212. * Represents a gravitational field event
  51213. */
  51214. class PhysicsGravitationalFieldEvent {
  51215. private _physicsHelper;
  51216. private _scene;
  51217. private _origin;
  51218. private _options;
  51219. private _tickCallback;
  51220. private _sphere;
  51221. private _dataFetched;
  51222. /**
  51223. * Initializes the physics gravitational field event
  51224. * @param _physicsHelper A physics helper
  51225. * @param _scene BabylonJS scene
  51226. * @param _origin The origin position of the gravitational field event
  51227. * @param _options The options for the vortex event
  51228. */
  51229. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51230. /**
  51231. * Returns the data related to the gravitational field event (sphere).
  51232. * @returns A gravitational field event
  51233. */
  51234. getData(): PhysicsGravitationalFieldEventData;
  51235. /**
  51236. * Enables the gravitational field.
  51237. */
  51238. enable(): void;
  51239. /**
  51240. * Disables the gravitational field.
  51241. */
  51242. disable(): void;
  51243. /**
  51244. * Disposes the sphere.
  51245. * @param force The force to dispose from the gravitational field event
  51246. */
  51247. dispose(force?: boolean): void;
  51248. private _tick;
  51249. }
  51250. /**
  51251. * Represents a physics updraft event
  51252. */
  51253. class PhysicsUpdraftEvent {
  51254. private _scene;
  51255. private _origin;
  51256. private _options;
  51257. private _physicsEngine;
  51258. private _originTop;
  51259. private _originDirection;
  51260. private _tickCallback;
  51261. private _cylinder;
  51262. private _cylinderPosition;
  51263. private _dataFetched;
  51264. /**
  51265. * Initializes the physics updraft event
  51266. * @param _scene BabylonJS scene
  51267. * @param _origin The origin position of the updraft
  51268. * @param _options The options for the updraft event
  51269. */
  51270. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51271. /**
  51272. * Returns the data related to the updraft event (cylinder).
  51273. * @returns A physics updraft event
  51274. */
  51275. getData(): PhysicsUpdraftEventData;
  51276. /**
  51277. * Enables the updraft.
  51278. */
  51279. enable(): void;
  51280. /**
  51281. * Disables the updraft.
  51282. */
  51283. disable(): void;
  51284. /**
  51285. * Disposes the cylinder.
  51286. * @param force Specifies if the updraft should be disposed by force
  51287. */
  51288. dispose(force?: boolean): void;
  51289. private getImpostorHitData;
  51290. private _tick;
  51291. /*** Helpers ***/
  51292. private _prepareCylinder;
  51293. private _intersectsWithCylinder;
  51294. }
  51295. /**
  51296. * Represents a physics vortex event
  51297. */
  51298. class PhysicsVortexEvent {
  51299. private _scene;
  51300. private _origin;
  51301. private _options;
  51302. private _physicsEngine;
  51303. private _originTop;
  51304. private _tickCallback;
  51305. private _cylinder;
  51306. private _cylinderPosition;
  51307. private _dataFetched;
  51308. /**
  51309. * Initializes the physics vortex event
  51310. * @param _scene The BabylonJS scene
  51311. * @param _origin The origin position of the vortex
  51312. * @param _options The options for the vortex event
  51313. */
  51314. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51315. /**
  51316. * Returns the data related to the vortex event (cylinder).
  51317. * @returns The physics vortex event data
  51318. */
  51319. getData(): PhysicsVortexEventData;
  51320. /**
  51321. * Enables the vortex.
  51322. */
  51323. enable(): void;
  51324. /**
  51325. * Disables the cortex.
  51326. */
  51327. disable(): void;
  51328. /**
  51329. * Disposes the sphere.
  51330. * @param force
  51331. */
  51332. dispose(force?: boolean): void;
  51333. private getImpostorHitData;
  51334. private _tick;
  51335. /*** Helpers ***/
  51336. private _prepareCylinder;
  51337. private _intersectsWithCylinder;
  51338. }
  51339. /**
  51340. * Options fot the radial explosion event
  51341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51342. */
  51343. export class PhysicsRadialExplosionEventOptions {
  51344. /**
  51345. * The radius of the sphere for the radial explosion.
  51346. */
  51347. radius: number;
  51348. /**
  51349. * The strenth of the explosion.
  51350. */
  51351. strength: number;
  51352. /**
  51353. * The strenght of the force in correspondence to the distance of the affected object
  51354. */
  51355. falloff: PhysicsRadialImpulseFalloff;
  51356. /**
  51357. * Sphere options for the radial explosion.
  51358. */
  51359. sphere: {
  51360. segments: number;
  51361. diameter: number;
  51362. };
  51363. /**
  51364. * Sphere options for the radial explosion.
  51365. */
  51366. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51367. }
  51368. /**
  51369. * Options fot the updraft event
  51370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51371. */
  51372. export class PhysicsUpdraftEventOptions {
  51373. /**
  51374. * The radius of the cylinder for the vortex
  51375. */
  51376. radius: number;
  51377. /**
  51378. * The strenth of the updraft.
  51379. */
  51380. strength: number;
  51381. /**
  51382. * The height of the cylinder for the updraft.
  51383. */
  51384. height: number;
  51385. /**
  51386. * The mode for the the updraft.
  51387. */
  51388. updraftMode: PhysicsUpdraftMode;
  51389. }
  51390. /**
  51391. * Options fot the vortex event
  51392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51393. */
  51394. export class PhysicsVortexEventOptions {
  51395. /**
  51396. * The radius of the cylinder for the vortex
  51397. */
  51398. radius: number;
  51399. /**
  51400. * The strenth of the vortex.
  51401. */
  51402. strength: number;
  51403. /**
  51404. * The height of the cylinder for the vortex.
  51405. */
  51406. height: number;
  51407. /**
  51408. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51409. */
  51410. centripetalForceThreshold: number;
  51411. /**
  51412. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51413. */
  51414. centripetalForceMultiplier: number;
  51415. /**
  51416. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51417. */
  51418. centrifugalForceMultiplier: number;
  51419. /**
  51420. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51421. */
  51422. updraftForceMultiplier: number;
  51423. }
  51424. /**
  51425. * The strenght of the force in correspondence to the distance of the affected object
  51426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51427. */
  51428. export enum PhysicsRadialImpulseFalloff {
  51429. /** Defines that impulse is constant in strength across it's whole radius */
  51430. Constant = 0,
  51431. /** Defines that impulse gets weaker if it's further from the origin */
  51432. Linear = 1
  51433. }
  51434. /**
  51435. * The strength of the force in correspondence to the distance of the affected object
  51436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51437. */
  51438. export enum PhysicsUpdraftMode {
  51439. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51440. Center = 0,
  51441. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51442. Perpendicular = 1
  51443. }
  51444. /**
  51445. * Interface for a physics hit data
  51446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51447. */
  51448. export interface PhysicsHitData {
  51449. /**
  51450. * The force applied at the contact point
  51451. */
  51452. force: Vector3;
  51453. /**
  51454. * The contact point
  51455. */
  51456. contactPoint: Vector3;
  51457. /**
  51458. * The distance from the origin to the contact point
  51459. */
  51460. distanceFromOrigin: number;
  51461. }
  51462. /**
  51463. * Interface for radial explosion event data
  51464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51465. */
  51466. export interface PhysicsRadialExplosionEventData {
  51467. /**
  51468. * A sphere used for the radial explosion event
  51469. */
  51470. sphere: Mesh;
  51471. }
  51472. /**
  51473. * Interface for gravitational field event data
  51474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51475. */
  51476. export interface PhysicsGravitationalFieldEventData {
  51477. /**
  51478. * A sphere mesh used for the gravitational field event
  51479. */
  51480. sphere: Mesh;
  51481. }
  51482. /**
  51483. * Interface for updraft event data
  51484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51485. */
  51486. export interface PhysicsUpdraftEventData {
  51487. /**
  51488. * A cylinder used for the updraft event
  51489. */
  51490. cylinder: Mesh;
  51491. }
  51492. /**
  51493. * Interface for vortex event data
  51494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51495. */
  51496. export interface PhysicsVortexEventData {
  51497. /**
  51498. * A cylinder used for the vortex event
  51499. */
  51500. cylinder: Mesh;
  51501. }
  51502. /**
  51503. * Interface for an affected physics impostor
  51504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51505. */
  51506. export interface PhysicsAffectedImpostorWithData {
  51507. /**
  51508. * The impostor affected by the effect
  51509. */
  51510. impostor: PhysicsImpostor;
  51511. /**
  51512. * The data about the hit/horce from the explosion
  51513. */
  51514. hitData: PhysicsHitData;
  51515. }
  51516. }
  51517. declare module BABYLON {
  51518. /** @hidden */
  51519. export var blackAndWhitePixelShader: {
  51520. name: string;
  51521. shader: string;
  51522. };
  51523. }
  51524. declare module BABYLON {
  51525. /**
  51526. * Post process used to render in black and white
  51527. */
  51528. export class BlackAndWhitePostProcess extends PostProcess {
  51529. /**
  51530. * Linear about to convert he result to black and white (default: 1)
  51531. */
  51532. degree: number;
  51533. /**
  51534. * Creates a black and white post process
  51535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51536. * @param name The name of the effect.
  51537. * @param options The required width/height ratio to downsize to before computing the render pass.
  51538. * @param camera The camera to apply the render pass to.
  51539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51540. * @param engine The engine which the post process will be applied. (default: current engine)
  51541. * @param reusable If the post process can be reused on the same frame. (default: false)
  51542. */
  51543. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51544. }
  51545. }
  51546. declare module BABYLON {
  51547. /**
  51548. * This represents a set of one or more post processes in Babylon.
  51549. * A post process can be used to apply a shader to a texture after it is rendered.
  51550. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51551. */
  51552. export class PostProcessRenderEffect {
  51553. private _postProcesses;
  51554. private _getPostProcesses;
  51555. private _singleInstance;
  51556. private _cameras;
  51557. private _indicesForCamera;
  51558. /**
  51559. * Name of the effect
  51560. * @hidden
  51561. */ name: string;
  51562. /**
  51563. * Instantiates a post process render effect.
  51564. * A post process can be used to apply a shader to a texture after it is rendered.
  51565. * @param engine The engine the effect is tied to
  51566. * @param name The name of the effect
  51567. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51568. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51569. */
  51570. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51571. /**
  51572. * Checks if all the post processes in the effect are supported.
  51573. */
  51574. readonly isSupported: boolean;
  51575. /**
  51576. * Updates the current state of the effect
  51577. * @hidden
  51578. */ update(): void;
  51579. /**
  51580. * Attaches the effect on cameras
  51581. * @param cameras The camera to attach to.
  51582. * @hidden
  51583. */ attachCameras(cameras: Camera): void;
  51584. /**
  51585. * Attaches the effect on cameras
  51586. * @param cameras The camera to attach to.
  51587. * @hidden
  51588. */ attachCameras(cameras: Camera[]): void;
  51589. /**
  51590. * Detaches the effect on cameras
  51591. * @param cameras The camera to detatch from.
  51592. * @hidden
  51593. */ detachCameras(cameras: Camera): void;
  51594. /**
  51595. * Detatches the effect on cameras
  51596. * @param cameras The camera to detatch from.
  51597. * @hidden
  51598. */ detachCameras(cameras: Camera[]): void;
  51599. /**
  51600. * Enables the effect on given cameras
  51601. * @param cameras The camera to enable.
  51602. * @hidden
  51603. */ enable(cameras: Camera): void;
  51604. /**
  51605. * Enables the effect on given cameras
  51606. * @param cameras The camera to enable.
  51607. * @hidden
  51608. */ enable(cameras: Nullable<Camera[]>): void;
  51609. /**
  51610. * Disables the effect on the given cameras
  51611. * @param cameras The camera to disable.
  51612. * @hidden
  51613. */ disable(cameras: Camera): void;
  51614. /**
  51615. * Disables the effect on the given cameras
  51616. * @param cameras The camera to disable.
  51617. * @hidden
  51618. */ disable(cameras: Nullable<Camera[]>): void;
  51619. /**
  51620. * Gets a list of the post processes contained in the effect.
  51621. * @param camera The camera to get the post processes on.
  51622. * @returns The list of the post processes in the effect.
  51623. */
  51624. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51625. }
  51626. }
  51627. declare module BABYLON {
  51628. /** @hidden */
  51629. export var extractHighlightsPixelShader: {
  51630. name: string;
  51631. shader: string;
  51632. };
  51633. }
  51634. declare module BABYLON {
  51635. /**
  51636. * 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.
  51637. */
  51638. export class ExtractHighlightsPostProcess extends PostProcess {
  51639. /**
  51640. * The luminance threshold, pixels below this value will be set to black.
  51641. */
  51642. threshold: number;
  51643. /** @hidden */ exposure: number;
  51644. /**
  51645. * Post process which has the input texture to be used when performing highlight extraction
  51646. * @hidden
  51647. */ inputPostProcess: Nullable<PostProcess>;
  51648. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51649. }
  51650. }
  51651. declare module BABYLON {
  51652. /** @hidden */
  51653. export var bloomMergePixelShader: {
  51654. name: string;
  51655. shader: string;
  51656. };
  51657. }
  51658. declare module BABYLON {
  51659. /**
  51660. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51661. */
  51662. export class BloomMergePostProcess extends PostProcess {
  51663. /** Weight of the bloom to be added to the original input. */
  51664. weight: number;
  51665. /**
  51666. * Creates a new instance of @see BloomMergePostProcess
  51667. * @param name The name of the effect.
  51668. * @param originalFromInput Post process which's input will be used for the merge.
  51669. * @param blurred Blurred highlights post process which's output will be used.
  51670. * @param weight Weight of the bloom to be added to the original input.
  51671. * @param options The required width/height ratio to downsize to before computing the render pass.
  51672. * @param camera The camera to apply the render pass to.
  51673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51674. * @param engine The engine which the post process will be applied. (default: current engine)
  51675. * @param reusable If the post process can be reused on the same frame. (default: false)
  51676. * @param textureType Type of textures used when performing the post process. (default: 0)
  51677. * @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)
  51678. */
  51679. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51680. /** Weight of the bloom to be added to the original input. */
  51681. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51682. }
  51683. }
  51684. declare module BABYLON {
  51685. /**
  51686. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51687. */
  51688. export class BloomEffect extends PostProcessRenderEffect {
  51689. private bloomScale;
  51690. /**
  51691. * @hidden Internal
  51692. */ effects: Array<PostProcess>;
  51693. /**
  51694. * @hidden Internal
  51695. */ downscale: ExtractHighlightsPostProcess;
  51696. private _blurX;
  51697. private _blurY;
  51698. private _merge;
  51699. /**
  51700. * The luminance threshold to find bright areas of the image to bloom.
  51701. */
  51702. threshold: number;
  51703. /**
  51704. * The strength of the bloom.
  51705. */
  51706. weight: number;
  51707. /**
  51708. * Specifies the size of the bloom blur kernel, relative to the final output size
  51709. */
  51710. kernel: number;
  51711. /**
  51712. * Creates a new instance of @see BloomEffect
  51713. * @param scene The scene the effect belongs to.
  51714. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51715. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51716. * @param bloomWeight The the strength of bloom.
  51717. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51718. * @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)
  51719. */
  51720. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51721. /**
  51722. * Disposes each of the internal effects for a given camera.
  51723. * @param camera The camera to dispose the effect on.
  51724. */
  51725. disposeEffects(camera: Camera): void;
  51726. /**
  51727. * @hidden Internal
  51728. */ updateEffects(): void;
  51729. /**
  51730. * Internal
  51731. * @returns if all the contained post processes are ready.
  51732. * @hidden
  51733. */ isReady(): boolean;
  51734. }
  51735. }
  51736. declare module BABYLON {
  51737. /** @hidden */
  51738. export var chromaticAberrationPixelShader: {
  51739. name: string;
  51740. shader: string;
  51741. };
  51742. }
  51743. declare module BABYLON {
  51744. /**
  51745. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51746. */
  51747. export class ChromaticAberrationPostProcess extends PostProcess {
  51748. /**
  51749. * The amount of seperation of rgb channels (default: 30)
  51750. */
  51751. aberrationAmount: number;
  51752. /**
  51753. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51754. */
  51755. radialIntensity: number;
  51756. /**
  51757. * 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))
  51758. */
  51759. direction: Vector2;
  51760. /**
  51761. * 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))
  51762. */
  51763. centerPosition: Vector2;
  51764. /**
  51765. * Creates a new instance ChromaticAberrationPostProcess
  51766. * @param name The name of the effect.
  51767. * @param screenWidth The width of the screen to apply the effect on.
  51768. * @param screenHeight The height of the screen to apply the effect on.
  51769. * @param options The required width/height ratio to downsize to before computing the render pass.
  51770. * @param camera The camera to apply the render pass to.
  51771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51772. * @param engine The engine which the post process will be applied. (default: current engine)
  51773. * @param reusable If the post process can be reused on the same frame. (default: false)
  51774. * @param textureType Type of textures used when performing the post process. (default: 0)
  51775. * @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)
  51776. */
  51777. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51778. }
  51779. }
  51780. declare module BABYLON {
  51781. /** @hidden */
  51782. export var circleOfConfusionPixelShader: {
  51783. name: string;
  51784. shader: string;
  51785. };
  51786. }
  51787. declare module BABYLON {
  51788. /**
  51789. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51790. */
  51791. export class CircleOfConfusionPostProcess extends PostProcess {
  51792. /**
  51793. * 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.
  51794. */
  51795. lensSize: number;
  51796. /**
  51797. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51798. */
  51799. fStop: number;
  51800. /**
  51801. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51802. */
  51803. focusDistance: number;
  51804. /**
  51805. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51806. */
  51807. focalLength: number;
  51808. private _depthTexture;
  51809. /**
  51810. * Creates a new instance CircleOfConfusionPostProcess
  51811. * @param name The name of the effect.
  51812. * @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.
  51813. * @param options The required width/height ratio to downsize to before computing the render pass.
  51814. * @param camera The camera to apply the render pass to.
  51815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51816. * @param engine The engine which the post process will be applied. (default: current engine)
  51817. * @param reusable If the post process can be reused on the same frame. (default: false)
  51818. * @param textureType Type of textures used when performing the post process. (default: 0)
  51819. * @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)
  51820. */
  51821. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51822. /**
  51823. * 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.
  51824. */
  51825. depthTexture: RenderTargetTexture;
  51826. }
  51827. }
  51828. declare module BABYLON {
  51829. /** @hidden */
  51830. export var colorCorrectionPixelShader: {
  51831. name: string;
  51832. shader: string;
  51833. };
  51834. }
  51835. declare module BABYLON {
  51836. /**
  51837. *
  51838. * This post-process allows the modification of rendered colors by using
  51839. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51840. *
  51841. * The object needs to be provided an url to a texture containing the color
  51842. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51843. * Use an image editing software to tweak the LUT to match your needs.
  51844. *
  51845. * For an example of a color LUT, see here:
  51846. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51847. * For explanations on color grading, see here:
  51848. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51849. *
  51850. */
  51851. export class ColorCorrectionPostProcess extends PostProcess {
  51852. private _colorTableTexture;
  51853. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51854. }
  51855. }
  51856. declare module BABYLON {
  51857. /** @hidden */
  51858. export var convolutionPixelShader: {
  51859. name: string;
  51860. shader: string;
  51861. };
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51866. * input texture to perform effects such as edge detection or sharpening
  51867. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51868. */
  51869. export class ConvolutionPostProcess extends PostProcess {
  51870. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51871. kernel: number[];
  51872. /**
  51873. * Creates a new instance ConvolutionPostProcess
  51874. * @param name The name of the effect.
  51875. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51876. * @param options The required width/height ratio to downsize to before computing the render pass.
  51877. * @param camera The camera to apply the render pass to.
  51878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51879. * @param engine The engine which the post process will be applied. (default: current engine)
  51880. * @param reusable If the post process can be reused on the same frame. (default: false)
  51881. * @param textureType Type of textures used when performing the post process. (default: 0)
  51882. */
  51883. constructor(name: string,
  51884. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51885. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51886. /**
  51887. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51888. */
  51889. static EdgeDetect0Kernel: number[];
  51890. /**
  51891. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51892. */
  51893. static EdgeDetect1Kernel: number[];
  51894. /**
  51895. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51896. */
  51897. static EdgeDetect2Kernel: number[];
  51898. /**
  51899. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51900. */
  51901. static SharpenKernel: number[];
  51902. /**
  51903. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51904. */
  51905. static EmbossKernel: number[];
  51906. /**
  51907. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51908. */
  51909. static GaussianKernel: number[];
  51910. }
  51911. }
  51912. declare module BABYLON {
  51913. /**
  51914. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51915. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51916. * based on samples that have a large difference in distance than the center pixel.
  51917. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51918. */
  51919. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51920. direction: Vector2;
  51921. /**
  51922. * Creates a new instance CircleOfConfusionPostProcess
  51923. * @param name The name of the effect.
  51924. * @param scene The scene the effect belongs to.
  51925. * @param direction The direction the blur should be applied.
  51926. * @param kernel The size of the kernel used to blur.
  51927. * @param options The required width/height ratio to downsize to before computing the render pass.
  51928. * @param camera The camera to apply the render pass to.
  51929. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51930. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51932. * @param engine The engine which the post process will be applied. (default: current engine)
  51933. * @param reusable If the post process can be reused on the same frame. (default: false)
  51934. * @param textureType Type of textures used when performing the post process. (default: 0)
  51935. * @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)
  51936. */
  51937. 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);
  51938. }
  51939. }
  51940. declare module BABYLON {
  51941. /** @hidden */
  51942. export var depthOfFieldMergePixelShader: {
  51943. name: string;
  51944. shader: string;
  51945. };
  51946. }
  51947. declare module BABYLON {
  51948. /**
  51949. * Options to be set when merging outputs from the default pipeline.
  51950. */
  51951. export class DepthOfFieldMergePostProcessOptions {
  51952. /**
  51953. * The original image to merge on top of
  51954. */
  51955. originalFromInput: PostProcess;
  51956. /**
  51957. * Parameters to perform the merge of the depth of field effect
  51958. */
  51959. depthOfField?: {
  51960. circleOfConfusion: PostProcess;
  51961. blurSteps: Array<PostProcess>;
  51962. };
  51963. /**
  51964. * Parameters to perform the merge of bloom effect
  51965. */
  51966. bloom?: {
  51967. blurred: PostProcess;
  51968. weight: number;
  51969. };
  51970. }
  51971. /**
  51972. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51973. */
  51974. export class DepthOfFieldMergePostProcess extends PostProcess {
  51975. private blurSteps;
  51976. /**
  51977. * Creates a new instance of DepthOfFieldMergePostProcess
  51978. * @param name The name of the effect.
  51979. * @param originalFromInput Post process which's input will be used for the merge.
  51980. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51981. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51982. * @param options The required width/height ratio to downsize to before computing the render pass.
  51983. * @param camera The camera to apply the render pass to.
  51984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51985. * @param engine The engine which the post process will be applied. (default: current engine)
  51986. * @param reusable If the post process can be reused on the same frame. (default: false)
  51987. * @param textureType Type of textures used when performing the post process. (default: 0)
  51988. * @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)
  51989. */
  51990. 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);
  51991. /**
  51992. * Updates the effect with the current post process compile time values and recompiles the shader.
  51993. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51994. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51995. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51996. * @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
  51997. * @param onCompiled Called when the shader has been compiled.
  51998. * @param onError Called if there is an error when compiling a shader.
  51999. */
  52000. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52001. }
  52002. }
  52003. declare module BABYLON {
  52004. /**
  52005. * Specifies the level of max blur that should be applied when using the depth of field effect
  52006. */
  52007. export enum DepthOfFieldEffectBlurLevel {
  52008. /**
  52009. * Subtle blur
  52010. */
  52011. Low = 0,
  52012. /**
  52013. * Medium blur
  52014. */
  52015. Medium = 1,
  52016. /**
  52017. * Large blur
  52018. */
  52019. High = 2
  52020. }
  52021. /**
  52022. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52023. */
  52024. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52025. private _circleOfConfusion;
  52026. /**
  52027. * @hidden Internal, blurs from high to low
  52028. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52029. private _depthOfFieldBlurY;
  52030. private _dofMerge;
  52031. /**
  52032. * @hidden Internal post processes in depth of field effect
  52033. */ effects: Array<PostProcess>;
  52034. /**
  52035. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52036. */
  52037. focalLength: number;
  52038. /**
  52039. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52040. */
  52041. fStop: number;
  52042. /**
  52043. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52044. */
  52045. focusDistance: number;
  52046. /**
  52047. * 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.
  52048. */
  52049. lensSize: number;
  52050. /**
  52051. * Creates a new instance DepthOfFieldEffect
  52052. * @param scene The scene the effect belongs to.
  52053. * @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.
  52054. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52055. * @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)
  52056. */
  52057. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52058. /**
  52059. * Get the current class name of the current effet
  52060. * @returns "DepthOfFieldEffect"
  52061. */
  52062. getClassName(): string;
  52063. /**
  52064. * 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.
  52065. */
  52066. depthTexture: RenderTargetTexture;
  52067. /**
  52068. * Disposes each of the internal effects for a given camera.
  52069. * @param camera The camera to dispose the effect on.
  52070. */
  52071. disposeEffects(camera: Camera): void;
  52072. /**
  52073. * @hidden Internal
  52074. */ updateEffects(): void;
  52075. /**
  52076. * Internal
  52077. * @returns if all the contained post processes are ready.
  52078. * @hidden
  52079. */ isReady(): boolean;
  52080. }
  52081. }
  52082. declare module BABYLON {
  52083. /** @hidden */
  52084. export var displayPassPixelShader: {
  52085. name: string;
  52086. shader: string;
  52087. };
  52088. }
  52089. declare module BABYLON {
  52090. /**
  52091. * DisplayPassPostProcess which produces an output the same as it's input
  52092. */
  52093. export class DisplayPassPostProcess extends PostProcess {
  52094. /**
  52095. * Creates the DisplayPassPostProcess
  52096. * @param name The name of the effect.
  52097. * @param options The required width/height ratio to downsize to before computing the render pass.
  52098. * @param camera The camera to apply the render pass to.
  52099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52100. * @param engine The engine which the post process will be applied. (default: current engine)
  52101. * @param reusable If the post process can be reused on the same frame. (default: false)
  52102. */
  52103. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52104. }
  52105. }
  52106. declare module BABYLON {
  52107. /** @hidden */
  52108. export var filterPixelShader: {
  52109. name: string;
  52110. shader: string;
  52111. };
  52112. }
  52113. declare module BABYLON {
  52114. /**
  52115. * Applies a kernel filter to the image
  52116. */
  52117. export class FilterPostProcess extends PostProcess {
  52118. /** The matrix to be applied to the image */
  52119. kernelMatrix: Matrix;
  52120. /**
  52121. *
  52122. * @param name The name of the effect.
  52123. * @param kernelMatrix The matrix to be applied to the image
  52124. * @param options The required width/height ratio to downsize to before computing the render pass.
  52125. * @param camera The camera to apply the render pass to.
  52126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52127. * @param engine The engine which the post process will be applied. (default: current engine)
  52128. * @param reusable If the post process can be reused on the same frame. (default: false)
  52129. */
  52130. constructor(name: string,
  52131. /** The matrix to be applied to the image */
  52132. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52133. }
  52134. }
  52135. declare module BABYLON {
  52136. /** @hidden */
  52137. export var fxaaPixelShader: {
  52138. name: string;
  52139. shader: string;
  52140. };
  52141. }
  52142. declare module BABYLON {
  52143. /** @hidden */
  52144. export var fxaaVertexShader: {
  52145. name: string;
  52146. shader: string;
  52147. };
  52148. }
  52149. declare module BABYLON {
  52150. /**
  52151. * Fxaa post process
  52152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52153. */
  52154. export class FxaaPostProcess extends PostProcess {
  52155. /** @hidden */
  52156. texelWidth: number;
  52157. /** @hidden */
  52158. texelHeight: number;
  52159. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52160. private _getDefines;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. /** @hidden */
  52165. export var grainPixelShader: {
  52166. name: string;
  52167. shader: string;
  52168. };
  52169. }
  52170. declare module BABYLON {
  52171. /**
  52172. * The GrainPostProcess adds noise to the image at mid luminance levels
  52173. */
  52174. export class GrainPostProcess extends PostProcess {
  52175. /**
  52176. * The intensity of the grain added (default: 30)
  52177. */
  52178. intensity: number;
  52179. /**
  52180. * If the grain should be randomized on every frame
  52181. */
  52182. animated: boolean;
  52183. /**
  52184. * Creates a new instance of @see GrainPostProcess
  52185. * @param name The name of the effect.
  52186. * @param options The required width/height ratio to downsize to before computing the render pass.
  52187. * @param camera The camera to apply the render pass to.
  52188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52189. * @param engine The engine which the post process will be applied. (default: current engine)
  52190. * @param reusable If the post process can be reused on the same frame. (default: false)
  52191. * @param textureType Type of textures used when performing the post process. (default: 0)
  52192. * @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)
  52193. */
  52194. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52195. }
  52196. }
  52197. declare module BABYLON {
  52198. /** @hidden */
  52199. export var highlightsPixelShader: {
  52200. name: string;
  52201. shader: string;
  52202. };
  52203. }
  52204. declare module BABYLON {
  52205. /**
  52206. * Extracts highlights from the image
  52207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52208. */
  52209. export class HighlightsPostProcess extends PostProcess {
  52210. /**
  52211. * Extracts highlights from the image
  52212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52213. * @param name The name of the effect.
  52214. * @param options The required width/height ratio to downsize to before computing the render pass.
  52215. * @param camera The camera to apply the render pass to.
  52216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52217. * @param engine The engine which the post process will be applied. (default: current engine)
  52218. * @param reusable If the post process can be reused on the same frame. (default: false)
  52219. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52220. */
  52221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52222. }
  52223. }
  52224. declare module BABYLON {
  52225. /** @hidden */
  52226. export var mrtFragmentDeclaration: {
  52227. name: string;
  52228. shader: string;
  52229. };
  52230. }
  52231. declare module BABYLON {
  52232. /** @hidden */
  52233. export var geometryPixelShader: {
  52234. name: string;
  52235. shader: string;
  52236. };
  52237. }
  52238. declare module BABYLON {
  52239. /** @hidden */
  52240. export var geometryVertexShader: {
  52241. name: string;
  52242. shader: string;
  52243. };
  52244. }
  52245. declare module BABYLON {
  52246. /**
  52247. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52248. */
  52249. export class GeometryBufferRenderer {
  52250. /**
  52251. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52252. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52253. */
  52254. static readonly POSITION_TEXTURE_TYPE: number;
  52255. /**
  52256. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52257. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52258. */
  52259. static readonly VELOCITY_TEXTURE_TYPE: number;
  52260. /**
  52261. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52262. * in order to compute objects velocities when enableVelocity is set to "true"
  52263. * @hidden
  52264. */ previousTransformationMatrices: {
  52265. [index: number]: Matrix;
  52266. };
  52267. private _scene;
  52268. private _multiRenderTarget;
  52269. private _ratio;
  52270. private _enablePosition;
  52271. private _enableVelocity;
  52272. private _positionIndex;
  52273. private _velocityIndex;
  52274. protected _effect: Effect;
  52275. protected _cachedDefines: string;
  52276. /**
  52277. * Set the render list (meshes to be rendered) used in the G buffer.
  52278. */
  52279. renderList: Mesh[];
  52280. /**
  52281. * Gets wether or not G buffer are supported by the running hardware.
  52282. * This requires draw buffer supports
  52283. */
  52284. readonly isSupported: boolean;
  52285. /**
  52286. * Returns the index of the given texture type in the G-Buffer textures array
  52287. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52288. * @returns the index of the given texture type in the G-Buffer textures array
  52289. */
  52290. getTextureIndex(textureType: number): number;
  52291. /**
  52292. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52293. */
  52294. /**
  52295. * Sets whether or not objects positions are enabled for the G buffer.
  52296. */
  52297. enablePosition: boolean;
  52298. /**
  52299. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52300. */
  52301. /**
  52302. * Sets wether or not objects velocities are enabled for the G buffer.
  52303. */
  52304. enableVelocity: boolean;
  52305. /**
  52306. * Gets the scene associated with the buffer.
  52307. */
  52308. readonly scene: Scene;
  52309. /**
  52310. * Gets the ratio used by the buffer during its creation.
  52311. * How big is the buffer related to the main canvas.
  52312. */
  52313. readonly ratio: number;
  52314. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  52315. /**
  52316. * Creates a new G Buffer for the scene
  52317. * @param scene The scene the buffer belongs to
  52318. * @param ratio How big is the buffer related to the main canvas.
  52319. */
  52320. constructor(scene: Scene, ratio?: number);
  52321. /**
  52322. * Checks wether everything is ready to render a submesh to the G buffer.
  52323. * @param subMesh the submesh to check readiness for
  52324. * @param useInstances is the mesh drawn using instance or not
  52325. * @returns true if ready otherwise false
  52326. */
  52327. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52328. /**
  52329. * Gets the current underlying G Buffer.
  52330. * @returns the buffer
  52331. */
  52332. getGBuffer(): MultiRenderTarget;
  52333. /**
  52334. * Gets the number of samples used to render the buffer (anti aliasing).
  52335. */
  52336. /**
  52337. * Sets the number of samples used to render the buffer (anti aliasing).
  52338. */
  52339. samples: number;
  52340. /**
  52341. * Disposes the renderer and frees up associated resources.
  52342. */
  52343. dispose(): void;
  52344. protected _createRenderTargets(): void;
  52345. }
  52346. }
  52347. declare module BABYLON {
  52348. interface Scene {
  52349. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52350. /**
  52351. * Gets or Sets the current geometry buffer associated to the scene.
  52352. */
  52353. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52354. /**
  52355. * Enables a GeometryBufferRender and associates it with the scene
  52356. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52357. * @returns the GeometryBufferRenderer
  52358. */
  52359. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52360. /**
  52361. * Disables the GeometryBufferRender associated with the scene
  52362. */
  52363. disableGeometryBufferRenderer(): void;
  52364. }
  52365. /**
  52366. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52367. * in several rendering techniques.
  52368. */
  52369. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52370. /**
  52371. * The component name helpful to identify the component in the list of scene components.
  52372. */
  52373. readonly name: string;
  52374. /**
  52375. * The scene the component belongs to.
  52376. */
  52377. scene: Scene;
  52378. /**
  52379. * Creates a new instance of the component for the given scene
  52380. * @param scene Defines the scene to register the component in
  52381. */
  52382. constructor(scene: Scene);
  52383. /**
  52384. * Registers the component in a given scene
  52385. */
  52386. register(): void;
  52387. /**
  52388. * Rebuilds the elements related to this component in case of
  52389. * context lost for instance.
  52390. */
  52391. rebuild(): void;
  52392. /**
  52393. * Disposes the component and the associated ressources
  52394. */
  52395. dispose(): void;
  52396. private _gatherRenderTargets;
  52397. }
  52398. }
  52399. declare module BABYLON {
  52400. /** @hidden */
  52401. export var motionBlurPixelShader: {
  52402. name: string;
  52403. shader: string;
  52404. };
  52405. }
  52406. declare module BABYLON {
  52407. /**
  52408. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52409. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52410. * As an example, all you have to do is to create the post-process:
  52411. * var mb = new BABYLON.MotionBlurPostProcess(
  52412. * 'mb', // The name of the effect.
  52413. * scene, // The scene containing the objects to blur according to their velocity.
  52414. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52415. * camera // The camera to apply the render pass to.
  52416. * );
  52417. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52418. */
  52419. export class MotionBlurPostProcess extends PostProcess {
  52420. /**
  52421. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52422. */
  52423. motionStrength: number;
  52424. /**
  52425. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52426. */
  52427. /**
  52428. * Sets the number of iterations to be used for motion blur quality
  52429. */
  52430. motionBlurSamples: number;
  52431. private _motionBlurSamples;
  52432. private _geometryBufferRenderer;
  52433. /**
  52434. * Creates a new instance MotionBlurPostProcess
  52435. * @param name The name of the effect.
  52436. * @param scene The scene containing the objects to blur according to their velocity.
  52437. * @param options The required width/height ratio to downsize to before computing the render pass.
  52438. * @param camera The camera to apply the render pass to.
  52439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52440. * @param engine The engine which the post process will be applied. (default: current engine)
  52441. * @param reusable If the post process can be reused on the same frame. (default: false)
  52442. * @param textureType Type of textures used when performing the post process. (default: 0)
  52443. * @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)
  52444. */
  52445. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52446. /**
  52447. * Disposes the post process.
  52448. * @param camera The camera to dispose the post process on.
  52449. */
  52450. dispose(camera?: Camera): void;
  52451. }
  52452. }
  52453. declare module BABYLON {
  52454. /** @hidden */
  52455. export var refractionPixelShader: {
  52456. name: string;
  52457. shader: string;
  52458. };
  52459. }
  52460. declare module BABYLON {
  52461. /**
  52462. * Post process which applies a refractin texture
  52463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52464. */
  52465. export class RefractionPostProcess extends PostProcess {
  52466. /** the base color of the refraction (used to taint the rendering) */
  52467. color: Color3;
  52468. /** simulated refraction depth */
  52469. depth: number;
  52470. /** the coefficient of the base color (0 to remove base color tainting) */
  52471. colorLevel: number;
  52472. private _refTexture;
  52473. private _ownRefractionTexture;
  52474. /**
  52475. * Gets or sets the refraction texture
  52476. * Please note that you are responsible for disposing the texture if you set it manually
  52477. */
  52478. refractionTexture: Texture;
  52479. /**
  52480. * Initializes the RefractionPostProcess
  52481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52482. * @param name The name of the effect.
  52483. * @param refractionTextureUrl Url of the refraction texture to use
  52484. * @param color the base color of the refraction (used to taint the rendering)
  52485. * @param depth simulated refraction depth
  52486. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52487. * @param camera The camera to apply the render pass to.
  52488. * @param options The required width/height ratio to downsize to before computing the render pass.
  52489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52490. * @param engine The engine which the post process will be applied. (default: current engine)
  52491. * @param reusable If the post process can be reused on the same frame. (default: false)
  52492. */
  52493. constructor(name: string, refractionTextureUrl: string,
  52494. /** the base color of the refraction (used to taint the rendering) */
  52495. color: Color3,
  52496. /** simulated refraction depth */
  52497. depth: number,
  52498. /** the coefficient of the base color (0 to remove base color tainting) */
  52499. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52500. /**
  52501. * Disposes of the post process
  52502. * @param camera Camera to dispose post process on
  52503. */
  52504. dispose(camera: Camera): void;
  52505. }
  52506. }
  52507. declare module BABYLON {
  52508. /** @hidden */
  52509. export var sharpenPixelShader: {
  52510. name: string;
  52511. shader: string;
  52512. };
  52513. }
  52514. declare module BABYLON {
  52515. /**
  52516. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52517. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52518. */
  52519. export class SharpenPostProcess extends PostProcess {
  52520. /**
  52521. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52522. */
  52523. colorAmount: number;
  52524. /**
  52525. * How much sharpness should be applied (default: 0.3)
  52526. */
  52527. edgeAmount: number;
  52528. /**
  52529. * Creates a new instance ConvolutionPostProcess
  52530. * @param name The name of the effect.
  52531. * @param options The required width/height ratio to downsize to before computing the render pass.
  52532. * @param camera The camera to apply the render pass to.
  52533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52534. * @param engine The engine which the post process will be applied. (default: current engine)
  52535. * @param reusable If the post process can be reused on the same frame. (default: false)
  52536. * @param textureType Type of textures used when performing the post process. (default: 0)
  52537. * @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)
  52538. */
  52539. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52540. }
  52541. }
  52542. declare module BABYLON {
  52543. /**
  52544. * PostProcessRenderPipeline
  52545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52546. */
  52547. export class PostProcessRenderPipeline {
  52548. private engine;
  52549. private _renderEffects;
  52550. private _renderEffectsForIsolatedPass;
  52551. /**
  52552. * List of inspectable custom properties (used by the Inspector)
  52553. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52554. */
  52555. inspectableCustomProperties: IInspectable[];
  52556. /**
  52557. * @hidden
  52558. */
  52559. protected _cameras: Camera[];
  52560. /** @hidden */ name: string;
  52561. /**
  52562. * Gets pipeline name
  52563. */
  52564. readonly name: string;
  52565. /**
  52566. * Initializes a PostProcessRenderPipeline
  52567. * @param engine engine to add the pipeline to
  52568. * @param name name of the pipeline
  52569. */
  52570. constructor(engine: Engine, name: string);
  52571. /**
  52572. * Gets the class name
  52573. * @returns "PostProcessRenderPipeline"
  52574. */
  52575. getClassName(): string;
  52576. /**
  52577. * If all the render effects in the pipeline are supported
  52578. */
  52579. readonly isSupported: boolean;
  52580. /**
  52581. * Adds an effect to the pipeline
  52582. * @param renderEffect the effect to add
  52583. */
  52584. addEffect(renderEffect: PostProcessRenderEffect): void;
  52585. /** @hidden */ rebuild(): void;
  52586. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52587. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52588. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52589. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52590. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52591. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52592. /** @hidden */ detachCameras(cameras: Camera): void;
  52593. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52594. /** @hidden */ update(): void;
  52595. /** @hidden */ reset(): void;
  52596. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52597. /**
  52598. * Disposes of the pipeline
  52599. */
  52600. dispose(): void;
  52601. }
  52602. }
  52603. declare module BABYLON {
  52604. /**
  52605. * PostProcessRenderPipelineManager class
  52606. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52607. */
  52608. export class PostProcessRenderPipelineManager {
  52609. private _renderPipelines;
  52610. /**
  52611. * Initializes a PostProcessRenderPipelineManager
  52612. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52613. */
  52614. constructor();
  52615. /**
  52616. * Gets the list of supported render pipelines
  52617. */
  52618. readonly supportedPipelines: PostProcessRenderPipeline[];
  52619. /**
  52620. * Adds a pipeline to the manager
  52621. * @param renderPipeline The pipeline to add
  52622. */
  52623. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52624. /**
  52625. * Attaches a camera to the pipeline
  52626. * @param renderPipelineName The name of the pipeline to attach to
  52627. * @param cameras the camera to attach
  52628. * @param unique if the camera can be attached multiple times to the pipeline
  52629. */
  52630. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52631. /**
  52632. * Detaches a camera from the pipeline
  52633. * @param renderPipelineName The name of the pipeline to detach from
  52634. * @param cameras the camera to detach
  52635. */
  52636. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52637. /**
  52638. * Enables an effect by name on a pipeline
  52639. * @param renderPipelineName the name of the pipeline to enable the effect in
  52640. * @param renderEffectName the name of the effect to enable
  52641. * @param cameras the cameras that the effect should be enabled on
  52642. */
  52643. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52644. /**
  52645. * Disables an effect by name on a pipeline
  52646. * @param renderPipelineName the name of the pipeline to disable the effect in
  52647. * @param renderEffectName the name of the effect to disable
  52648. * @param cameras the cameras that the effect should be disabled on
  52649. */
  52650. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52651. /**
  52652. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52653. */
  52654. update(): void;
  52655. /** @hidden */ rebuild(): void;
  52656. /**
  52657. * Disposes of the manager and pipelines
  52658. */
  52659. dispose(): void;
  52660. }
  52661. }
  52662. declare module BABYLON {
  52663. interface Scene {
  52664. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52665. /**
  52666. * Gets the postprocess render pipeline manager
  52667. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52668. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52669. */
  52670. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52671. }
  52672. /**
  52673. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52674. */
  52675. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52676. /**
  52677. * The component name helpfull to identify the component in the list of scene components.
  52678. */
  52679. readonly name: string;
  52680. /**
  52681. * The scene the component belongs to.
  52682. */
  52683. scene: Scene;
  52684. /**
  52685. * Creates a new instance of the component for the given scene
  52686. * @param scene Defines the scene to register the component in
  52687. */
  52688. constructor(scene: Scene);
  52689. /**
  52690. * Registers the component in a given scene
  52691. */
  52692. register(): void;
  52693. /**
  52694. * Rebuilds the elements related to this component in case of
  52695. * context lost for instance.
  52696. */
  52697. rebuild(): void;
  52698. /**
  52699. * Disposes the component and the associated ressources
  52700. */
  52701. dispose(): void;
  52702. private _gatherRenderTargets;
  52703. }
  52704. }
  52705. declare module BABYLON {
  52706. /**
  52707. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52708. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52709. */
  52710. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52711. private _scene;
  52712. private _camerasToBeAttached;
  52713. /**
  52714. * ID of the sharpen post process,
  52715. */
  52716. private readonly SharpenPostProcessId;
  52717. /**
  52718. * @ignore
  52719. * ID of the image processing post process;
  52720. */
  52721. readonly ImageProcessingPostProcessId: string;
  52722. /**
  52723. * @ignore
  52724. * ID of the Fast Approximate Anti-Aliasing post process;
  52725. */
  52726. readonly FxaaPostProcessId: string;
  52727. /**
  52728. * ID of the chromatic aberration post process,
  52729. */
  52730. private readonly ChromaticAberrationPostProcessId;
  52731. /**
  52732. * ID of the grain post process
  52733. */
  52734. private readonly GrainPostProcessId;
  52735. /**
  52736. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52737. */
  52738. sharpen: SharpenPostProcess;
  52739. private _sharpenEffect;
  52740. private bloom;
  52741. /**
  52742. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52743. */
  52744. depthOfField: DepthOfFieldEffect;
  52745. /**
  52746. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52747. */
  52748. fxaa: FxaaPostProcess;
  52749. /**
  52750. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52751. */
  52752. imageProcessing: ImageProcessingPostProcess;
  52753. /**
  52754. * Chromatic aberration post process which will shift rgb colors in the image
  52755. */
  52756. chromaticAberration: ChromaticAberrationPostProcess;
  52757. private _chromaticAberrationEffect;
  52758. /**
  52759. * Grain post process which add noise to the image
  52760. */
  52761. grain: GrainPostProcess;
  52762. private _grainEffect;
  52763. /**
  52764. * Glow post process which adds a glow to emissive areas of the image
  52765. */
  52766. private _glowLayer;
  52767. /**
  52768. * Animations which can be used to tweak settings over a period of time
  52769. */
  52770. animations: Animation[];
  52771. private _imageProcessingConfigurationObserver;
  52772. private _sharpenEnabled;
  52773. private _bloomEnabled;
  52774. private _depthOfFieldEnabled;
  52775. private _depthOfFieldBlurLevel;
  52776. private _fxaaEnabled;
  52777. private _imageProcessingEnabled;
  52778. private _defaultPipelineTextureType;
  52779. private _bloomScale;
  52780. private _chromaticAberrationEnabled;
  52781. private _grainEnabled;
  52782. private _buildAllowed;
  52783. /**
  52784. * Gets active scene
  52785. */
  52786. readonly scene: Scene;
  52787. /**
  52788. * Enable or disable the sharpen process from the pipeline
  52789. */
  52790. sharpenEnabled: boolean;
  52791. private _resizeObserver;
  52792. private _hardwareScaleLevel;
  52793. private _bloomKernel;
  52794. /**
  52795. * Specifies the size of the bloom blur kernel, relative to the final output size
  52796. */
  52797. bloomKernel: number;
  52798. /**
  52799. * Specifies the weight of the bloom in the final rendering
  52800. */
  52801. private _bloomWeight;
  52802. /**
  52803. * Specifies the luma threshold for the area that will be blurred by the bloom
  52804. */
  52805. private _bloomThreshold;
  52806. private _hdr;
  52807. /**
  52808. * The strength of the bloom.
  52809. */
  52810. bloomWeight: number;
  52811. /**
  52812. * The strength of the bloom.
  52813. */
  52814. bloomThreshold: number;
  52815. /**
  52816. * The scale of the bloom, lower value will provide better performance.
  52817. */
  52818. bloomScale: number;
  52819. /**
  52820. * Enable or disable the bloom from the pipeline
  52821. */
  52822. bloomEnabled: boolean;
  52823. private _rebuildBloom;
  52824. /**
  52825. * If the depth of field is enabled.
  52826. */
  52827. depthOfFieldEnabled: boolean;
  52828. /**
  52829. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52830. */
  52831. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52832. /**
  52833. * If the anti aliasing is enabled.
  52834. */
  52835. fxaaEnabled: boolean;
  52836. private _samples;
  52837. /**
  52838. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52839. */
  52840. samples: number;
  52841. /**
  52842. * If image processing is enabled.
  52843. */
  52844. imageProcessingEnabled: boolean;
  52845. /**
  52846. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52847. */
  52848. glowLayerEnabled: boolean;
  52849. /**
  52850. * Gets the glow layer (or null if not defined)
  52851. */
  52852. readonly glowLayer: Nullable<GlowLayer>;
  52853. /**
  52854. * Enable or disable the chromaticAberration process from the pipeline
  52855. */
  52856. chromaticAberrationEnabled: boolean;
  52857. /**
  52858. * Enable or disable the grain process from the pipeline
  52859. */
  52860. grainEnabled: boolean;
  52861. /**
  52862. * @constructor
  52863. * @param name - The rendering pipeline name (default: "")
  52864. * @param hdr - If high dynamic range textures should be used (default: true)
  52865. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52866. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52867. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52868. */
  52869. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52870. /**
  52871. * Get the class name
  52872. * @returns "DefaultRenderingPipeline"
  52873. */
  52874. getClassName(): string;
  52875. /**
  52876. * Force the compilation of the entire pipeline.
  52877. */
  52878. prepare(): void;
  52879. private _hasCleared;
  52880. private _prevPostProcess;
  52881. private _prevPrevPostProcess;
  52882. private _setAutoClearAndTextureSharing;
  52883. private _depthOfFieldSceneObserver;
  52884. private _buildPipeline;
  52885. private _disposePostProcesses;
  52886. /**
  52887. * Adds a camera to the pipeline
  52888. * @param camera the camera to be added
  52889. */
  52890. addCamera(camera: Camera): void;
  52891. /**
  52892. * Removes a camera from the pipeline
  52893. * @param camera the camera to remove
  52894. */
  52895. removeCamera(camera: Camera): void;
  52896. /**
  52897. * Dispose of the pipeline and stop all post processes
  52898. */
  52899. dispose(): void;
  52900. /**
  52901. * Serialize the rendering pipeline (Used when exporting)
  52902. * @returns the serialized object
  52903. */
  52904. serialize(): any;
  52905. /**
  52906. * Parse the serialized pipeline
  52907. * @param source Source pipeline.
  52908. * @param scene The scene to load the pipeline to.
  52909. * @param rootUrl The URL of the serialized pipeline.
  52910. * @returns An instantiated pipeline from the serialized object.
  52911. */
  52912. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52913. }
  52914. }
  52915. declare module BABYLON {
  52916. /** @hidden */
  52917. export var lensHighlightsPixelShader: {
  52918. name: string;
  52919. shader: string;
  52920. };
  52921. }
  52922. declare module BABYLON {
  52923. /** @hidden */
  52924. export var depthOfFieldPixelShader: {
  52925. name: string;
  52926. shader: string;
  52927. };
  52928. }
  52929. declare module BABYLON {
  52930. /**
  52931. * BABYLON.JS Chromatic Aberration GLSL Shader
  52932. * Author: Olivier Guyot
  52933. * Separates very slightly R, G and B colors on the edges of the screen
  52934. * Inspired by Francois Tarlier & Martins Upitis
  52935. */
  52936. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52937. /**
  52938. * @ignore
  52939. * The chromatic aberration PostProcess id in the pipeline
  52940. */
  52941. LensChromaticAberrationEffect: string;
  52942. /**
  52943. * @ignore
  52944. * The highlights enhancing PostProcess id in the pipeline
  52945. */
  52946. HighlightsEnhancingEffect: string;
  52947. /**
  52948. * @ignore
  52949. * The depth-of-field PostProcess id in the pipeline
  52950. */
  52951. LensDepthOfFieldEffect: string;
  52952. private _scene;
  52953. private _depthTexture;
  52954. private _grainTexture;
  52955. private _chromaticAberrationPostProcess;
  52956. private _highlightsPostProcess;
  52957. private _depthOfFieldPostProcess;
  52958. private _edgeBlur;
  52959. private _grainAmount;
  52960. private _chromaticAberration;
  52961. private _distortion;
  52962. private _highlightsGain;
  52963. private _highlightsThreshold;
  52964. private _dofDistance;
  52965. private _dofAperture;
  52966. private _dofDarken;
  52967. private _dofPentagon;
  52968. private _blurNoise;
  52969. /**
  52970. * @constructor
  52971. *
  52972. * Effect parameters are as follow:
  52973. * {
  52974. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52975. * edge_blur: number; // from 0 to x (1 for realism)
  52976. * distortion: number; // from 0 to x (1 for realism)
  52977. * grain_amount: number; // from 0 to 1
  52978. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52979. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52980. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52981. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52982. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52983. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52984. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52985. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52986. * }
  52987. * Note: if an effect parameter is unset, effect is disabled
  52988. *
  52989. * @param name The rendering pipeline name
  52990. * @param parameters - An object containing all parameters (see above)
  52991. * @param scene The scene linked to this pipeline
  52992. * @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)
  52993. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52994. */
  52995. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52996. /**
  52997. * Get the class name
  52998. * @returns "LensRenderingPipeline"
  52999. */
  53000. getClassName(): string;
  53001. /**
  53002. * Gets associated scene
  53003. */
  53004. readonly scene: Scene;
  53005. /**
  53006. * Gets or sets the edge blur
  53007. */
  53008. edgeBlur: number;
  53009. /**
  53010. * Gets or sets the grain amount
  53011. */
  53012. grainAmount: number;
  53013. /**
  53014. * Gets or sets the chromatic aberration amount
  53015. */
  53016. chromaticAberration: number;
  53017. /**
  53018. * Gets or sets the depth of field aperture
  53019. */
  53020. dofAperture: number;
  53021. /**
  53022. * Gets or sets the edge distortion
  53023. */
  53024. edgeDistortion: number;
  53025. /**
  53026. * Gets or sets the depth of field distortion
  53027. */
  53028. dofDistortion: number;
  53029. /**
  53030. * Gets or sets the darken out of focus amount
  53031. */
  53032. darkenOutOfFocus: number;
  53033. /**
  53034. * Gets or sets a boolean indicating if blur noise is enabled
  53035. */
  53036. blurNoise: boolean;
  53037. /**
  53038. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53039. */
  53040. pentagonBokeh: boolean;
  53041. /**
  53042. * Gets or sets the highlight grain amount
  53043. */
  53044. highlightsGain: number;
  53045. /**
  53046. * Gets or sets the highlight threshold
  53047. */
  53048. highlightsThreshold: number;
  53049. /**
  53050. * Sets the amount of blur at the edges
  53051. * @param amount blur amount
  53052. */
  53053. setEdgeBlur(amount: number): void;
  53054. /**
  53055. * Sets edge blur to 0
  53056. */
  53057. disableEdgeBlur(): void;
  53058. /**
  53059. * Sets the amout of grain
  53060. * @param amount Amount of grain
  53061. */
  53062. setGrainAmount(amount: number): void;
  53063. /**
  53064. * Set grain amount to 0
  53065. */
  53066. disableGrain(): void;
  53067. /**
  53068. * Sets the chromatic aberration amount
  53069. * @param amount amount of chromatic aberration
  53070. */
  53071. setChromaticAberration(amount: number): void;
  53072. /**
  53073. * Sets chromatic aberration amount to 0
  53074. */
  53075. disableChromaticAberration(): void;
  53076. /**
  53077. * Sets the EdgeDistortion amount
  53078. * @param amount amount of EdgeDistortion
  53079. */
  53080. setEdgeDistortion(amount: number): void;
  53081. /**
  53082. * Sets edge distortion to 0
  53083. */
  53084. disableEdgeDistortion(): void;
  53085. /**
  53086. * Sets the FocusDistance amount
  53087. * @param amount amount of FocusDistance
  53088. */
  53089. setFocusDistance(amount: number): void;
  53090. /**
  53091. * Disables depth of field
  53092. */
  53093. disableDepthOfField(): void;
  53094. /**
  53095. * Sets the Aperture amount
  53096. * @param amount amount of Aperture
  53097. */
  53098. setAperture(amount: number): void;
  53099. /**
  53100. * Sets the DarkenOutOfFocus amount
  53101. * @param amount amount of DarkenOutOfFocus
  53102. */
  53103. setDarkenOutOfFocus(amount: number): void;
  53104. private _pentagonBokehIsEnabled;
  53105. /**
  53106. * Creates a pentagon bokeh effect
  53107. */
  53108. enablePentagonBokeh(): void;
  53109. /**
  53110. * Disables the pentagon bokeh effect
  53111. */
  53112. disablePentagonBokeh(): void;
  53113. /**
  53114. * Enables noise blur
  53115. */
  53116. enableNoiseBlur(): void;
  53117. /**
  53118. * Disables noise blur
  53119. */
  53120. disableNoiseBlur(): void;
  53121. /**
  53122. * Sets the HighlightsGain amount
  53123. * @param amount amount of HighlightsGain
  53124. */
  53125. setHighlightsGain(amount: number): void;
  53126. /**
  53127. * Sets the HighlightsThreshold amount
  53128. * @param amount amount of HighlightsThreshold
  53129. */
  53130. setHighlightsThreshold(amount: number): void;
  53131. /**
  53132. * Disables highlights
  53133. */
  53134. disableHighlights(): void;
  53135. /**
  53136. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53137. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53138. */
  53139. dispose(disableDepthRender?: boolean): void;
  53140. private _createChromaticAberrationPostProcess;
  53141. private _createHighlightsPostProcess;
  53142. private _createDepthOfFieldPostProcess;
  53143. private _createGrainTexture;
  53144. }
  53145. }
  53146. declare module BABYLON {
  53147. /** @hidden */
  53148. export var ssao2PixelShader: {
  53149. name: string;
  53150. shader: string;
  53151. };
  53152. }
  53153. declare module BABYLON {
  53154. /** @hidden */
  53155. export var ssaoCombinePixelShader: {
  53156. name: string;
  53157. shader: string;
  53158. };
  53159. }
  53160. declare module BABYLON {
  53161. /**
  53162. * Render pipeline to produce ssao effect
  53163. */
  53164. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53165. /**
  53166. * @ignore
  53167. * The PassPostProcess id in the pipeline that contains the original scene color
  53168. */
  53169. SSAOOriginalSceneColorEffect: string;
  53170. /**
  53171. * @ignore
  53172. * The SSAO PostProcess id in the pipeline
  53173. */
  53174. SSAORenderEffect: string;
  53175. /**
  53176. * @ignore
  53177. * The horizontal blur PostProcess id in the pipeline
  53178. */
  53179. SSAOBlurHRenderEffect: string;
  53180. /**
  53181. * @ignore
  53182. * The vertical blur PostProcess id in the pipeline
  53183. */
  53184. SSAOBlurVRenderEffect: string;
  53185. /**
  53186. * @ignore
  53187. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53188. */
  53189. SSAOCombineRenderEffect: string;
  53190. /**
  53191. * The output strength of the SSAO post-process. Default value is 1.0.
  53192. */
  53193. totalStrength: number;
  53194. /**
  53195. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53196. */
  53197. maxZ: number;
  53198. /**
  53199. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53200. */
  53201. minZAspect: number;
  53202. private _samples;
  53203. /**
  53204. * Number of samples used for the SSAO calculations. Default value is 8
  53205. */
  53206. samples: number;
  53207. private _textureSamples;
  53208. /**
  53209. * Number of samples to use for antialiasing
  53210. */
  53211. textureSamples: number;
  53212. /**
  53213. * Ratio object used for SSAO ratio and blur ratio
  53214. */
  53215. private _ratio;
  53216. /**
  53217. * Dynamically generated sphere sampler.
  53218. */
  53219. private _sampleSphere;
  53220. /**
  53221. * Blur filter offsets
  53222. */
  53223. private _samplerOffsets;
  53224. private _expensiveBlur;
  53225. /**
  53226. * If bilateral blur should be used
  53227. */
  53228. expensiveBlur: boolean;
  53229. /**
  53230. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53231. */
  53232. radius: number;
  53233. /**
  53234. * The base color of the SSAO post-process
  53235. * The final result is "base + ssao" between [0, 1]
  53236. */
  53237. base: number;
  53238. /**
  53239. * Support test.
  53240. */
  53241. static readonly IsSupported: boolean;
  53242. private _scene;
  53243. private _depthTexture;
  53244. private _normalTexture;
  53245. private _randomTexture;
  53246. private _originalColorPostProcess;
  53247. private _ssaoPostProcess;
  53248. private _blurHPostProcess;
  53249. private _blurVPostProcess;
  53250. private _ssaoCombinePostProcess;
  53251. private _firstUpdate;
  53252. /**
  53253. * Gets active scene
  53254. */
  53255. readonly scene: Scene;
  53256. /**
  53257. * @constructor
  53258. * @param name The rendering pipeline name
  53259. * @param scene The scene linked to this pipeline
  53260. * @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 }
  53261. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53262. */
  53263. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53264. /**
  53265. * Get the class name
  53266. * @returns "SSAO2RenderingPipeline"
  53267. */
  53268. getClassName(): string;
  53269. /**
  53270. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53271. */
  53272. dispose(disableGeometryBufferRenderer?: boolean): void;
  53273. private _createBlurPostProcess;
  53274. /** @hidden */ rebuild(): void;
  53275. private _bits;
  53276. private _radicalInverse_VdC;
  53277. private _hammersley;
  53278. private _hemisphereSample_uniform;
  53279. private _generateHemisphere;
  53280. private _createSSAOPostProcess;
  53281. private _createSSAOCombinePostProcess;
  53282. private _createRandomTexture;
  53283. /**
  53284. * Serialize the rendering pipeline (Used when exporting)
  53285. * @returns the serialized object
  53286. */
  53287. serialize(): any;
  53288. /**
  53289. * Parse the serialized pipeline
  53290. * @param source Source pipeline.
  53291. * @param scene The scene to load the pipeline to.
  53292. * @param rootUrl The URL of the serialized pipeline.
  53293. * @returns An instantiated pipeline from the serialized object.
  53294. */
  53295. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53296. }
  53297. }
  53298. declare module BABYLON {
  53299. /** @hidden */
  53300. export var ssaoPixelShader: {
  53301. name: string;
  53302. shader: string;
  53303. };
  53304. }
  53305. declare module BABYLON {
  53306. /**
  53307. * Render pipeline to produce ssao effect
  53308. */
  53309. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53310. /**
  53311. * @ignore
  53312. * The PassPostProcess id in the pipeline that contains the original scene color
  53313. */
  53314. SSAOOriginalSceneColorEffect: string;
  53315. /**
  53316. * @ignore
  53317. * The SSAO PostProcess id in the pipeline
  53318. */
  53319. SSAORenderEffect: string;
  53320. /**
  53321. * @ignore
  53322. * The horizontal blur PostProcess id in the pipeline
  53323. */
  53324. SSAOBlurHRenderEffect: string;
  53325. /**
  53326. * @ignore
  53327. * The vertical blur PostProcess id in the pipeline
  53328. */
  53329. SSAOBlurVRenderEffect: string;
  53330. /**
  53331. * @ignore
  53332. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53333. */
  53334. SSAOCombineRenderEffect: string;
  53335. /**
  53336. * The output strength of the SSAO post-process. Default value is 1.0.
  53337. */
  53338. totalStrength: number;
  53339. /**
  53340. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53341. */
  53342. radius: number;
  53343. /**
  53344. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53345. * Must not be equal to fallOff and superior to fallOff.
  53346. * Default value is 0.0075
  53347. */
  53348. area: number;
  53349. /**
  53350. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53351. * Must not be equal to area and inferior to area.
  53352. * Default value is 0.000001
  53353. */
  53354. fallOff: number;
  53355. /**
  53356. * The base color of the SSAO post-process
  53357. * The final result is "base + ssao" between [0, 1]
  53358. */
  53359. base: number;
  53360. private _scene;
  53361. private _depthTexture;
  53362. private _randomTexture;
  53363. private _originalColorPostProcess;
  53364. private _ssaoPostProcess;
  53365. private _blurHPostProcess;
  53366. private _blurVPostProcess;
  53367. private _ssaoCombinePostProcess;
  53368. private _firstUpdate;
  53369. /**
  53370. * Gets active scene
  53371. */
  53372. readonly scene: Scene;
  53373. /**
  53374. * @constructor
  53375. * @param name - The rendering pipeline name
  53376. * @param scene - The scene linked to this pipeline
  53377. * @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 }
  53378. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53379. */
  53380. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53381. /**
  53382. * Get the class name
  53383. * @returns "SSAORenderingPipeline"
  53384. */
  53385. getClassName(): string;
  53386. /**
  53387. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53388. */
  53389. dispose(disableDepthRender?: boolean): void;
  53390. private _createBlurPostProcess;
  53391. /** @hidden */ rebuild(): void;
  53392. private _createSSAOPostProcess;
  53393. private _createSSAOCombinePostProcess;
  53394. private _createRandomTexture;
  53395. }
  53396. }
  53397. declare module BABYLON {
  53398. /** @hidden */
  53399. export var standardPixelShader: {
  53400. name: string;
  53401. shader: string;
  53402. };
  53403. }
  53404. declare module BABYLON {
  53405. /**
  53406. * Standard rendering pipeline
  53407. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53408. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53409. */
  53410. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53411. /**
  53412. * Public members
  53413. */
  53414. /**
  53415. * Post-process which contains the original scene color before the pipeline applies all the effects
  53416. */
  53417. originalPostProcess: Nullable<PostProcess>;
  53418. /**
  53419. * Post-process used to down scale an image x4
  53420. */
  53421. downSampleX4PostProcess: Nullable<PostProcess>;
  53422. /**
  53423. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53424. */
  53425. brightPassPostProcess: Nullable<PostProcess>;
  53426. /**
  53427. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53428. */
  53429. blurHPostProcesses: PostProcess[];
  53430. /**
  53431. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53432. */
  53433. blurVPostProcesses: PostProcess[];
  53434. /**
  53435. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53436. */
  53437. textureAdderPostProcess: Nullable<PostProcess>;
  53438. /**
  53439. * Post-process used to create volumetric lighting effect
  53440. */
  53441. volumetricLightPostProcess: Nullable<PostProcess>;
  53442. /**
  53443. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53444. */
  53445. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53446. /**
  53447. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53448. */
  53449. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53450. /**
  53451. * Post-process used to merge the volumetric light effect and the real scene color
  53452. */
  53453. volumetricLightMergePostProces: Nullable<PostProcess>;
  53454. /**
  53455. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53456. */
  53457. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53458. /**
  53459. * Base post-process used to calculate the average luminance of the final image for HDR
  53460. */
  53461. luminancePostProcess: Nullable<PostProcess>;
  53462. /**
  53463. * Post-processes used to create down sample post-processes in order to get
  53464. * the average luminance of the final image for HDR
  53465. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53466. */
  53467. luminanceDownSamplePostProcesses: PostProcess[];
  53468. /**
  53469. * Post-process used to create a HDR effect (light adaptation)
  53470. */
  53471. hdrPostProcess: Nullable<PostProcess>;
  53472. /**
  53473. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53474. */
  53475. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53476. /**
  53477. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53478. */
  53479. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53480. /**
  53481. * Post-process used to merge the final HDR post-process and the real scene color
  53482. */
  53483. hdrFinalPostProcess: Nullable<PostProcess>;
  53484. /**
  53485. * Post-process used to create a lens flare effect
  53486. */
  53487. lensFlarePostProcess: Nullable<PostProcess>;
  53488. /**
  53489. * Post-process that merges the result of the lens flare post-process and the real scene color
  53490. */
  53491. lensFlareComposePostProcess: Nullable<PostProcess>;
  53492. /**
  53493. * Post-process used to create a motion blur effect
  53494. */
  53495. motionBlurPostProcess: Nullable<PostProcess>;
  53496. /**
  53497. * Post-process used to create a depth of field effect
  53498. */
  53499. depthOfFieldPostProcess: Nullable<PostProcess>;
  53500. /**
  53501. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53502. */
  53503. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53504. /**
  53505. * Represents the brightness threshold in order to configure the illuminated surfaces
  53506. */
  53507. brightThreshold: number;
  53508. /**
  53509. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53510. */
  53511. blurWidth: number;
  53512. /**
  53513. * Sets if the blur for highlighted surfaces must be only horizontal
  53514. */
  53515. horizontalBlur: boolean;
  53516. /**
  53517. * Gets the overall exposure used by the pipeline
  53518. */
  53519. /**
  53520. * Sets the overall exposure used by the pipeline
  53521. */
  53522. exposure: number;
  53523. /**
  53524. * Texture used typically to simulate "dirty" on camera lens
  53525. */
  53526. lensTexture: Nullable<Texture>;
  53527. /**
  53528. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53529. */
  53530. volumetricLightCoefficient: number;
  53531. /**
  53532. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53533. */
  53534. volumetricLightPower: number;
  53535. /**
  53536. * Used the set the blur intensity to smooth the volumetric lights
  53537. */
  53538. volumetricLightBlurScale: number;
  53539. /**
  53540. * Light (spot or directional) used to generate the volumetric lights rays
  53541. * The source light must have a shadow generate so the pipeline can get its
  53542. * depth map
  53543. */
  53544. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53545. /**
  53546. * For eye adaptation, represents the minimum luminance the eye can see
  53547. */
  53548. hdrMinimumLuminance: number;
  53549. /**
  53550. * For eye adaptation, represents the decrease luminance speed
  53551. */
  53552. hdrDecreaseRate: number;
  53553. /**
  53554. * For eye adaptation, represents the increase luminance speed
  53555. */
  53556. hdrIncreaseRate: number;
  53557. /**
  53558. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53559. */
  53560. /**
  53561. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53562. */
  53563. hdrAutoExposure: boolean;
  53564. /**
  53565. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53566. */
  53567. lensColorTexture: Nullable<Texture>;
  53568. /**
  53569. * The overall strengh for the lens flare effect
  53570. */
  53571. lensFlareStrength: number;
  53572. /**
  53573. * Dispersion coefficient for lens flare ghosts
  53574. */
  53575. lensFlareGhostDispersal: number;
  53576. /**
  53577. * Main lens flare halo width
  53578. */
  53579. lensFlareHaloWidth: number;
  53580. /**
  53581. * Based on the lens distortion effect, defines how much the lens flare result
  53582. * is distorted
  53583. */
  53584. lensFlareDistortionStrength: number;
  53585. /**
  53586. * Lens star texture must be used to simulate rays on the flares and is available
  53587. * in the documentation
  53588. */
  53589. lensStarTexture: Nullable<Texture>;
  53590. /**
  53591. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53592. * flare effect by taking account of the dirt texture
  53593. */
  53594. lensFlareDirtTexture: Nullable<Texture>;
  53595. /**
  53596. * Represents the focal length for the depth of field effect
  53597. */
  53598. depthOfFieldDistance: number;
  53599. /**
  53600. * Represents the blur intensity for the blurred part of the depth of field effect
  53601. */
  53602. depthOfFieldBlurWidth: number;
  53603. /**
  53604. * For motion blur, defines how much the image is blurred by the movement
  53605. */
  53606. motionStrength: number;
  53607. /**
  53608. * List of animations for the pipeline (IAnimatable implementation)
  53609. */
  53610. animations: Animation[];
  53611. /**
  53612. * Private members
  53613. */
  53614. private _scene;
  53615. private _currentDepthOfFieldSource;
  53616. private _basePostProcess;
  53617. private _fixedExposure;
  53618. private _currentExposure;
  53619. private _hdrAutoExposure;
  53620. private _hdrCurrentLuminance;
  53621. private _floatTextureType;
  53622. private _ratio;
  53623. private _bloomEnabled;
  53624. private _depthOfFieldEnabled;
  53625. private _vlsEnabled;
  53626. private _lensFlareEnabled;
  53627. private _hdrEnabled;
  53628. private _motionBlurEnabled;
  53629. private _fxaaEnabled;
  53630. private _motionBlurSamples;
  53631. private _volumetricLightStepsCount;
  53632. private _samples;
  53633. /**
  53634. * @ignore
  53635. * Specifies if the bloom pipeline is enabled
  53636. */
  53637. BloomEnabled: boolean;
  53638. /**
  53639. * @ignore
  53640. * Specifies if the depth of field pipeline is enabed
  53641. */
  53642. DepthOfFieldEnabled: boolean;
  53643. /**
  53644. * @ignore
  53645. * Specifies if the lens flare pipeline is enabed
  53646. */
  53647. LensFlareEnabled: boolean;
  53648. /**
  53649. * @ignore
  53650. * Specifies if the HDR pipeline is enabled
  53651. */
  53652. HDREnabled: boolean;
  53653. /**
  53654. * @ignore
  53655. * Specifies if the volumetric lights scattering effect is enabled
  53656. */
  53657. VLSEnabled: boolean;
  53658. /**
  53659. * @ignore
  53660. * Specifies if the motion blur effect is enabled
  53661. */
  53662. MotionBlurEnabled: boolean;
  53663. /**
  53664. * Specifies if anti-aliasing is enabled
  53665. */
  53666. fxaaEnabled: boolean;
  53667. /**
  53668. * Specifies the number of steps used to calculate the volumetric lights
  53669. * Typically in interval [50, 200]
  53670. */
  53671. volumetricLightStepsCount: number;
  53672. /**
  53673. * Specifies the number of samples used for the motion blur effect
  53674. * Typically in interval [16, 64]
  53675. */
  53676. motionBlurSamples: number;
  53677. /**
  53678. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53679. */
  53680. samples: number;
  53681. /**
  53682. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53683. * @constructor
  53684. * @param name The rendering pipeline name
  53685. * @param scene The scene linked to this pipeline
  53686. * @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)
  53687. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53688. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53689. */
  53690. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53691. private _buildPipeline;
  53692. private _createDownSampleX4PostProcess;
  53693. private _createBrightPassPostProcess;
  53694. private _createBlurPostProcesses;
  53695. private _createTextureAdderPostProcess;
  53696. private _createVolumetricLightPostProcess;
  53697. private _createLuminancePostProcesses;
  53698. private _createHdrPostProcess;
  53699. private _createLensFlarePostProcess;
  53700. private _createDepthOfFieldPostProcess;
  53701. private _createMotionBlurPostProcess;
  53702. private _getDepthTexture;
  53703. private _disposePostProcesses;
  53704. /**
  53705. * Dispose of the pipeline and stop all post processes
  53706. */
  53707. dispose(): void;
  53708. /**
  53709. * Serialize the rendering pipeline (Used when exporting)
  53710. * @returns the serialized object
  53711. */
  53712. serialize(): any;
  53713. /**
  53714. * Parse the serialized pipeline
  53715. * @param source Source pipeline.
  53716. * @param scene The scene to load the pipeline to.
  53717. * @param rootUrl The URL of the serialized pipeline.
  53718. * @returns An instantiated pipeline from the serialized object.
  53719. */
  53720. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53721. /**
  53722. * Luminance steps
  53723. */
  53724. static LuminanceSteps: number;
  53725. }
  53726. }
  53727. declare module BABYLON {
  53728. /** @hidden */
  53729. export var tonemapPixelShader: {
  53730. name: string;
  53731. shader: string;
  53732. };
  53733. }
  53734. declare module BABYLON {
  53735. /** Defines operator used for tonemapping */
  53736. export enum TonemappingOperator {
  53737. /** Hable */
  53738. Hable = 0,
  53739. /** Reinhard */
  53740. Reinhard = 1,
  53741. /** HejiDawson */
  53742. HejiDawson = 2,
  53743. /** Photographic */
  53744. Photographic = 3
  53745. }
  53746. /**
  53747. * Defines a post process to apply tone mapping
  53748. */
  53749. export class TonemapPostProcess extends PostProcess {
  53750. private _operator;
  53751. /** Defines the required exposure adjustement */
  53752. exposureAdjustment: number;
  53753. /**
  53754. * Creates a new TonemapPostProcess
  53755. * @param name defines the name of the postprocess
  53756. * @param _operator defines the operator to use
  53757. * @param exposureAdjustment defines the required exposure adjustement
  53758. * @param camera defines the camera to use (can be null)
  53759. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53760. * @param engine defines the hosting engine (can be ignore if camera is set)
  53761. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53762. */
  53763. constructor(name: string, _operator: TonemappingOperator,
  53764. /** Defines the required exposure adjustement */
  53765. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53766. }
  53767. }
  53768. declare module BABYLON {
  53769. /** @hidden */
  53770. export var depthVertexShader: {
  53771. name: string;
  53772. shader: string;
  53773. };
  53774. }
  53775. declare module BABYLON {
  53776. /** @hidden */
  53777. export var volumetricLightScatteringPixelShader: {
  53778. name: string;
  53779. shader: string;
  53780. };
  53781. }
  53782. declare module BABYLON {
  53783. /** @hidden */
  53784. export var volumetricLightScatteringPassPixelShader: {
  53785. name: string;
  53786. shader: string;
  53787. };
  53788. }
  53789. declare module BABYLON {
  53790. /**
  53791. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53792. */
  53793. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53794. private _volumetricLightScatteringPass;
  53795. private _volumetricLightScatteringRTT;
  53796. private _viewPort;
  53797. private _screenCoordinates;
  53798. private _cachedDefines;
  53799. /**
  53800. * If not undefined, the mesh position is computed from the attached node position
  53801. */
  53802. attachedNode: {
  53803. position: Vector3;
  53804. };
  53805. /**
  53806. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53807. */
  53808. customMeshPosition: Vector3;
  53809. /**
  53810. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53811. */
  53812. useCustomMeshPosition: boolean;
  53813. /**
  53814. * If the post-process should inverse the light scattering direction
  53815. */
  53816. invert: boolean;
  53817. /**
  53818. * The internal mesh used by the post-process
  53819. */
  53820. mesh: Mesh;
  53821. /**
  53822. * @hidden
  53823. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53824. */
  53825. useDiffuseColor: boolean;
  53826. /**
  53827. * Array containing the excluded meshes not rendered in the internal pass
  53828. */
  53829. excludedMeshes: AbstractMesh[];
  53830. /**
  53831. * Controls the overall intensity of the post-process
  53832. */
  53833. exposure: number;
  53834. /**
  53835. * Dissipates each sample's contribution in range [0, 1]
  53836. */
  53837. decay: number;
  53838. /**
  53839. * Controls the overall intensity of each sample
  53840. */
  53841. weight: number;
  53842. /**
  53843. * Controls the density of each sample
  53844. */
  53845. density: number;
  53846. /**
  53847. * @constructor
  53848. * @param name The post-process name
  53849. * @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)
  53850. * @param camera The camera that the post-process will be attached to
  53851. * @param mesh The mesh used to create the light scattering
  53852. * @param samples The post-process quality, default 100
  53853. * @param samplingModeThe post-process filtering mode
  53854. * @param engine The babylon engine
  53855. * @param reusable If the post-process is reusable
  53856. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53857. */
  53858. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53859. /**
  53860. * Returns the string "VolumetricLightScatteringPostProcess"
  53861. * @returns "VolumetricLightScatteringPostProcess"
  53862. */
  53863. getClassName(): string;
  53864. private _isReady;
  53865. /**
  53866. * Sets the new light position for light scattering effect
  53867. * @param position The new custom light position
  53868. */
  53869. setCustomMeshPosition(position: Vector3): void;
  53870. /**
  53871. * Returns the light position for light scattering effect
  53872. * @return Vector3 The custom light position
  53873. */
  53874. getCustomMeshPosition(): Vector3;
  53875. /**
  53876. * Disposes the internal assets and detaches the post-process from the camera
  53877. */
  53878. dispose(camera: Camera): void;
  53879. /**
  53880. * Returns the render target texture used by the post-process
  53881. * @return the render target texture used by the post-process
  53882. */
  53883. getPass(): RenderTargetTexture;
  53884. private _meshExcluded;
  53885. private _createPass;
  53886. private _updateMeshScreenCoordinates;
  53887. /**
  53888. * Creates a default mesh for the Volumeric Light Scattering post-process
  53889. * @param name The mesh name
  53890. * @param scene The scene where to create the mesh
  53891. * @return the default mesh
  53892. */
  53893. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53894. }
  53895. }
  53896. declare module BABYLON {
  53897. interface Scene {
  53898. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53899. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53900. /**
  53901. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53902. */
  53903. forceShowBoundingBoxes: boolean;
  53904. /**
  53905. * Gets the bounding box renderer associated with the scene
  53906. * @returns a BoundingBoxRenderer
  53907. */
  53908. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53909. }
  53910. interface AbstractMesh {
  53911. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53912. /**
  53913. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53914. */
  53915. showBoundingBox: boolean;
  53916. }
  53917. /**
  53918. * Component responsible of rendering the bounding box of the meshes in a scene.
  53919. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53920. */
  53921. export class BoundingBoxRenderer implements ISceneComponent {
  53922. /**
  53923. * The component name helpfull to identify the component in the list of scene components.
  53924. */
  53925. readonly name: string;
  53926. /**
  53927. * The scene the component belongs to.
  53928. */
  53929. scene: Scene;
  53930. /**
  53931. * Color of the bounding box lines placed in front of an object
  53932. */
  53933. frontColor: Color3;
  53934. /**
  53935. * Color of the bounding box lines placed behind an object
  53936. */
  53937. backColor: Color3;
  53938. /**
  53939. * Defines if the renderer should show the back lines or not
  53940. */
  53941. showBackLines: boolean;
  53942. /**
  53943. * @hidden
  53944. */
  53945. renderList: SmartArray<BoundingBox>;
  53946. private _colorShader;
  53947. private _vertexBuffers;
  53948. private _indexBuffer;
  53949. /**
  53950. * Instantiates a new bounding box renderer in a scene.
  53951. * @param scene the scene the renderer renders in
  53952. */
  53953. constructor(scene: Scene);
  53954. /**
  53955. * Registers the component in a given scene
  53956. */
  53957. register(): void;
  53958. private _evaluateSubMesh;
  53959. private _activeMesh;
  53960. private _prepareRessources;
  53961. private _createIndexBuffer;
  53962. /**
  53963. * Rebuilds the elements related to this component in case of
  53964. * context lost for instance.
  53965. */
  53966. rebuild(): void;
  53967. /**
  53968. * @hidden
  53969. */
  53970. reset(): void;
  53971. /**
  53972. * Render the bounding boxes of a specific rendering group
  53973. * @param renderingGroupId defines the rendering group to render
  53974. */
  53975. render(renderingGroupId: number): void;
  53976. /**
  53977. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53978. * @param mesh Define the mesh to render the occlusion bounding box for
  53979. */
  53980. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53981. /**
  53982. * Dispose and release the resources attached to this renderer.
  53983. */
  53984. dispose(): void;
  53985. }
  53986. }
  53987. declare module BABYLON {
  53988. /** @hidden */
  53989. export var depthPixelShader: {
  53990. name: string;
  53991. shader: string;
  53992. };
  53993. }
  53994. declare module BABYLON {
  53995. /**
  53996. * This represents a depth renderer in Babylon.
  53997. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53998. */
  53999. export class DepthRenderer {
  54000. private _scene;
  54001. private _depthMap;
  54002. private _effect;
  54003. private _cachedDefines;
  54004. private _camera;
  54005. /**
  54006. * Specifiess that the depth renderer will only be used within
  54007. * the camera it is created for.
  54008. * This can help forcing its rendering during the camera processing.
  54009. */
  54010. useOnlyInActiveCamera: boolean;
  54011. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  54012. /**
  54013. * Instantiates a depth renderer
  54014. * @param scene The scene the renderer belongs to
  54015. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54016. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54017. */
  54018. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54019. /**
  54020. * Creates the depth rendering effect and checks if the effect is ready.
  54021. * @param subMesh The submesh to be used to render the depth map of
  54022. * @param useInstances If multiple world instances should be used
  54023. * @returns if the depth renderer is ready to render the depth map
  54024. */
  54025. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54026. /**
  54027. * Gets the texture which the depth map will be written to.
  54028. * @returns The depth map texture
  54029. */
  54030. getDepthMap(): RenderTargetTexture;
  54031. /**
  54032. * Disposes of the depth renderer.
  54033. */
  54034. dispose(): void;
  54035. }
  54036. }
  54037. declare module BABYLON {
  54038. interface Scene {
  54039. /** @hidden (Backing field) */ depthRenderer: {
  54040. [id: string]: DepthRenderer;
  54041. };
  54042. /**
  54043. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54044. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54045. * @returns the created depth renderer
  54046. */
  54047. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54048. /**
  54049. * Disables a depth renderer for a given camera
  54050. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54051. */
  54052. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54053. }
  54054. /**
  54055. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54056. * in several rendering techniques.
  54057. */
  54058. export class DepthRendererSceneComponent implements ISceneComponent {
  54059. /**
  54060. * The component name helpfull to identify the component in the list of scene components.
  54061. */
  54062. readonly name: string;
  54063. /**
  54064. * The scene the component belongs to.
  54065. */
  54066. scene: Scene;
  54067. /**
  54068. * Creates a new instance of the component for the given scene
  54069. * @param scene Defines the scene to register the component in
  54070. */
  54071. constructor(scene: Scene);
  54072. /**
  54073. * Registers the component in a given scene
  54074. */
  54075. register(): void;
  54076. /**
  54077. * Rebuilds the elements related to this component in case of
  54078. * context lost for instance.
  54079. */
  54080. rebuild(): void;
  54081. /**
  54082. * Disposes the component and the associated ressources
  54083. */
  54084. dispose(): void;
  54085. private _gatherRenderTargets;
  54086. private _gatherActiveCameraRenderTargets;
  54087. }
  54088. }
  54089. declare module BABYLON {
  54090. /** @hidden */
  54091. export var outlinePixelShader: {
  54092. name: string;
  54093. shader: string;
  54094. };
  54095. }
  54096. declare module BABYLON {
  54097. /** @hidden */
  54098. export var outlineVertexShader: {
  54099. name: string;
  54100. shader: string;
  54101. };
  54102. }
  54103. declare module BABYLON {
  54104. interface Scene {
  54105. /** @hidden */ outlineRenderer: OutlineRenderer;
  54106. /**
  54107. * Gets the outline renderer associated with the scene
  54108. * @returns a OutlineRenderer
  54109. */
  54110. getOutlineRenderer(): OutlineRenderer;
  54111. }
  54112. interface AbstractMesh {
  54113. /** @hidden (Backing field) */ renderOutline: boolean;
  54114. /**
  54115. * Gets or sets a boolean indicating if the outline must be rendered as well
  54116. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54117. */
  54118. renderOutline: boolean;
  54119. /** @hidden (Backing field) */ renderOverlay: boolean;
  54120. /**
  54121. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54122. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54123. */
  54124. renderOverlay: boolean;
  54125. }
  54126. /**
  54127. * This class is responsible to draw bothe outline/overlay of meshes.
  54128. * It should not be used directly but through the available method on mesh.
  54129. */
  54130. export class OutlineRenderer implements ISceneComponent {
  54131. /**
  54132. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54133. */
  54134. private static _StencilReference;
  54135. /**
  54136. * The name of the component. Each component must have a unique name.
  54137. */
  54138. name: string;
  54139. /**
  54140. * The scene the component belongs to.
  54141. */
  54142. scene: Scene;
  54143. /**
  54144. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54145. */
  54146. zOffset: number;
  54147. private _engine;
  54148. private _effect;
  54149. private _cachedDefines;
  54150. private _savedDepthWrite;
  54151. /**
  54152. * Instantiates a new outline renderer. (There could be only one per scene).
  54153. * @param scene Defines the scene it belongs to
  54154. */
  54155. constructor(scene: Scene);
  54156. /**
  54157. * Register the component to one instance of a scene.
  54158. */
  54159. register(): void;
  54160. /**
  54161. * Rebuilds the elements related to this component in case of
  54162. * context lost for instance.
  54163. */
  54164. rebuild(): void;
  54165. /**
  54166. * Disposes the component and the associated ressources.
  54167. */
  54168. dispose(): void;
  54169. /**
  54170. * Renders the outline in the canvas.
  54171. * @param subMesh Defines the sumesh to render
  54172. * @param batch Defines the batch of meshes in case of instances
  54173. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54174. */
  54175. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54176. /**
  54177. * Returns whether or not the outline renderer is ready for a given submesh.
  54178. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54179. * @param subMesh Defines the submesh to check readyness for
  54180. * @param useInstances Defines wheter wee are trying to render instances or not
  54181. * @returns true if ready otherwise false
  54182. */
  54183. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54184. private _beforeRenderingMesh;
  54185. private _afterRenderingMesh;
  54186. }
  54187. }
  54188. declare module BABYLON {
  54189. /**
  54190. * Defines the list of states available for a task inside a AssetsManager
  54191. */
  54192. export enum AssetTaskState {
  54193. /**
  54194. * Initialization
  54195. */
  54196. INIT = 0,
  54197. /**
  54198. * Running
  54199. */
  54200. RUNNING = 1,
  54201. /**
  54202. * Done
  54203. */
  54204. DONE = 2,
  54205. /**
  54206. * Error
  54207. */
  54208. ERROR = 3
  54209. }
  54210. /**
  54211. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54212. */
  54213. export abstract class AbstractAssetTask {
  54214. /**
  54215. * Task name
  54216. */ name: string;
  54217. /**
  54218. * Callback called when the task is successful
  54219. */
  54220. onSuccess: (task: any) => void;
  54221. /**
  54222. * Callback called when the task is not successful
  54223. */
  54224. onError: (task: any, message?: string, exception?: any) => void;
  54225. /**
  54226. * Creates a new AssetsManager
  54227. * @param name defines the name of the task
  54228. */
  54229. constructor(
  54230. /**
  54231. * Task name
  54232. */ name: string);
  54233. private _isCompleted;
  54234. private _taskState;
  54235. private _errorObject;
  54236. /**
  54237. * Get if the task is completed
  54238. */
  54239. readonly isCompleted: boolean;
  54240. /**
  54241. * Gets the current state of the task
  54242. */
  54243. readonly taskState: AssetTaskState;
  54244. /**
  54245. * Gets the current error object (if task is in error)
  54246. */
  54247. readonly errorObject: {
  54248. message?: string;
  54249. exception?: any;
  54250. };
  54251. /**
  54252. * Internal only
  54253. * @hidden
  54254. */ setErrorObject(message?: string, exception?: any): void;
  54255. /**
  54256. * Execute the current task
  54257. * @param scene defines the scene where you want your assets to be loaded
  54258. * @param onSuccess is a callback called when the task is successfully executed
  54259. * @param onError is a callback called if an error occurs
  54260. */
  54261. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54262. /**
  54263. * Execute the current task
  54264. * @param scene defines the scene where you want your assets to be loaded
  54265. * @param onSuccess is a callback called when the task is successfully executed
  54266. * @param onError is a callback called if an error occurs
  54267. */
  54268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54269. /**
  54270. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54271. * This can be used with failed tasks that have the reason for failure fixed.
  54272. */
  54273. reset(): void;
  54274. private onErrorCallback;
  54275. private onDoneCallback;
  54276. }
  54277. /**
  54278. * Define the interface used by progress events raised during assets loading
  54279. */
  54280. export interface IAssetsProgressEvent {
  54281. /**
  54282. * Defines the number of remaining tasks to process
  54283. */
  54284. remainingCount: number;
  54285. /**
  54286. * Defines the total number of tasks
  54287. */
  54288. totalCount: number;
  54289. /**
  54290. * Defines the task that was just processed
  54291. */
  54292. task: AbstractAssetTask;
  54293. }
  54294. /**
  54295. * Class used to share progress information about assets loading
  54296. */
  54297. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54298. /**
  54299. * Defines the number of remaining tasks to process
  54300. */
  54301. remainingCount: number;
  54302. /**
  54303. * Defines the total number of tasks
  54304. */
  54305. totalCount: number;
  54306. /**
  54307. * Defines the task that was just processed
  54308. */
  54309. task: AbstractAssetTask;
  54310. /**
  54311. * Creates a AssetsProgressEvent
  54312. * @param remainingCount defines the number of remaining tasks to process
  54313. * @param totalCount defines the total number of tasks
  54314. * @param task defines the task that was just processed
  54315. */
  54316. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54317. }
  54318. /**
  54319. * Define a task used by AssetsManager to load meshes
  54320. */
  54321. export class MeshAssetTask extends AbstractAssetTask {
  54322. /**
  54323. * Defines the name of the task
  54324. */
  54325. name: string;
  54326. /**
  54327. * Defines the list of mesh's names you want to load
  54328. */
  54329. meshesNames: any;
  54330. /**
  54331. * Defines the root url to use as a base to load your meshes and associated resources
  54332. */
  54333. rootUrl: string;
  54334. /**
  54335. * Defines the filename of the scene to load from
  54336. */
  54337. sceneFilename: string;
  54338. /**
  54339. * Gets the list of loaded meshes
  54340. */
  54341. loadedMeshes: Array<AbstractMesh>;
  54342. /**
  54343. * Gets the list of loaded particle systems
  54344. */
  54345. loadedParticleSystems: Array<IParticleSystem>;
  54346. /**
  54347. * Gets the list of loaded skeletons
  54348. */
  54349. loadedSkeletons: Array<Skeleton>;
  54350. /**
  54351. * Gets the list of loaded animation groups
  54352. */
  54353. loadedAnimationGroups: Array<AnimationGroup>;
  54354. /**
  54355. * Callback called when the task is successful
  54356. */
  54357. onSuccess: (task: MeshAssetTask) => void;
  54358. /**
  54359. * Callback called when the task is successful
  54360. */
  54361. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54362. /**
  54363. * Creates a new MeshAssetTask
  54364. * @param name defines the name of the task
  54365. * @param meshesNames defines the list of mesh's names you want to load
  54366. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54367. * @param sceneFilename defines the filename of the scene to load from
  54368. */
  54369. constructor(
  54370. /**
  54371. * Defines the name of the task
  54372. */
  54373. name: string,
  54374. /**
  54375. * Defines the list of mesh's names you want to load
  54376. */
  54377. meshesNames: any,
  54378. /**
  54379. * Defines the root url to use as a base to load your meshes and associated resources
  54380. */
  54381. rootUrl: string,
  54382. /**
  54383. * Defines the filename of the scene to load from
  54384. */
  54385. sceneFilename: string);
  54386. /**
  54387. * Execute the current task
  54388. * @param scene defines the scene where you want your assets to be loaded
  54389. * @param onSuccess is a callback called when the task is successfully executed
  54390. * @param onError is a callback called if an error occurs
  54391. */
  54392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54393. }
  54394. /**
  54395. * Define a task used by AssetsManager to load text content
  54396. */
  54397. export class TextFileAssetTask extends AbstractAssetTask {
  54398. /**
  54399. * Defines the name of the task
  54400. */
  54401. name: string;
  54402. /**
  54403. * Defines the location of the file to load
  54404. */
  54405. url: string;
  54406. /**
  54407. * Gets the loaded text string
  54408. */
  54409. text: string;
  54410. /**
  54411. * Callback called when the task is successful
  54412. */
  54413. onSuccess: (task: TextFileAssetTask) => void;
  54414. /**
  54415. * Callback called when the task is successful
  54416. */
  54417. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54418. /**
  54419. * Creates a new TextFileAssetTask object
  54420. * @param name defines the name of the task
  54421. * @param url defines the location of the file to load
  54422. */
  54423. constructor(
  54424. /**
  54425. * Defines the name of the task
  54426. */
  54427. name: string,
  54428. /**
  54429. * Defines the location of the file to load
  54430. */
  54431. url: string);
  54432. /**
  54433. * Execute the current task
  54434. * @param scene defines the scene where you want your assets to be loaded
  54435. * @param onSuccess is a callback called when the task is successfully executed
  54436. * @param onError is a callback called if an error occurs
  54437. */
  54438. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54439. }
  54440. /**
  54441. * Define a task used by AssetsManager to load binary data
  54442. */
  54443. export class BinaryFileAssetTask extends AbstractAssetTask {
  54444. /**
  54445. * Defines the name of the task
  54446. */
  54447. name: string;
  54448. /**
  54449. * Defines the location of the file to load
  54450. */
  54451. url: string;
  54452. /**
  54453. * Gets the lodaded data (as an array buffer)
  54454. */
  54455. data: ArrayBuffer;
  54456. /**
  54457. * Callback called when the task is successful
  54458. */
  54459. onSuccess: (task: BinaryFileAssetTask) => void;
  54460. /**
  54461. * Callback called when the task is successful
  54462. */
  54463. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54464. /**
  54465. * Creates a new BinaryFileAssetTask object
  54466. * @param name defines the name of the new task
  54467. * @param url defines the location of the file to load
  54468. */
  54469. constructor(
  54470. /**
  54471. * Defines the name of the task
  54472. */
  54473. name: string,
  54474. /**
  54475. * Defines the location of the file to load
  54476. */
  54477. url: string);
  54478. /**
  54479. * Execute the current task
  54480. * @param scene defines the scene where you want your assets to be loaded
  54481. * @param onSuccess is a callback called when the task is successfully executed
  54482. * @param onError is a callback called if an error occurs
  54483. */
  54484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54485. }
  54486. /**
  54487. * Define a task used by AssetsManager to load images
  54488. */
  54489. export class ImageAssetTask extends AbstractAssetTask {
  54490. /**
  54491. * Defines the name of the task
  54492. */
  54493. name: string;
  54494. /**
  54495. * Defines the location of the image to load
  54496. */
  54497. url: string;
  54498. /**
  54499. * Gets the loaded images
  54500. */
  54501. image: HTMLImageElement;
  54502. /**
  54503. * Callback called when the task is successful
  54504. */
  54505. onSuccess: (task: ImageAssetTask) => void;
  54506. /**
  54507. * Callback called when the task is successful
  54508. */
  54509. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54510. /**
  54511. * Creates a new ImageAssetTask
  54512. * @param name defines the name of the task
  54513. * @param url defines the location of the image to load
  54514. */
  54515. constructor(
  54516. /**
  54517. * Defines the name of the task
  54518. */
  54519. name: string,
  54520. /**
  54521. * Defines the location of the image to load
  54522. */
  54523. url: string);
  54524. /**
  54525. * Execute the current task
  54526. * @param scene defines the scene where you want your assets to be loaded
  54527. * @param onSuccess is a callback called when the task is successfully executed
  54528. * @param onError is a callback called if an error occurs
  54529. */
  54530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54531. }
  54532. /**
  54533. * Defines the interface used by texture loading tasks
  54534. */
  54535. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54536. /**
  54537. * Gets the loaded texture
  54538. */
  54539. texture: TEX;
  54540. }
  54541. /**
  54542. * Define a task used by AssetsManager to load 2D textures
  54543. */
  54544. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54545. /**
  54546. * Defines the name of the task
  54547. */
  54548. name: string;
  54549. /**
  54550. * Defines the location of the file to load
  54551. */
  54552. url: string;
  54553. /**
  54554. * Defines if mipmap should not be generated (default is false)
  54555. */
  54556. noMipmap?: boolean | undefined;
  54557. /**
  54558. * Defines if texture must be inverted on Y axis (default is false)
  54559. */
  54560. invertY?: boolean | undefined;
  54561. /**
  54562. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54563. */
  54564. samplingMode: number;
  54565. /**
  54566. * Gets the loaded texture
  54567. */
  54568. texture: Texture;
  54569. /**
  54570. * Callback called when the task is successful
  54571. */
  54572. onSuccess: (task: TextureAssetTask) => void;
  54573. /**
  54574. * Callback called when the task is successful
  54575. */
  54576. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54577. /**
  54578. * Creates a new TextureAssetTask object
  54579. * @param name defines the name of the task
  54580. * @param url defines the location of the file to load
  54581. * @param noMipmap defines if mipmap should not be generated (default is false)
  54582. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54583. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54584. */
  54585. constructor(
  54586. /**
  54587. * Defines the name of the task
  54588. */
  54589. name: string,
  54590. /**
  54591. * Defines the location of the file to load
  54592. */
  54593. url: string,
  54594. /**
  54595. * Defines if mipmap should not be generated (default is false)
  54596. */
  54597. noMipmap?: boolean | undefined,
  54598. /**
  54599. * Defines if texture must be inverted on Y axis (default is false)
  54600. */
  54601. invertY?: boolean | undefined,
  54602. /**
  54603. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54604. */
  54605. samplingMode?: number);
  54606. /**
  54607. * Execute the current task
  54608. * @param scene defines the scene where you want your assets to be loaded
  54609. * @param onSuccess is a callback called when the task is successfully executed
  54610. * @param onError is a callback called if an error occurs
  54611. */
  54612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54613. }
  54614. /**
  54615. * Define a task used by AssetsManager to load cube textures
  54616. */
  54617. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54618. /**
  54619. * Defines the name of the task
  54620. */
  54621. name: string;
  54622. /**
  54623. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54624. */
  54625. url: string;
  54626. /**
  54627. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54628. */
  54629. extensions?: string[] | undefined;
  54630. /**
  54631. * Defines if mipmaps should not be generated (default is false)
  54632. */
  54633. noMipmap?: boolean | undefined;
  54634. /**
  54635. * Defines the explicit list of files (undefined by default)
  54636. */
  54637. files?: string[] | undefined;
  54638. /**
  54639. * Gets the loaded texture
  54640. */
  54641. texture: CubeTexture;
  54642. /**
  54643. * Callback called when the task is successful
  54644. */
  54645. onSuccess: (task: CubeTextureAssetTask) => void;
  54646. /**
  54647. * Callback called when the task is successful
  54648. */
  54649. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54650. /**
  54651. * Creates a new CubeTextureAssetTask
  54652. * @param name defines the name of the task
  54653. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54654. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54655. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54656. * @param files defines the explicit list of files (undefined by default)
  54657. */
  54658. constructor(
  54659. /**
  54660. * Defines the name of the task
  54661. */
  54662. name: string,
  54663. /**
  54664. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54665. */
  54666. url: string,
  54667. /**
  54668. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54669. */
  54670. extensions?: string[] | undefined,
  54671. /**
  54672. * Defines if mipmaps should not be generated (default is false)
  54673. */
  54674. noMipmap?: boolean | undefined,
  54675. /**
  54676. * Defines the explicit list of files (undefined by default)
  54677. */
  54678. files?: string[] | undefined);
  54679. /**
  54680. * Execute the current task
  54681. * @param scene defines the scene where you want your assets to be loaded
  54682. * @param onSuccess is a callback called when the task is successfully executed
  54683. * @param onError is a callback called if an error occurs
  54684. */
  54685. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54686. }
  54687. /**
  54688. * Define a task used by AssetsManager to load HDR cube textures
  54689. */
  54690. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54691. /**
  54692. * Defines the name of the task
  54693. */
  54694. name: string;
  54695. /**
  54696. * Defines the location of the file to load
  54697. */
  54698. url: string;
  54699. /**
  54700. * Defines the desired size (the more it increases the longer the generation will be)
  54701. */
  54702. size: number;
  54703. /**
  54704. * Defines if mipmaps should not be generated (default is false)
  54705. */
  54706. noMipmap: boolean;
  54707. /**
  54708. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54709. */
  54710. generateHarmonics: boolean;
  54711. /**
  54712. * 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)
  54713. */
  54714. gammaSpace: boolean;
  54715. /**
  54716. * Internal Use Only
  54717. */
  54718. reserved: boolean;
  54719. /**
  54720. * Gets the loaded texture
  54721. */
  54722. texture: HDRCubeTexture;
  54723. /**
  54724. * Callback called when the task is successful
  54725. */
  54726. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54727. /**
  54728. * Callback called when the task is successful
  54729. */
  54730. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54731. /**
  54732. * Creates a new HDRCubeTextureAssetTask object
  54733. * @param name defines the name of the task
  54734. * @param url defines the location of the file to load
  54735. * @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.
  54736. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54737. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54738. * @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)
  54739. * @param reserved Internal use only
  54740. */
  54741. constructor(
  54742. /**
  54743. * Defines the name of the task
  54744. */
  54745. name: string,
  54746. /**
  54747. * Defines the location of the file to load
  54748. */
  54749. url: string,
  54750. /**
  54751. * Defines the desired size (the more it increases the longer the generation will be)
  54752. */
  54753. size: number,
  54754. /**
  54755. * Defines if mipmaps should not be generated (default is false)
  54756. */
  54757. noMipmap?: boolean,
  54758. /**
  54759. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54760. */
  54761. generateHarmonics?: boolean,
  54762. /**
  54763. * 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)
  54764. */
  54765. gammaSpace?: boolean,
  54766. /**
  54767. * Internal Use Only
  54768. */
  54769. reserved?: boolean);
  54770. /**
  54771. * Execute the current task
  54772. * @param scene defines the scene where you want your assets to be loaded
  54773. * @param onSuccess is a callback called when the task is successfully executed
  54774. * @param onError is a callback called if an error occurs
  54775. */
  54776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54777. }
  54778. /**
  54779. * Define a task used by AssetsManager to load Equirectangular cube textures
  54780. */
  54781. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54782. /**
  54783. * Defines the name of the task
  54784. */
  54785. name: string;
  54786. /**
  54787. * Defines the location of the file to load
  54788. */
  54789. url: string;
  54790. /**
  54791. * Defines the desired size (the more it increases the longer the generation will be)
  54792. */
  54793. size: number;
  54794. /**
  54795. * Defines if mipmaps should not be generated (default is false)
  54796. */
  54797. noMipmap: boolean;
  54798. /**
  54799. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54800. * but the standard material would require them in Gamma space) (default is true)
  54801. */
  54802. gammaSpace: boolean;
  54803. /**
  54804. * Gets the loaded texture
  54805. */
  54806. texture: EquiRectangularCubeTexture;
  54807. /**
  54808. * Callback called when the task is successful
  54809. */
  54810. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54811. /**
  54812. * Callback called when the task is successful
  54813. */
  54814. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54815. /**
  54816. * Creates a new EquiRectangularCubeTextureAssetTask object
  54817. * @param name defines the name of the task
  54818. * @param url defines the location of the file to load
  54819. * @param size defines the desired size (the more it increases the longer the generation will be)
  54820. * If the size is omitted this implies you are using a preprocessed cubemap.
  54821. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54822. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54823. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54824. * (default is true)
  54825. */
  54826. constructor(
  54827. /**
  54828. * Defines the name of the task
  54829. */
  54830. name: string,
  54831. /**
  54832. * Defines the location of the file to load
  54833. */
  54834. url: string,
  54835. /**
  54836. * Defines the desired size (the more it increases the longer the generation will be)
  54837. */
  54838. size: number,
  54839. /**
  54840. * Defines if mipmaps should not be generated (default is false)
  54841. */
  54842. noMipmap?: boolean,
  54843. /**
  54844. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54845. * but the standard material would require them in Gamma space) (default is true)
  54846. */
  54847. gammaSpace?: boolean);
  54848. /**
  54849. * Execute the current task
  54850. * @param scene defines the scene where you want your assets to be loaded
  54851. * @param onSuccess is a callback called when the task is successfully executed
  54852. * @param onError is a callback called if an error occurs
  54853. */
  54854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54855. }
  54856. /**
  54857. * This class can be used to easily import assets into a scene
  54858. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54859. */
  54860. export class AssetsManager {
  54861. private _scene;
  54862. private _isLoading;
  54863. protected _tasks: AbstractAssetTask[];
  54864. protected _waitingTasksCount: number;
  54865. protected _totalTasksCount: number;
  54866. /**
  54867. * Callback called when all tasks are processed
  54868. */
  54869. onFinish: (tasks: AbstractAssetTask[]) => void;
  54870. /**
  54871. * Callback called when a task is successful
  54872. */
  54873. onTaskSuccess: (task: AbstractAssetTask) => void;
  54874. /**
  54875. * Callback called when a task had an error
  54876. */
  54877. onTaskError: (task: AbstractAssetTask) => void;
  54878. /**
  54879. * Callback called when a task is done (whatever the result is)
  54880. */
  54881. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54882. /**
  54883. * Observable called when all tasks are processed
  54884. */
  54885. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54886. /**
  54887. * Observable called when a task had an error
  54888. */
  54889. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54890. /**
  54891. * Observable called when all tasks were executed
  54892. */
  54893. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54894. /**
  54895. * Observable called when a task is done (whatever the result is)
  54896. */
  54897. onProgressObservable: Observable<IAssetsProgressEvent>;
  54898. /**
  54899. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54901. */
  54902. useDefaultLoadingScreen: boolean;
  54903. /**
  54904. * Creates a new AssetsManager
  54905. * @param scene defines the scene to work on
  54906. */
  54907. constructor(scene: Scene);
  54908. /**
  54909. * Add a MeshAssetTask to the list of active tasks
  54910. * @param taskName defines the name of the new task
  54911. * @param meshesNames defines the name of meshes to load
  54912. * @param rootUrl defines the root url to use to locate files
  54913. * @param sceneFilename defines the filename of the scene file
  54914. * @returns a new MeshAssetTask object
  54915. */
  54916. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54917. /**
  54918. * Add a TextFileAssetTask to the list of active tasks
  54919. * @param taskName defines the name of the new task
  54920. * @param url defines the url of the file to load
  54921. * @returns a new TextFileAssetTask object
  54922. */
  54923. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54924. /**
  54925. * Add a BinaryFileAssetTask to the list of active tasks
  54926. * @param taskName defines the name of the new task
  54927. * @param url defines the url of the file to load
  54928. * @returns a new BinaryFileAssetTask object
  54929. */
  54930. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54931. /**
  54932. * Add a ImageAssetTask to the list of active tasks
  54933. * @param taskName defines the name of the new task
  54934. * @param url defines the url of the file to load
  54935. * @returns a new ImageAssetTask object
  54936. */
  54937. addImageTask(taskName: string, url: string): ImageAssetTask;
  54938. /**
  54939. * Add a TextureAssetTask to the list of active tasks
  54940. * @param taskName defines the name of the new task
  54941. * @param url defines the url of the file to load
  54942. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54943. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54944. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54945. * @returns a new TextureAssetTask object
  54946. */
  54947. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54948. /**
  54949. * Add a CubeTextureAssetTask to the list of active tasks
  54950. * @param taskName defines the name of the new task
  54951. * @param url defines the url of the file to load
  54952. * @param extensions defines the extension to use to load the cube map (can be null)
  54953. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54954. * @param files defines the list of files to load (can be null)
  54955. * @returns a new CubeTextureAssetTask object
  54956. */
  54957. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54958. /**
  54959. *
  54960. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54961. * @param taskName defines the name of the new task
  54962. * @param url defines the url of the file to load
  54963. * @param size defines the size you want for the cubemap (can be null)
  54964. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54965. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54966. * @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)
  54967. * @param reserved Internal use only
  54968. * @returns a new HDRCubeTextureAssetTask object
  54969. */
  54970. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54971. /**
  54972. *
  54973. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54974. * @param taskName defines the name of the new task
  54975. * @param url defines the url of the file to load
  54976. * @param size defines the size you want for the cubemap (can be null)
  54977. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54978. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54979. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54980. * @returns a new EquiRectangularCubeTextureAssetTask object
  54981. */
  54982. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54983. /**
  54984. * Remove a task from the assets manager.
  54985. * @param task the task to remove
  54986. */
  54987. removeTask(task: AbstractAssetTask): void;
  54988. private _decreaseWaitingTasksCount;
  54989. private _runTask;
  54990. /**
  54991. * Reset the AssetsManager and remove all tasks
  54992. * @return the current instance of the AssetsManager
  54993. */
  54994. reset(): AssetsManager;
  54995. /**
  54996. * Start the loading process
  54997. * @return the current instance of the AssetsManager
  54998. */
  54999. load(): AssetsManager;
  55000. /**
  55001. * Start the loading process as an async operation
  55002. * @return a promise returning the list of failed tasks
  55003. */
  55004. loadAsync(): Promise<void>;
  55005. }
  55006. }
  55007. declare module BABYLON {
  55008. /**
  55009. * Wrapper class for promise with external resolve and reject.
  55010. */
  55011. export class Deferred<T> {
  55012. /**
  55013. * The promise associated with this deferred object.
  55014. */
  55015. readonly promise: Promise<T>;
  55016. private _resolve;
  55017. private _reject;
  55018. /**
  55019. * The resolve method of the promise associated with this deferred object.
  55020. */
  55021. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55022. /**
  55023. * The reject method of the promise associated with this deferred object.
  55024. */
  55025. readonly reject: (reason?: any) => void;
  55026. /**
  55027. * Constructor for this deferred object.
  55028. */
  55029. constructor();
  55030. }
  55031. }
  55032. declare module BABYLON {
  55033. /**
  55034. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55035. */
  55036. export class MeshExploder {
  55037. private _centerMesh;
  55038. private _meshes;
  55039. private _meshesOrigins;
  55040. private _toCenterVectors;
  55041. private _scaledDirection;
  55042. private _newPosition;
  55043. private _centerPosition;
  55044. /**
  55045. * Explodes meshes from a center mesh.
  55046. * @param meshes The meshes to explode.
  55047. * @param centerMesh The mesh to be center of explosion.
  55048. */
  55049. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55050. private _setCenterMesh;
  55051. /**
  55052. * Get class name
  55053. * @returns "MeshExploder"
  55054. */
  55055. getClassName(): string;
  55056. /**
  55057. * "Exploded meshes"
  55058. * @returns Array of meshes with the centerMesh at index 0.
  55059. */
  55060. getMeshes(): Array<Mesh>;
  55061. /**
  55062. * Explodes meshes giving a specific direction
  55063. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55064. */
  55065. explode(direction?: number): void;
  55066. }
  55067. }
  55068. declare module BABYLON {
  55069. /**
  55070. * Class used to help managing file picking and drag'n'drop
  55071. */
  55072. export class FilesInput {
  55073. /**
  55074. * List of files ready to be loaded
  55075. */
  55076. static readonly FilesToLoad: {
  55077. [key: string]: File;
  55078. };
  55079. /**
  55080. * Callback called when a file is processed
  55081. */
  55082. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55083. private _engine;
  55084. private _currentScene;
  55085. private _sceneLoadedCallback;
  55086. private _progressCallback;
  55087. private _additionalRenderLoopLogicCallback;
  55088. private _textureLoadingCallback;
  55089. private _startingProcessingFilesCallback;
  55090. private _onReloadCallback;
  55091. private _errorCallback;
  55092. private _elementToMonitor;
  55093. private _sceneFileToLoad;
  55094. private _filesToLoad;
  55095. /**
  55096. * Creates a new FilesInput
  55097. * @param engine defines the rendering engine
  55098. * @param scene defines the hosting scene
  55099. * @param sceneLoadedCallback callback called when scene is loaded
  55100. * @param progressCallback callback called to track progress
  55101. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55102. * @param textureLoadingCallback callback called when a texture is loading
  55103. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55104. * @param onReloadCallback callback called when a reload is requested
  55105. * @param errorCallback callback call if an error occurs
  55106. */
  55107. 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);
  55108. private _dragEnterHandler;
  55109. private _dragOverHandler;
  55110. private _dropHandler;
  55111. /**
  55112. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55113. * @param elementToMonitor defines the DOM element to track
  55114. */
  55115. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55116. /**
  55117. * Release all associated resources
  55118. */
  55119. dispose(): void;
  55120. private renderFunction;
  55121. private drag;
  55122. private drop;
  55123. private _traverseFolder;
  55124. private _processFiles;
  55125. /**
  55126. * Load files from a drop event
  55127. * @param event defines the drop event to use as source
  55128. */
  55129. loadFiles(event: any): void;
  55130. private _processReload;
  55131. /**
  55132. * Reload the current scene from the loaded files
  55133. */
  55134. reload(): void;
  55135. }
  55136. }
  55137. declare module BABYLON {
  55138. /**
  55139. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55141. */
  55142. export class SceneOptimization {
  55143. /**
  55144. * Defines the priority of this optimization (0 by default which means first in the list)
  55145. */
  55146. priority: number;
  55147. /**
  55148. * Gets a string describing the action executed by the current optimization
  55149. * @returns description string
  55150. */
  55151. getDescription(): string;
  55152. /**
  55153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55154. * @param scene defines the current scene where to apply this optimization
  55155. * @param optimizer defines the current optimizer
  55156. * @returns true if everything that can be done was applied
  55157. */
  55158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55159. /**
  55160. * Creates the SceneOptimization object
  55161. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55162. * @param desc defines the description associated with the optimization
  55163. */
  55164. constructor(
  55165. /**
  55166. * Defines the priority of this optimization (0 by default which means first in the list)
  55167. */
  55168. priority?: number);
  55169. }
  55170. /**
  55171. * Defines an optimization used to reduce the size of render target textures
  55172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55173. */
  55174. export class TextureOptimization extends SceneOptimization {
  55175. /**
  55176. * Defines the priority of this optimization (0 by default which means first in the list)
  55177. */
  55178. priority: number;
  55179. /**
  55180. * 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
  55181. */
  55182. maximumSize: number;
  55183. /**
  55184. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55185. */
  55186. step: number;
  55187. /**
  55188. * Gets a string describing the action executed by the current optimization
  55189. * @returns description string
  55190. */
  55191. getDescription(): string;
  55192. /**
  55193. * Creates the TextureOptimization object
  55194. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55195. * @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
  55196. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55197. */
  55198. constructor(
  55199. /**
  55200. * Defines the priority of this optimization (0 by default which means first in the list)
  55201. */
  55202. priority?: number,
  55203. /**
  55204. * 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
  55205. */
  55206. maximumSize?: number,
  55207. /**
  55208. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55209. */
  55210. step?: number);
  55211. /**
  55212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55213. * @param scene defines the current scene where to apply this optimization
  55214. * @param optimizer defines the current optimizer
  55215. * @returns true if everything that can be done was applied
  55216. */
  55217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55218. }
  55219. /**
  55220. * Defines an optimization used to increase or decrease the rendering resolution
  55221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55222. */
  55223. export class HardwareScalingOptimization extends SceneOptimization {
  55224. /**
  55225. * Defines the priority of this optimization (0 by default which means first in the list)
  55226. */
  55227. priority: number;
  55228. /**
  55229. * Defines the maximum scale to use (2 by default)
  55230. */
  55231. maximumScale: number;
  55232. /**
  55233. * Defines the step to use between two passes (0.5 by default)
  55234. */
  55235. step: number;
  55236. private _currentScale;
  55237. private _directionOffset;
  55238. /**
  55239. * Gets a string describing the action executed by the current optimization
  55240. * @return description string
  55241. */
  55242. getDescription(): string;
  55243. /**
  55244. * Creates the HardwareScalingOptimization object
  55245. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55246. * @param maximumScale defines the maximum scale to use (2 by default)
  55247. * @param step defines the step to use between two passes (0.5 by default)
  55248. */
  55249. constructor(
  55250. /**
  55251. * Defines the priority of this optimization (0 by default which means first in the list)
  55252. */
  55253. priority?: number,
  55254. /**
  55255. * Defines the maximum scale to use (2 by default)
  55256. */
  55257. maximumScale?: number,
  55258. /**
  55259. * Defines the step to use between two passes (0.5 by default)
  55260. */
  55261. step?: number);
  55262. /**
  55263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55264. * @param scene defines the current scene where to apply this optimization
  55265. * @param optimizer defines the current optimizer
  55266. * @returns true if everything that can be done was applied
  55267. */
  55268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55269. }
  55270. /**
  55271. * Defines an optimization used to remove shadows
  55272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55273. */
  55274. export class ShadowsOptimization extends SceneOptimization {
  55275. /**
  55276. * Gets a string describing the action executed by the current optimization
  55277. * @return description string
  55278. */
  55279. getDescription(): string;
  55280. /**
  55281. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55282. * @param scene defines the current scene where to apply this optimization
  55283. * @param optimizer defines the current optimizer
  55284. * @returns true if everything that can be done was applied
  55285. */
  55286. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55287. }
  55288. /**
  55289. * Defines an optimization used to turn post-processes off
  55290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55291. */
  55292. export class PostProcessesOptimization extends SceneOptimization {
  55293. /**
  55294. * Gets a string describing the action executed by the current optimization
  55295. * @return description string
  55296. */
  55297. getDescription(): string;
  55298. /**
  55299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55300. * @param scene defines the current scene where to apply this optimization
  55301. * @param optimizer defines the current optimizer
  55302. * @returns true if everything that can be done was applied
  55303. */
  55304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55305. }
  55306. /**
  55307. * Defines an optimization used to turn lens flares off
  55308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55309. */
  55310. export class LensFlaresOptimization extends SceneOptimization {
  55311. /**
  55312. * Gets a string describing the action executed by the current optimization
  55313. * @return description string
  55314. */
  55315. getDescription(): string;
  55316. /**
  55317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55318. * @param scene defines the current scene where to apply this optimization
  55319. * @param optimizer defines the current optimizer
  55320. * @returns true if everything that can be done was applied
  55321. */
  55322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55323. }
  55324. /**
  55325. * Defines an optimization based on user defined callback.
  55326. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55327. */
  55328. export class CustomOptimization extends SceneOptimization {
  55329. /**
  55330. * Callback called to apply the custom optimization.
  55331. */
  55332. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55333. /**
  55334. * Callback called to get custom description
  55335. */
  55336. onGetDescription: () => string;
  55337. /**
  55338. * Gets a string describing the action executed by the current optimization
  55339. * @returns description string
  55340. */
  55341. getDescription(): string;
  55342. /**
  55343. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55344. * @param scene defines the current scene where to apply this optimization
  55345. * @param optimizer defines the current optimizer
  55346. * @returns true if everything that can be done was applied
  55347. */
  55348. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55349. }
  55350. /**
  55351. * Defines an optimization used to turn particles off
  55352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55353. */
  55354. export class ParticlesOptimization extends SceneOptimization {
  55355. /**
  55356. * Gets a string describing the action executed by the current optimization
  55357. * @return description string
  55358. */
  55359. getDescription(): string;
  55360. /**
  55361. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55362. * @param scene defines the current scene where to apply this optimization
  55363. * @param optimizer defines the current optimizer
  55364. * @returns true if everything that can be done was applied
  55365. */
  55366. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55367. }
  55368. /**
  55369. * Defines an optimization used to turn render targets off
  55370. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55371. */
  55372. export class RenderTargetsOptimization extends SceneOptimization {
  55373. /**
  55374. * Gets a string describing the action executed by the current optimization
  55375. * @return description string
  55376. */
  55377. getDescription(): string;
  55378. /**
  55379. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55380. * @param scene defines the current scene where to apply this optimization
  55381. * @param optimizer defines the current optimizer
  55382. * @returns true if everything that can be done was applied
  55383. */
  55384. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55385. }
  55386. /**
  55387. * Defines an optimization used to merge meshes with compatible materials
  55388. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55389. */
  55390. export class MergeMeshesOptimization extends SceneOptimization {
  55391. private static _UpdateSelectionTree;
  55392. /**
  55393. * Gets or sets a boolean which defines if optimization octree has to be updated
  55394. */
  55395. /**
  55396. * Gets or sets a boolean which defines if optimization octree has to be updated
  55397. */
  55398. static UpdateSelectionTree: boolean;
  55399. /**
  55400. * Gets a string describing the action executed by the current optimization
  55401. * @return description string
  55402. */
  55403. getDescription(): string;
  55404. private _canBeMerged;
  55405. /**
  55406. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55407. * @param scene defines the current scene where to apply this optimization
  55408. * @param optimizer defines the current optimizer
  55409. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55410. * @returns true if everything that can be done was applied
  55411. */
  55412. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55413. }
  55414. /**
  55415. * Defines a list of options used by SceneOptimizer
  55416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55417. */
  55418. export class SceneOptimizerOptions {
  55419. /**
  55420. * Defines the target frame rate to reach (60 by default)
  55421. */
  55422. targetFrameRate: number;
  55423. /**
  55424. * Defines the interval between two checkes (2000ms by default)
  55425. */
  55426. trackerDuration: number;
  55427. /**
  55428. * Gets the list of optimizations to apply
  55429. */
  55430. optimizations: SceneOptimization[];
  55431. /**
  55432. * Creates a new list of options used by SceneOptimizer
  55433. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55434. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55435. */
  55436. constructor(
  55437. /**
  55438. * Defines the target frame rate to reach (60 by default)
  55439. */
  55440. targetFrameRate?: number,
  55441. /**
  55442. * Defines the interval between two checkes (2000ms by default)
  55443. */
  55444. trackerDuration?: number);
  55445. /**
  55446. * Add a new optimization
  55447. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55448. * @returns the current SceneOptimizerOptions
  55449. */
  55450. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55451. /**
  55452. * Add a new custom optimization
  55453. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55454. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55455. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55456. * @returns the current SceneOptimizerOptions
  55457. */
  55458. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55459. /**
  55460. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55461. * @param targetFrameRate defines the target frame rate (60 by default)
  55462. * @returns a SceneOptimizerOptions object
  55463. */
  55464. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55465. /**
  55466. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55467. * @param targetFrameRate defines the target frame rate (60 by default)
  55468. * @returns a SceneOptimizerOptions object
  55469. */
  55470. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55471. /**
  55472. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55473. * @param targetFrameRate defines the target frame rate (60 by default)
  55474. * @returns a SceneOptimizerOptions object
  55475. */
  55476. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55477. }
  55478. /**
  55479. * Class used to run optimizations in order to reach a target frame rate
  55480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55481. */
  55482. export class SceneOptimizer implements IDisposable {
  55483. private _isRunning;
  55484. private _options;
  55485. private _scene;
  55486. private _currentPriorityLevel;
  55487. private _targetFrameRate;
  55488. private _trackerDuration;
  55489. private _currentFrameRate;
  55490. private _sceneDisposeObserver;
  55491. private _improvementMode;
  55492. /**
  55493. * Defines an observable called when the optimizer reaches the target frame rate
  55494. */
  55495. onSuccessObservable: Observable<SceneOptimizer>;
  55496. /**
  55497. * Defines an observable called when the optimizer enables an optimization
  55498. */
  55499. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55500. /**
  55501. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55502. */
  55503. onFailureObservable: Observable<SceneOptimizer>;
  55504. /**
  55505. * Gets a boolean indicating if the optimizer is in improvement mode
  55506. */
  55507. readonly isInImprovementMode: boolean;
  55508. /**
  55509. * Gets the current priority level (0 at start)
  55510. */
  55511. readonly currentPriorityLevel: number;
  55512. /**
  55513. * Gets the current frame rate checked by the SceneOptimizer
  55514. */
  55515. readonly currentFrameRate: number;
  55516. /**
  55517. * Gets or sets the current target frame rate (60 by default)
  55518. */
  55519. /**
  55520. * Gets or sets the current target frame rate (60 by default)
  55521. */
  55522. targetFrameRate: number;
  55523. /**
  55524. * Gets or sets the current interval between two checks (every 2000ms by default)
  55525. */
  55526. /**
  55527. * Gets or sets the current interval between two checks (every 2000ms by default)
  55528. */
  55529. trackerDuration: number;
  55530. /**
  55531. * Gets the list of active optimizations
  55532. */
  55533. readonly optimizations: SceneOptimization[];
  55534. /**
  55535. * Creates a new SceneOptimizer
  55536. * @param scene defines the scene to work on
  55537. * @param options defines the options to use with the SceneOptimizer
  55538. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55539. * @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)
  55540. */
  55541. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55542. /**
  55543. * Stops the current optimizer
  55544. */
  55545. stop(): void;
  55546. /**
  55547. * Reset the optimizer to initial step (current priority level = 0)
  55548. */
  55549. reset(): void;
  55550. /**
  55551. * Start the optimizer. By default it will try to reach a specific framerate
  55552. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55553. */
  55554. start(): void;
  55555. private _checkCurrentState;
  55556. /**
  55557. * Release all resources
  55558. */
  55559. dispose(): void;
  55560. /**
  55561. * Helper function to create a SceneOptimizer with one single line of code
  55562. * @param scene defines the scene to work on
  55563. * @param options defines the options to use with the SceneOptimizer
  55564. * @param onSuccess defines a callback to call on success
  55565. * @param onFailure defines a callback to call on failure
  55566. * @returns the new SceneOptimizer object
  55567. */
  55568. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55569. }
  55570. }
  55571. declare module BABYLON {
  55572. /**
  55573. * Class used to serialize a scene into a string
  55574. */
  55575. export class SceneSerializer {
  55576. /**
  55577. * Clear cache used by a previous serialization
  55578. */
  55579. static ClearCache(): void;
  55580. /**
  55581. * Serialize a scene into a JSON compatible object
  55582. * @param scene defines the scene to serialize
  55583. * @returns a JSON compatible object
  55584. */
  55585. static Serialize(scene: Scene): any;
  55586. /**
  55587. * Serialize a mesh into a JSON compatible object
  55588. * @param toSerialize defines the mesh to serialize
  55589. * @param withParents defines if parents must be serialized as well
  55590. * @param withChildren defines if children must be serialized as well
  55591. * @returns a JSON compatible object
  55592. */
  55593. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55594. }
  55595. }
  55596. declare module BABYLON {
  55597. /**
  55598. * Class used to host texture specific utilities
  55599. */
  55600. export class TextureTools {
  55601. /**
  55602. * Uses the GPU to create a copy texture rescaled at a given size
  55603. * @param texture Texture to copy from
  55604. * @param width defines the desired width
  55605. * @param height defines the desired height
  55606. * @param useBilinearMode defines if bilinear mode has to be used
  55607. * @return the generated texture
  55608. */
  55609. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55610. }
  55611. }
  55612. declare module BABYLON {
  55613. /**
  55614. * This represents the different options avilable for the video capture.
  55615. */
  55616. export interface VideoRecorderOptions {
  55617. /** Defines the mime type of the video */
  55618. mimeType: string;
  55619. /** Defines the video the video should be recorded at */
  55620. fps: number;
  55621. /** Defines the chunk size for the recording data */
  55622. recordChunckSize: number;
  55623. /** The audio tracks to attach to the record */
  55624. audioTracks?: MediaStreamTrack[];
  55625. }
  55626. /**
  55627. * This can helps recording videos from BabylonJS.
  55628. * This is based on the available WebRTC functionalities of the browser.
  55629. *
  55630. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55631. */
  55632. export class VideoRecorder {
  55633. private static readonly _defaultOptions;
  55634. /**
  55635. * Returns wehther or not the VideoRecorder is available in your browser.
  55636. * @param engine Defines the Babylon Engine to check the support for
  55637. * @returns true if supported otherwise false
  55638. */
  55639. static IsSupported(engine: Engine): boolean;
  55640. private readonly _options;
  55641. private _canvas;
  55642. private _mediaRecorder;
  55643. private _recordedChunks;
  55644. private _fileName;
  55645. private _resolve;
  55646. private _reject;
  55647. /**
  55648. * True wether a recording is already in progress.
  55649. */
  55650. readonly isRecording: boolean;
  55651. /**
  55652. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55653. * a video file.
  55654. * @param engine Defines the BabylonJS Engine you wish to record
  55655. * @param options Defines options that can be used to customized the capture
  55656. */
  55657. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55658. /**
  55659. * Stops the current recording before the default capture timeout passed in the startRecording
  55660. * functions.
  55661. */
  55662. stopRecording(): void;
  55663. /**
  55664. * Starts recording the canvas for a max duration specified in parameters.
  55665. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  55666. * @param maxDuration Defines the maximum recording time in seconds.
  55667. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55668. * @return a promise callback at the end of the recording with the video data in Blob.
  55669. */
  55670. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55671. /**
  55672. * Releases internal resources used during the recording.
  55673. */
  55674. dispose(): void;
  55675. private _handleDataAvailable;
  55676. private _handleError;
  55677. private _handleStop;
  55678. }
  55679. }
  55680. declare module BABYLON {
  55681. /**
  55682. * Class containing a set of static utilities functions for screenshots
  55683. */
  55684. export class ScreenshotTools {
  55685. /**
  55686. * Captures a screenshot of the current rendering
  55687. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55688. * @param engine defines the rendering engine
  55689. * @param camera defines the source camera
  55690. * @param size This parameter can be set to a single number or to an object with the
  55691. * following (optional) properties: precision, width, height. If a single number is passed,
  55692. * it will be used for both width and height. If an object is passed, the screenshot size
  55693. * will be derived from the parameters. The precision property is a multiplier allowing
  55694. * rendering at a higher or lower resolution
  55695. * @param successCallback defines the callback receives a single parameter which contains the
  55696. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55697. * src parameter of an <img> to display it
  55698. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55699. * Check your browser for supported MIME types
  55700. */
  55701. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55702. /**
  55703. * Generates an image screenshot from the specified camera.
  55704. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55705. * @param engine The engine to use for rendering
  55706. * @param camera The camera to use for rendering
  55707. * @param size This parameter can be set to a single number or to an object with the
  55708. * following (optional) properties: precision, width, height. If a single number is passed,
  55709. * it will be used for both width and height. If an object is passed, the screenshot size
  55710. * will be derived from the parameters. The precision property is a multiplier allowing
  55711. * rendering at a higher or lower resolution
  55712. * @param successCallback The callback receives a single parameter which contains the
  55713. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55714. * src parameter of an <img> to display it
  55715. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55716. * Check your browser for supported MIME types
  55717. * @param samples Texture samples (default: 1)
  55718. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55719. * @param fileName A name for for the downloaded file.
  55720. */
  55721. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55722. }
  55723. }
  55724. declare module BABYLON {
  55725. /**
  55726. * A cursor which tracks a point on a path
  55727. */
  55728. export class PathCursor {
  55729. private path;
  55730. /**
  55731. * Stores path cursor callbacks for when an onchange event is triggered
  55732. */
  55733. private _onchange;
  55734. /**
  55735. * The value of the path cursor
  55736. */
  55737. value: number;
  55738. /**
  55739. * The animation array of the path cursor
  55740. */
  55741. animations: Animation[];
  55742. /**
  55743. * Initializes the path cursor
  55744. * @param path The path to track
  55745. */
  55746. constructor(path: Path2);
  55747. /**
  55748. * Gets the cursor point on the path
  55749. * @returns A point on the path cursor at the cursor location
  55750. */
  55751. getPoint(): Vector3;
  55752. /**
  55753. * Moves the cursor ahead by the step amount
  55754. * @param step The amount to move the cursor forward
  55755. * @returns This path cursor
  55756. */
  55757. moveAhead(step?: number): PathCursor;
  55758. /**
  55759. * Moves the cursor behind by the step amount
  55760. * @param step The amount to move the cursor back
  55761. * @returns This path cursor
  55762. */
  55763. moveBack(step?: number): PathCursor;
  55764. /**
  55765. * Moves the cursor by the step amount
  55766. * If the step amount is greater than one, an exception is thrown
  55767. * @param step The amount to move the cursor
  55768. * @returns This path cursor
  55769. */
  55770. move(step: number): PathCursor;
  55771. /**
  55772. * Ensures that the value is limited between zero and one
  55773. * @returns This path cursor
  55774. */
  55775. private ensureLimits;
  55776. /**
  55777. * Runs onchange callbacks on change (used by the animation engine)
  55778. * @returns This path cursor
  55779. */
  55780. private raiseOnChange;
  55781. /**
  55782. * Executes a function on change
  55783. * @param f A path cursor onchange callback
  55784. * @returns This path cursor
  55785. */
  55786. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55787. }
  55788. }
  55789. declare module BABYLON {
  55790. /** @hidden */
  55791. export var blurPixelShader: {
  55792. name: string;
  55793. shader: string;
  55794. };
  55795. }
  55796. declare module BABYLON {
  55797. /** @hidden */
  55798. export var bones300Declaration: {
  55799. name: string;
  55800. shader: string;
  55801. };
  55802. }
  55803. declare module BABYLON {
  55804. /** @hidden */
  55805. export var instances300Declaration: {
  55806. name: string;
  55807. shader: string;
  55808. };
  55809. }
  55810. declare module BABYLON {
  55811. /** @hidden */
  55812. export var pointCloudVertexDeclaration: {
  55813. name: string;
  55814. shader: string;
  55815. };
  55816. }
  55817. // Mixins
  55818. interface Window {
  55819. mozIndexedDB: IDBFactory;
  55820. webkitIndexedDB: IDBFactory;
  55821. msIndexedDB: IDBFactory;
  55822. webkitURL: typeof URL;
  55823. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55824. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55825. WebGLRenderingContext: WebGLRenderingContext;
  55826. MSGesture: MSGesture;
  55827. CANNON: any;
  55828. AudioContext: AudioContext;
  55829. webkitAudioContext: AudioContext;
  55830. PointerEvent: any;
  55831. Math: Math;
  55832. Uint8Array: Uint8ArrayConstructor;
  55833. Float32Array: Float32ArrayConstructor;
  55834. mozURL: typeof URL;
  55835. msURL: typeof URL;
  55836. VRFrameData: any; // WebVR, from specs 1.1
  55837. DracoDecoderModule: any;
  55838. setImmediate(handler: (...args: any[]) => void): number;
  55839. }
  55840. interface HTMLCanvasElement {
  55841. requestPointerLock(): void;
  55842. msRequestPointerLock?(): void;
  55843. mozRequestPointerLock?(): void;
  55844. webkitRequestPointerLock?(): void;
  55845. /** Track wether a record is in progress */
  55846. isRecording: boolean;
  55847. /** Capture Stream method defined by some browsers */
  55848. captureStream(fps?: number): MediaStream;
  55849. }
  55850. interface CanvasRenderingContext2D {
  55851. msImageSmoothingEnabled: boolean;
  55852. }
  55853. interface MouseEvent {
  55854. mozMovementX: number;
  55855. mozMovementY: number;
  55856. webkitMovementX: number;
  55857. webkitMovementY: number;
  55858. msMovementX: number;
  55859. msMovementY: number;
  55860. }
  55861. interface Navigator {
  55862. mozGetVRDevices: (any: any) => any;
  55863. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55864. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55865. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55866. webkitGetGamepads(): Gamepad[];
  55867. msGetGamepads(): Gamepad[];
  55868. webkitGamepads(): Gamepad[];
  55869. }
  55870. interface HTMLVideoElement {
  55871. mozSrcObject: any;
  55872. }
  55873. interface Math {
  55874. fround(x: number): number;
  55875. imul(a: number, b: number): number;
  55876. }
  55877. interface WebGLRenderingContext {
  55878. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55879. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55880. vertexAttribDivisor(index: number, divisor: number): void;
  55881. createVertexArray(): any;
  55882. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55883. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55884. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55885. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55886. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55887. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55888. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55889. // Queries
  55890. createQuery(): WebGLQuery;
  55891. deleteQuery(query: WebGLQuery): void;
  55892. beginQuery(target: number, query: WebGLQuery): void;
  55893. endQuery(target: number): void;
  55894. getQueryParameter(query: WebGLQuery, pname: number): any;
  55895. getQuery(target: number, pname: number): any;
  55896. MAX_SAMPLES: number;
  55897. RGBA8: number;
  55898. READ_FRAMEBUFFER: number;
  55899. DRAW_FRAMEBUFFER: number;
  55900. UNIFORM_BUFFER: number;
  55901. HALF_FLOAT_OES: number;
  55902. RGBA16F: number;
  55903. RGBA32F: number;
  55904. R32F: number;
  55905. RG32F: number;
  55906. RGB32F: number;
  55907. R16F: number;
  55908. RG16F: number;
  55909. RGB16F: number;
  55910. RED: number;
  55911. RG: number;
  55912. R8: number;
  55913. RG8: number;
  55914. UNSIGNED_INT_24_8: number;
  55915. DEPTH24_STENCIL8: number;
  55916. /* Multiple Render Targets */
  55917. drawBuffers(buffers: number[]): void;
  55918. readBuffer(src: number): void;
  55919. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55920. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55921. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55922. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55923. // Occlusion Query
  55924. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55925. ANY_SAMPLES_PASSED: number;
  55926. QUERY_RESULT_AVAILABLE: number;
  55927. QUERY_RESULT: number;
  55928. }
  55929. interface WebGLProgram { private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55930. }
  55931. interface EXT_disjoint_timer_query {
  55932. QUERY_COUNTER_BITS_EXT: number;
  55933. TIME_ELAPSED_EXT: number;
  55934. TIMESTAMP_EXT: number;
  55935. GPU_DISJOINT_EXT: number;
  55936. QUERY_RESULT_EXT: number;
  55937. QUERY_RESULT_AVAILABLE_EXT: number;
  55938. queryCounterEXT(query: WebGLQuery, target: number): void;
  55939. createQueryEXT(): WebGLQuery;
  55940. beginQueryEXT(target: number, query: WebGLQuery): void;
  55941. endQueryEXT(target: number): void;
  55942. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55943. deleteQueryEXT(query: WebGLQuery): void;
  55944. }
  55945. interface WebGLUniformLocation { currentState: any;
  55946. }
  55947. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55948. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55949. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55950. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55951. interface WebGLRenderingContext {
  55952. readonly RASTERIZER_DISCARD: number;
  55953. readonly DEPTH_COMPONENT24: number;
  55954. readonly TEXTURE_3D: number;
  55955. readonly TEXTURE_2D_ARRAY: number;
  55956. readonly TEXTURE_COMPARE_FUNC: number;
  55957. readonly TEXTURE_COMPARE_MODE: number;
  55958. readonly COMPARE_REF_TO_TEXTURE: number;
  55959. readonly TEXTURE_WRAP_R: number;
  55960. readonly HALF_FLOAT: number;
  55961. readonly RGB8: number;
  55962. readonly RED_INTEGER: number;
  55963. readonly RG_INTEGER: number;
  55964. readonly RGB_INTEGER: number;
  55965. readonly RGBA_INTEGER: number;
  55966. readonly R8_SNORM: number;
  55967. readonly RG8_SNORM: number;
  55968. readonly RGB8_SNORM: number;
  55969. readonly RGBA8_SNORM: number;
  55970. readonly R8I: number;
  55971. readonly RG8I: number;
  55972. readonly RGB8I: number;
  55973. readonly RGBA8I: number;
  55974. readonly R8UI: number;
  55975. readonly RG8UI: number;
  55976. readonly RGB8UI: number;
  55977. readonly RGBA8UI: number;
  55978. readonly R16I: number;
  55979. readonly RG16I: number;
  55980. readonly RGB16I: number;
  55981. readonly RGBA16I: number;
  55982. readonly R16UI: number;
  55983. readonly RG16UI: number;
  55984. readonly RGB16UI: number;
  55985. readonly RGBA16UI: number;
  55986. readonly R32I: number;
  55987. readonly RG32I: number;
  55988. readonly RGB32I: number;
  55989. readonly RGBA32I: number;
  55990. readonly R32UI: number;
  55991. readonly RG32UI: number;
  55992. readonly RGB32UI: number;
  55993. readonly RGBA32UI: number;
  55994. readonly RGB10_A2UI: number;
  55995. readonly R11F_G11F_B10F: number;
  55996. readonly RGB9_E5: number;
  55997. readonly RGB10_A2: number;
  55998. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55999. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56000. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56001. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56002. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56003. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56004. 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;
  56005. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56006. readonly TRANSFORM_FEEDBACK: number;
  56007. readonly INTERLEAVED_ATTRIBS: number;
  56008. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56009. createTransformFeedback(): WebGLTransformFeedback;
  56010. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56011. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56012. beginTransformFeedback(primitiveMode: number): void;
  56013. endTransformFeedback(): void;
  56014. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56015. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56016. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56017. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56018. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56019. }
  56020. interface ImageBitmap {
  56021. readonly width: number;
  56022. readonly height: number;
  56023. close(): void;
  56024. }
  56025. interface WebGLQuery extends WebGLObject {
  56026. }
  56027. declare var WebGLQuery: {
  56028. prototype: WebGLQuery;
  56029. new(): WebGLQuery;
  56030. };
  56031. interface WebGLSampler extends WebGLObject {
  56032. }
  56033. declare var WebGLSampler: {
  56034. prototype: WebGLSampler;
  56035. new(): WebGLSampler;
  56036. };
  56037. interface WebGLSync extends WebGLObject {
  56038. }
  56039. declare var WebGLSync: {
  56040. prototype: WebGLSync;
  56041. new(): WebGLSync;
  56042. };
  56043. interface WebGLTransformFeedback extends WebGLObject {
  56044. }
  56045. declare var WebGLTransformFeedback: {
  56046. prototype: WebGLTransformFeedback;
  56047. new(): WebGLTransformFeedback;
  56048. };
  56049. interface WebGLVertexArrayObject extends WebGLObject {
  56050. }
  56051. declare var WebGLVertexArrayObject: {
  56052. prototype: WebGLVertexArrayObject;
  56053. new(): WebGLVertexArrayObject;
  56054. };
  56055. // Type definitions for WebVR API
  56056. // Project: https://w3c.github.io/webvr/
  56057. // Definitions by: six a <https://github.com/lostfictions>
  56058. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56059. interface VRDisplay extends EventTarget {
  56060. /**
  56061. * Dictionary of capabilities describing the VRDisplay.
  56062. */
  56063. readonly capabilities: VRDisplayCapabilities;
  56064. /**
  56065. * z-depth defining the far plane of the eye view frustum
  56066. * enables mapping of values in the render target depth
  56067. * attachment to scene coordinates. Initially set to 10000.0.
  56068. */
  56069. depthFar: number;
  56070. /**
  56071. * z-depth defining the near plane of the eye view frustum
  56072. * enables mapping of values in the render target depth
  56073. * attachment to scene coordinates. Initially set to 0.01.
  56074. */
  56075. depthNear: number;
  56076. /**
  56077. * An identifier for this distinct VRDisplay. Used as an
  56078. * association point in the Gamepad API.
  56079. */
  56080. readonly displayId: number;
  56081. /**
  56082. * A display name, a user-readable name identifying it.
  56083. */
  56084. readonly displayName: string;
  56085. readonly isConnected: boolean;
  56086. readonly isPresenting: boolean;
  56087. /**
  56088. * If this VRDisplay supports room-scale experiences, the optional
  56089. * stage attribute contains details on the room-scale parameters.
  56090. */
  56091. readonly stageParameters: VRStageParameters | null;
  56092. /**
  56093. * Passing the value returned by `requestAnimationFrame` to
  56094. * `cancelAnimationFrame` will unregister the callback.
  56095. * @param handle Define the hanle of the request to cancel
  56096. */
  56097. cancelAnimationFrame(handle: number): void;
  56098. /**
  56099. * Stops presenting to the VRDisplay.
  56100. * @returns a promise to know when it stopped
  56101. */
  56102. exitPresent(): Promise<void>;
  56103. /**
  56104. * Return the current VREyeParameters for the given eye.
  56105. * @param whichEye Define the eye we want the parameter for
  56106. * @returns the eye parameters
  56107. */
  56108. getEyeParameters(whichEye: string): VREyeParameters;
  56109. /**
  56110. * Populates the passed VRFrameData with the information required to render
  56111. * the current frame.
  56112. * @param frameData Define the data structure to populate
  56113. * @returns true if ok otherwise false
  56114. */
  56115. getFrameData(frameData: VRFrameData): boolean;
  56116. /**
  56117. * Get the layers currently being presented.
  56118. * @returns the list of VR layers
  56119. */
  56120. getLayers(): VRLayer[];
  56121. /**
  56122. * Return a VRPose containing the future predicted pose of the VRDisplay
  56123. * when the current frame will be presented. The value returned will not
  56124. * change until JavaScript has returned control to the browser.
  56125. *
  56126. * The VRPose will contain the position, orientation, velocity,
  56127. * and acceleration of each of these properties.
  56128. * @returns the pose object
  56129. */
  56130. getPose(): VRPose;
  56131. /**
  56132. * Return the current instantaneous pose of the VRDisplay, with no
  56133. * prediction applied.
  56134. * @returns the current instantaneous pose
  56135. */
  56136. getImmediatePose(): VRPose;
  56137. /**
  56138. * The callback passed to `requestAnimationFrame` will be called
  56139. * any time a new frame should be rendered. When the VRDisplay is
  56140. * presenting the callback will be called at the native refresh
  56141. * rate of the HMD. When not presenting this function acts
  56142. * identically to how window.requestAnimationFrame acts. Content should
  56143. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56144. * asynchronously from other displays and at differing refresh rates.
  56145. * @param callback Define the eaction to run next frame
  56146. * @returns the request handle it
  56147. */
  56148. requestAnimationFrame(callback: FrameRequestCallback): number;
  56149. /**
  56150. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56151. * Repeat calls while already presenting will update the VRLayers being displayed.
  56152. * @param layers Define the list of layer to present
  56153. * @returns a promise to know when the request has been fulfilled
  56154. */
  56155. requestPresent(layers: VRLayer[]): Promise<void>;
  56156. /**
  56157. * Reset the pose for this display, treating its current position and
  56158. * orientation as the "origin/zero" values. VRPose.position,
  56159. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56160. * updated when calling resetPose(). This should be called in only
  56161. * sitting-space experiences.
  56162. */
  56163. resetPose(): void;
  56164. /**
  56165. * The VRLayer provided to the VRDisplay will be captured and presented
  56166. * in the HMD. Calling this function has the same effect on the source
  56167. * canvas as any other operation that uses its source image, and canvases
  56168. * created without preserveDrawingBuffer set to true will be cleared.
  56169. * @param pose Define the pose to submit
  56170. */
  56171. submitFrame(pose?: VRPose): void;
  56172. }
  56173. declare var VRDisplay: {
  56174. prototype: VRDisplay;
  56175. new(): VRDisplay;
  56176. };
  56177. interface VRLayer {
  56178. leftBounds?: number[] | Float32Array | null;
  56179. rightBounds?: number[] | Float32Array | null;
  56180. source?: HTMLCanvasElement | null;
  56181. }
  56182. interface VRDisplayCapabilities {
  56183. readonly canPresent: boolean;
  56184. readonly hasExternalDisplay: boolean;
  56185. readonly hasOrientation: boolean;
  56186. readonly hasPosition: boolean;
  56187. readonly maxLayers: number;
  56188. }
  56189. interface VREyeParameters {
  56190. /** @deprecated */
  56191. readonly fieldOfView: VRFieldOfView;
  56192. readonly offset: Float32Array;
  56193. readonly renderHeight: number;
  56194. readonly renderWidth: number;
  56195. }
  56196. interface VRFieldOfView {
  56197. readonly downDegrees: number;
  56198. readonly leftDegrees: number;
  56199. readonly rightDegrees: number;
  56200. readonly upDegrees: number;
  56201. }
  56202. interface VRFrameData {
  56203. readonly leftProjectionMatrix: Float32Array;
  56204. readonly leftViewMatrix: Float32Array;
  56205. readonly pose: VRPose;
  56206. readonly rightProjectionMatrix: Float32Array;
  56207. readonly rightViewMatrix: Float32Array;
  56208. readonly timestamp: number;
  56209. }
  56210. interface VRPose {
  56211. readonly angularAcceleration: Float32Array | null;
  56212. readonly angularVelocity: Float32Array | null;
  56213. readonly linearAcceleration: Float32Array | null;
  56214. readonly linearVelocity: Float32Array | null;
  56215. readonly orientation: Float32Array | null;
  56216. readonly position: Float32Array | null;
  56217. readonly timestamp: number;
  56218. }
  56219. interface VRStageParameters {
  56220. sittingToStandingTransform?: Float32Array;
  56221. sizeX?: number;
  56222. sizeY?: number;
  56223. }
  56224. interface Navigator {
  56225. getVRDisplays(): Promise<VRDisplay[]>;
  56226. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56227. }
  56228. interface Window {
  56229. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56230. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56231. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56232. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56233. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56234. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56235. }
  56236. interface Gamepad {
  56237. readonly displayId: number;
  56238. }
  56239. interface XRDevice {
  56240. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56241. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56242. }
  56243. interface XRSession {
  56244. getInputSources(): Array<any>;
  56245. baseLayer: XRWebGLLayer;
  56246. requestFrameOfReference(type: string): Promise<void>;
  56247. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56248. end(): Promise<void>;
  56249. requestAnimationFrame: Function;
  56250. addEventListener: Function;
  56251. }
  56252. interface XRSessionCreationOptions {
  56253. outputContext?: WebGLRenderingContext | null;
  56254. immersive?: boolean;
  56255. environmentIntegration?: boolean;
  56256. }
  56257. interface XRLayer {
  56258. getViewport: Function;
  56259. framebufferWidth: number;
  56260. framebufferHeight: number;
  56261. }
  56262. interface XRView {
  56263. projectionMatrix: Float32Array;
  56264. }
  56265. interface XRFrame {
  56266. getDevicePose: Function;
  56267. getInputPose: Function;
  56268. views: Array<XRView>;
  56269. baseLayer: XRLayer;
  56270. }
  56271. interface XRFrameOfReference {
  56272. }
  56273. interface XRWebGLLayer extends XRLayer {
  56274. framebuffer: WebGLFramebuffer;
  56275. }
  56276. declare var XRWebGLLayer: {
  56277. prototype: XRWebGLLayer;
  56278. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56279. };
  56280. declare module BABYLON.GUI {
  56281. /**
  56282. * Class used to specific a value and its associated unit
  56283. */
  56284. export class ValueAndUnit {
  56285. /** defines the unit to store */
  56286. unit: number;
  56287. /** defines a boolean indicating if the value can be negative */
  56288. negativeValueAllowed: boolean;
  56289. private _value;
  56290. private _originalUnit;
  56291. /**
  56292. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56293. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56294. */
  56295. ignoreAdaptiveScaling: boolean;
  56296. /**
  56297. * Creates a new ValueAndUnit
  56298. * @param value defines the value to store
  56299. * @param unit defines the unit to store
  56300. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  56301. */
  56302. constructor(value: number,
  56303. /** defines the unit to store */
  56304. unit?: number,
  56305. /** defines a boolean indicating if the value can be negative */
  56306. negativeValueAllowed?: boolean);
  56307. /** Gets a boolean indicating if the value is a percentage */
  56308. readonly isPercentage: boolean;
  56309. /** Gets a boolean indicating if the value is store as pixel */
  56310. readonly isPixel: boolean;
  56311. /** Gets direct internal value */
  56312. readonly internalValue: number;
  56313. /**
  56314. * Gets value as pixel
  56315. * @param host defines the root host
  56316. * @param refValue defines the reference value for percentages
  56317. * @returns the value as pixel
  56318. */
  56319. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  56320. /**
  56321. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  56322. * @param value defines the value to store
  56323. * @param unit defines the unit to store
  56324. * @returns the current ValueAndUnit
  56325. */
  56326. updateInPlace(value: number, unit?: number): ValueAndUnit;
  56327. /**
  56328. * Gets the value accordingly to its unit
  56329. * @param host defines the root host
  56330. * @returns the value
  56331. */
  56332. getValue(host: AdvancedDynamicTexture): number;
  56333. /**
  56334. * Gets a string representation of the value
  56335. * @param host defines the root host
  56336. * @param decimals defines an optional number of decimals to display
  56337. * @returns a string
  56338. */
  56339. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  56340. /**
  56341. * Store a value parsed from a string
  56342. * @param source defines the source string
  56343. * @returns true if the value was successfully parsed
  56344. */
  56345. fromString(source: string | number): boolean;
  56346. private static _Regex;
  56347. private static _UNITMODE_PERCENTAGE;
  56348. private static _UNITMODE_PIXEL;
  56349. /** UNITMODE_PERCENTAGE */
  56350. static readonly UNITMODE_PERCENTAGE: number;
  56351. /** UNITMODE_PIXEL */
  56352. static readonly UNITMODE_PIXEL: number;
  56353. }
  56354. }
  56355. declare module BABYLON.GUI {
  56356. /**
  56357. * Define a style used by control to automatically setup properties based on a template.
  56358. * Only support font related properties so far
  56359. */
  56360. export class Style implements BABYLON.IDisposable {
  56361. private _fontFamily;
  56362. private _fontStyle;
  56363. private _fontWeight;
  56364. /** @hidden */ host: AdvancedDynamicTexture;
  56365. /** @hidden */ fontSize: ValueAndUnit;
  56366. /**
  56367. * BABYLON.Observable raised when the style values are changed
  56368. */
  56369. onChangedObservable: BABYLON.Observable<Style>;
  56370. /**
  56371. * Creates a new style object
  56372. * @param host defines the AdvancedDynamicTexture which hosts this style
  56373. */
  56374. constructor(host: AdvancedDynamicTexture);
  56375. /**
  56376. * Gets or sets the font size
  56377. */
  56378. fontSize: string | number;
  56379. /**
  56380. * Gets or sets the font family
  56381. */
  56382. fontFamily: string;
  56383. /**
  56384. * Gets or sets the font style
  56385. */
  56386. fontStyle: string;
  56387. /** Gets or sets font weight */
  56388. fontWeight: string;
  56389. /** Dispose all associated resources */
  56390. dispose(): void;
  56391. }
  56392. }
  56393. declare module BABYLON.GUI {
  56394. /**
  56395. * Class used to transport BABYLON.Vector2 information for pointer events
  56396. */
  56397. export class Vector2WithInfo extends BABYLON.Vector2 {
  56398. /** defines the current mouse button index */
  56399. buttonIndex: number;
  56400. /**
  56401. * Creates a new Vector2WithInfo
  56402. * @param source defines the vector2 data to transport
  56403. * @param buttonIndex defines the current mouse button index
  56404. */
  56405. constructor(source: BABYLON.Vector2,
  56406. /** defines the current mouse button index */
  56407. buttonIndex?: number);
  56408. }
  56409. /** Class used to provide 2D matrix features */
  56410. export class Matrix2D {
  56411. /** Gets the internal array of 6 floats used to store matrix data */
  56412. m: Float32Array;
  56413. /**
  56414. * Creates a new matrix
  56415. * @param m00 defines value for (0, 0)
  56416. * @param m01 defines value for (0, 1)
  56417. * @param m10 defines value for (1, 0)
  56418. * @param m11 defines value for (1, 1)
  56419. * @param m20 defines value for (2, 0)
  56420. * @param m21 defines value for (2, 1)
  56421. */
  56422. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56423. /**
  56424. * Fills the matrix from direct values
  56425. * @param m00 defines value for (0, 0)
  56426. * @param m01 defines value for (0, 1)
  56427. * @param m10 defines value for (1, 0)
  56428. * @param m11 defines value for (1, 1)
  56429. * @param m20 defines value for (2, 0)
  56430. * @param m21 defines value for (2, 1)
  56431. * @returns the current modified matrix
  56432. */
  56433. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56434. /**
  56435. * Gets matrix determinant
  56436. * @returns the determinant
  56437. */
  56438. determinant(): number;
  56439. /**
  56440. * Inverses the matrix and stores it in a target matrix
  56441. * @param result defines the target matrix
  56442. * @returns the current matrix
  56443. */
  56444. invertToRef(result: Matrix2D): Matrix2D;
  56445. /**
  56446. * Multiplies the current matrix with another one
  56447. * @param other defines the second operand
  56448. * @param result defines the target matrix
  56449. * @returns the current matrix
  56450. */
  56451. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56452. /**
  56453. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56454. * @param x defines the x coordinate to transform
  56455. * @param y defines the x coordinate to transform
  56456. * @param result defines the target vector2
  56457. * @returns the current matrix
  56458. */
  56459. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56460. /**
  56461. * Creates an identity matrix
  56462. * @returns a new matrix
  56463. */
  56464. static Identity(): Matrix2D;
  56465. /**
  56466. * Creates a translation matrix and stores it in a target matrix
  56467. * @param x defines the x coordinate of the translation
  56468. * @param y defines the y coordinate of the translation
  56469. * @param result defines the target matrix
  56470. */
  56471. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56472. /**
  56473. * Creates a scaling matrix and stores it in a target matrix
  56474. * @param x defines the x coordinate of the scaling
  56475. * @param y defines the y coordinate of the scaling
  56476. * @param result defines the target matrix
  56477. */
  56478. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56479. /**
  56480. * Creates a rotation matrix and stores it in a target matrix
  56481. * @param angle defines the rotation angle
  56482. * @param result defines the target matrix
  56483. */
  56484. static RotationToRef(angle: number, result: Matrix2D): void;
  56485. private static _TempPreTranslationMatrix;
  56486. private static _TempPostTranslationMatrix;
  56487. private static _TempRotationMatrix;
  56488. private static _TempScalingMatrix;
  56489. private static _TempCompose0;
  56490. private static _TempCompose1;
  56491. private static _TempCompose2;
  56492. /**
  56493. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56494. * @param tx defines the x coordinate of the translation
  56495. * @param ty defines the y coordinate of the translation
  56496. * @param angle defines the rotation angle
  56497. * @param scaleX defines the x coordinate of the scaling
  56498. * @param scaleY defines the y coordinate of the scaling
  56499. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56500. * @param result defines the target matrix
  56501. */
  56502. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56503. }
  56504. }
  56505. declare module BABYLON.GUI {
  56506. /**
  56507. * Class used to store 2D control sizes
  56508. */
  56509. export class Measure {
  56510. /** defines left coordinate */
  56511. left: number;
  56512. /** defines top coordinate */
  56513. top: number;
  56514. /** defines width dimension */
  56515. width: number;
  56516. /** defines height dimension */
  56517. height: number;
  56518. /**
  56519. * Creates a new measure
  56520. * @param left defines left coordinate
  56521. * @param top defines top coordinate
  56522. * @param width defines width dimension
  56523. * @param height defines height dimension
  56524. */
  56525. constructor(
  56526. /** defines left coordinate */
  56527. left: number,
  56528. /** defines top coordinate */
  56529. top: number,
  56530. /** defines width dimension */
  56531. width: number,
  56532. /** defines height dimension */
  56533. height: number);
  56534. /**
  56535. * Copy from another measure
  56536. * @param other defines the other measure to copy from
  56537. */
  56538. copyFrom(other: Measure): void;
  56539. /**
  56540. * Copy from a group of 4 floats
  56541. * @param left defines left coordinate
  56542. * @param top defines top coordinate
  56543. * @param width defines width dimension
  56544. * @param height defines height dimension
  56545. */
  56546. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56547. /**
  56548. * Computes the axis aligned bounding box measure for two given measures
  56549. * @param a Input measure
  56550. * @param b Input measure
  56551. * @param result the resulting bounding measure
  56552. */
  56553. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56554. /**
  56555. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56556. * @param transform the matrix to transform the measure before computing the AABB
  56557. * @param result the resulting AABB
  56558. */
  56559. transformToRef(transform: Matrix2D, result: Measure): void;
  56560. /**
  56561. * Check equality between this measure and another one
  56562. * @param other defines the other measures
  56563. * @returns true if both measures are equals
  56564. */
  56565. isEqualsTo(other: Measure): boolean;
  56566. /**
  56567. * Creates an empty measure
  56568. * @returns a new measure
  56569. */
  56570. static Empty(): Measure;
  56571. }
  56572. }
  56573. declare module BABYLON.GUI {
  56574. /**
  56575. * Interface used to define a control that can receive focus
  56576. */
  56577. export interface IFocusableControl {
  56578. /**
  56579. * Function called when the control receives the focus
  56580. */
  56581. onFocus(): void;
  56582. /**
  56583. * Function called when the control loses the focus
  56584. */
  56585. onBlur(): void;
  56586. /**
  56587. * Function called to let the control handle keyboard events
  56588. * @param evt defines the current keyboard event
  56589. */
  56590. processKeyboard(evt: KeyboardEvent): void;
  56591. /**
  56592. * Function called to get the list of controls that should not steal the focus from this control
  56593. * @returns an array of controls
  56594. */
  56595. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56596. }
  56597. /**
  56598. * Class used to create texture to support 2D GUI elements
  56599. * @see http://doc.babylonjs.com/how_to/gui
  56600. */
  56601. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56602. private _isDirty;
  56603. private _renderObserver;
  56604. private _resizeObserver;
  56605. private _preKeyboardObserver;
  56606. private _pointerMoveObserver;
  56607. private _pointerObserver;
  56608. private _canvasPointerOutObserver;
  56609. private _background;
  56610. /** @hidden */ rootContainer: Container;
  56611. /** @hidden */ lastPickedControl: Control;
  56612. /** @hidden */ lastControlOver: {
  56613. [pointerId: number]: Control;
  56614. };
  56615. /** @hidden */ lastControlDown: {
  56616. [pointerId: number]: Control;
  56617. };
  56618. /** @hidden */ capturingControl: {
  56619. [pointerId: number]: Control;
  56620. };
  56621. /** @hidden */ shouldBlockPointer: boolean;
  56622. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56623. /** @hidden */ linkedControls: Control[];
  56624. private _isFullscreen;
  56625. private _fullscreenViewport;
  56626. private _idealWidth;
  56627. private _idealHeight;
  56628. private _useSmallestIdeal;
  56629. private _renderAtIdealSize;
  56630. private _focusedControl;
  56631. private _blockNextFocusCheck;
  56632. private _renderScale;
  56633. private _rootCanvas;
  56634. private _cursorChanged;
  56635. /**
  56636. * Define type to string to ensure compatibility across browsers
  56637. * Safari doesn't support DataTransfer constructor
  56638. */
  56639. private _clipboardData;
  56640. /**
  56641. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56642. */
  56643. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56644. /**
  56645. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56646. */
  56647. onControlPickedObservable: BABYLON.Observable<Control>;
  56648. /**
  56649. * BABYLON.Observable event triggered before layout is evaluated
  56650. */
  56651. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56652. /**
  56653. * BABYLON.Observable event triggered after the layout was evaluated
  56654. */
  56655. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56656. /**
  56657. * BABYLON.Observable event triggered before the texture is rendered
  56658. */
  56659. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56660. /**
  56661. * BABYLON.Observable event triggered after the texture was rendered
  56662. */
  56663. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56664. /**
  56665. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56666. */
  56667. premulAlpha: boolean;
  56668. /**
  56669. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56670. * Useful when you want more antialiasing
  56671. */
  56672. renderScale: number;
  56673. /** Gets or sets the background color */
  56674. background: string;
  56675. /**
  56676. * Gets or sets the ideal width used to design controls.
  56677. * The GUI will then rescale everything accordingly
  56678. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56679. */
  56680. idealWidth: number;
  56681. /**
  56682. * Gets or sets the ideal height used to design controls.
  56683. * The GUI will then rescale everything accordingly
  56684. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56685. */
  56686. idealHeight: number;
  56687. /**
  56688. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56689. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56690. */
  56691. useSmallestIdeal: boolean;
  56692. /**
  56693. * Gets or sets a boolean indicating if adaptive scaling must be used
  56694. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56695. */
  56696. renderAtIdealSize: boolean;
  56697. /**
  56698. * Gets the underlying layer used to render the texture when in fullscreen mode
  56699. */
  56700. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56701. /**
  56702. * Gets the root container control
  56703. */
  56704. readonly rootContainer: Container;
  56705. /**
  56706. * Returns an array containing the root container.
  56707. * This is mostly used to let the Inspector introspects the ADT
  56708. * @returns an array containing the rootContainer
  56709. */
  56710. getChildren(): Array<Container>;
  56711. /**
  56712. * Will return all controls that are inside this texture
  56713. * @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
  56714. * @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
  56715. * @return all child controls
  56716. */
  56717. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56718. /**
  56719. * Gets or sets the current focused control
  56720. */
  56721. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56722. /**
  56723. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56724. */
  56725. isForeground: boolean;
  56726. /**
  56727. * Gets or set information about clipboardData
  56728. */
  56729. clipboardData: string;
  56730. /**
  56731. * Creates a new AdvancedDynamicTexture
  56732. * @param name defines the name of the texture
  56733. * @param width defines the width of the texture
  56734. * @param height defines the height of the texture
  56735. * @param scene defines the hosting scene
  56736. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56737. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56738. */
  56739. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56740. /**
  56741. * Get the current class name of the texture useful for serialization or dynamic coding.
  56742. * @returns "AdvancedDynamicTexture"
  56743. */
  56744. getClassName(): string;
  56745. /**
  56746. * Function used to execute a function on all controls
  56747. * @param func defines the function to execute
  56748. * @param container defines the container where controls belong. If null the root container will be used
  56749. */
  56750. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56751. private _useInvalidateRectOptimization;
  56752. /**
  56753. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56754. */
  56755. useInvalidateRectOptimization: boolean;
  56756. private _invalidatedRectangle;
  56757. /**
  56758. * Invalidates a rectangle area on the gui texture
  56759. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56760. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56761. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56762. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56763. */
  56764. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56765. /**
  56766. * Marks the texture as dirty forcing a complete update
  56767. */
  56768. markAsDirty(): void;
  56769. /**
  56770. * Helper function used to create a new style
  56771. * @returns a new style
  56772. * @see http://doc.babylonjs.com/how_to/gui#styles
  56773. */
  56774. createStyle(): Style;
  56775. /**
  56776. * Adds a new control to the root container
  56777. * @param control defines the control to add
  56778. * @returns the current texture
  56779. */
  56780. addControl(control: Control): AdvancedDynamicTexture;
  56781. /**
  56782. * Removes a control from the root container
  56783. * @param control defines the control to remove
  56784. * @returns the current texture
  56785. */
  56786. removeControl(control: Control): AdvancedDynamicTexture;
  56787. /**
  56788. * Release all resources
  56789. */
  56790. dispose(): void;
  56791. private _onResize;
  56792. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56793. /**
  56794. * Get screen coordinates for a vector3
  56795. * @param position defines the position to project
  56796. * @param worldMatrix defines the world matrix to use
  56797. * @returns the projected position
  56798. */
  56799. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56800. private _checkUpdate;
  56801. private _clearMeasure;
  56802. private _render;
  56803. /** @hidden */ changeCursor(cursor: string): void;
  56804. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56805. private _doPicking;
  56806. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56807. [pointerId: number]: Control;
  56808. }, control: Control): void;
  56809. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56810. /** Attach to all scene events required to support pointer events */
  56811. attach(): void;
  56812. /** @hidden */
  56813. private onClipboardCopy;
  56814. /** @hidden */
  56815. private onClipboardCut;
  56816. /** @hidden */
  56817. private onClipboardPaste;
  56818. /**
  56819. * Register the clipboard Events onto the canvas
  56820. */
  56821. registerClipboardEvents(): void;
  56822. /**
  56823. * Unregister the clipboard Events from the canvas
  56824. */
  56825. unRegisterClipboardEvents(): void;
  56826. /**
  56827. * Connect the texture to a hosting mesh to enable interactions
  56828. * @param mesh defines the mesh to attach to
  56829. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56830. */
  56831. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56832. /**
  56833. * Move the focus to a specific control
  56834. * @param control defines the control which will receive the focus
  56835. */
  56836. moveFocusToControl(control: IFocusableControl): void;
  56837. private _manageFocus;
  56838. private _attachToOnPointerOut;
  56839. /**
  56840. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56841. * @param mesh defines the mesh which will receive the texture
  56842. * @param width defines the texture width (1024 by default)
  56843. * @param height defines the texture height (1024 by default)
  56844. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56845. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56846. * @returns a new AdvancedDynamicTexture
  56847. */
  56848. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56849. /**
  56850. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56851. * In this mode the texture will rely on a layer for its rendering.
  56852. * This allows it to be treated like any other layer.
  56853. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56854. * LayerMask is set through advancedTexture.layer.layerMask
  56855. * @param name defines name for the texture
  56856. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56857. * @param scene defines the hsoting scene
  56858. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56859. * @returns a new AdvancedDynamicTexture
  56860. */
  56861. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56862. }
  56863. }
  56864. declare module BABYLON.GUI {
  56865. /**
  56866. * Root class used for all 2D controls
  56867. * @see http://doc.babylonjs.com/how_to/gui#controls
  56868. */
  56869. export class Control {
  56870. /** defines the name of the control */
  56871. name?: string | undefined;
  56872. /**
  56873. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56874. */
  56875. static AllowAlphaInheritance: boolean;
  56876. private _alpha;
  56877. private _alphaSet;
  56878. private _zIndex;
  56879. /** @hidden */ host: AdvancedDynamicTexture;
  56880. /** Gets or sets the control parent */
  56881. parent: BABYLON.Nullable<Container>;
  56882. /** @hidden */ currentMeasure: Measure;
  56883. private _fontFamily;
  56884. private _fontStyle;
  56885. private _fontWeight;
  56886. private _fontSize;
  56887. private _font;
  56888. /** @hidden */ width: ValueAndUnit;
  56889. /** @hidden */ height: ValueAndUnit;
  56890. /** @hidden */
  56891. protected _fontOffset: {
  56892. ascent: number;
  56893. height: number;
  56894. descent: number;
  56895. };
  56896. private _color;
  56897. private _style;
  56898. private _styleObserver;
  56899. /** @hidden */
  56900. protected _horizontalAlignment: number;
  56901. /** @hidden */
  56902. protected _verticalAlignment: number;
  56903. /** @hidden */
  56904. protected _isDirty: boolean;
  56905. /** @hidden */
  56906. protected _wasDirty: boolean;
  56907. /** @hidden */ tempParentMeasure: Measure;
  56908. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56909. /** @hidden */
  56910. protected _cachedParentMeasure: Measure;
  56911. private _paddingLeft;
  56912. private _paddingRight;
  56913. private _paddingTop;
  56914. private _paddingBottom;
  56915. /** @hidden */ left: ValueAndUnit;
  56916. /** @hidden */ top: ValueAndUnit;
  56917. private _scaleX;
  56918. private _scaleY;
  56919. private _rotation;
  56920. private _transformCenterX;
  56921. private _transformCenterY;
  56922. /** @hidden */ transformMatrix: Matrix2D;
  56923. /** @hidden */
  56924. protected _invertTransformMatrix: Matrix2D;
  56925. /** @hidden */
  56926. protected _transformedPosition: BABYLON.Vector2;
  56927. private _isMatrixDirty;
  56928. private _cachedOffsetX;
  56929. private _cachedOffsetY;
  56930. private _isVisible;
  56931. private _isHighlighted;
  56932. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56933. private _fontSet;
  56934. private _dummyVector2;
  56935. private _downCount;
  56936. private _enterCount;
  56937. private _doNotRender;
  56938. private _downPointerIds;
  56939. protected _isEnabled: boolean;
  56940. protected _disabledColor: string;
  56941. /** @hidden */
  56942. protected _rebuildLayout: boolean;
  56943. /** @hidden */ isClipped: boolean;
  56944. /** @hidden */ tag: any;
  56945. /**
  56946. * 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
  56947. */
  56948. uniqueId: number;
  56949. /**
  56950. * Gets or sets an object used to store user defined information for the node
  56951. */
  56952. metadata: any;
  56953. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56954. isHitTestVisible: boolean;
  56955. /** Gets or sets a boolean indicating if the control can block pointer events */
  56956. isPointerBlocker: boolean;
  56957. /** Gets or sets a boolean indicating if the control can be focusable */
  56958. isFocusInvisible: boolean;
  56959. /**
  56960. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56961. * 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
  56962. */
  56963. clipChildren: boolean;
  56964. /**
  56965. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56966. */
  56967. useBitmapCache: boolean;
  56968. private _cacheData;
  56969. private _shadowOffsetX;
  56970. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56971. shadowOffsetX: number;
  56972. private _shadowOffsetY;
  56973. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56974. shadowOffsetY: number;
  56975. private _shadowBlur;
  56976. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56977. shadowBlur: number;
  56978. private _shadowColor;
  56979. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56980. shadowColor: string;
  56981. /** Gets or sets the cursor to use when the control is hovered */
  56982. hoverCursor: string;
  56983. /** @hidden */
  56984. protected _linkOffsetX: ValueAndUnit;
  56985. /** @hidden */
  56986. protected _linkOffsetY: ValueAndUnit;
  56987. /** Gets the control type name */
  56988. readonly typeName: string;
  56989. /**
  56990. * Get the current class name of the control.
  56991. * @returns current class name
  56992. */
  56993. getClassName(): string;
  56994. /**
  56995. * An event triggered when the pointer move over the control.
  56996. */
  56997. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56998. /**
  56999. * An event triggered when the pointer move out of the control.
  57000. */
  57001. onPointerOutObservable: BABYLON.Observable<Control>;
  57002. /**
  57003. * An event triggered when the pointer taps the control
  57004. */
  57005. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  57006. /**
  57007. * An event triggered when pointer up
  57008. */
  57009. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  57010. /**
  57011. * An event triggered when a control is clicked on
  57012. */
  57013. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  57014. /**
  57015. * An event triggered when pointer enters the control
  57016. */
  57017. onPointerEnterObservable: BABYLON.Observable<Control>;
  57018. /**
  57019. * An event triggered when the control is marked as dirty
  57020. */
  57021. onDirtyObservable: BABYLON.Observable<Control>;
  57022. /**
  57023. * An event triggered before drawing the control
  57024. */
  57025. onBeforeDrawObservable: BABYLON.Observable<Control>;
  57026. /**
  57027. * An event triggered after the control was drawn
  57028. */
  57029. onAfterDrawObservable: BABYLON.Observable<Control>;
  57030. /**
  57031. * Get the hosting AdvancedDynamicTexture
  57032. */
  57033. readonly host: AdvancedDynamicTexture;
  57034. /** Gets or set information about font offsets (used to render and align text) */
  57035. fontOffset: {
  57036. ascent: number;
  57037. height: number;
  57038. descent: number;
  57039. };
  57040. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  57041. alpha: number;
  57042. /**
  57043. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  57044. */
  57045. isHighlighted: boolean;
  57046. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  57047. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57048. */
  57049. scaleX: number;
  57050. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  57051. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57052. */
  57053. scaleY: number;
  57054. /** Gets or sets the rotation angle (0 by default)
  57055. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57056. */
  57057. rotation: number;
  57058. /** Gets or sets the transformation center on Y axis (0 by default)
  57059. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57060. */
  57061. transformCenterY: number;
  57062. /** Gets or sets the transformation center on X axis (0 by default)
  57063. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57064. */
  57065. transformCenterX: number;
  57066. /**
  57067. * Gets or sets the horizontal alignment
  57068. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57069. */
  57070. horizontalAlignment: number;
  57071. /**
  57072. * Gets or sets the vertical alignment
  57073. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57074. */
  57075. verticalAlignment: number;
  57076. /**
  57077. * Gets or sets control width
  57078. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57079. */
  57080. width: string | number;
  57081. /**
  57082. * Gets control width in pixel
  57083. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57084. */
  57085. readonly widthInPixels: number;
  57086. /**
  57087. * Gets or sets control height
  57088. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57089. */
  57090. height: string | number;
  57091. /**
  57092. * Gets control height in pixel
  57093. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57094. */
  57095. readonly heightInPixels: number;
  57096. /** Gets or set font family */
  57097. fontFamily: string;
  57098. /** Gets or sets font style */
  57099. fontStyle: string;
  57100. /** Gets or sets font weight */
  57101. fontWeight: string;
  57102. /**
  57103. * Gets or sets style
  57104. * @see http://doc.babylonjs.com/how_to/gui#styles
  57105. */
  57106. style: BABYLON.Nullable<Style>;
  57107. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  57108. /** Gets font size in pixels */
  57109. readonly fontSizeInPixels: number;
  57110. /** Gets or sets font size */
  57111. fontSize: string | number;
  57112. /** Gets or sets foreground color */
  57113. color: string;
  57114. /** Gets or sets z index which is used to reorder controls on the z axis */
  57115. zIndex: number;
  57116. /** Gets or sets a boolean indicating if the control can be rendered */
  57117. notRenderable: boolean;
  57118. /** Gets or sets a boolean indicating if the control is visible */
  57119. isVisible: boolean;
  57120. /** Gets a boolean indicating that the control needs to update its rendering */
  57121. readonly isDirty: boolean;
  57122. /**
  57123. * Gets the current linked mesh (or null if none)
  57124. */
  57125. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  57126. /**
  57127. * Gets or sets a value indicating the padding to use on the left of the control
  57128. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57129. */
  57130. paddingLeft: string | number;
  57131. /**
  57132. * Gets a value indicating the padding in pixels to use on the left of the control
  57133. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57134. */
  57135. readonly paddingLeftInPixels: number;
  57136. /**
  57137. * Gets or sets a value indicating the padding to use on the right of the control
  57138. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57139. */
  57140. paddingRight: string | number;
  57141. /**
  57142. * Gets a value indicating the padding in pixels to use on the right of the control
  57143. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57144. */
  57145. readonly paddingRightInPixels: number;
  57146. /**
  57147. * Gets or sets a value indicating the padding to use on the top of the control
  57148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57149. */
  57150. paddingTop: string | number;
  57151. /**
  57152. * Gets a value indicating the padding in pixels to use on the top of the control
  57153. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57154. */
  57155. readonly paddingTopInPixels: number;
  57156. /**
  57157. * Gets or sets a value indicating the padding to use on the bottom of the control
  57158. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57159. */
  57160. paddingBottom: string | number;
  57161. /**
  57162. * Gets a value indicating the padding in pixels to use on the bottom of the control
  57163. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57164. */
  57165. readonly paddingBottomInPixels: number;
  57166. /**
  57167. * Gets or sets a value indicating the left coordinate of the control
  57168. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57169. */
  57170. left: string | number;
  57171. /**
  57172. * Gets a value indicating the left coordinate in pixels of the control
  57173. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57174. */
  57175. readonly leftInPixels: number;
  57176. /**
  57177. * Gets or sets a value indicating the top coordinate of the control
  57178. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57179. */
  57180. top: string | number;
  57181. /**
  57182. * Gets a value indicating the top coordinate in pixels of the control
  57183. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57184. */
  57185. readonly topInPixels: number;
  57186. /**
  57187. * Gets or sets a value indicating the offset on X axis to the linked mesh
  57188. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57189. */
  57190. linkOffsetX: string | number;
  57191. /**
  57192. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  57193. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57194. */
  57195. readonly linkOffsetXInPixels: number;
  57196. /**
  57197. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  57198. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57199. */
  57200. linkOffsetY: string | number;
  57201. /**
  57202. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  57203. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57204. */
  57205. readonly linkOffsetYInPixels: number;
  57206. /** Gets the center coordinate on X axis */
  57207. readonly centerX: number;
  57208. /** Gets the center coordinate on Y axis */
  57209. readonly centerY: number;
  57210. /** Gets or sets if control is Enabled*/
  57211. isEnabled: boolean;
  57212. /** Gets or sets background color of control if it's disabled*/
  57213. disabledColor: string;
  57214. /**
  57215. * Creates a new control
  57216. * @param name defines the name of the control
  57217. */
  57218. constructor(
  57219. /** defines the name of the control */
  57220. name?: string | undefined);
  57221. /** @hidden */
  57222. protected _getTypeName(): string;
  57223. /**
  57224. * Gets the first ascendant in the hierarchy of the given type
  57225. * @param className defines the required type
  57226. * @returns the ascendant or null if not found
  57227. */
  57228. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  57229. /** @hidden */ resetFontCache(): void;
  57230. /**
  57231. * Determines if a container is an ascendant of the current control
  57232. * @param container defines the container to look for
  57233. * @returns true if the container is one of the ascendant of the control
  57234. */
  57235. isAscendant(container: Control): boolean;
  57236. /**
  57237. * Gets coordinates in local control space
  57238. * @param globalCoordinates defines the coordinates to transform
  57239. * @returns the new coordinates in local space
  57240. */
  57241. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57242. /**
  57243. * Gets coordinates in local control space
  57244. * @param globalCoordinates defines the coordinates to transform
  57245. * @param result defines the target vector2 where to store the result
  57246. * @returns the current control
  57247. */
  57248. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  57249. /**
  57250. * Gets coordinates in parent local control space
  57251. * @param globalCoordinates defines the coordinates to transform
  57252. * @returns the new coordinates in parent local space
  57253. */
  57254. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57255. /**
  57256. * Move the current control to a vector3 position projected onto the screen.
  57257. * @param position defines the target position
  57258. * @param scene defines the hosting scene
  57259. */
  57260. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  57261. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57262. /**
  57263. * Will return all controls that have this control as ascendant
  57264. * @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
  57265. * @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
  57266. * @return all child controls
  57267. */
  57268. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  57269. /**
  57270. * Link current control with a target mesh
  57271. * @param mesh defines the mesh to link with
  57272. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57273. */
  57274. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  57275. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  57276. /** @hidden */ offsetLeft(offset: number): void;
  57277. /** @hidden */ offsetTop(offset: number): void;
  57278. /** @hidden */ markMatrixAsDirty(): void;
  57279. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  57280. /** @hidden */ intersectsRect(rect: Measure): boolean;
  57281. /** @hidden */
  57282. protected invalidateRect(): void;
  57283. /** @hidden */ markAsDirty(force?: boolean): void;
  57284. /** @hidden */ markAllAsDirty(): void;
  57285. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57286. /** @hidden */
  57287. protected _transform(context?: CanvasRenderingContext2D): void;
  57288. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  57289. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57290. /** @hidden */
  57291. protected _applyStates(context: CanvasRenderingContext2D): void;
  57292. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57293. /** @hidden */
  57294. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57295. protected _evaluateClippingState(parentMeasure: Measure): void;
  57296. /** @hidden */ measure(): void;
  57297. /** @hidden */
  57298. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57299. /** @hidden */
  57300. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57301. /** @hidden */
  57302. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57303. /** @hidden */
  57304. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57305. private static _ClipMeasure;
  57306. private _tmpMeasureA;
  57307. private _clip;
  57308. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  57309. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  57310. /**
  57311. * Tests if a given coordinates belong to the current control
  57312. * @param x defines x coordinate to test
  57313. * @param y defines y coordinate to test
  57314. * @returns true if the coordinates are inside the control
  57315. */
  57316. contains(x: number, y: number): boolean;
  57317. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57318. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  57319. /** @hidden */ onPointerEnter(target: Control): boolean;
  57320. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57321. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57322. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57323. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  57324. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  57325. private _prepareFont;
  57326. /** Releases associated resources */
  57327. dispose(): void;
  57328. private static _HORIZONTAL_ALIGNMENT_LEFT;
  57329. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  57330. private static _HORIZONTAL_ALIGNMENT_CENTER;
  57331. private static _VERTICAL_ALIGNMENT_TOP;
  57332. private static _VERTICAL_ALIGNMENT_BOTTOM;
  57333. private static _VERTICAL_ALIGNMENT_CENTER;
  57334. /** HORIZONTAL_ALIGNMENT_LEFT */
  57335. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  57336. /** HORIZONTAL_ALIGNMENT_RIGHT */
  57337. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  57338. /** HORIZONTAL_ALIGNMENT_CENTER */
  57339. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  57340. /** VERTICAL_ALIGNMENT_TOP */
  57341. static readonly VERTICAL_ALIGNMENT_TOP: number;
  57342. /** VERTICAL_ALIGNMENT_BOTTOM */
  57343. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  57344. /** VERTICAL_ALIGNMENT_CENTER */
  57345. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  57346. private static _FontHeightSizes;
  57347. /** @hidden */ private static _GetFontOffset(font: string): {
  57348. ascent: number;
  57349. height: number;
  57350. descent: number;
  57351. };
  57352. /**
  57353. * Creates a stack panel that can be used to render headers
  57354. * @param control defines the control to associate with the header
  57355. * @param text defines the text of the header
  57356. * @param size defines the size of the header
  57357. * @param options defines options used to configure the header
  57358. * @returns a new StackPanel
  57359. * @ignore
  57360. * @hidden
  57361. */
  57362. static AddHeader: (control: Control, text: string, size: string | number, options: {
  57363. isHorizontal: boolean;
  57364. controlFirst: boolean;
  57365. }) => any;
  57366. /** @hidden */
  57367. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  57368. }
  57369. }
  57370. declare module BABYLON.GUI {
  57371. /**
  57372. * Root class for 2D containers
  57373. * @see http://doc.babylonjs.com/how_to/gui#containers
  57374. */
  57375. export class Container extends Control {
  57376. name?: string | undefined;
  57377. /** @hidden */
  57378. protected _children: Control[];
  57379. /** @hidden */
  57380. protected _measureForChildren: Measure;
  57381. /** @hidden */
  57382. protected _background: string;
  57383. /** @hidden */
  57384. protected _adaptWidthToChildren: boolean;
  57385. /** @hidden */
  57386. protected _adaptHeightToChildren: boolean;
  57387. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57388. adaptHeightToChildren: boolean;
  57389. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57390. adaptWidthToChildren: boolean;
  57391. /** Gets or sets background color */
  57392. background: string;
  57393. /** Gets the list of children */
  57394. readonly children: Control[];
  57395. /**
  57396. * Creates a new Container
  57397. * @param name defines the name of the container
  57398. */
  57399. constructor(name?: string | undefined);
  57400. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57401. /**
  57402. * Gets a child using its name
  57403. * @param name defines the child name to look for
  57404. * @returns the child control if found
  57405. */
  57406. getChildByName(name: string): BABYLON.Nullable<Control>;
  57407. /**
  57408. * Gets a child using its type and its name
  57409. * @param name defines the child name to look for
  57410. * @param type defines the child type to look for
  57411. * @returns the child control if found
  57412. */
  57413. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57414. /**
  57415. * Search for a specific control in children
  57416. * @param control defines the control to look for
  57417. * @returns true if the control is in child list
  57418. */
  57419. containsControl(control: Control): boolean;
  57420. /**
  57421. * Adds a new control to the current container
  57422. * @param control defines the control to add
  57423. * @returns the current container
  57424. */
  57425. addControl(control: BABYLON.Nullable<Control>): Container;
  57426. /**
  57427. * Removes all controls from the current container
  57428. * @returns the current container
  57429. */
  57430. clearControls(): Container;
  57431. /**
  57432. * Removes a control from the current container
  57433. * @param control defines the control to remove
  57434. * @returns the current container
  57435. */
  57436. removeControl(control: Control): Container;
  57437. /** @hidden */ reOrderControl(control: Control): void;
  57438. /** @hidden */ offsetLeft(offset: number): void;
  57439. /** @hidden */ offsetTop(offset: number): void;
  57440. /** @hidden */ markAllAsDirty(): void;
  57441. /** @hidden */
  57442. protected _localDraw(context: CanvasRenderingContext2D): void;
  57443. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57444. /** @hidden */
  57445. protected _beforeLayout(): void;
  57446. /** @hidden */
  57447. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57448. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57449. protected _postMeasure(): void;
  57450. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57451. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57452. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57453. /** @hidden */
  57454. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57455. /** Releases associated resources */
  57456. dispose(): void;
  57457. }
  57458. }
  57459. declare module BABYLON.GUI {
  57460. /** Class used to create rectangle container */
  57461. export class Rectangle extends Container {
  57462. name?: string | undefined;
  57463. private _thickness;
  57464. private _cornerRadius;
  57465. /** Gets or sets border thickness */
  57466. thickness: number;
  57467. /** Gets or sets the corner radius angle */
  57468. cornerRadius: number;
  57469. /**
  57470. * Creates a new Rectangle
  57471. * @param name defines the control name
  57472. */
  57473. constructor(name?: string | undefined);
  57474. protected _getTypeName(): string;
  57475. protected _localDraw(context: CanvasRenderingContext2D): void;
  57476. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57477. private _drawRoundedRect;
  57478. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57479. }
  57480. }
  57481. declare module BABYLON.GUI {
  57482. /**
  57483. * Enum that determines the text-wrapping mode to use.
  57484. */
  57485. export enum TextWrapping {
  57486. /**
  57487. * Clip the text when it's larger than Control.width; this is the default mode.
  57488. */
  57489. Clip = 0,
  57490. /**
  57491. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57492. */
  57493. WordWrap = 1,
  57494. /**
  57495. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57496. */
  57497. Ellipsis = 2
  57498. }
  57499. /**
  57500. * Class used to create text block control
  57501. */
  57502. export class TextBlock extends Control {
  57503. /**
  57504. * Defines the name of the control
  57505. */
  57506. name?: string | undefined;
  57507. private _text;
  57508. private _textWrapping;
  57509. private _textHorizontalAlignment;
  57510. private _textVerticalAlignment;
  57511. private _lines;
  57512. private _resizeToFit;
  57513. private _lineSpacing;
  57514. private _outlineWidth;
  57515. private _outlineColor;
  57516. /**
  57517. * An event triggered after the text is changed
  57518. */
  57519. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57520. /**
  57521. * An event triggered after the text was broken up into lines
  57522. */
  57523. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57524. /**
  57525. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57526. */
  57527. readonly lines: any[];
  57528. /**
  57529. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57530. */
  57531. /**
  57532. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57533. */
  57534. resizeToFit: boolean;
  57535. /**
  57536. * Gets or sets a boolean indicating if text must be wrapped
  57537. */
  57538. /**
  57539. * Gets or sets a boolean indicating if text must be wrapped
  57540. */
  57541. textWrapping: TextWrapping | boolean;
  57542. /**
  57543. * Gets or sets text to display
  57544. */
  57545. /**
  57546. * Gets or sets text to display
  57547. */
  57548. text: string;
  57549. /**
  57550. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57551. */
  57552. /**
  57553. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57554. */
  57555. textHorizontalAlignment: number;
  57556. /**
  57557. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57558. */
  57559. /**
  57560. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57561. */
  57562. textVerticalAlignment: number;
  57563. /**
  57564. * Gets or sets line spacing value
  57565. */
  57566. /**
  57567. * Gets or sets line spacing value
  57568. */
  57569. lineSpacing: string | number;
  57570. /**
  57571. * Gets or sets outlineWidth of the text to display
  57572. */
  57573. /**
  57574. * Gets or sets outlineWidth of the text to display
  57575. */
  57576. outlineWidth: number;
  57577. /**
  57578. * Gets or sets outlineColor of the text to display
  57579. */
  57580. /**
  57581. * Gets or sets outlineColor of the text to display
  57582. */
  57583. outlineColor: string;
  57584. /**
  57585. * Creates a new TextBlock object
  57586. * @param name defines the name of the control
  57587. * @param text defines the text to display (emptry string by default)
  57588. */
  57589. constructor(
  57590. /**
  57591. * Defines the name of the control
  57592. */
  57593. name?: string | undefined, text?: string);
  57594. protected _getTypeName(): string;
  57595. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57596. private _drawText;
  57597. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57598. protected _applyStates(context: CanvasRenderingContext2D): void;
  57599. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57600. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57601. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57602. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57603. protected _renderLines(context: CanvasRenderingContext2D): void;
  57604. /**
  57605. * Given a width constraint applied on the text block, find the expected height
  57606. * @returns expected height
  57607. */
  57608. computeExpectedHeight(): number;
  57609. dispose(): void;
  57610. }
  57611. }
  57612. declare module BABYLON.GUI {
  57613. /**
  57614. * Class used to create 2D images
  57615. */
  57616. export class Image extends Control {
  57617. name?: string | undefined;
  57618. private static _WorkingCanvas;
  57619. private _domImage;
  57620. private _imageWidth;
  57621. private _imageHeight;
  57622. private _loaded;
  57623. private _stretch;
  57624. private _source;
  57625. private _autoScale;
  57626. private _sourceLeft;
  57627. private _sourceTop;
  57628. private _sourceWidth;
  57629. private _sourceHeight;
  57630. private _cellWidth;
  57631. private _cellHeight;
  57632. private _cellId;
  57633. private _populateNinePatchSlicesFromImage;
  57634. private _sliceLeft;
  57635. private _sliceRight;
  57636. private _sliceTop;
  57637. private _sliceBottom;
  57638. private _detectPointerOnOpaqueOnly;
  57639. /**
  57640. * BABYLON.Observable notified when the content is loaded
  57641. */
  57642. onImageLoadedObservable: BABYLON.Observable<Image>;
  57643. /**
  57644. * Gets a boolean indicating that the content is loaded
  57645. */
  57646. readonly isLoaded: boolean;
  57647. /**
  57648. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57649. */
  57650. populateNinePatchSlicesFromImage: boolean;
  57651. /**
  57652. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57653. * Beware using this as this will comsume more memory as the image has to be stored twice
  57654. */
  57655. detectPointerOnOpaqueOnly: boolean;
  57656. /**
  57657. * Gets or sets the left value for slicing (9-patch)
  57658. */
  57659. sliceLeft: number;
  57660. /**
  57661. * Gets or sets the right value for slicing (9-patch)
  57662. */
  57663. sliceRight: number;
  57664. /**
  57665. * Gets or sets the top value for slicing (9-patch)
  57666. */
  57667. sliceTop: number;
  57668. /**
  57669. * Gets or sets the bottom value for slicing (9-patch)
  57670. */
  57671. sliceBottom: number;
  57672. /**
  57673. * Gets or sets the left coordinate in the source image
  57674. */
  57675. sourceLeft: number;
  57676. /**
  57677. * Gets or sets the top coordinate in the source image
  57678. */
  57679. sourceTop: number;
  57680. /**
  57681. * Gets or sets the width to capture in the source image
  57682. */
  57683. sourceWidth: number;
  57684. /**
  57685. * Gets or sets the height to capture in the source image
  57686. */
  57687. sourceHeight: number;
  57688. /**
  57689. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57690. * @see http://doc.babylonjs.com/how_to/gui#image
  57691. */
  57692. autoScale: boolean;
  57693. /** Gets or sets the streching mode used by the image */
  57694. stretch: number;
  57695. /**
  57696. * Gets or sets the internal DOM image used to render the control
  57697. */
  57698. domImage: HTMLImageElement;
  57699. private _onImageLoaded;
  57700. private _extractNinePatchSliceDataFromImage;
  57701. /**
  57702. * Gets or sets image source url
  57703. */
  57704. source: BABYLON.Nullable<string>;
  57705. /**
  57706. * Gets or sets the cell width to use when animation sheet is enabled
  57707. * @see http://doc.babylonjs.com/how_to/gui#image
  57708. */
  57709. cellWidth: number;
  57710. /**
  57711. * Gets or sets the cell height to use when animation sheet is enabled
  57712. * @see http://doc.babylonjs.com/how_to/gui#image
  57713. */
  57714. cellHeight: number;
  57715. /**
  57716. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57717. * @see http://doc.babylonjs.com/how_to/gui#image
  57718. */
  57719. cellId: number;
  57720. /**
  57721. * Creates a new Image
  57722. * @param name defines the control name
  57723. * @param url defines the image url
  57724. */
  57725. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57726. /**
  57727. * Tests if a given coordinates belong to the current control
  57728. * @param x defines x coordinate to test
  57729. * @param y defines y coordinate to test
  57730. * @returns true if the coordinates are inside the control
  57731. */
  57732. contains(x: number, y: number): boolean;
  57733. protected _getTypeName(): string;
  57734. /** Force the control to synchronize with its content */
  57735. synchronizeSizeWithContent(): void;
  57736. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57737. private _prepareWorkingCanvasForOpaqueDetection;
  57738. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57739. private _renderCornerPatch;
  57740. private _renderNinePatch;
  57741. dispose(): void;
  57742. /** STRETCH_NONE */
  57743. static readonly STRETCH_NONE: number;
  57744. /** STRETCH_FILL */
  57745. static readonly STRETCH_FILL: number;
  57746. /** STRETCH_UNIFORM */
  57747. static readonly STRETCH_UNIFORM: number;
  57748. /** STRETCH_EXTEND */
  57749. static readonly STRETCH_EXTEND: number;
  57750. /** NINE_PATCH */
  57751. static readonly STRETCH_NINE_PATCH: number;
  57752. }
  57753. }
  57754. declare module BABYLON.GUI {
  57755. /**
  57756. * Class used to create 2D buttons
  57757. */
  57758. export class Button extends Rectangle {
  57759. name?: string | undefined;
  57760. /**
  57761. * Function called to generate a pointer enter animation
  57762. */
  57763. pointerEnterAnimation: () => void;
  57764. /**
  57765. * Function called to generate a pointer out animation
  57766. */
  57767. pointerOutAnimation: () => void;
  57768. /**
  57769. * Function called to generate a pointer down animation
  57770. */
  57771. pointerDownAnimation: () => void;
  57772. /**
  57773. * Function called to generate a pointer up animation
  57774. */
  57775. pointerUpAnimation: () => void;
  57776. private _image;
  57777. /**
  57778. * Returns the image part of the button (if any)
  57779. */
  57780. readonly image: BABYLON.Nullable<Image>;
  57781. private _textBlock;
  57782. /**
  57783. * Returns the image part of the button (if any)
  57784. */
  57785. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57786. /**
  57787. * Creates a new Button
  57788. * @param name defines the name of the button
  57789. */
  57790. constructor(name?: string | undefined);
  57791. protected _getTypeName(): string;
  57792. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57793. /** @hidden */ onPointerEnter(target: Control): boolean;
  57794. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57795. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57796. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57797. /**
  57798. * Creates a new button made with an image and a text
  57799. * @param name defines the name of the button
  57800. * @param text defines the text of the button
  57801. * @param imageUrl defines the url of the image
  57802. * @returns a new Button
  57803. */
  57804. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57805. /**
  57806. * Creates a new button made with an image
  57807. * @param name defines the name of the button
  57808. * @param imageUrl defines the url of the image
  57809. * @returns a new Button
  57810. */
  57811. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57812. /**
  57813. * Creates a new button made with a text
  57814. * @param name defines the name of the button
  57815. * @param text defines the text of the button
  57816. * @returns a new Button
  57817. */
  57818. static CreateSimpleButton(name: string, text: string): Button;
  57819. /**
  57820. * Creates a new button made with an image and a centered text
  57821. * @param name defines the name of the button
  57822. * @param text defines the text of the button
  57823. * @param imageUrl defines the url of the image
  57824. * @returns a new Button
  57825. */
  57826. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57827. }
  57828. }
  57829. declare module BABYLON.GUI {
  57830. /**
  57831. * Class used to create a 2D stack panel container
  57832. */
  57833. export class StackPanel extends Container {
  57834. name?: string | undefined;
  57835. private _isVertical;
  57836. private _manualWidth;
  57837. private _manualHeight;
  57838. private _doNotTrackManualChanges;
  57839. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57840. isVertical: boolean;
  57841. /**
  57842. * Gets or sets panel width.
  57843. * This value should not be set when in horizontal mode as it will be computed automatically
  57844. */
  57845. width: string | number;
  57846. /**
  57847. * Gets or sets panel height.
  57848. * This value should not be set when in vertical mode as it will be computed automatically
  57849. */
  57850. height: string | number;
  57851. /**
  57852. * Creates a new StackPanel
  57853. * @param name defines control name
  57854. */
  57855. constructor(name?: string | undefined);
  57856. protected _getTypeName(): string;
  57857. /** @hidden */
  57858. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57859. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57860. protected _postMeasure(): void;
  57861. }
  57862. }
  57863. declare module BABYLON.GUI {
  57864. /**
  57865. * Class used to represent a 2D checkbox
  57866. */
  57867. export class Checkbox extends Control {
  57868. name?: string | undefined;
  57869. private _isChecked;
  57870. private _background;
  57871. private _checkSizeRatio;
  57872. private _thickness;
  57873. /** Gets or sets border thickness */
  57874. thickness: number;
  57875. /**
  57876. * BABYLON.Observable raised when isChecked property changes
  57877. */
  57878. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57879. /** Gets or sets a value indicating the ratio between overall size and check size */
  57880. checkSizeRatio: number;
  57881. /** Gets or sets background color */
  57882. background: string;
  57883. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57884. isChecked: boolean;
  57885. /**
  57886. * Creates a new CheckBox
  57887. * @param name defines the control name
  57888. */
  57889. constructor(name?: string | undefined);
  57890. protected _getTypeName(): string;
  57891. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57892. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57893. /**
  57894. * Utility function to easily create a checkbox with a header
  57895. * @param title defines the label to use for the header
  57896. * @param onValueChanged defines the callback to call when value changes
  57897. * @returns a StackPanel containing the checkbox and a textBlock
  57898. */
  57899. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57900. }
  57901. }
  57902. declare module BABYLON.GUI {
  57903. /**
  57904. * Class used to store key control properties
  57905. */
  57906. export class KeyPropertySet {
  57907. /** Width */
  57908. width?: string;
  57909. /** Height */
  57910. height?: string;
  57911. /** Left padding */
  57912. paddingLeft?: string;
  57913. /** Right padding */
  57914. paddingRight?: string;
  57915. /** Top padding */
  57916. paddingTop?: string;
  57917. /** Bottom padding */
  57918. paddingBottom?: string;
  57919. /** Foreground color */
  57920. color?: string;
  57921. /** Background color */
  57922. background?: string;
  57923. }
  57924. /**
  57925. * Class used to create virtual keyboard
  57926. */
  57927. export class VirtualKeyboard extends StackPanel {
  57928. /** BABYLON.Observable raised when a key is pressed */
  57929. onKeyPressObservable: BABYLON.Observable<string>;
  57930. /** Gets or sets default key button width */
  57931. defaultButtonWidth: string;
  57932. /** Gets or sets default key button height */
  57933. defaultButtonHeight: string;
  57934. /** Gets or sets default key button left padding */
  57935. defaultButtonPaddingLeft: string;
  57936. /** Gets or sets default key button right padding */
  57937. defaultButtonPaddingRight: string;
  57938. /** Gets or sets default key button top padding */
  57939. defaultButtonPaddingTop: string;
  57940. /** Gets or sets default key button bottom padding */
  57941. defaultButtonPaddingBottom: string;
  57942. /** Gets or sets default key button foreground color */
  57943. defaultButtonColor: string;
  57944. /** Gets or sets default key button background color */
  57945. defaultButtonBackground: string;
  57946. /** Gets or sets shift button foreground color */
  57947. shiftButtonColor: string;
  57948. /** Gets or sets shift button thickness*/
  57949. selectedShiftThickness: number;
  57950. /** Gets shift key state */
  57951. shiftState: number;
  57952. protected _getTypeName(): string;
  57953. private _createKey;
  57954. /**
  57955. * Adds a new row of keys
  57956. * @param keys defines the list of keys to add
  57957. * @param propertySets defines the associated property sets
  57958. */
  57959. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57960. /**
  57961. * Set the shift key to a specific state
  57962. * @param shiftState defines the new shift state
  57963. */
  57964. applyShiftState(shiftState: number): void;
  57965. private _currentlyConnectedInputText;
  57966. private _connectedInputTexts;
  57967. private _onKeyPressObserver;
  57968. /** Gets the input text control currently attached to the keyboard */
  57969. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57970. /**
  57971. * Connects the keyboard with an input text control
  57972. *
  57973. * @param input defines the target control
  57974. */
  57975. connect(input: InputText): void;
  57976. /**
  57977. * Disconnects the keyboard from connected InputText controls
  57978. *
  57979. * @param input optionally defines a target control, otherwise all are disconnected
  57980. */
  57981. disconnect(input?: InputText): void;
  57982. private _removeConnectedInputObservables;
  57983. /**
  57984. * Release all resources
  57985. */
  57986. dispose(): void;
  57987. /**
  57988. * Creates a new keyboard using a default layout
  57989. *
  57990. * @param name defines control name
  57991. * @returns a new VirtualKeyboard
  57992. */
  57993. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57994. }
  57995. }
  57996. declare module BABYLON.GUI {
  57997. /**
  57998. * Class used to create input text control
  57999. */
  58000. export class InputText extends Control implements IFocusableControl {
  58001. name?: string | undefined;
  58002. private _text;
  58003. private _placeholderText;
  58004. private _background;
  58005. private _focusedBackground;
  58006. private _focusedColor;
  58007. private _placeholderColor;
  58008. private _thickness;
  58009. private _margin;
  58010. private _autoStretchWidth;
  58011. private _maxWidth;
  58012. private _isFocused;
  58013. private _blinkTimeout;
  58014. private _blinkIsEven;
  58015. private _cursorOffset;
  58016. private _scrollLeft;
  58017. private _textWidth;
  58018. private _clickedCoordinate;
  58019. private _deadKey;
  58020. private _addKey;
  58021. private _currentKey;
  58022. private _isTextHighlightOn;
  58023. private _textHighlightColor;
  58024. private _highligherOpacity;
  58025. private _highlightedText;
  58026. private _startHighlightIndex;
  58027. private _endHighlightIndex;
  58028. private _cursorIndex;
  58029. private _onFocusSelectAll;
  58030. private _isPointerDown;
  58031. private _onClipboardObserver;
  58032. private _onPointerDblTapObserver;
  58033. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  58034. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  58035. promptMessage: string;
  58036. /** BABYLON.Observable raised when the text changes */
  58037. onTextChangedObservable: BABYLON.Observable<InputText>;
  58038. /** BABYLON.Observable raised just before an entered character is to be added */
  58039. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  58040. /** BABYLON.Observable raised when the control gets the focus */
  58041. onFocusObservable: BABYLON.Observable<InputText>;
  58042. /** BABYLON.Observable raised when the control loses the focus */
  58043. onBlurObservable: BABYLON.Observable<InputText>;
  58044. /**Observable raised when the text is highlighted */
  58045. onTextHighlightObservable: BABYLON.Observable<InputText>;
  58046. /**Observable raised when copy event is triggered */
  58047. onTextCopyObservable: BABYLON.Observable<InputText>;
  58048. /** BABYLON.Observable raised when cut event is triggered */
  58049. onTextCutObservable: BABYLON.Observable<InputText>;
  58050. /** BABYLON.Observable raised when paste event is triggered */
  58051. onTextPasteObservable: BABYLON.Observable<InputText>;
  58052. /** BABYLON.Observable raised when a key event was processed */
  58053. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  58054. /** Gets or sets the maximum width allowed by the control */
  58055. maxWidth: string | number;
  58056. /** Gets the maximum width allowed by the control in pixels */
  58057. readonly maxWidthInPixels: number;
  58058. /** Gets or sets the text highlighter transparency; default: 0.4 */
  58059. highligherOpacity: number;
  58060. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  58061. onFocusSelectAll: boolean;
  58062. /** Gets or sets the text hightlight color */
  58063. textHighlightColor: string;
  58064. /** Gets or sets control margin */
  58065. margin: string;
  58066. /** Gets control margin in pixels */
  58067. readonly marginInPixels: number;
  58068. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  58069. autoStretchWidth: boolean;
  58070. /** Gets or sets border thickness */
  58071. thickness: number;
  58072. /** Gets or sets the background color when focused */
  58073. focusedBackground: string;
  58074. /** Gets or sets the background color when focused */
  58075. focusedColor: string;
  58076. /** Gets or sets the background color */
  58077. background: string;
  58078. /** Gets or sets the placeholder color */
  58079. placeholderColor: string;
  58080. /** Gets or sets the text displayed when the control is empty */
  58081. placeholderText: string;
  58082. /** Gets or sets the dead key flag */
  58083. deadKey: boolean;
  58084. /** Gets or sets the highlight text */
  58085. highlightedText: string;
  58086. /** Gets or sets if the current key should be added */
  58087. addKey: boolean;
  58088. /** Gets or sets the value of the current key being entered */
  58089. currentKey: string;
  58090. /** Gets or sets the text displayed in the control */
  58091. text: string;
  58092. /** Gets or sets control width */
  58093. width: string | number;
  58094. /**
  58095. * Creates a new InputText
  58096. * @param name defines the control name
  58097. * @param text defines the text of the control
  58098. */
  58099. constructor(name?: string | undefined, text?: string);
  58100. /** @hidden */
  58101. onBlur(): void;
  58102. /** @hidden */
  58103. onFocus(): void;
  58104. protected _getTypeName(): string;
  58105. /**
  58106. * Function called to get the list of controls that should not steal the focus from this control
  58107. * @returns an array of controls
  58108. */
  58109. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  58110. /** @hidden */
  58111. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  58112. /** @hidden */
  58113. private _updateValueFromCursorIndex;
  58114. /** @hidden */
  58115. private _processDblClick;
  58116. /** @hidden */
  58117. private _selectAllText;
  58118. /**
  58119. * Handles the keyboard event
  58120. * @param evt Defines the KeyboardEvent
  58121. */
  58122. processKeyboard(evt: KeyboardEvent): void;
  58123. /** @hidden */
  58124. private _onCopyText;
  58125. /** @hidden */
  58126. private _onCutText;
  58127. /** @hidden */
  58128. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58129. protected _beforeRenderText(text: string): string;
  58130. dispose(): void;
  58131. }
  58132. }
  58133. declare module BABYLON.GUI {
  58134. /**
  58135. * Class used to create a 2D grid container
  58136. */
  58137. export class Grid extends Container {
  58138. name?: string | undefined;
  58139. private _rowDefinitions;
  58140. private _columnDefinitions;
  58141. private _cells;
  58142. private _childControls;
  58143. /**
  58144. * Gets the number of columns
  58145. */
  58146. readonly columnCount: number;
  58147. /**
  58148. * Gets the number of rows
  58149. */
  58150. readonly rowCount: number;
  58151. /** Gets the list of children */
  58152. readonly children: Control[];
  58153. /**
  58154. * Gets the definition of a specific row
  58155. * @param index defines the index of the row
  58156. * @returns the row definition
  58157. */
  58158. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58159. /**
  58160. * Gets the definition of a specific column
  58161. * @param index defines the index of the column
  58162. * @returns the column definition
  58163. */
  58164. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58165. /**
  58166. * Adds a new row to the grid
  58167. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58168. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  58169. * @returns the current grid
  58170. */
  58171. addRowDefinition(height: number, isPixel?: boolean): Grid;
  58172. /**
  58173. * Adds a new column to the grid
  58174. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58175. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58176. * @returns the current grid
  58177. */
  58178. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  58179. /**
  58180. * Update a row definition
  58181. * @param index defines the index of the row to update
  58182. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58183. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  58184. * @returns the current grid
  58185. */
  58186. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  58187. /**
  58188. * Update a column definition
  58189. * @param index defines the index of the column to update
  58190. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58191. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58192. * @returns the current grid
  58193. */
  58194. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  58195. /**
  58196. * Gets the list of children stored in a specific cell
  58197. * @param row defines the row to check
  58198. * @param column defines the column to check
  58199. * @returns the list of controls
  58200. */
  58201. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  58202. /**
  58203. * Gets a string representing the child cell info (row x column)
  58204. * @param child defines the control to get info from
  58205. * @returns a string containing the child cell info (row x column)
  58206. */
  58207. getChildCellInfo(child: Control): string;
  58208. private _removeCell;
  58209. private _offsetCell;
  58210. /**
  58211. * Remove a column definition at specified index
  58212. * @param index defines the index of the column to remove
  58213. * @returns the current grid
  58214. */
  58215. removeColumnDefinition(index: number): Grid;
  58216. /**
  58217. * Remove a row definition at specified index
  58218. * @param index defines the index of the row to remove
  58219. * @returns the current grid
  58220. */
  58221. removeRowDefinition(index: number): Grid;
  58222. /**
  58223. * Adds a new control to the current grid
  58224. * @param control defines the control to add
  58225. * @param row defines the row where to add the control (0 by default)
  58226. * @param column defines the column where to add the control (0 by default)
  58227. * @returns the current grid
  58228. */
  58229. addControl(control: Control, row?: number, column?: number): Grid;
  58230. /**
  58231. * Removes a control from the current container
  58232. * @param control defines the control to remove
  58233. * @returns the current container
  58234. */
  58235. removeControl(control: Control): Container;
  58236. /**
  58237. * Creates a new Grid
  58238. * @param name defines control name
  58239. */
  58240. constructor(name?: string | undefined);
  58241. protected _getTypeName(): string;
  58242. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  58243. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58244. /** Releases associated resources */
  58245. dispose(): void;
  58246. }
  58247. }
  58248. declare module BABYLON.GUI {
  58249. /** Class used to create color pickers */
  58250. export class ColorPicker extends Control {
  58251. name?: string | undefined;
  58252. private static _Epsilon;
  58253. private _colorWheelCanvas;
  58254. private _value;
  58255. private _tmpColor;
  58256. private _pointerStartedOnSquare;
  58257. private _pointerStartedOnWheel;
  58258. private _squareLeft;
  58259. private _squareTop;
  58260. private _squareSize;
  58261. private _h;
  58262. private _s;
  58263. private _v;
  58264. private _lastPointerDownID;
  58265. /**
  58266. * BABYLON.Observable raised when the value changes
  58267. */
  58268. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  58269. /** Gets or sets the color of the color picker */
  58270. value: BABYLON.Color3;
  58271. /**
  58272. * Gets or sets control width
  58273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58274. */
  58275. width: string | number;
  58276. /**
  58277. * Gets or sets control height
  58278. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58279. */
  58280. /** Gets or sets control height */
  58281. height: string | number;
  58282. /** Gets or sets control size */
  58283. size: string | number;
  58284. /**
  58285. * Creates a new ColorPicker
  58286. * @param name defines the control name
  58287. */
  58288. constructor(name?: string | undefined);
  58289. protected _getTypeName(): string;
  58290. /** @hidden */
  58291. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58292. private _updateSquareProps;
  58293. private _drawGradientSquare;
  58294. private _drawCircle;
  58295. private _createColorWheelCanvas;
  58296. private _RGBtoHSV;
  58297. private _HSVtoRGB;
  58298. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  58299. private _pointerIsDown;
  58300. private _updateValueFromPointer;
  58301. private _isPointOnSquare;
  58302. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58303. /**
  58304. * This function expands the color picker by creating a color picker dialog with manual
  58305. * color value input and the ability to save colors into an array to be used later in
  58306. * subsequent launches of the dialogue.
  58307. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  58308. * @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.
  58309. * @returns picked color as a hex string and the saved colors array as hex strings.
  58310. */
  58311. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  58312. pickerWidth?: string;
  58313. pickerHeight?: string;
  58314. headerHeight?: string;
  58315. lastColor?: string;
  58316. swatchLimit?: number;
  58317. numSwatchesPerLine?: number;
  58318. savedColors?: Array<string>;
  58319. }): Promise<{
  58320. savedColors?: string[];
  58321. pickedColor: string;
  58322. }>;
  58323. }
  58324. }
  58325. declare module BABYLON.GUI {
  58326. /** Class used to create 2D ellipse containers */
  58327. export class Ellipse extends Container {
  58328. name?: string | undefined;
  58329. private _thickness;
  58330. /** Gets or sets border thickness */
  58331. thickness: number;
  58332. /**
  58333. * Creates a new Ellipse
  58334. * @param name defines the control name
  58335. */
  58336. constructor(name?: string | undefined);
  58337. protected _getTypeName(): string;
  58338. protected _localDraw(context: CanvasRenderingContext2D): void;
  58339. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58340. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  58341. }
  58342. }
  58343. declare module BABYLON.GUI {
  58344. /**
  58345. * Class used to create a password control
  58346. */
  58347. export class InputPassword extends InputText {
  58348. protected _beforeRenderText(text: string): string;
  58349. }
  58350. }
  58351. declare module BABYLON.GUI {
  58352. /** Class used to render 2D lines */
  58353. export class Line extends Control {
  58354. name?: string | undefined;
  58355. private _lineWidth;
  58356. private _x1;
  58357. private _y1;
  58358. private _x2;
  58359. private _y2;
  58360. private _dash;
  58361. private _connectedControl;
  58362. private _connectedControlDirtyObserver;
  58363. /** Gets or sets the dash pattern */
  58364. dash: Array<number>;
  58365. /** Gets or sets the control connected with the line end */
  58366. connectedControl: Control;
  58367. /** Gets or sets start coordinates on X axis */
  58368. x1: string | number;
  58369. /** Gets or sets start coordinates on Y axis */
  58370. y1: string | number;
  58371. /** Gets or sets end coordinates on X axis */
  58372. x2: string | number;
  58373. /** Gets or sets end coordinates on Y axis */
  58374. y2: string | number;
  58375. /** Gets or sets line width */
  58376. lineWidth: number;
  58377. /** Gets or sets horizontal alignment */
  58378. horizontalAlignment: number;
  58379. /** Gets or sets vertical alignment */
  58380. verticalAlignment: number;
  58381. private readonly _effectiveX2;
  58382. private readonly _effectiveY2;
  58383. /**
  58384. * Creates a new Line
  58385. * @param name defines the control name
  58386. */
  58387. constructor(name?: string | undefined);
  58388. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58389. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58390. /**
  58391. * Move one end of the line given 3D cartesian coordinates.
  58392. * @param position Targeted world position
  58393. * @param scene BABYLON.Scene
  58394. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58395. */
  58396. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58397. /**
  58398. * Move one end of the line to a position in screen absolute space.
  58399. * @param projectedPosition Position in screen absolute space (X, Y)
  58400. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58401. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58402. }
  58403. }
  58404. declare module BABYLON.GUI {
  58405. /**
  58406. * Class used to store a point for a MultiLine object.
  58407. * The point can be pure 2D coordinates, a mesh or a control
  58408. */
  58409. export class MultiLinePoint {
  58410. private _multiLine;
  58411. private _x;
  58412. private _y;
  58413. private _control;
  58414. private _mesh;
  58415. private _controlObserver;
  58416. private _meshObserver;
  58417. /** @hidden */ point: BABYLON.Vector2;
  58418. /**
  58419. * Creates a new MultiLinePoint
  58420. * @param multiLine defines the source MultiLine object
  58421. */
  58422. constructor(multiLine: MultiLine);
  58423. /** Gets or sets x coordinate */
  58424. x: string | number;
  58425. /** Gets or sets y coordinate */
  58426. y: string | number;
  58427. /** Gets or sets the control associated with this point */
  58428. control: BABYLON.Nullable<Control>;
  58429. /** Gets or sets the mesh associated with this point */
  58430. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58431. /** Resets links */
  58432. resetLinks(): void;
  58433. /**
  58434. * Gets a translation vector
  58435. * @returns the translation vector
  58436. */
  58437. translate(): BABYLON.Vector2;
  58438. private _translatePoint;
  58439. /** Release associated resources */
  58440. dispose(): void;
  58441. }
  58442. }
  58443. declare module BABYLON.GUI {
  58444. /**
  58445. * Class used to create multi line control
  58446. */
  58447. export class MultiLine extends Control {
  58448. name?: string | undefined;
  58449. private _lineWidth;
  58450. private _dash;
  58451. private _points;
  58452. private _minX;
  58453. private _minY;
  58454. private _maxX;
  58455. private _maxY;
  58456. /**
  58457. * Creates a new MultiLine
  58458. * @param name defines the control name
  58459. */
  58460. constructor(name?: string | undefined);
  58461. /** Gets or sets dash pattern */
  58462. dash: Array<number>;
  58463. /**
  58464. * Gets point stored at specified index
  58465. * @param index defines the index to look for
  58466. * @returns the requested point if found
  58467. */
  58468. getAt(index: number): MultiLinePoint;
  58469. /** Function called when a point is updated */
  58470. onPointUpdate: () => void;
  58471. /**
  58472. * Adds new points to the point collection
  58473. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58474. * @returns the list of created MultiLinePoint
  58475. */
  58476. add(...items: (AbstractMesh | Control | {
  58477. x: string | number;
  58478. y: string | number;
  58479. })[]): MultiLinePoint[];
  58480. /**
  58481. * Adds a new point to the point collection
  58482. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58483. * @returns the created MultiLinePoint
  58484. */
  58485. push(item?: (AbstractMesh | Control | {
  58486. x: string | number;
  58487. y: string | number;
  58488. })): MultiLinePoint;
  58489. /**
  58490. * Remove a specific value or point from the active point collection
  58491. * @param value defines the value or point to remove
  58492. */
  58493. remove(value: number | MultiLinePoint): void;
  58494. /**
  58495. * Resets this object to initial state (no point)
  58496. */
  58497. reset(): void;
  58498. /**
  58499. * Resets all links
  58500. */
  58501. resetLinks(): void;
  58502. /** Gets or sets line width */
  58503. lineWidth: number;
  58504. horizontalAlignment: number;
  58505. verticalAlignment: number;
  58506. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58507. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58508. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58509. dispose(): void;
  58510. }
  58511. }
  58512. declare module BABYLON.GUI {
  58513. /**
  58514. * Class used to create radio button controls
  58515. */
  58516. export class RadioButton extends Control {
  58517. name?: string | undefined;
  58518. private _isChecked;
  58519. private _background;
  58520. private _checkSizeRatio;
  58521. private _thickness;
  58522. /** Gets or sets border thickness */
  58523. thickness: number;
  58524. /** Gets or sets group name */
  58525. group: string;
  58526. /** BABYLON.Observable raised when isChecked is changed */
  58527. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58528. /** Gets or sets a value indicating the ratio between overall size and check size */
  58529. checkSizeRatio: number;
  58530. /** Gets or sets background color */
  58531. background: string;
  58532. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58533. isChecked: boolean;
  58534. /**
  58535. * Creates a new RadioButton
  58536. * @param name defines the control name
  58537. */
  58538. constructor(name?: string | undefined);
  58539. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58540. /**
  58541. * Utility function to easily create a radio button with a header
  58542. * @param title defines the label to use for the header
  58543. * @param group defines the group to use for the radio button
  58544. * @param isChecked defines the initial state of the radio button
  58545. * @param onValueChanged defines the callback to call when value changes
  58546. * @returns a StackPanel containing the radio button and a textBlock
  58547. */
  58548. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58549. }
  58550. }
  58551. declare module BABYLON.GUI {
  58552. /**
  58553. * Class used to create slider controls
  58554. */
  58555. export class BaseSlider extends Control {
  58556. name?: string | undefined;
  58557. protected _thumbWidth: ValueAndUnit;
  58558. private _minimum;
  58559. private _maximum;
  58560. private _value;
  58561. private _isVertical;
  58562. protected _barOffset: ValueAndUnit;
  58563. private _isThumbClamped;
  58564. protected _displayThumb: boolean;
  58565. private _step;
  58566. private _lastPointerDownID;
  58567. protected _effectiveBarOffset: number;
  58568. protected _renderLeft: number;
  58569. protected _renderTop: number;
  58570. protected _renderWidth: number;
  58571. protected _renderHeight: number;
  58572. protected _backgroundBoxLength: number;
  58573. protected _backgroundBoxThickness: number;
  58574. protected _effectiveThumbThickness: number;
  58575. /** BABYLON.Observable raised when the sldier value changes */
  58576. onValueChangedObservable: BABYLON.Observable<number>;
  58577. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58578. displayThumb: boolean;
  58579. /** Gets or sets a step to apply to values (0 by default) */
  58580. step: number;
  58581. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58582. barOffset: string | number;
  58583. /** Gets main bar offset in pixels*/
  58584. readonly barOffsetInPixels: number;
  58585. /** Gets or sets thumb width */
  58586. thumbWidth: string | number;
  58587. /** Gets thumb width in pixels */
  58588. readonly thumbWidthInPixels: number;
  58589. /** Gets or sets minimum value */
  58590. minimum: number;
  58591. /** Gets or sets maximum value */
  58592. maximum: number;
  58593. /** Gets or sets current value */
  58594. value: number;
  58595. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58596. isVertical: boolean;
  58597. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58598. isThumbClamped: boolean;
  58599. /**
  58600. * Creates a new BaseSlider
  58601. * @param name defines the control name
  58602. */
  58603. constructor(name?: string | undefined);
  58604. protected _getTypeName(): string;
  58605. protected _getThumbPosition(): number;
  58606. protected _getThumbThickness(type: string): number;
  58607. protected _prepareRenderingData(type: string): void;
  58608. private _pointerIsDown;
  58609. /** @hidden */
  58610. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58611. }
  58612. }
  58613. declare module BABYLON.GUI {
  58614. /**
  58615. * Class used to create slider controls
  58616. */
  58617. export class Slider extends BaseSlider {
  58618. name?: string | undefined;
  58619. private _background;
  58620. private _borderColor;
  58621. private _isThumbCircle;
  58622. protected _displayValueBar: boolean;
  58623. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58624. displayValueBar: boolean;
  58625. /** Gets or sets border color */
  58626. borderColor: string;
  58627. /** Gets or sets background color */
  58628. background: string;
  58629. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58630. isThumbCircle: boolean;
  58631. /**
  58632. * Creates a new Slider
  58633. * @param name defines the control name
  58634. */
  58635. constructor(name?: string | undefined);
  58636. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58637. }
  58638. }
  58639. declare module BABYLON.GUI {
  58640. /** Class used to create a RadioGroup
  58641. * which contains groups of radio buttons
  58642. */
  58643. export class SelectorGroup {
  58644. /** name of SelectorGroup */
  58645. name: string;
  58646. private _groupPanel;
  58647. private _selectors;
  58648. private _groupHeader;
  58649. /**
  58650. * Creates a new SelectorGroup
  58651. * @param name of group, used as a group heading
  58652. */
  58653. constructor(
  58654. /** name of SelectorGroup */
  58655. name: string);
  58656. /** Gets the groupPanel of the SelectorGroup */
  58657. readonly groupPanel: StackPanel;
  58658. /** Gets the selectors array */
  58659. readonly selectors: StackPanel[];
  58660. /** Gets and sets the group header */
  58661. header: string;
  58662. /** @hidden */
  58663. private _addGroupHeader;
  58664. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58665. /** Removes the selector at the given position
  58666. * @param selectorNb the position of the selector within the group
  58667. */
  58668. removeSelector(selectorNb: number): void;
  58669. }
  58670. /** Class used to create a CheckboxGroup
  58671. * which contains groups of checkbox buttons
  58672. */
  58673. export class CheckboxGroup extends SelectorGroup {
  58674. /** Adds a checkbox as a control
  58675. * @param text is the label for the selector
  58676. * @param func is the function called when the Selector is checked
  58677. * @param checked is true when Selector is checked
  58678. */
  58679. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58680. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58681. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58682. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58683. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58684. }
  58685. /** Class used to create a RadioGroup
  58686. * which contains groups of radio buttons
  58687. */
  58688. export class RadioGroup extends SelectorGroup {
  58689. private _selectNb;
  58690. /** Adds a radio button as a control
  58691. * @param label is the label for the selector
  58692. * @param func is the function called when the Selector is checked
  58693. * @param checked is true when Selector is checked
  58694. */
  58695. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58696. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58697. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58698. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58699. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58700. }
  58701. /** Class used to create a SliderGroup
  58702. * which contains groups of slider buttons
  58703. */
  58704. export class SliderGroup extends SelectorGroup {
  58705. /**
  58706. * Adds a slider to the SelectorGroup
  58707. * @param label is the label for the SliderBar
  58708. * @param func is the function called when the Slider moves
  58709. * @param unit is a string describing the units used, eg degrees or metres
  58710. * @param min is the minimum value for the Slider
  58711. * @param max is the maximum value for the Slider
  58712. * @param value is the start value for the Slider between min and max
  58713. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58714. */
  58715. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58716. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58717. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58718. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58719. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58720. }
  58721. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58722. * @see http://doc.babylonjs.com/how_to/selector
  58723. */
  58724. export class SelectionPanel extends Rectangle {
  58725. /** name of SelectionPanel */
  58726. name: string;
  58727. /** an array of SelectionGroups */
  58728. groups: SelectorGroup[];
  58729. private _panel;
  58730. private _buttonColor;
  58731. private _buttonBackground;
  58732. private _headerColor;
  58733. private _barColor;
  58734. private _barHeight;
  58735. private _spacerHeight;
  58736. private _labelColor;
  58737. private _groups;
  58738. private _bars;
  58739. /**
  58740. * Creates a new SelectionPanel
  58741. * @param name of SelectionPanel
  58742. * @param groups is an array of SelectionGroups
  58743. */
  58744. constructor(
  58745. /** name of SelectionPanel */
  58746. name: string,
  58747. /** an array of SelectionGroups */
  58748. groups?: SelectorGroup[]);
  58749. protected _getTypeName(): string;
  58750. /** Gets or sets the headerColor */
  58751. headerColor: string;
  58752. private _setHeaderColor;
  58753. /** Gets or sets the button color */
  58754. buttonColor: string;
  58755. private _setbuttonColor;
  58756. /** Gets or sets the label color */
  58757. labelColor: string;
  58758. private _setLabelColor;
  58759. /** Gets or sets the button background */
  58760. buttonBackground: string;
  58761. private _setButtonBackground;
  58762. /** Gets or sets the color of separator bar */
  58763. barColor: string;
  58764. private _setBarColor;
  58765. /** Gets or sets the height of separator bar */
  58766. barHeight: string;
  58767. private _setBarHeight;
  58768. /** Gets or sets the height of spacers*/
  58769. spacerHeight: string;
  58770. private _setSpacerHeight;
  58771. /** Adds a bar between groups */
  58772. private _addSpacer;
  58773. /** Add a group to the selection panel
  58774. * @param group is the selector group to add
  58775. */
  58776. addGroup(group: SelectorGroup): void;
  58777. /** Remove the group from the given position
  58778. * @param groupNb is the position of the group in the list
  58779. */
  58780. removeGroup(groupNb: number): void;
  58781. /** Change a group header label
  58782. * @param label is the new group header label
  58783. * @param groupNb is the number of the group to relabel
  58784. * */
  58785. setHeaderName(label: string, groupNb: number): void;
  58786. /** Change selector label to the one given
  58787. * @param label is the new selector label
  58788. * @param groupNb is the number of the groupcontaining the selector
  58789. * @param selectorNb is the number of the selector within a group to relabel
  58790. * */
  58791. relabel(label: string, groupNb: number, selectorNb: number): void;
  58792. /** For a given group position remove the selector at the given position
  58793. * @param groupNb is the number of the group to remove the selector from
  58794. * @param selectorNb is the number of the selector within the group
  58795. */
  58796. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58797. /** For a given group position of correct type add a checkbox button
  58798. * @param groupNb is the number of the group to remove the selector from
  58799. * @param label is the label for the selector
  58800. * @param func is the function called when the Selector is checked
  58801. * @param checked is true when Selector is checked
  58802. */
  58803. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58804. /** For a given group position of correct type add a radio button
  58805. * @param groupNb is the number of the group to remove the selector from
  58806. * @param label is the label for the selector
  58807. * @param func is the function called when the Selector is checked
  58808. * @param checked is true when Selector is checked
  58809. */
  58810. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58811. /**
  58812. * For a given slider group add a slider
  58813. * @param groupNb is the number of the group to add the slider to
  58814. * @param label is the label for the Slider
  58815. * @param func is the function called when the Slider moves
  58816. * @param unit is a string describing the units used, eg degrees or metres
  58817. * @param min is the minimum value for the Slider
  58818. * @param max is the maximum value for the Slider
  58819. * @param value is the start value for the Slider between min and max
  58820. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58821. */
  58822. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58823. }
  58824. }
  58825. declare module BABYLON.GUI {
  58826. /**
  58827. * Class used to hold a the container for ScrollViewer
  58828. * @hidden
  58829. */
  58830. export class _ScrollViewerWindow extends Container {
  58831. parentClientWidth: number;
  58832. parentClientHeight: number;
  58833. /**
  58834. * Creates a new ScrollViewerWindow
  58835. * @param name of ScrollViewerWindow
  58836. */
  58837. constructor(name?: string);
  58838. protected _getTypeName(): string;
  58839. /** @hidden */
  58840. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58841. protected _postMeasure(): void;
  58842. }
  58843. }
  58844. declare module BABYLON.GUI {
  58845. /**
  58846. * Class used to create slider controls
  58847. */
  58848. export class ScrollBar extends BaseSlider {
  58849. name?: string | undefined;
  58850. private _background;
  58851. private _borderColor;
  58852. private _thumbMeasure;
  58853. /** Gets or sets border color */
  58854. borderColor: string;
  58855. /** Gets or sets background color */
  58856. background: string;
  58857. /**
  58858. * Creates a new Slider
  58859. * @param name defines the control name
  58860. */
  58861. constructor(name?: string | undefined);
  58862. protected _getTypeName(): string;
  58863. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58864. private _first;
  58865. private _originX;
  58866. private _originY;
  58867. /** @hidden */
  58868. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58869. }
  58870. }
  58871. declare module BABYLON.GUI {
  58872. /**
  58873. * Class used to hold a viewer window and sliders in a grid
  58874. */
  58875. export class ScrollViewer extends Rectangle {
  58876. private _grid;
  58877. private _horizontalBarSpace;
  58878. private _verticalBarSpace;
  58879. private _dragSpace;
  58880. private _horizontalBar;
  58881. private _verticalBar;
  58882. private _barColor;
  58883. private _barBackground;
  58884. private _barSize;
  58885. private _endLeft;
  58886. private _endTop;
  58887. private _window;
  58888. private _pointerIsOver;
  58889. private _wheelPrecision;
  58890. private _onPointerObserver;
  58891. private _clientWidth;
  58892. private _clientHeight;
  58893. /**
  58894. * Gets the horizontal scrollbar
  58895. */
  58896. readonly horizontalBar: ScrollBar;
  58897. /**
  58898. * Gets the vertical scrollbar
  58899. */
  58900. readonly verticalBar: ScrollBar;
  58901. /**
  58902. * Adds a new control to the current container
  58903. * @param control defines the control to add
  58904. * @returns the current container
  58905. */
  58906. addControl(control: BABYLON.Nullable<Control>): Container;
  58907. /**
  58908. * Removes a control from the current container
  58909. * @param control defines the control to remove
  58910. * @returns the current container
  58911. */
  58912. removeControl(control: Control): Container;
  58913. /** Gets the list of children */
  58914. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58915. /**
  58916. * Creates a new ScrollViewer
  58917. * @param name of ScrollViewer
  58918. */
  58919. constructor(name?: string);
  58920. /** Reset the scroll viewer window to initial size */
  58921. resetWindow(): void;
  58922. protected _getTypeName(): string;
  58923. private _buildClientSizes;
  58924. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58925. protected _postMeasure(): void;
  58926. /**
  58927. * Gets or sets the mouse wheel precision
  58928. * from 0 to 1 with a default value of 0.05
  58929. * */
  58930. wheelPrecision: number;
  58931. /** Gets or sets the bar color */
  58932. barColor: string;
  58933. /** Gets or sets the size of the bar */
  58934. barSize: number;
  58935. /** Gets or sets the bar background */
  58936. barBackground: string;
  58937. /** @hidden */
  58938. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58939. /** @hidden */
  58940. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58941. /** Releases associated resources */
  58942. dispose(): void;
  58943. }
  58944. }
  58945. declare module BABYLON.GUI {
  58946. /** Class used to render a grid */
  58947. export class DisplayGrid extends Control {
  58948. name?: string | undefined;
  58949. private _cellWidth;
  58950. private _cellHeight;
  58951. private _minorLineTickness;
  58952. private _minorLineColor;
  58953. private _majorLineTickness;
  58954. private _majorLineColor;
  58955. private _majorLineFrequency;
  58956. private _background;
  58957. private _displayMajorLines;
  58958. private _displayMinorLines;
  58959. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58960. displayMinorLines: boolean;
  58961. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58962. displayMajorLines: boolean;
  58963. /** Gets or sets background color (Black by default) */
  58964. background: string;
  58965. /** Gets or sets the width of each cell (20 by default) */
  58966. cellWidth: number;
  58967. /** Gets or sets the height of each cell (20 by default) */
  58968. cellHeight: number;
  58969. /** Gets or sets the tickness of minor lines (1 by default) */
  58970. minorLineTickness: number;
  58971. /** Gets or sets the color of minor lines (DarkGray by default) */
  58972. minorLineColor: string;
  58973. /** Gets or sets the tickness of major lines (2 by default) */
  58974. majorLineTickness: number;
  58975. /** Gets or sets the color of major lines (White by default) */
  58976. majorLineColor: string;
  58977. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58978. majorLineFrequency: number;
  58979. /**
  58980. * Creates a new GridDisplayRectangle
  58981. * @param name defines the control name
  58982. */
  58983. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58984. protected _getTypeName(): string;
  58985. }
  58986. }
  58987. declare module BABYLON.GUI {
  58988. /**
  58989. * Class used to create slider controls based on images
  58990. */
  58991. export class ImageBasedSlider extends BaseSlider {
  58992. name?: string | undefined;
  58993. private _backgroundImage;
  58994. private _thumbImage;
  58995. private _valueBarImage;
  58996. private _tempMeasure;
  58997. displayThumb: boolean;
  58998. /**
  58999. * Gets or sets the image used to render the background
  59000. */
  59001. backgroundImage: Image;
  59002. /**
  59003. * Gets or sets the image used to render the value bar
  59004. */
  59005. valueBarImage: Image;
  59006. /**
  59007. * Gets or sets the image used to render the thumb
  59008. */
  59009. thumbImage: Image;
  59010. /**
  59011. * Creates a new ImageBasedSlider
  59012. * @param name defines the control name
  59013. */
  59014. constructor(name?: string | undefined);
  59015. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  59016. }
  59017. }
  59018. declare module BABYLON.GUI {
  59019. /**
  59020. * Forcing an export so that this code will execute
  59021. * @hidden
  59022. */
  59023. const name = "Statics";
  59024. }
  59025. declare module BABYLON.GUI {
  59026. /**
  59027. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  59028. */
  59029. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  59030. /**
  59031. * Define the instrumented AdvancedDynamicTexture.
  59032. */
  59033. texture: AdvancedDynamicTexture;
  59034. private _captureRenderTime;
  59035. private _renderTime;
  59036. private _captureLayoutTime;
  59037. private _layoutTime;
  59038. private _onBeginRenderObserver;
  59039. private _onEndRenderObserver;
  59040. private _onBeginLayoutObserver;
  59041. private _onEndLayoutObserver;
  59042. /**
  59043. * Gets the perf counter used to capture render time
  59044. */
  59045. readonly renderTimeCounter: BABYLON.PerfCounter;
  59046. /**
  59047. * Gets the perf counter used to capture layout time
  59048. */
  59049. readonly layoutTimeCounter: BABYLON.PerfCounter;
  59050. /**
  59051. * Enable or disable the render time capture
  59052. */
  59053. captureRenderTime: boolean;
  59054. /**
  59055. * Enable or disable the layout time capture
  59056. */
  59057. captureLayoutTime: boolean;
  59058. /**
  59059. * Instantiates a new advanced dynamic texture instrumentation.
  59060. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  59061. * @param texture Defines the AdvancedDynamicTexture to instrument
  59062. */
  59063. constructor(
  59064. /**
  59065. * Define the instrumented AdvancedDynamicTexture.
  59066. */
  59067. texture: AdvancedDynamicTexture);
  59068. /**
  59069. * Dispose and release associated resources.
  59070. */
  59071. dispose(): void;
  59072. }
  59073. }
  59074. declare module BABYLON.GUI {
  59075. /**
  59076. * Class used to create containers for controls
  59077. */
  59078. export class Container3D extends Control3D {
  59079. private _blockLayout;
  59080. /**
  59081. * Gets the list of child controls
  59082. */
  59083. protected _children: Control3D[];
  59084. /**
  59085. * Gets the list of child controls
  59086. */
  59087. readonly children: Array<Control3D>;
  59088. /**
  59089. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  59090. * This is helpful to optimize layout operation when adding multiple children in a row
  59091. */
  59092. blockLayout: boolean;
  59093. /**
  59094. * Creates a new container
  59095. * @param name defines the container name
  59096. */
  59097. constructor(name?: string);
  59098. /**
  59099. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  59100. * @returns the current container
  59101. */
  59102. updateLayout(): Container3D;
  59103. /**
  59104. * Gets a boolean indicating if the given control is in the children of this control
  59105. * @param control defines the control to check
  59106. * @returns true if the control is in the child list
  59107. */
  59108. containsControl(control: Control3D): boolean;
  59109. /**
  59110. * Adds a control to the children of this control
  59111. * @param control defines the control to add
  59112. * @returns the current container
  59113. */
  59114. addControl(control: Control3D): Container3D;
  59115. /**
  59116. * This function will be called everytime a new control is added
  59117. */
  59118. protected _arrangeChildren(): void;
  59119. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59120. /**
  59121. * Removes a control from the children of this control
  59122. * @param control defines the control to remove
  59123. * @returns the current container
  59124. */
  59125. removeControl(control: Control3D): Container3D;
  59126. protected _getTypeName(): string;
  59127. /**
  59128. * Releases all associated resources
  59129. */
  59130. dispose(): void;
  59131. /** Control rotation will remain unchanged */
  59132. static readonly UNSET_ORIENTATION: number;
  59133. /** Control will rotate to make it look at sphere central axis */
  59134. static readonly FACEORIGIN_ORIENTATION: number;
  59135. /** Control will rotate to make it look back at sphere central axis */
  59136. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  59137. /** Control will rotate to look at z axis (0, 0, 1) */
  59138. static readonly FACEFORWARD_ORIENTATION: number;
  59139. /** Control will rotate to look at negative z axis (0, 0, -1) */
  59140. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  59141. }
  59142. }
  59143. declare module BABYLON.GUI {
  59144. /**
  59145. * Class used to manage 3D user interface
  59146. * @see http://doc.babylonjs.com/how_to/gui3d
  59147. */
  59148. export class GUI3DManager implements BABYLON.IDisposable {
  59149. private _scene;
  59150. private _sceneDisposeObserver;
  59151. private _utilityLayer;
  59152. private _rootContainer;
  59153. private _pointerObserver;
  59154. private _pointerOutObserver;
  59155. /** @hidden */ lastPickedControl: Control3D;
  59156. /** @hidden */ lastControlOver: {
  59157. [pointerId: number]: Control3D;
  59158. };
  59159. /** @hidden */ lastControlDown: {
  59160. [pointerId: number]: Control3D;
  59161. };
  59162. /**
  59163. * BABYLON.Observable raised when the point picked by the pointer events changed
  59164. */
  59165. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  59166. /** @hidden */ sharedMaterials: {
  59167. [key: string]: BABYLON.Material;
  59168. };
  59169. /** Gets the hosting scene */
  59170. readonly scene: BABYLON.Scene;
  59171. /** Gets associated utility layer */
  59172. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  59173. /**
  59174. * Creates a new GUI3DManager
  59175. * @param scene
  59176. */
  59177. constructor(scene?: BABYLON.Scene);
  59178. private _handlePointerOut;
  59179. private _doPicking;
  59180. /**
  59181. * Gets the root container
  59182. */
  59183. readonly rootContainer: Container3D;
  59184. /**
  59185. * Gets a boolean indicating if the given control is in the root child list
  59186. * @param control defines the control to check
  59187. * @returns true if the control is in the root child list
  59188. */
  59189. containsControl(control: Control3D): boolean;
  59190. /**
  59191. * Adds a control to the root child list
  59192. * @param control defines the control to add
  59193. * @returns the current manager
  59194. */
  59195. addControl(control: Control3D): GUI3DManager;
  59196. /**
  59197. * Removes a control from the root child list
  59198. * @param control defines the control to remove
  59199. * @returns the current container
  59200. */
  59201. removeControl(control: Control3D): GUI3DManager;
  59202. /**
  59203. * Releases all associated resources
  59204. */
  59205. dispose(): void;
  59206. }
  59207. }
  59208. declare module BABYLON.GUI {
  59209. /**
  59210. * Class used to transport BABYLON.Vector3 information for pointer events
  59211. */
  59212. export class Vector3WithInfo extends BABYLON.Vector3 {
  59213. /** defines the current mouse button index */
  59214. buttonIndex: number;
  59215. /**
  59216. * Creates a new Vector3WithInfo
  59217. * @param source defines the vector3 data to transport
  59218. * @param buttonIndex defines the current mouse button index
  59219. */
  59220. constructor(source: BABYLON.Vector3,
  59221. /** defines the current mouse button index */
  59222. buttonIndex?: number);
  59223. }
  59224. }
  59225. declare module BABYLON.GUI {
  59226. /**
  59227. * Class used as base class for controls
  59228. */
  59229. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  59230. /** Defines the control name */
  59231. name?: string | undefined;
  59232. /** @hidden */ host: GUI3DManager;
  59233. private _node;
  59234. private _downCount;
  59235. private _enterCount;
  59236. private _downPointerIds;
  59237. private _isVisible;
  59238. /** Gets or sets the control position in world space */
  59239. position: BABYLON.Vector3;
  59240. /** Gets or sets the control scaling in world space */
  59241. scaling: BABYLON.Vector3;
  59242. /** Callback used to start pointer enter animation */
  59243. pointerEnterAnimation: () => void;
  59244. /** Callback used to start pointer out animation */
  59245. pointerOutAnimation: () => void;
  59246. /** Callback used to start pointer down animation */
  59247. pointerDownAnimation: () => void;
  59248. /** Callback used to start pointer up animation */
  59249. pointerUpAnimation: () => void;
  59250. /**
  59251. * An event triggered when the pointer move over the control
  59252. */
  59253. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  59254. /**
  59255. * An event triggered when the pointer move out of the control
  59256. */
  59257. onPointerOutObservable: BABYLON.Observable<Control3D>;
  59258. /**
  59259. * An event triggered when the pointer taps the control
  59260. */
  59261. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  59262. /**
  59263. * An event triggered when pointer is up
  59264. */
  59265. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  59266. /**
  59267. * An event triggered when a control is clicked on (with a mouse)
  59268. */
  59269. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  59270. /**
  59271. * An event triggered when pointer enters the control
  59272. */
  59273. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  59274. /**
  59275. * Gets or sets the parent container
  59276. */
  59277. parent: BABYLON.Nullable<Container3D>;
  59278. private _behaviors;
  59279. /**
  59280. * Gets the list of attached behaviors
  59281. * @see http://doc.babylonjs.com/features/behaviour
  59282. */
  59283. readonly behaviors: BABYLON.Behavior<Control3D>[];
  59284. /**
  59285. * Attach a behavior to the control
  59286. * @see http://doc.babylonjs.com/features/behaviour
  59287. * @param behavior defines the behavior to attach
  59288. * @returns the current control
  59289. */
  59290. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59291. /**
  59292. * Remove an attached behavior
  59293. * @see http://doc.babylonjs.com/features/behaviour
  59294. * @param behavior defines the behavior to attach
  59295. * @returns the current control
  59296. */
  59297. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59298. /**
  59299. * Gets an attached behavior by name
  59300. * @param name defines the name of the behavior to look for
  59301. * @see http://doc.babylonjs.com/features/behaviour
  59302. * @returns null if behavior was not found else the requested behavior
  59303. */
  59304. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  59305. /** Gets or sets a boolean indicating if the control is visible */
  59306. isVisible: boolean;
  59307. /**
  59308. * Creates a new control
  59309. * @param name defines the control name
  59310. */
  59311. constructor(
  59312. /** Defines the control name */
  59313. name?: string | undefined);
  59314. /**
  59315. * Gets a string representing the class name
  59316. */
  59317. readonly typeName: string;
  59318. /**
  59319. * Get the current class name of the control.
  59320. * @returns current class name
  59321. */
  59322. getClassName(): string;
  59323. protected _getTypeName(): string;
  59324. /**
  59325. * Gets the transform node used by this control
  59326. */
  59327. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  59328. /**
  59329. * Gets the mesh used to render this control
  59330. */
  59331. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59332. /**
  59333. * Link the control as child of the given node
  59334. * @param node defines the node to link to. Use null to unlink the control
  59335. * @returns the current control
  59336. */
  59337. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  59338. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  59339. /**
  59340. * Node creation.
  59341. * Can be overriden by children
  59342. * @param scene defines the scene where the node must be attached
  59343. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  59344. */
  59345. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59346. /**
  59347. * Affect a material to the given mesh
  59348. * @param mesh defines the mesh which will represent the control
  59349. */
  59350. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59351. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  59352. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  59353. /** @hidden */ onPointerOut(target: Control3D): void;
  59354. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59355. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59356. /** @hidden */
  59357. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59358. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59359. /** @hidden */ disposeNode(): void;
  59360. /**
  59361. * Releases all associated resources
  59362. */
  59363. dispose(): void;
  59364. }
  59365. }
  59366. declare module BABYLON.GUI {
  59367. /**
  59368. * Class used as a root to all buttons
  59369. */
  59370. export class AbstractButton3D extends Control3D {
  59371. /**
  59372. * Creates a new button
  59373. * @param name defines the control name
  59374. */
  59375. constructor(name?: string);
  59376. protected _getTypeName(): string;
  59377. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59378. }
  59379. }
  59380. declare module BABYLON.GUI {
  59381. /**
  59382. * Class used to create a button in 3D
  59383. */
  59384. export class Button3D extends AbstractButton3D {
  59385. /** @hidden */
  59386. protected _currentMaterial: BABYLON.Material;
  59387. private _facadeTexture;
  59388. private _content;
  59389. private _contentResolution;
  59390. private _contentScaleRatio;
  59391. /**
  59392. * Gets or sets the texture resolution used to render content (512 by default)
  59393. */
  59394. contentResolution: BABYLON.int;
  59395. /**
  59396. * Gets or sets the texture scale ratio used to render content (2 by default)
  59397. */
  59398. contentScaleRatio: number;
  59399. protected _disposeFacadeTexture(): void;
  59400. protected _resetContent(): void;
  59401. /**
  59402. * Creates a new button
  59403. * @param name defines the control name
  59404. */
  59405. constructor(name?: string);
  59406. /**
  59407. * Gets or sets the GUI 2D content used to display the button's facade
  59408. */
  59409. content: Control;
  59410. /**
  59411. * Apply the facade texture (created from the content property).
  59412. * This function can be overloaded by child classes
  59413. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59414. */
  59415. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59416. protected _getTypeName(): string;
  59417. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59418. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59419. /**
  59420. * Releases all associated resources
  59421. */
  59422. dispose(): void;
  59423. }
  59424. }
  59425. declare module BABYLON.GUI {
  59426. /**
  59427. * Abstract class used to create a container panel deployed on the surface of a volume
  59428. */
  59429. export abstract class VolumeBasedPanel extends Container3D {
  59430. private _columns;
  59431. private _rows;
  59432. private _rowThenColum;
  59433. private _orientation;
  59434. protected _cellWidth: number;
  59435. protected _cellHeight: number;
  59436. /**
  59437. * Gets or sets the distance between elements
  59438. */
  59439. margin: number;
  59440. /**
  59441. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59442. * | Value | Type | Description |
  59443. * | ----- | ----------------------------------- | ----------- |
  59444. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59445. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59446. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59447. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59448. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59449. */
  59450. orientation: number;
  59451. /**
  59452. * Gets or sets the number of columns requested (10 by default).
  59453. * The panel will automatically compute the number of rows based on number of child controls.
  59454. */
  59455. columns: BABYLON.int;
  59456. /**
  59457. * Gets or sets a the number of rows requested.
  59458. * The panel will automatically compute the number of columns based on number of child controls.
  59459. */
  59460. rows: BABYLON.int;
  59461. /**
  59462. * Creates new VolumeBasedPanel
  59463. */
  59464. constructor();
  59465. protected _arrangeChildren(): void;
  59466. /** Child classes must implement this function to provide correct control positioning */
  59467. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59468. /** Child classes can implement this function to provide additional processing */
  59469. protected _finalProcessing(): void;
  59470. }
  59471. }
  59472. declare module BABYLON.GUI {
  59473. /**
  59474. * Class used to create a container panel deployed on the surface of a cylinder
  59475. */
  59476. export class CylinderPanel extends VolumeBasedPanel {
  59477. private _radius;
  59478. /**
  59479. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59480. */
  59481. radius: BABYLON.float;
  59482. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59483. private _cylindricalMapping;
  59484. }
  59485. }
  59486. declare module BABYLON.GUI {
  59487. /** @hidden */
  59488. export var fluentVertexShader: {
  59489. name: string;
  59490. shader: string;
  59491. };
  59492. }
  59493. declare module BABYLON.GUI {
  59494. /** @hidden */
  59495. export var fluentPixelShader: {
  59496. name: string;
  59497. shader: string;
  59498. };
  59499. }
  59500. declare module BABYLON.GUI {
  59501. /** @hidden */
  59502. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59503. INNERGLOW: boolean;
  59504. BORDER: boolean;
  59505. HOVERLIGHT: boolean;
  59506. TEXTURE: boolean;
  59507. constructor();
  59508. }
  59509. /**
  59510. * Class used to render controls with fluent desgin
  59511. */
  59512. export class FluentMaterial extends BABYLON.PushMaterial {
  59513. /**
  59514. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59515. */
  59516. innerGlowColorIntensity: number;
  59517. /**
  59518. * Gets or sets the inner glow color (white by default)
  59519. */
  59520. innerGlowColor: BABYLON.Color3;
  59521. /**
  59522. * Gets or sets alpha value (default is 1.0)
  59523. */
  59524. alpha: number;
  59525. /**
  59526. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59527. */
  59528. albedoColor: BABYLON.Color3;
  59529. /**
  59530. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59531. */
  59532. renderBorders: boolean;
  59533. /**
  59534. * Gets or sets border width (default is 0.5)
  59535. */
  59536. borderWidth: number;
  59537. /**
  59538. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59539. */
  59540. edgeSmoothingValue: number;
  59541. /**
  59542. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59543. */
  59544. borderMinValue: number;
  59545. /**
  59546. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59547. */
  59548. renderHoverLight: boolean;
  59549. /**
  59550. * Gets or sets the radius used to render the hover light (default is 1.0)
  59551. */
  59552. hoverRadius: number;
  59553. /**
  59554. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59555. */
  59556. hoverColor: BABYLON.Color4;
  59557. /**
  59558. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59559. */
  59560. hoverPosition: BABYLON.Vector3;
  59561. private _albedoTexture;
  59562. /** Gets or sets the texture to use for albedo color */
  59563. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59564. /**
  59565. * Creates a new Fluent material
  59566. * @param name defines the name of the material
  59567. * @param scene defines the hosting scene
  59568. */
  59569. constructor(name: string, scene: BABYLON.Scene);
  59570. needAlphaBlending(): boolean;
  59571. needAlphaTesting(): boolean;
  59572. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59573. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59574. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59575. getActiveTextures(): BABYLON.BaseTexture[];
  59576. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59577. dispose(forceDisposeEffect?: boolean): void;
  59578. clone(name: string): FluentMaterial;
  59579. serialize(): any;
  59580. getClassName(): string;
  59581. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59582. }
  59583. }
  59584. declare module BABYLON.GUI {
  59585. /**
  59586. * Class used to create a holographic button in 3D
  59587. */
  59588. export class HolographicButton extends Button3D {
  59589. private _backPlate;
  59590. private _textPlate;
  59591. private _frontPlate;
  59592. private _text;
  59593. private _imageUrl;
  59594. private _shareMaterials;
  59595. private _frontMaterial;
  59596. private _backMaterial;
  59597. private _plateMaterial;
  59598. private _pickedPointObserver;
  59599. private _tooltipFade;
  59600. private _tooltipTextBlock;
  59601. private _tooltipTexture;
  59602. private _tooltipMesh;
  59603. private _tooltipHoverObserver;
  59604. private _tooltipOutObserver;
  59605. private _disposeTooltip;
  59606. /**
  59607. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59608. */
  59609. tooltipText: BABYLON.Nullable<string>;
  59610. /**
  59611. * Gets or sets text for the button
  59612. */
  59613. text: string;
  59614. /**
  59615. * Gets or sets the image url for the button
  59616. */
  59617. imageUrl: string;
  59618. /**
  59619. * Gets the back material used by this button
  59620. */
  59621. readonly backMaterial: FluentMaterial;
  59622. /**
  59623. * Gets the front material used by this button
  59624. */
  59625. readonly frontMaterial: FluentMaterial;
  59626. /**
  59627. * Gets the plate material used by this button
  59628. */
  59629. readonly plateMaterial: BABYLON.StandardMaterial;
  59630. /**
  59631. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59632. */
  59633. readonly shareMaterials: boolean;
  59634. /**
  59635. * Creates a new button
  59636. * @param name defines the control name
  59637. */
  59638. constructor(name?: string, shareMaterials?: boolean);
  59639. protected _getTypeName(): string;
  59640. private _rebuildContent;
  59641. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59642. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59643. private _createBackMaterial;
  59644. private _createFrontMaterial;
  59645. private _createPlateMaterial;
  59646. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59647. /**
  59648. * Releases all associated resources
  59649. */
  59650. dispose(): void;
  59651. }
  59652. }
  59653. declare module BABYLON.GUI {
  59654. /**
  59655. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59656. */
  59657. export class MeshButton3D extends Button3D {
  59658. /** @hidden */
  59659. protected _currentMesh: BABYLON.Mesh;
  59660. /**
  59661. * Creates a new 3D button based on a mesh
  59662. * @param mesh mesh to become a 3D button
  59663. * @param name defines the control name
  59664. */
  59665. constructor(mesh: BABYLON.Mesh, name?: string);
  59666. protected _getTypeName(): string;
  59667. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59668. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59669. }
  59670. }
  59671. declare module BABYLON.GUI {
  59672. /**
  59673. * Class used to create a container panel deployed on the surface of a plane
  59674. */
  59675. export class PlanePanel extends VolumeBasedPanel {
  59676. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59677. }
  59678. }
  59679. declare module BABYLON.GUI {
  59680. /**
  59681. * Class used to create a container panel where items get randomized planar mapping
  59682. */
  59683. export class ScatterPanel extends VolumeBasedPanel {
  59684. private _iteration;
  59685. /**
  59686. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59687. */
  59688. iteration: BABYLON.float;
  59689. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59690. private _scatterMapping;
  59691. protected _finalProcessing(): void;
  59692. }
  59693. }
  59694. declare module BABYLON.GUI {
  59695. /**
  59696. * Class used to create a container panel deployed on the surface of a sphere
  59697. */
  59698. export class SpherePanel extends VolumeBasedPanel {
  59699. private _radius;
  59700. /**
  59701. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59702. */
  59703. radius: BABYLON.float;
  59704. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59705. private _sphericalMapping;
  59706. }
  59707. }
  59708. declare module BABYLON.GUI {
  59709. /**
  59710. * Class used to create a stack panel in 3D on XY plane
  59711. */
  59712. export class StackPanel3D extends Container3D {
  59713. private _isVertical;
  59714. /**
  59715. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59716. */
  59717. isVertical: boolean;
  59718. /**
  59719. * Gets or sets the distance between elements
  59720. */
  59721. margin: number;
  59722. /**
  59723. * Creates new StackPanel
  59724. * @param isVertical
  59725. */
  59726. constructor(isVertical?: boolean);
  59727. protected _arrangeChildren(): void;
  59728. }
  59729. }
  59730. declare module BABYLON {
  59731. /**
  59732. * Mode that determines the coordinate system to use.
  59733. */
  59734. export enum GLTFLoaderCoordinateSystemMode {
  59735. /**
  59736. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59737. */
  59738. AUTO = 0,
  59739. /**
  59740. * Sets the useRightHandedSystem flag on the scene.
  59741. */
  59742. FORCE_RIGHT_HANDED = 1
  59743. }
  59744. /**
  59745. * Mode that determines what animations will start.
  59746. */
  59747. export enum GLTFLoaderAnimationStartMode {
  59748. /**
  59749. * No animation will start.
  59750. */
  59751. NONE = 0,
  59752. /**
  59753. * The first animation will start.
  59754. */
  59755. FIRST = 1,
  59756. /**
  59757. * All animations will start.
  59758. */
  59759. ALL = 2
  59760. }
  59761. /**
  59762. * Interface that contains the data for the glTF asset.
  59763. */
  59764. export interface IGLTFLoaderData {
  59765. /**
  59766. * Object that represents the glTF JSON.
  59767. */
  59768. json: Object;
  59769. /**
  59770. * The BIN chunk of a binary glTF.
  59771. */
  59772. bin: Nullable<ArrayBufferView>;
  59773. }
  59774. /**
  59775. * Interface for extending the loader.
  59776. */
  59777. export interface IGLTFLoaderExtension {
  59778. /**
  59779. * The name of this extension.
  59780. */
  59781. readonly name: string;
  59782. /**
  59783. * Defines whether this extension is enabled.
  59784. */
  59785. enabled: boolean;
  59786. }
  59787. /**
  59788. * Loader state.
  59789. */
  59790. export enum GLTFLoaderState {
  59791. /**
  59792. * The asset is loading.
  59793. */
  59794. LOADING = 0,
  59795. /**
  59796. * The asset is ready for rendering.
  59797. */
  59798. READY = 1,
  59799. /**
  59800. * The asset is completely loaded.
  59801. */
  59802. COMPLETE = 2
  59803. }
  59804. /** @hidden */
  59805. export interface IGLTFLoader extends IDisposable {
  59806. readonly state: Nullable<GLTFLoaderState>;
  59807. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59808. meshes: AbstractMesh[];
  59809. particleSystems: IParticleSystem[];
  59810. skeletons: Skeleton[];
  59811. animationGroups: AnimationGroup[];
  59812. }>;
  59813. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59814. }
  59815. /**
  59816. * File loader for loading glTF files into a scene.
  59817. */
  59818. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59819. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59820. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59821. /**
  59822. * Raised when the asset has been parsed
  59823. */
  59824. onParsedObservable: Observable<IGLTFLoaderData>;
  59825. private _onParsedObserver;
  59826. /**
  59827. * Raised when the asset has been parsed
  59828. */
  59829. onParsed: (loaderData: IGLTFLoaderData) => void;
  59830. /**
  59831. * 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.
  59832. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59833. * Defaults to true.
  59834. * @hidden
  59835. */
  59836. static IncrementalLoading: boolean;
  59837. /**
  59838. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59839. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59840. * @hidden
  59841. */
  59842. static HomogeneousCoordinates: boolean;
  59843. /**
  59844. * The coordinate system mode. Defaults to AUTO.
  59845. */
  59846. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59847. /**
  59848. * The animation start mode. Defaults to FIRST.
  59849. */
  59850. animationStartMode: GLTFLoaderAnimationStartMode;
  59851. /**
  59852. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59853. */
  59854. compileMaterials: boolean;
  59855. /**
  59856. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59857. */
  59858. useClipPlane: boolean;
  59859. /**
  59860. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59861. */
  59862. compileShadowGenerators: boolean;
  59863. /**
  59864. * Defines if the Alpha blended materials are only applied as coverage.
  59865. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59866. * If true, no extra effects are applied to transparent pixels.
  59867. */
  59868. transparencyAsCoverage: boolean;
  59869. /**
  59870. * Function called before loading a url referenced by the asset.
  59871. */
  59872. preprocessUrlAsync: (url: string) => Promise<string>;
  59873. /**
  59874. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59875. */
  59876. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59877. private _onMeshLoadedObserver;
  59878. /**
  59879. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59880. */
  59881. onMeshLoaded: (mesh: AbstractMesh) => void;
  59882. /**
  59883. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59884. */
  59885. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59886. private _onTextureLoadedObserver;
  59887. /**
  59888. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59889. */
  59890. onTextureLoaded: (texture: BaseTexture) => void;
  59891. /**
  59892. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59893. */
  59894. readonly onMaterialLoadedObservable: Observable<Material>;
  59895. private _onMaterialLoadedObserver;
  59896. /**
  59897. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59898. */
  59899. onMaterialLoaded: (material: Material) => void;
  59900. /**
  59901. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59902. */
  59903. readonly onCameraLoadedObservable: Observable<Camera>;
  59904. private _onCameraLoadedObserver;
  59905. /**
  59906. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59907. */
  59908. onCameraLoaded: (camera: Camera) => void;
  59909. /**
  59910. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59911. * For assets with LODs, raised when all of the LODs are complete.
  59912. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59913. */
  59914. readonly onCompleteObservable: Observable<void>;
  59915. private _onCompleteObserver;
  59916. /**
  59917. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59918. * For assets with LODs, raised when all of the LODs are complete.
  59919. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59920. */
  59921. onComplete: () => void;
  59922. /**
  59923. * Observable raised when an error occurs.
  59924. */
  59925. readonly onErrorObservable: Observable<any>;
  59926. private _onErrorObserver;
  59927. /**
  59928. * Callback raised when an error occurs.
  59929. */
  59930. onError: (reason: any) => void;
  59931. /**
  59932. * Observable raised after the loader is disposed.
  59933. */
  59934. readonly onDisposeObservable: Observable<void>;
  59935. private _onDisposeObserver;
  59936. /**
  59937. * Callback raised after the loader is disposed.
  59938. */
  59939. onDispose: () => void;
  59940. /**
  59941. * Observable raised after a loader extension is created.
  59942. * Set additional options for a loader extension in this event.
  59943. */
  59944. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59945. private _onExtensionLoadedObserver;
  59946. /**
  59947. * Callback raised after a loader extension is created.
  59948. */
  59949. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59950. /**
  59951. * Defines if the loader logging is enabled.
  59952. */
  59953. loggingEnabled: boolean;
  59954. /**
  59955. * Defines if the loader should capture performance counters.
  59956. */
  59957. capturePerformanceCounters: boolean;
  59958. /**
  59959. * Defines if the loader should validate the asset.
  59960. */
  59961. validate: boolean;
  59962. /**
  59963. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59964. */
  59965. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59966. private _onValidatedObserver;
  59967. /**
  59968. * Callback raised after a loader extension is created.
  59969. */
  59970. onValidated: (results: IGLTFValidationResults) => void;
  59971. private _loader;
  59972. /**
  59973. * Name of the loader ("gltf")
  59974. */
  59975. name: string;
  59976. /**
  59977. * Supported file extensions of the loader (.gltf, .glb)
  59978. */
  59979. extensions: ISceneLoaderPluginExtensions;
  59980. /**
  59981. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59982. */
  59983. dispose(): void;
  59984. /** @hidden */ clear(): void;
  59985. /**
  59986. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59987. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59988. * @param scene the scene the meshes should be added to
  59989. * @param data the glTF data to load
  59990. * @param rootUrl root url to load from
  59991. * @param onProgress event that fires when loading progress has occured
  59992. * @param fileName Defines the name of the file to load
  59993. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59994. */
  59995. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59996. meshes: AbstractMesh[];
  59997. particleSystems: IParticleSystem[];
  59998. skeletons: Skeleton[];
  59999. animationGroups: AnimationGroup[];
  60000. }>;
  60001. /**
  60002. * Imports all objects from the loaded glTF data and adds them to the scene
  60003. * @param scene the scene the objects should be added to
  60004. * @param data the glTF data to load
  60005. * @param rootUrl root url to load from
  60006. * @param onProgress event that fires when loading progress has occured
  60007. * @param fileName Defines the name of the file to load
  60008. * @returns a promise which completes when objects have been loaded to the scene
  60009. */
  60010. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60011. /**
  60012. * Load into an asset container.
  60013. * @param scene The scene to load into
  60014. * @param data The data to import
  60015. * @param rootUrl The root url for scene and resources
  60016. * @param onProgress The callback when the load progresses
  60017. * @param fileName Defines the name of the file to load
  60018. * @returns The loaded asset container
  60019. */
  60020. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  60021. /**
  60022. * If the data string can be loaded directly.
  60023. * @param data string contianing the file data
  60024. * @returns if the data can be loaded directly
  60025. */
  60026. canDirectLoad(data: string): boolean;
  60027. /**
  60028. * Rewrites a url by combining a root url and response url.
  60029. */
  60030. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  60031. /**
  60032. * Instantiates a glTF file loader plugin.
  60033. * @returns the created plugin
  60034. */
  60035. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  60036. /**
  60037. * The loader state or null if the loader is not active.
  60038. */
  60039. readonly loaderState: Nullable<GLTFLoaderState>;
  60040. /**
  60041. * Returns a promise that resolves when the asset is completely loaded.
  60042. * @returns a promise that resolves when the asset is completely loaded.
  60043. */
  60044. whenCompleteAsync(): Promise<void>;
  60045. private _parseAsync;
  60046. private _validateAsync;
  60047. private _getLoader;
  60048. private _unpackBinary;
  60049. private _unpackBinaryV1;
  60050. private _unpackBinaryV2;
  60051. private static _parseVersion;
  60052. private static _compareVersion;
  60053. private static _decodeBufferToText;
  60054. private static readonly _logSpaces;
  60055. private _logIndentLevel;
  60056. private _loggingEnabled;
  60057. /** @hidden */ log: (message: string) => void;
  60058. /** @hidden */ logOpen(message: string): void;
  60059. /** @hidden */ logClose(): void;
  60060. private _logEnabled;
  60061. private _logDisabled;
  60062. private _capturePerformanceCounters;
  60063. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  60064. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  60065. private _startPerformanceCounterEnabled;
  60066. private _startPerformanceCounterDisabled;
  60067. private _endPerformanceCounterEnabled;
  60068. private _endPerformanceCounterDisabled;
  60069. }
  60070. }
  60071. declare module BABYLON.GLTF1 {
  60072. /**
  60073. * Enums
  60074. * @hidden
  60075. */
  60076. export enum EComponentType {
  60077. BYTE = 5120,
  60078. UNSIGNED_BYTE = 5121,
  60079. SHORT = 5122,
  60080. UNSIGNED_SHORT = 5123,
  60081. FLOAT = 5126
  60082. }
  60083. /** @hidden */
  60084. export enum EShaderType {
  60085. FRAGMENT = 35632,
  60086. VERTEX = 35633
  60087. }
  60088. /** @hidden */
  60089. export enum EParameterType {
  60090. BYTE = 5120,
  60091. UNSIGNED_BYTE = 5121,
  60092. SHORT = 5122,
  60093. UNSIGNED_SHORT = 5123,
  60094. INT = 5124,
  60095. UNSIGNED_INT = 5125,
  60096. FLOAT = 5126,
  60097. FLOAT_VEC2 = 35664,
  60098. FLOAT_VEC3 = 35665,
  60099. FLOAT_VEC4 = 35666,
  60100. INT_VEC2 = 35667,
  60101. INT_VEC3 = 35668,
  60102. INT_VEC4 = 35669,
  60103. BOOL = 35670,
  60104. BOOL_VEC2 = 35671,
  60105. BOOL_VEC3 = 35672,
  60106. BOOL_VEC4 = 35673,
  60107. FLOAT_MAT2 = 35674,
  60108. FLOAT_MAT3 = 35675,
  60109. FLOAT_MAT4 = 35676,
  60110. SAMPLER_2D = 35678
  60111. }
  60112. /** @hidden */
  60113. export enum ETextureWrapMode {
  60114. CLAMP_TO_EDGE = 33071,
  60115. MIRRORED_REPEAT = 33648,
  60116. REPEAT = 10497
  60117. }
  60118. /** @hidden */
  60119. export enum ETextureFilterType {
  60120. NEAREST = 9728,
  60121. LINEAR = 9728,
  60122. NEAREST_MIPMAP_NEAREST = 9984,
  60123. LINEAR_MIPMAP_NEAREST = 9985,
  60124. NEAREST_MIPMAP_LINEAR = 9986,
  60125. LINEAR_MIPMAP_LINEAR = 9987
  60126. }
  60127. /** @hidden */
  60128. export enum ETextureFormat {
  60129. ALPHA = 6406,
  60130. RGB = 6407,
  60131. RGBA = 6408,
  60132. LUMINANCE = 6409,
  60133. LUMINANCE_ALPHA = 6410
  60134. }
  60135. /** @hidden */
  60136. export enum ECullingType {
  60137. FRONT = 1028,
  60138. BACK = 1029,
  60139. FRONT_AND_BACK = 1032
  60140. }
  60141. /** @hidden */
  60142. export enum EBlendingFunction {
  60143. ZERO = 0,
  60144. ONE = 1,
  60145. SRC_COLOR = 768,
  60146. ONE_MINUS_SRC_COLOR = 769,
  60147. DST_COLOR = 774,
  60148. ONE_MINUS_DST_COLOR = 775,
  60149. SRC_ALPHA = 770,
  60150. ONE_MINUS_SRC_ALPHA = 771,
  60151. DST_ALPHA = 772,
  60152. ONE_MINUS_DST_ALPHA = 773,
  60153. CONSTANT_COLOR = 32769,
  60154. ONE_MINUS_CONSTANT_COLOR = 32770,
  60155. CONSTANT_ALPHA = 32771,
  60156. ONE_MINUS_CONSTANT_ALPHA = 32772,
  60157. SRC_ALPHA_SATURATE = 776
  60158. }
  60159. /** @hidden */
  60160. export interface IGLTFProperty {
  60161. extensions?: {
  60162. [key: string]: any;
  60163. };
  60164. extras?: Object;
  60165. }
  60166. /** @hidden */
  60167. export interface IGLTFChildRootProperty extends IGLTFProperty {
  60168. name?: string;
  60169. }
  60170. /** @hidden */
  60171. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  60172. bufferView: string;
  60173. byteOffset: number;
  60174. byteStride: number;
  60175. count: number;
  60176. type: string;
  60177. componentType: EComponentType;
  60178. max?: number[];
  60179. min?: number[];
  60180. name?: string;
  60181. }
  60182. /** @hidden */
  60183. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  60184. buffer: string;
  60185. byteOffset: number;
  60186. byteLength: number;
  60187. byteStride: number;
  60188. target?: number;
  60189. }
  60190. /** @hidden */
  60191. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  60192. uri: string;
  60193. byteLength?: number;
  60194. type?: string;
  60195. }
  60196. /** @hidden */
  60197. export interface IGLTFShader extends IGLTFChildRootProperty {
  60198. uri: string;
  60199. type: EShaderType;
  60200. }
  60201. /** @hidden */
  60202. export interface IGLTFProgram extends IGLTFChildRootProperty {
  60203. attributes: string[];
  60204. fragmentShader: string;
  60205. vertexShader: string;
  60206. }
  60207. /** @hidden */
  60208. export interface IGLTFTechniqueParameter {
  60209. type: number;
  60210. count?: number;
  60211. semantic?: string;
  60212. node?: string;
  60213. value?: number | boolean | string | Array<any>;
  60214. source?: string;
  60215. babylonValue?: any;
  60216. }
  60217. /** @hidden */
  60218. export interface IGLTFTechniqueCommonProfile {
  60219. lightingModel: string;
  60220. texcoordBindings: Object;
  60221. parameters?: Array<any>;
  60222. }
  60223. /** @hidden */
  60224. export interface IGLTFTechniqueStatesFunctions {
  60225. blendColor?: number[];
  60226. blendEquationSeparate?: number[];
  60227. blendFuncSeparate?: number[];
  60228. colorMask: boolean[];
  60229. cullFace: number[];
  60230. }
  60231. /** @hidden */
  60232. export interface IGLTFTechniqueStates {
  60233. enable: number[];
  60234. functions: IGLTFTechniqueStatesFunctions;
  60235. }
  60236. /** @hidden */
  60237. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  60238. parameters: {
  60239. [key: string]: IGLTFTechniqueParameter;
  60240. };
  60241. program: string;
  60242. attributes: {
  60243. [key: string]: string;
  60244. };
  60245. uniforms: {
  60246. [key: string]: string;
  60247. };
  60248. states: IGLTFTechniqueStates;
  60249. }
  60250. /** @hidden */
  60251. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  60252. technique?: string;
  60253. values: string[];
  60254. }
  60255. /** @hidden */
  60256. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  60257. attributes: {
  60258. [key: string]: string;
  60259. };
  60260. indices: string;
  60261. material: string;
  60262. mode?: number;
  60263. }
  60264. /** @hidden */
  60265. export interface IGLTFMesh extends IGLTFChildRootProperty {
  60266. primitives: IGLTFMeshPrimitive[];
  60267. }
  60268. /** @hidden */
  60269. export interface IGLTFImage extends IGLTFChildRootProperty {
  60270. uri: string;
  60271. }
  60272. /** @hidden */
  60273. export interface IGLTFSampler extends IGLTFChildRootProperty {
  60274. magFilter?: number;
  60275. minFilter?: number;
  60276. wrapS?: number;
  60277. wrapT?: number;
  60278. }
  60279. /** @hidden */
  60280. export interface IGLTFTexture extends IGLTFChildRootProperty {
  60281. sampler: string;
  60282. source: string;
  60283. format?: ETextureFormat;
  60284. internalFormat?: ETextureFormat;
  60285. target?: number;
  60286. type?: number;
  60287. babylonTexture?: Texture;
  60288. }
  60289. /** @hidden */
  60290. export interface IGLTFAmbienLight {
  60291. color?: number[];
  60292. }
  60293. /** @hidden */
  60294. export interface IGLTFDirectionalLight {
  60295. color?: number[];
  60296. }
  60297. /** @hidden */
  60298. export interface IGLTFPointLight {
  60299. color?: number[];
  60300. constantAttenuation?: number;
  60301. linearAttenuation?: number;
  60302. quadraticAttenuation?: number;
  60303. }
  60304. /** @hidden */
  60305. export interface IGLTFSpotLight {
  60306. color?: number[];
  60307. constantAttenuation?: number;
  60308. fallOfAngle?: number;
  60309. fallOffExponent?: number;
  60310. linearAttenuation?: number;
  60311. quadraticAttenuation?: number;
  60312. }
  60313. /** @hidden */
  60314. export interface IGLTFLight extends IGLTFChildRootProperty {
  60315. type: string;
  60316. }
  60317. /** @hidden */
  60318. export interface IGLTFCameraOrthographic {
  60319. xmag: number;
  60320. ymag: number;
  60321. zfar: number;
  60322. znear: number;
  60323. }
  60324. /** @hidden */
  60325. export interface IGLTFCameraPerspective {
  60326. aspectRatio: number;
  60327. yfov: number;
  60328. zfar: number;
  60329. znear: number;
  60330. }
  60331. /** @hidden */
  60332. export interface IGLTFCamera extends IGLTFChildRootProperty {
  60333. type: string;
  60334. }
  60335. /** @hidden */
  60336. export interface IGLTFAnimationChannelTarget {
  60337. id: string;
  60338. path: string;
  60339. }
  60340. /** @hidden */
  60341. export interface IGLTFAnimationChannel {
  60342. sampler: string;
  60343. target: IGLTFAnimationChannelTarget;
  60344. }
  60345. /** @hidden */
  60346. export interface IGLTFAnimationSampler {
  60347. input: string;
  60348. output: string;
  60349. interpolation?: string;
  60350. }
  60351. /** @hidden */
  60352. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  60353. channels?: IGLTFAnimationChannel[];
  60354. parameters?: {
  60355. [key: string]: string;
  60356. };
  60357. samplers?: {
  60358. [key: string]: IGLTFAnimationSampler;
  60359. };
  60360. }
  60361. /** @hidden */
  60362. export interface IGLTFNodeInstanceSkin {
  60363. skeletons: string[];
  60364. skin: string;
  60365. meshes: string[];
  60366. }
  60367. /** @hidden */
  60368. export interface IGLTFSkins extends IGLTFChildRootProperty {
  60369. bindShapeMatrix: number[];
  60370. inverseBindMatrices: string;
  60371. jointNames: string[];
  60372. babylonSkeleton?: Skeleton;
  60373. }
  60374. /** @hidden */
  60375. export interface IGLTFNode extends IGLTFChildRootProperty {
  60376. camera?: string;
  60377. children: string[];
  60378. skin?: string;
  60379. jointName?: string;
  60380. light?: string;
  60381. matrix: number[];
  60382. mesh?: string;
  60383. meshes?: string[];
  60384. rotation?: number[];
  60385. scale?: number[];
  60386. translation?: number[];
  60387. babylonNode?: Node;
  60388. }
  60389. /** @hidden */
  60390. export interface IGLTFScene extends IGLTFChildRootProperty {
  60391. nodes: string[];
  60392. }
  60393. /** @hidden */
  60394. export interface IGLTFRuntime {
  60395. extensions: {
  60396. [key: string]: any;
  60397. };
  60398. accessors: {
  60399. [key: string]: IGLTFAccessor;
  60400. };
  60401. buffers: {
  60402. [key: string]: IGLTFBuffer;
  60403. };
  60404. bufferViews: {
  60405. [key: string]: IGLTFBufferView;
  60406. };
  60407. meshes: {
  60408. [key: string]: IGLTFMesh;
  60409. };
  60410. lights: {
  60411. [key: string]: IGLTFLight;
  60412. };
  60413. cameras: {
  60414. [key: string]: IGLTFCamera;
  60415. };
  60416. nodes: {
  60417. [key: string]: IGLTFNode;
  60418. };
  60419. images: {
  60420. [key: string]: IGLTFImage;
  60421. };
  60422. textures: {
  60423. [key: string]: IGLTFTexture;
  60424. };
  60425. shaders: {
  60426. [key: string]: IGLTFShader;
  60427. };
  60428. programs: {
  60429. [key: string]: IGLTFProgram;
  60430. };
  60431. samplers: {
  60432. [key: string]: IGLTFSampler;
  60433. };
  60434. techniques: {
  60435. [key: string]: IGLTFTechnique;
  60436. };
  60437. materials: {
  60438. [key: string]: IGLTFMaterial;
  60439. };
  60440. animations: {
  60441. [key: string]: IGLTFAnimation;
  60442. };
  60443. skins: {
  60444. [key: string]: IGLTFSkins;
  60445. };
  60446. currentScene?: Object;
  60447. scenes: {
  60448. [key: string]: IGLTFScene;
  60449. };
  60450. extensionsUsed: string[];
  60451. extensionsRequired?: string[];
  60452. buffersCount: number;
  60453. shaderscount: number;
  60454. scene: Scene;
  60455. rootUrl: string;
  60456. loadedBufferCount: number;
  60457. loadedBufferViews: {
  60458. [name: string]: ArrayBufferView;
  60459. };
  60460. loadedShaderCount: number;
  60461. importOnlyMeshes: boolean;
  60462. importMeshesNames?: string[];
  60463. dummyNodes: Node[];
  60464. }
  60465. /** @hidden */
  60466. export interface INodeToRoot {
  60467. bone: Bone;
  60468. node: IGLTFNode;
  60469. id: string;
  60470. }
  60471. /** @hidden */
  60472. export interface IJointNode {
  60473. node: IGLTFNode;
  60474. id: string;
  60475. }
  60476. }
  60477. declare module BABYLON.GLTF1 {
  60478. /**
  60479. * Utils functions for GLTF
  60480. * @hidden
  60481. */
  60482. export class GLTFUtils {
  60483. /**
  60484. * Sets the given "parameter" matrix
  60485. * @param scene: the Scene object
  60486. * @param source: the source node where to pick the matrix
  60487. * @param parameter: the GLTF technique parameter
  60488. * @param uniformName: the name of the shader's uniform
  60489. * @param shaderMaterial: the shader material
  60490. */
  60491. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60492. /**
  60493. * Sets the given "parameter" matrix
  60494. * @param shaderMaterial: the shader material
  60495. * @param uniform: the name of the shader's uniform
  60496. * @param value: the value of the uniform
  60497. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60498. */
  60499. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60500. /**
  60501. * Returns the wrap mode of the texture
  60502. * @param mode: the mode value
  60503. */
  60504. static GetWrapMode(mode: number): number;
  60505. /**
  60506. * Returns the byte stride giving an accessor
  60507. * @param accessor: the GLTF accessor objet
  60508. */
  60509. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60510. /**
  60511. * Returns the texture filter mode giving a mode value
  60512. * @param mode: the filter mode value
  60513. */
  60514. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60515. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60516. /**
  60517. * Returns a buffer from its accessor
  60518. * @param gltfRuntime: the GLTF runtime
  60519. * @param accessor: the GLTF accessor
  60520. */
  60521. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60522. /**
  60523. * Decodes a buffer view into a string
  60524. * @param view: the buffer view
  60525. */
  60526. static DecodeBufferToText(view: ArrayBufferView): string;
  60527. /**
  60528. * Returns the default material of gltf. Related to
  60529. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60530. * @param scene: the Babylon.js scene
  60531. */
  60532. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60533. private static _DefaultMaterial;
  60534. }
  60535. }
  60536. declare module BABYLON.GLTF1 {
  60537. /**
  60538. * Implementation of the base glTF spec
  60539. * @hidden
  60540. */
  60541. export class GLTFLoaderBase {
  60542. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60543. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60544. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60545. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60546. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60547. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60548. }
  60549. /**
  60550. * glTF V1 Loader
  60551. * @hidden
  60552. */
  60553. export class GLTFLoader implements IGLTFLoader {
  60554. static Extensions: {
  60555. [name: string]: GLTFLoaderExtension;
  60556. };
  60557. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60558. state: Nullable<GLTFLoaderState>;
  60559. dispose(): void;
  60560. private _importMeshAsync;
  60561. /**
  60562. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60563. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60564. * @param scene the scene the meshes should be added to
  60565. * @param data gltf data containing information of the meshes in a loaded file
  60566. * @param rootUrl root url to load from
  60567. * @param onProgress event that fires when loading progress has occured
  60568. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60569. */
  60570. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60571. meshes: AbstractMesh[];
  60572. particleSystems: IParticleSystem[];
  60573. skeletons: Skeleton[];
  60574. animationGroups: AnimationGroup[];
  60575. }>;
  60576. private _loadAsync;
  60577. /**
  60578. * Imports all objects from a loaded gltf file and adds them to the scene
  60579. * @param scene the scene the objects should be added to
  60580. * @param data gltf data containing information of the meshes in a loaded file
  60581. * @param rootUrl root url to load from
  60582. * @param onProgress event that fires when loading progress has occured
  60583. * @returns a promise which completes when objects have been loaded to the scene
  60584. */
  60585. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60586. private _loadShadersAsync;
  60587. private _loadBuffersAsync;
  60588. private _createNodes;
  60589. }
  60590. /** @hidden */
  60591. export abstract class GLTFLoaderExtension {
  60592. private _name;
  60593. constructor(name: string);
  60594. readonly name: string;
  60595. /**
  60596. * Defines an override for loading the runtime
  60597. * Return true to stop further extensions from loading the runtime
  60598. */
  60599. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60600. /**
  60601. * Defines an onverride for creating gltf runtime
  60602. * Return true to stop further extensions from creating the runtime
  60603. */
  60604. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60605. /**
  60606. * Defines an override for loading buffers
  60607. * Return true to stop further extensions from loading this buffer
  60608. */
  60609. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60610. /**
  60611. * Defines an override for loading texture buffers
  60612. * Return true to stop further extensions from loading this texture data
  60613. */
  60614. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60615. /**
  60616. * Defines an override for creating textures
  60617. * Return true to stop further extensions from loading this texture
  60618. */
  60619. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60620. /**
  60621. * Defines an override for loading shader strings
  60622. * Return true to stop further extensions from loading this shader data
  60623. */
  60624. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60625. /**
  60626. * Defines an override for loading materials
  60627. * Return true to stop further extensions from loading this material
  60628. */
  60629. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60630. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60631. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60632. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60633. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60634. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60635. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60636. private static LoadTextureBufferAsync;
  60637. private static CreateTextureAsync;
  60638. private static ApplyExtensions;
  60639. }
  60640. }
  60641. declare module BABYLON.GLTF1 {
  60642. /** @hidden */
  60643. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60644. private _bin;
  60645. constructor();
  60646. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60647. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60648. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60649. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60650. }
  60651. }
  60652. declare module BABYLON.GLTF1 {
  60653. /** @hidden */
  60654. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60655. constructor();
  60656. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60657. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60658. private _loadTexture;
  60659. }
  60660. }
  60661. declare module BABYLON.GLTF2.Loader {
  60662. /**
  60663. * Loader interface with an index field.
  60664. */
  60665. export interface IArrayItem {
  60666. /**
  60667. * The index of this item in the array.
  60668. */
  60669. index: number;
  60670. }
  60671. /**
  60672. * Loader interface with additional members.
  60673. */
  60674. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60675. /** @hidden */ data?: Promise<ArrayBufferView>;
  60676. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60677. }
  60678. /**
  60679. * Loader interface with additional members.
  60680. */
  60681. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60682. }
  60683. /** @hidden */
  60684. export interface _IAnimationSamplerData {
  60685. input: Float32Array;
  60686. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60687. output: Float32Array;
  60688. }
  60689. /**
  60690. * Loader interface with additional members.
  60691. */
  60692. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60693. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60694. }
  60695. /**
  60696. * Loader interface with additional members.
  60697. */
  60698. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60699. channels: IAnimationChannel[];
  60700. samplers: IAnimationSampler[];
  60701. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60702. }
  60703. /**
  60704. * Loader interface with additional members.
  60705. */
  60706. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60707. /** @hidden */ data?: Promise<ArrayBufferView>;
  60708. }
  60709. /**
  60710. * Loader interface with additional members.
  60711. */
  60712. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60713. /** @hidden */ data?: Promise<ArrayBufferView>;
  60714. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60715. }
  60716. /**
  60717. * Loader interface with additional members.
  60718. */
  60719. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60720. }
  60721. /**
  60722. * Loader interface with additional members.
  60723. */
  60724. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60725. /** @hidden */ data?: Promise<ArrayBufferView>;
  60726. }
  60727. /**
  60728. * Loader interface with additional members.
  60729. */
  60730. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60731. }
  60732. /**
  60733. * Loader interface with additional members.
  60734. */
  60735. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60736. }
  60737. /**
  60738. * Loader interface with additional members.
  60739. */
  60740. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60741. baseColorTexture?: ITextureInfo;
  60742. metallicRoughnessTexture?: ITextureInfo;
  60743. }
  60744. /**
  60745. * Loader interface with additional members.
  60746. */
  60747. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60748. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60749. normalTexture?: IMaterialNormalTextureInfo;
  60750. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60751. emissiveTexture?: ITextureInfo;
  60752. /** @hidden */ data?: {
  60753. [babylonDrawMode: number]: {
  60754. babylonMaterial: Material;
  60755. babylonMeshes: AbstractMesh[];
  60756. promise: Promise<void>;
  60757. };
  60758. };
  60759. }
  60760. /**
  60761. * Loader interface with additional members.
  60762. */
  60763. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60764. primitives: IMeshPrimitive[];
  60765. }
  60766. /**
  60767. * Loader interface with additional members.
  60768. */
  60769. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60770. /** @hidden */ instanceData?: {
  60771. babylonSourceMesh: Mesh;
  60772. promise: Promise<any>;
  60773. };
  60774. }
  60775. /**
  60776. * Loader interface with additional members.
  60777. */
  60778. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60779. /**
  60780. * The parent glTF node.
  60781. */
  60782. parent?: INode;
  60783. /** @hidden */ babylonTransformNode?: TransformNode;
  60784. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60785. /** @hidden */ babylonBones?: Bone[];
  60786. /** @hidden */ numMorphTargets?: number;
  60787. }
  60788. /** @hidden */
  60789. export interface _ISamplerData {
  60790. noMipMaps: boolean;
  60791. samplingMode: number;
  60792. wrapU: number;
  60793. wrapV: number;
  60794. }
  60795. /**
  60796. * Loader interface with additional members.
  60797. */
  60798. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60799. /** @hidden */ data?: _ISamplerData;
  60800. }
  60801. /**
  60802. * Loader interface with additional members.
  60803. */
  60804. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60805. }
  60806. /**
  60807. * Loader interface with additional members.
  60808. */
  60809. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60810. /** @hidden */ data?: {
  60811. babylonSkeleton: Skeleton;
  60812. promise: Promise<void>;
  60813. };
  60814. }
  60815. /**
  60816. * Loader interface with additional members.
  60817. */
  60818. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60819. }
  60820. /**
  60821. * Loader interface with additional members.
  60822. */
  60823. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60824. }
  60825. /**
  60826. * Loader interface with additional members.
  60827. */
  60828. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60829. accessors?: IAccessor[];
  60830. animations?: IAnimation[];
  60831. buffers?: IBuffer[];
  60832. bufferViews?: IBufferView[];
  60833. cameras?: ICamera[];
  60834. images?: IImage[];
  60835. materials?: IMaterial[];
  60836. meshes?: IMesh[];
  60837. nodes?: INode[];
  60838. samplers?: ISampler[];
  60839. scenes?: IScene[];
  60840. skins?: ISkin[];
  60841. textures?: ITexture[];
  60842. }
  60843. }
  60844. declare module BABYLON.GLTF2 {
  60845. /**
  60846. * Interface for a glTF loader extension.
  60847. */
  60848. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60849. /**
  60850. * Called after the loader state changes to LOADING.
  60851. */
  60852. onLoading?(): void;
  60853. /**
  60854. * Called after the loader state changes to READY.
  60855. */
  60856. onReady?(): void;
  60857. /**
  60858. * Define this method to modify the default behavior when loading scenes.
  60859. * @param context The context when loading the asset
  60860. * @param scene The glTF scene property
  60861. * @returns A promise that resolves when the load is complete or null if not handled
  60862. */
  60863. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60864. /**
  60865. * Define this method to modify the default behavior when loading nodes.
  60866. * @param context The context when loading the asset
  60867. * @param node The glTF node property
  60868. * @param assign A function called synchronously after parsing the glTF properties
  60869. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60870. */
  60871. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60872. /**
  60873. * Define this method to modify the default behavior when loading cameras.
  60874. * @param context The context when loading the asset
  60875. * @param camera The glTF camera property
  60876. * @param assign A function called synchronously after parsing the glTF properties
  60877. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60878. */
  60879. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60880. /**
  60881. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60882. * @param context The context when loading the asset
  60883. * @param primitive The glTF mesh primitive property
  60884. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60885. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60886. /**
  60887. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60888. * @param context The context when loading the asset
  60889. * @param name The mesh name when loading the asset
  60890. * @param node The glTF node when loading the asset
  60891. * @param mesh The glTF mesh when loading the asset
  60892. * @param primitive The glTF mesh primitive property
  60893. * @param assign A function called synchronously after parsing the glTF properties
  60894. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60895. */ loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60896. /**
  60897. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60898. * @param context The context when loading the asset
  60899. * @param material The glTF material property
  60900. * @param assign A function called synchronously after parsing the glTF properties
  60901. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60902. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60903. /**
  60904. * Define this method to modify the default behavior when creating materials.
  60905. * @param context The context when loading the asset
  60906. * @param material The glTF material property
  60907. * @param babylonDrawMode The draw mode for the Babylon material
  60908. * @returns The Babylon material or null if not handled
  60909. */
  60910. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60911. /**
  60912. * Define this method to modify the default behavior when loading material properties.
  60913. * @param context The context when loading the asset
  60914. * @param material The glTF material property
  60915. * @param babylonMaterial The Babylon material
  60916. * @returns A promise that resolves when the load is complete or null if not handled
  60917. */
  60918. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60919. /**
  60920. * Define this method to modify the default behavior when loading texture infos.
  60921. * @param context The context when loading the asset
  60922. * @param textureInfo The glTF texture info property
  60923. * @param assign A function called synchronously after parsing the glTF properties
  60924. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60925. */
  60926. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60927. /**
  60928. * Define this method to modify the default behavior when loading animations.
  60929. * @param context The context when loading the asset
  60930. * @param animation The glTF animation property
  60931. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60932. */
  60933. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60934. /**
  60935. * @hidden Define this method to modify the default behavior when loading skins.
  60936. * @param context The context when loading the asset
  60937. * @param node The glTF node property
  60938. * @param skin The glTF skin property
  60939. * @returns A promise that resolves when the load is complete or null if not handled
  60940. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60941. /**
  60942. * @hidden Define this method to modify the default behavior when loading uris.
  60943. * @param context The context when loading the asset
  60944. * @param property The glTF property associated with the uri
  60945. * @param uri The uri to load
  60946. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60947. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60948. }
  60949. }
  60950. declare module BABYLON.GLTF2 {
  60951. /**
  60952. * Helper class for working with arrays when loading the glTF asset
  60953. */
  60954. export class ArrayItem {
  60955. /**
  60956. * Gets an item from the given array.
  60957. * @param context The context when loading the asset
  60958. * @param array The array to get the item from
  60959. * @param index The index to the array
  60960. * @returns The array item
  60961. */
  60962. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60963. /**
  60964. * Assign an `index` field to each item of the given array.
  60965. * @param array The array of items
  60966. */
  60967. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60968. }
  60969. /**
  60970. * The glTF 2.0 loader
  60971. */
  60972. export class GLTFLoader implements IGLTFLoader {
  60973. /** @hidden */ completePromises: Promise<any>[];
  60974. private _disposed;
  60975. private _parent;
  60976. private _state;
  60977. private _extensions;
  60978. private _rootUrl;
  60979. private _fileName;
  60980. private _uniqueRootUrl;
  60981. private _gltf;
  60982. private _babylonScene;
  60983. private _rootBabylonMesh;
  60984. private _defaultBabylonMaterialData;
  60985. private _progressCallback?;
  60986. private _requests;
  60987. private static readonly _DefaultSampler;
  60988. private static _ExtensionNames;
  60989. private static _ExtensionFactories;
  60990. /**
  60991. * Registers a loader extension.
  60992. * @param name The name of the loader extension.
  60993. * @param factory The factory function that creates the loader extension.
  60994. */
  60995. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60996. /**
  60997. * Unregisters a loader extension.
  60998. * @param name The name of the loader extenion.
  60999. * @returns A boolean indicating whether the extension has been unregistered
  61000. */
  61001. static UnregisterExtension(name: string): boolean;
  61002. /**
  61003. * Gets the loader state.
  61004. */
  61005. readonly state: Nullable<GLTFLoaderState>;
  61006. /**
  61007. * The glTF object parsed from the JSON.
  61008. */
  61009. readonly gltf: IGLTF;
  61010. /**
  61011. * The Babylon scene when loading the asset.
  61012. */
  61013. readonly babylonScene: Scene;
  61014. /**
  61015. * The root Babylon mesh when loading the asset.
  61016. */
  61017. readonly rootBabylonMesh: Mesh;
  61018. /** @hidden */
  61019. constructor(parent: GLTFFileLoader);
  61020. /** @hidden */
  61021. dispose(): void;
  61022. /** @hidden */
  61023. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61024. meshes: AbstractMesh[];
  61025. particleSystems: IParticleSystem[];
  61026. skeletons: Skeleton[];
  61027. animationGroups: AnimationGroup[];
  61028. }>;
  61029. /** @hidden */
  61030. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61031. private _loadAsync;
  61032. private _loadData;
  61033. private _setupData;
  61034. private _loadExtensions;
  61035. private _checkExtensions;
  61036. private _setState;
  61037. private _createRootNode;
  61038. /**
  61039. * Loads a glTF scene.
  61040. * @param context The context when loading the asset
  61041. * @param scene The glTF scene property
  61042. * @returns A promise that resolves when the load is complete
  61043. */
  61044. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  61045. private _forEachPrimitive;
  61046. private _getMeshes;
  61047. private _getSkeletons;
  61048. private _getAnimationGroups;
  61049. private _startAnimations;
  61050. /**
  61051. * Loads a glTF node.
  61052. * @param context The context when loading the asset
  61053. * @param node The glTF node property
  61054. * @param assign A function called synchronously after parsing the glTF properties
  61055. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  61056. */
  61057. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  61058. private _loadMeshAsync;
  61059. /**
  61060. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  61061. * @param context The context when loading the asset
  61062. * @param name The mesh name when loading the asset
  61063. * @param node The glTF node when loading the asset
  61064. * @param mesh The glTF mesh when loading the asset
  61065. * @param primitive The glTF mesh primitive property
  61066. * @param assign A function called synchronously after parsing the glTF properties
  61067. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  61068. */ loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  61069. private _loadVertexDataAsync;
  61070. private _createMorphTargets;
  61071. private _loadMorphTargetsAsync;
  61072. private _loadMorphTargetVertexDataAsync;
  61073. private static _LoadTransform;
  61074. private _loadSkinAsync;
  61075. private _loadBones;
  61076. private _loadBone;
  61077. private _loadSkinInverseBindMatricesDataAsync;
  61078. private _updateBoneMatrices;
  61079. private _getNodeMatrix;
  61080. /**
  61081. * Loads a glTF camera.
  61082. * @param context The context when loading the asset
  61083. * @param camera The glTF camera property
  61084. * @param assign A function called synchronously after parsing the glTF properties
  61085. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  61086. */
  61087. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  61088. private _loadAnimationsAsync;
  61089. /**
  61090. * Loads a glTF animation.
  61091. * @param context The context when loading the asset
  61092. * @param animation The glTF animation property
  61093. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  61094. */
  61095. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  61096. /**
  61097. * @hidden Loads a glTF animation channel.
  61098. * @param context The context when loading the asset
  61099. * @param animationContext The context of the animation when loading the asset
  61100. * @param animation The glTF animation property
  61101. * @param channel The glTF animation channel property
  61102. * @param babylonAnimationGroup The babylon animation group property
  61103. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  61104. * @returns A void promise when the channel load is complete
  61105. */ loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  61106. private _loadAnimationSamplerAsync;
  61107. private _loadBufferAsync;
  61108. /**
  61109. * Loads a glTF buffer view.
  61110. * @param context The context when loading the asset
  61111. * @param bufferView The glTF buffer view property
  61112. * @returns A promise that resolves with the loaded data when the load is complete
  61113. */
  61114. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  61115. private _loadIndicesAccessorAsync;
  61116. private _loadFloatAccessorAsync;
  61117. private _loadVertexBufferViewAsync;
  61118. private _loadVertexAccessorAsync;
  61119. private _loadMaterialMetallicRoughnessPropertiesAsync;
  61120. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  61121. private _createDefaultMaterial;
  61122. /**
  61123. * Creates a Babylon material from a glTF material.
  61124. * @param context The context when loading the asset
  61125. * @param material The glTF material property
  61126. * @param babylonDrawMode The draw mode for the Babylon material
  61127. * @returns The Babylon material
  61128. */
  61129. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  61130. /**
  61131. * Loads properties from a glTF material into a Babylon material.
  61132. * @param context The context when loading the asset
  61133. * @param material The glTF material property
  61134. * @param babylonMaterial The Babylon material
  61135. * @returns A promise that resolves when the load is complete
  61136. */
  61137. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61138. /**
  61139. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  61140. * @param context The context when loading the asset
  61141. * @param material The glTF material property
  61142. * @param babylonMaterial The Babylon material
  61143. * @returns A promise that resolves when the load is complete
  61144. */
  61145. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61146. /**
  61147. * Loads the alpha properties from a glTF material into a Babylon material.
  61148. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  61149. * @param context The context when loading the asset
  61150. * @param material The glTF material property
  61151. * @param babylonMaterial The Babylon material
  61152. */
  61153. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  61154. /**
  61155. * Loads a glTF texture info.
  61156. * @param context The context when loading the asset
  61157. * @param textureInfo The glTF texture info property
  61158. * @param assign A function called synchronously after parsing the glTF properties
  61159. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  61160. */
  61161. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  61162. private _loadTextureAsync;
  61163. private _loadSampler;
  61164. /**
  61165. * Loads a glTF image.
  61166. * @param context The context when loading the asset
  61167. * @param image The glTF image property
  61168. * @returns A promise that resolves with the loaded data when the load is complete
  61169. */
  61170. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  61171. /**
  61172. * Loads a glTF uri.
  61173. * @param context The context when loading the asset
  61174. * @param property The glTF property associated with the uri
  61175. * @param uri The base64 or relative uri
  61176. * @returns A promise that resolves with the loaded data when the load is complete
  61177. */
  61178. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  61179. private _onProgress;
  61180. /**
  61181. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  61182. * @param babylonObject the Babylon object with metadata
  61183. * @param pointer the JSON pointer
  61184. */
  61185. static AddPointerMetadata(babylonObject: {
  61186. metadata: any;
  61187. }, pointer: string): void;
  61188. private static _GetTextureWrapMode;
  61189. private static _GetTextureSamplingMode;
  61190. private static _GetTypedArray;
  61191. private static _GetNumComponents;
  61192. private static _ValidateUri;
  61193. private static _GetDrawMode;
  61194. private _compileMaterialsAsync;
  61195. private _compileShadowGeneratorsAsync;
  61196. private _forEachExtensions;
  61197. private _applyExtensions;
  61198. private _extensionsOnLoading;
  61199. private _extensionsOnReady;
  61200. private _extensionsLoadSceneAsync;
  61201. private _extensionsLoadNodeAsync;
  61202. private _extensionsLoadCameraAsync;
  61203. private _extensionsLoadVertexDataAsync;
  61204. private _extensionsLoadMeshPrimitiveAsync;
  61205. private _extensionsLoadMaterialAsync;
  61206. private _extensionsCreateMaterial;
  61207. private _extensionsLoadMaterialPropertiesAsync;
  61208. private _extensionsLoadTextureInfoAsync;
  61209. private _extensionsLoadAnimationAsync;
  61210. private _extensionsLoadSkinAsync;
  61211. private _extensionsLoadUriAsync;
  61212. /**
  61213. * Helper method called by a loader extension to load an glTF extension.
  61214. * @param context The context when loading the asset
  61215. * @param property The glTF property to load the extension from
  61216. * @param extensionName The name of the extension to load
  61217. * @param actionAsync The action to run
  61218. * @returns The promise returned by actionAsync or null if the extension does not exist
  61219. */
  61220. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61221. /**
  61222. * Helper method called by a loader extension to load a glTF extra.
  61223. * @param context The context when loading the asset
  61224. * @param property The glTF property to load the extra from
  61225. * @param extensionName The name of the extension to load
  61226. * @param actionAsync The action to run
  61227. * @returns The promise returned by actionAsync or null if the extra does not exist
  61228. */
  61229. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61230. /**
  61231. * Increments the indentation level and logs a message.
  61232. * @param message The message to log
  61233. */
  61234. logOpen(message: string): void;
  61235. /**
  61236. * Decrements the indentation level.
  61237. */
  61238. logClose(): void;
  61239. /**
  61240. * Logs a message
  61241. * @param message The message to log
  61242. */
  61243. log(message: string): void;
  61244. /**
  61245. * Starts a performance counter.
  61246. * @param counterName The name of the performance counter
  61247. */
  61248. startPerformanceCounter(counterName: string): void;
  61249. /**
  61250. * Ends a performance counter.
  61251. * @param counterName The name of the performance counter
  61252. */
  61253. endPerformanceCounter(counterName: string): void;
  61254. }
  61255. }
  61256. declare module BABYLON.GLTF2.Loader.Extensions {
  61257. /**
  61258. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  61259. */
  61260. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  61261. /** The name of this extension. */
  61262. readonly name: string;
  61263. /** Defines whether this extension is enabled. */
  61264. enabled: boolean;
  61265. private _loader;
  61266. private _lights?;
  61267. /** @hidden */
  61268. constructor(loader: GLTFLoader);
  61269. /** @hidden */
  61270. dispose(): void;
  61271. /** @hidden */
  61272. onLoading(): void;
  61273. /** @hidden */
  61274. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61275. private _loadLightAsync;
  61276. }
  61277. }
  61278. declare module BABYLON.GLTF2.Loader.Extensions {
  61279. /**
  61280. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  61281. */
  61282. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  61283. /** The name of this extension. */
  61284. readonly name: string;
  61285. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  61286. dracoCompression?: DracoCompression;
  61287. /** Defines whether this extension is enabled. */
  61288. enabled: boolean;
  61289. private _loader;
  61290. /** @hidden */
  61291. constructor(loader: GLTFLoader);
  61292. /** @hidden */
  61293. dispose(): void;
  61294. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  61295. }
  61296. }
  61297. declare module BABYLON.GLTF2.Loader.Extensions {
  61298. /**
  61299. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  61300. */
  61301. export class KHR_lights implements IGLTFLoaderExtension {
  61302. /** The name of this extension. */
  61303. readonly name: string;
  61304. /** Defines whether this extension is enabled. */
  61305. enabled: boolean;
  61306. private _loader;
  61307. private _lights?;
  61308. /** @hidden */
  61309. constructor(loader: GLTFLoader);
  61310. /** @hidden */
  61311. dispose(): void;
  61312. /** @hidden */
  61313. onLoading(): void;
  61314. /** @hidden */
  61315. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61316. }
  61317. }
  61318. declare module BABYLON.GLTF2.Loader.Extensions {
  61319. /**
  61320. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  61321. */
  61322. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  61323. /** The name of this extension. */
  61324. readonly name: string;
  61325. /** Defines whether this extension is enabled. */
  61326. enabled: boolean;
  61327. private _loader;
  61328. /** @hidden */
  61329. constructor(loader: GLTFLoader);
  61330. /** @hidden */
  61331. dispose(): void;
  61332. /** @hidden */
  61333. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61334. private _loadSpecularGlossinessPropertiesAsync;
  61335. }
  61336. }
  61337. declare module BABYLON.GLTF2.Loader.Extensions {
  61338. /**
  61339. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  61340. */
  61341. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  61342. /** The name of this extension. */
  61343. readonly name: string;
  61344. /** Defines whether this extension is enabled. */
  61345. enabled: boolean;
  61346. private _loader;
  61347. /** @hidden */
  61348. constructor(loader: GLTFLoader);
  61349. /** @hidden */
  61350. dispose(): void;
  61351. /** @hidden */
  61352. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61353. private _loadUnlitPropertiesAsync;
  61354. }
  61355. }
  61356. declare module BABYLON.GLTF2.Loader.Extensions {
  61357. /**
  61358. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  61359. */
  61360. export class KHR_texture_transform implements IGLTFLoaderExtension {
  61361. /** The name of this extension. */
  61362. readonly name: string;
  61363. /** Defines whether this extension is enabled. */
  61364. enabled: boolean;
  61365. private _loader;
  61366. /** @hidden */
  61367. constructor(loader: GLTFLoader);
  61368. /** @hidden */
  61369. dispose(): void;
  61370. /** @hidden */
  61371. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  61372. }
  61373. }
  61374. declare module BABYLON.GLTF2.Loader.Extensions {
  61375. /**
  61376. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  61377. */
  61378. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  61379. /** The name of this extension. */
  61380. readonly name: string;
  61381. /** Defines whether this extension is enabled. */
  61382. enabled: boolean;
  61383. private _loader;
  61384. private _clips;
  61385. private _emitters;
  61386. /** @hidden */
  61387. constructor(loader: GLTFLoader);
  61388. /** @hidden */
  61389. dispose(): void;
  61390. /** @hidden */
  61391. onLoading(): void;
  61392. /** @hidden */
  61393. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61394. /** @hidden */
  61395. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61396. /** @hidden */
  61397. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  61398. private _loadClipAsync;
  61399. private _loadEmitterAsync;
  61400. private _getEventAction;
  61401. private _loadAnimationEventAsync;
  61402. }
  61403. }
  61404. declare module BABYLON.GLTF2.Loader.Extensions {
  61405. /**
  61406. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  61407. */
  61408. export class MSFT_lod implements IGLTFLoaderExtension {
  61409. /** The name of this extension. */
  61410. readonly name: string;
  61411. /** Defines whether this extension is enabled. */
  61412. enabled: boolean;
  61413. /**
  61414. * Maximum number of LODs to load, starting from the lowest LOD.
  61415. */
  61416. maxLODsToLoad: number;
  61417. /**
  61418. * Observable raised when all node LODs of one level are loaded.
  61419. * The event data is the index of the loaded LOD starting from zero.
  61420. * Dispose the loader to cancel the loading of the next level of LODs.
  61421. */
  61422. onNodeLODsLoadedObservable: Observable<number>;
  61423. /**
  61424. * Observable raised when all material LODs of one level are loaded.
  61425. * The event data is the index of the loaded LOD starting from zero.
  61426. * Dispose the loader to cancel the loading of the next level of LODs.
  61427. */
  61428. onMaterialLODsLoadedObservable: Observable<number>;
  61429. private _loader;
  61430. private _nodeIndexLOD;
  61431. private _nodeSignalLODs;
  61432. private _nodePromiseLODs;
  61433. private _materialIndexLOD;
  61434. private _materialSignalLODs;
  61435. private _materialPromiseLODs;
  61436. /** @hidden */
  61437. constructor(loader: GLTFLoader);
  61438. /** @hidden */
  61439. dispose(): void;
  61440. /** @hidden */
  61441. onReady(): void;
  61442. /** @hidden */
  61443. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61444. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61445. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61446. /**
  61447. * Gets an array of LOD properties from lowest to highest.
  61448. */
  61449. private _getLODs;
  61450. private _disposeUnusedMaterials;
  61451. }
  61452. }
  61453. declare module BABYLON.GLTF2.Loader.Extensions {
  61454. /** @hidden */
  61455. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61456. readonly name: string;
  61457. enabled: boolean;
  61458. private _loader;
  61459. constructor(loader: GLTFLoader);
  61460. dispose(): void;
  61461. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61462. }
  61463. }
  61464. declare module BABYLON.GLTF2.Loader.Extensions {
  61465. /** @hidden */
  61466. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61467. readonly name: string;
  61468. enabled: boolean;
  61469. private _loader;
  61470. constructor(loader: GLTFLoader);
  61471. dispose(): void;
  61472. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61473. }
  61474. }
  61475. declare module BABYLON {
  61476. /**
  61477. * Class reading and parsing the MTL file bundled with the obj file.
  61478. */
  61479. export class MTLFileLoader {
  61480. /**
  61481. * All material loaded from the mtl will be set here
  61482. */
  61483. materials: StandardMaterial[];
  61484. /**
  61485. * This function will read the mtl file and create each material described inside
  61486. * This function could be improve by adding :
  61487. * -some component missing (Ni, Tf...)
  61488. * -including the specific options available
  61489. *
  61490. * @param scene defines the scene the material will be created in
  61491. * @param data defines the mtl data to parse
  61492. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61493. */
  61494. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61495. /**
  61496. * Gets the texture for the material.
  61497. *
  61498. * If the material is imported from input file,
  61499. * We sanitize the url to ensure it takes the textre from aside the material.
  61500. *
  61501. * @param rootUrl The root url to load from
  61502. * @param value The value stored in the mtl
  61503. * @return The Texture
  61504. */
  61505. private static _getTexture;
  61506. }
  61507. /**
  61508. * Options for loading OBJ/MTL files
  61509. */
  61510. type MeshLoadOptions = {
  61511. /**
  61512. * Defines if UVs are optimized by default during load.
  61513. */
  61514. OptimizeWithUV: boolean;
  61515. /**
  61516. * Defines custom scaling of UV coordinates of loaded meshes.
  61517. */
  61518. UVScaling: Vector2;
  61519. /**
  61520. * Invert model on y-axis (does a model scaling inversion)
  61521. */
  61522. InvertY: boolean;
  61523. /**
  61524. * Invert Y-Axis of referenced textures on load
  61525. */
  61526. InvertTextureY: boolean;
  61527. /**
  61528. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61529. */
  61530. ImportVertexColors: boolean;
  61531. /**
  61532. * Compute the normals for the model, even if normals are present in the file.
  61533. */
  61534. ComputeNormals: boolean;
  61535. /**
  61536. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61537. */
  61538. SkipMaterials: boolean;
  61539. /**
  61540. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61541. */
  61542. MaterialLoadingFailsSilently: boolean;
  61543. };
  61544. /**
  61545. * OBJ file type loader.
  61546. * This is a babylon scene loader plugin.
  61547. */
  61548. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61549. /**
  61550. * Defines if UVs are optimized by default during load.
  61551. */
  61552. static OPTIMIZE_WITH_UV: boolean;
  61553. /**
  61554. * Invert model on y-axis (does a model scaling inversion)
  61555. */
  61556. static INVERT_Y: boolean;
  61557. /**
  61558. * Invert Y-Axis of referenced textures on load
  61559. */
  61560. static INVERT_TEXTURE_Y: boolean;
  61561. /**
  61562. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61563. */
  61564. static IMPORT_VERTEX_COLORS: boolean;
  61565. /**
  61566. * Compute the normals for the model, even if normals are present in the file.
  61567. */
  61568. static COMPUTE_NORMALS: boolean;
  61569. /**
  61570. * Defines custom scaling of UV coordinates of loaded meshes.
  61571. */
  61572. static UV_SCALING: Vector2;
  61573. /**
  61574. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61575. */
  61576. static SKIP_MATERIALS: boolean;
  61577. /**
  61578. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61579. *
  61580. * Defaults to true for backwards compatibility.
  61581. */
  61582. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61583. /**
  61584. * Defines the name of the plugin.
  61585. */
  61586. name: string;
  61587. /**
  61588. * Defines the extension the plugin is able to load.
  61589. */
  61590. extensions: string;
  61591. /** @hidden */
  61592. obj: RegExp;
  61593. /** @hidden */
  61594. group: RegExp;
  61595. /** @hidden */
  61596. mtllib: RegExp;
  61597. /** @hidden */
  61598. usemtl: RegExp;
  61599. /** @hidden */
  61600. smooth: RegExp;
  61601. /** @hidden */
  61602. vertexPattern: RegExp;
  61603. /** @hidden */
  61604. normalPattern: RegExp;
  61605. /** @hidden */
  61606. uvPattern: RegExp;
  61607. /** @hidden */
  61608. facePattern1: RegExp;
  61609. /** @hidden */
  61610. facePattern2: RegExp;
  61611. /** @hidden */
  61612. facePattern3: RegExp;
  61613. /** @hidden */
  61614. facePattern4: RegExp;
  61615. /** @hidden */
  61616. facePattern5: RegExp;
  61617. private _meshLoadOptions;
  61618. /**
  61619. * Creates loader for .OBJ files
  61620. *
  61621. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61622. */
  61623. constructor(meshLoadOptions?: MeshLoadOptions);
  61624. private static readonly currentMeshLoadOptions;
  61625. /**
  61626. * Calls synchronously the MTL file attached to this obj.
  61627. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61628. * Without this function materials are not displayed in the first frame (but displayed after).
  61629. * In consequence it is impossible to get material information in your HTML file
  61630. *
  61631. * @param url The URL of the MTL file
  61632. * @param rootUrl
  61633. * @param onSuccess Callback function to be called when the MTL file is loaded
  61634. * @private
  61635. */
  61636. private _loadMTL;
  61637. /**
  61638. * Instantiates a OBJ file loader plugin.
  61639. * @returns the created plugin
  61640. */
  61641. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61642. /**
  61643. * If the data string can be loaded directly.
  61644. *
  61645. * @param data string containing the file data
  61646. * @returns if the data can be loaded directly
  61647. */
  61648. canDirectLoad(data: string): boolean;
  61649. /**
  61650. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61651. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61652. * @param scene the scene the meshes should be added to
  61653. * @param data the OBJ data to load
  61654. * @param rootUrl root url to load from
  61655. * @param onProgress event that fires when loading progress has occured
  61656. * @param fileName Defines the name of the file to load
  61657. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61658. */
  61659. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61660. meshes: AbstractMesh[];
  61661. particleSystems: IParticleSystem[];
  61662. skeletons: Skeleton[];
  61663. animationGroups: AnimationGroup[];
  61664. }>;
  61665. /**
  61666. * Imports all objects from the loaded OBJ data and adds them to the scene
  61667. * @param scene the scene the objects should be added to
  61668. * @param data the OBJ data to load
  61669. * @param rootUrl root url to load from
  61670. * @param onProgress event that fires when loading progress has occured
  61671. * @param fileName Defines the name of the file to load
  61672. * @returns a promise which completes when objects have been loaded to the scene
  61673. */
  61674. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61675. /**
  61676. * Load into an asset container.
  61677. * @param scene The scene to load into
  61678. * @param data The data to import
  61679. * @param rootUrl The root url for scene and resources
  61680. * @param onProgress The callback when the load progresses
  61681. * @param fileName Defines the name of the file to load
  61682. * @returns The loaded asset container
  61683. */
  61684. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61685. /**
  61686. * Read the OBJ file and create an Array of meshes.
  61687. * Each mesh contains all information given by the OBJ and the MTL file.
  61688. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61689. *
  61690. * @param meshesNames
  61691. * @param scene Scene The scene where are displayed the data
  61692. * @param data String The content of the obj file
  61693. * @param rootUrl String The path to the folder
  61694. * @returns Array<AbstractMesh>
  61695. * @private
  61696. */
  61697. private _parseSolid;
  61698. }
  61699. }
  61700. declare module BABYLON {
  61701. /**
  61702. * STL file type loader.
  61703. * This is a babylon scene loader plugin.
  61704. */
  61705. export class STLFileLoader implements ISceneLoaderPlugin {
  61706. /** @hidden */
  61707. solidPattern: RegExp;
  61708. /** @hidden */
  61709. facetsPattern: RegExp;
  61710. /** @hidden */
  61711. normalPattern: RegExp;
  61712. /** @hidden */
  61713. vertexPattern: RegExp;
  61714. /**
  61715. * Defines the name of the plugin.
  61716. */
  61717. name: string;
  61718. /**
  61719. * Defines the extensions the stl loader is able to load.
  61720. * force data to come in as an ArrayBuffer
  61721. * we'll convert to string if it looks like it's an ASCII .stl
  61722. */
  61723. extensions: ISceneLoaderPluginExtensions;
  61724. /**
  61725. * Import meshes into a scene.
  61726. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61727. * @param scene The scene to import into
  61728. * @param data The data to import
  61729. * @param rootUrl The root url for scene and resources
  61730. * @param meshes The meshes array to import into
  61731. * @param particleSystems The particle systems array to import into
  61732. * @param skeletons The skeletons array to import into
  61733. * @param onError The callback when import fails
  61734. * @returns True if successful or false otherwise
  61735. */
  61736. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61737. /**
  61738. * Load into a scene.
  61739. * @param scene The scene to load into
  61740. * @param data The data to import
  61741. * @param rootUrl The root url for scene and resources
  61742. * @param onError The callback when import fails
  61743. * @returns true if successful or false otherwise
  61744. */
  61745. load(scene: Scene, data: any, rootUrl: string): boolean;
  61746. /**
  61747. * Load into an asset container.
  61748. * @param scene The scene to load into
  61749. * @param data The data to import
  61750. * @param rootUrl The root url for scene and resources
  61751. * @param onError The callback when import fails
  61752. * @returns The loaded asset container
  61753. */
  61754. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61755. private _isBinary;
  61756. private _parseBinary;
  61757. private _parseASCII;
  61758. }
  61759. }
  61760. declare module BABYLON {
  61761. /**
  61762. * Class for generating OBJ data from a Babylon scene.
  61763. */
  61764. export class OBJExport {
  61765. /**
  61766. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61767. * @param mesh defines the list of meshes to serialize
  61768. * @param materials defines if materials should be exported
  61769. * @param matlibname defines the name of the associated mtl file
  61770. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61771. * @returns the OBJ content
  61772. */
  61773. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61774. /**
  61775. * Exports the material(s) of a mesh in .MTL file format (text)
  61776. * @param mesh defines the mesh to extract the material from
  61777. * @returns the mtl content
  61778. */
  61779. static MTL(mesh: Mesh): string;
  61780. }
  61781. }
  61782. declare module BABYLON {
  61783. /** @hidden */
  61784. export var __IGLTFExporterExtension: number;
  61785. /**
  61786. * Interface for extending the exporter
  61787. * @hidden
  61788. */
  61789. export interface IGLTFExporterExtension {
  61790. /**
  61791. * The name of this extension
  61792. */
  61793. readonly name: string;
  61794. /**
  61795. * Defines whether this extension is enabled
  61796. */
  61797. enabled: boolean;
  61798. /**
  61799. * Defines whether this extension is required
  61800. */
  61801. required: boolean;
  61802. }
  61803. }
  61804. declare module BABYLON.GLTF2.Exporter {
  61805. /** @hidden */
  61806. export var __IGLTFExporterExtensionV2: number;
  61807. /**
  61808. * Interface for a glTF exporter extension
  61809. * @hidden
  61810. */
  61811. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61812. /**
  61813. * Define this method to modify the default behavior before exporting a texture
  61814. * @param context The context when loading the asset
  61815. * @param babylonTexture The glTF texture info property
  61816. * @param mimeType The mime-type of the generated image
  61817. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61818. */
  61819. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61820. /**
  61821. * Define this method to modify the default behavior when exporting texture info
  61822. * @param context The context when loading the asset
  61823. * @param meshPrimitive glTF mesh primitive
  61824. * @param babylonSubMesh Babylon submesh
  61825. * @param binaryWriter glTF serializer binary writer instance
  61826. * @returns nullable IMeshPrimitive promise
  61827. */
  61828. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61829. /**
  61830. * Define this method to modify the default behavior when exporting a node
  61831. * @param context The context when exporting the node
  61832. * @param node glTF node
  61833. * @param babylonNode BabylonJS node
  61834. * @returns nullable INode promise
  61835. */
  61836. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61837. /**
  61838. * Called after the exporter state changes to EXPORTING
  61839. */
  61840. onExporting?(): void;
  61841. }
  61842. }
  61843. declare module BABYLON.GLTF2.Exporter {
  61844. /**
  61845. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61846. * @hidden
  61847. */
  61848. export class _GLTFMaterialExporter {
  61849. /**
  61850. * Represents the dielectric specular values for R, G and B
  61851. */
  61852. private static readonly _DielectricSpecular;
  61853. /**
  61854. * Allows the maximum specular power to be defined for material calculations
  61855. */
  61856. private static readonly _MaxSpecularPower;
  61857. /**
  61858. * Mapping to store textures
  61859. */
  61860. private _textureMap;
  61861. /**
  61862. * Numeric tolerance value
  61863. */
  61864. private static readonly _Epsilon;
  61865. /**
  61866. * Reference to the glTF Exporter
  61867. */
  61868. private _exporter;
  61869. constructor(exporter: _Exporter);
  61870. /**
  61871. * Specifies if two colors are approximately equal in value
  61872. * @param color1 first color to compare to
  61873. * @param color2 second color to compare to
  61874. * @param epsilon threshold value
  61875. */
  61876. private static FuzzyEquals;
  61877. /**
  61878. * Gets the materials from a Babylon scene and converts them to glTF materials
  61879. * @param scene babylonjs scene
  61880. * @param mimeType texture mime type
  61881. * @param images array of images
  61882. * @param textures array of textures
  61883. * @param materials array of materials
  61884. * @param imageData mapping of texture names to base64 textures
  61885. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61886. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61887. /**
  61888. * Makes a copy of the glTF material without the texture parameters
  61889. * @param originalMaterial original glTF material
  61890. * @returns glTF material without texture parameters
  61891. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61892. /**
  61893. * Specifies if the material has any texture parameters present
  61894. * @param material glTF Material
  61895. * @returns boolean specifying if texture parameters are present
  61896. */ hasTexturesPresent(material: IMaterial): boolean;
  61897. /**
  61898. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61899. * @param babylonStandardMaterial
  61900. * @returns glTF Metallic Roughness Material representation
  61901. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61902. /**
  61903. * Computes the metallic factor
  61904. * @param diffuse diffused value
  61905. * @param specular specular value
  61906. * @param oneMinusSpecularStrength one minus the specular strength
  61907. * @returns metallic value
  61908. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61909. /**
  61910. * Gets the glTF alpha mode from the Babylon Material
  61911. * @param babylonMaterial Babylon Material
  61912. * @returns The Babylon alpha mode value
  61913. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61914. /**
  61915. * Converts a Babylon Standard Material to a glTF Material
  61916. * @param babylonStandardMaterial BJS Standard Material
  61917. * @param mimeType mime type to use for the textures
  61918. * @param images array of glTF image interfaces
  61919. * @param textures array of glTF texture interfaces
  61920. * @param materials array of glTF material interfaces
  61921. * @param imageData map of image file name to data
  61922. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61923. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61924. /**
  61925. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61926. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61927. * @param mimeType mime type to use for the textures
  61928. * @param images array of glTF image interfaces
  61929. * @param textures array of glTF texture interfaces
  61930. * @param materials array of glTF material interfaces
  61931. * @param imageData map of image file name to data
  61932. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61933. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61934. /**
  61935. * Converts an image typed array buffer to a base64 image
  61936. * @param buffer typed array buffer
  61937. * @param width width of the image
  61938. * @param height height of the image
  61939. * @param mimeType mimetype of the image
  61940. * @returns base64 image string
  61941. */
  61942. private _createBase64FromCanvasAsync;
  61943. /**
  61944. * Generates a white texture based on the specified width and height
  61945. * @param width width of the texture in pixels
  61946. * @param height height of the texture in pixels
  61947. * @param scene babylonjs scene
  61948. * @returns white texture
  61949. */
  61950. private _createWhiteTexture;
  61951. /**
  61952. * 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
  61953. * @param texture1 first texture to resize
  61954. * @param texture2 second texture to resize
  61955. * @param scene babylonjs scene
  61956. * @returns resized textures or null
  61957. */
  61958. private _resizeTexturesToSameDimensions;
  61959. /**
  61960. * Converts an array of pixels to a Float32Array
  61961. * Throws an error if the pixel format is not supported
  61962. * @param pixels - array buffer containing pixel values
  61963. * @returns Float32 of pixels
  61964. */
  61965. private _convertPixelArrayToFloat32;
  61966. /**
  61967. * Convert Specular Glossiness Textures to Metallic Roughness
  61968. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61969. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61970. * @param diffuseTexture texture used to store diffuse information
  61971. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61972. * @param factors specular glossiness material factors
  61973. * @param mimeType the mime type to use for the texture
  61974. * @returns pbr metallic roughness interface or null
  61975. */
  61976. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61977. /**
  61978. * Converts specular glossiness material properties to metallic roughness
  61979. * @param specularGlossiness interface with specular glossiness material properties
  61980. * @returns interface with metallic roughness material properties
  61981. */
  61982. private _convertSpecularGlossinessToMetallicRoughness;
  61983. /**
  61984. * Calculates the surface reflectance, independent of lighting conditions
  61985. * @param color Color source to calculate brightness from
  61986. * @returns number representing the perceived brightness, or zero if color is undefined
  61987. */
  61988. private _getPerceivedBrightness;
  61989. /**
  61990. * Returns the maximum color component value
  61991. * @param color
  61992. * @returns maximum color component value, or zero if color is null or undefined
  61993. */
  61994. private _getMaxComponent;
  61995. /**
  61996. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61997. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61998. * @param mimeType mime type to use for the textures
  61999. * @param images array of glTF image interfaces
  62000. * @param textures array of glTF texture interfaces
  62001. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  62002. * @param imageData map of image file name to data
  62003. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62004. * @returns glTF PBR Metallic Roughness factors
  62005. */
  62006. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  62007. private _getGLTFTextureSampler;
  62008. private _getGLTFTextureWrapMode;
  62009. private _getGLTFTextureWrapModesSampler;
  62010. /**
  62011. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  62012. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  62013. * @param mimeType mime type to use for the textures
  62014. * @param images array of glTF image interfaces
  62015. * @param textures array of glTF texture interfaces
  62016. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  62017. * @param imageData map of image file name to data
  62018. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62019. * @returns glTF PBR Metallic Roughness factors
  62020. */
  62021. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  62022. /**
  62023. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  62024. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  62025. * @param mimeType mime type to use for the textures
  62026. * @param images array of glTF image interfaces
  62027. * @param textures array of glTF texture interfaces
  62028. * @param materials array of glTF material interfaces
  62029. * @param imageData map of image file name to data
  62030. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62031. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  62032. private setMetallicRoughnessPbrMaterial;
  62033. private getPixelsFromTexture;
  62034. /**
  62035. * Extracts a texture from a Babylon texture into file data and glTF data
  62036. * @param babylonTexture Babylon texture to extract
  62037. * @param mimeType Mime Type of the babylonTexture
  62038. * @return glTF texture info, or null if the texture format is not supported
  62039. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  62040. /**
  62041. * Builds a texture from base64 string
  62042. * @param base64Texture base64 texture string
  62043. * @param baseTextureName Name to use for the texture
  62044. * @param mimeType image mime type for the texture
  62045. * @param images array of images
  62046. * @param textures array of textures
  62047. * @param imageData map of image data
  62048. * @returns glTF texture info, or null if the texture format is not supported
  62049. */
  62050. private _getTextureInfoFromBase64;
  62051. }
  62052. }
  62053. declare module BABYLON {
  62054. /**
  62055. * Class for holding and downloading glTF file data
  62056. */
  62057. export class GLTFData {
  62058. /**
  62059. * Object which contains the file name as the key and its data as the value
  62060. */
  62061. glTFFiles: {
  62062. [fileName: string]: string | Blob;
  62063. };
  62064. /**
  62065. * Initializes the glTF file object
  62066. */
  62067. constructor();
  62068. /**
  62069. * Downloads the glTF data as files based on their names and data
  62070. */
  62071. downloadFiles(): void;
  62072. }
  62073. }
  62074. declare module BABYLON {
  62075. /**
  62076. * Holds a collection of exporter options and parameters
  62077. */
  62078. export interface IExportOptions {
  62079. /**
  62080. * Function which indicates whether a babylon node should be exported or not
  62081. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  62082. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  62083. */
  62084. shouldExportNode?(node: Node): boolean;
  62085. /**
  62086. * The sample rate to bake animation curves
  62087. */
  62088. animationSampleRate?: number;
  62089. /**
  62090. * Begin serialization without waiting for the scene to be ready
  62091. */
  62092. exportWithoutWaitingForScene?: boolean;
  62093. }
  62094. /**
  62095. * Class for generating glTF data from a Babylon scene.
  62096. */
  62097. export class GLTF2Export {
  62098. /**
  62099. * Exports the geometry of the scene to .gltf file format asynchronously
  62100. * @param scene Babylon scene with scene hierarchy information
  62101. * @param filePrefix File prefix to use when generating the glTF file
  62102. * @param options Exporter options
  62103. * @returns Returns an object with a .gltf file and associates texture names
  62104. * as keys and their data and paths as values
  62105. */
  62106. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62107. private static _PreExportAsync;
  62108. private static _PostExportAsync;
  62109. /**
  62110. * Exports the geometry of the scene to .glb file format asychronously
  62111. * @param scene Babylon scene with scene hierarchy information
  62112. * @param filePrefix File prefix to use when generating glb file
  62113. * @param options Exporter options
  62114. * @returns Returns an object with a .glb filename as key and data as value
  62115. */
  62116. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62117. }
  62118. }
  62119. declare module BABYLON.GLTF2.Exporter {
  62120. /**
  62121. * @hidden
  62122. */
  62123. export class _GLTFUtilities {
  62124. /**
  62125. * Creates a buffer view based on the supplied arguments
  62126. * @param bufferIndex index value of the specified buffer
  62127. * @param byteOffset byte offset value
  62128. * @param byteLength byte length of the bufferView
  62129. * @param byteStride byte distance between conequential elements
  62130. * @param name name of the buffer view
  62131. * @returns bufferView for glTF
  62132. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  62133. /**
  62134. * Creates an accessor based on the supplied arguments
  62135. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  62136. * @param name The name of the accessor
  62137. * @param type The type of the accessor
  62138. * @param componentType The datatype of components in the attribute
  62139. * @param count The number of attributes referenced by this accessor
  62140. * @param byteOffset The offset relative to the start of the bufferView in bytes
  62141. * @param min Minimum value of each component in this attribute
  62142. * @param max Maximum value of each component in this attribute
  62143. * @returns accessor for glTF
  62144. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  62145. /**
  62146. * Calculates the minimum and maximum values of an array of position floats
  62147. * @param positions Positions array of a mesh
  62148. * @param vertexStart Starting vertex offset to calculate min and max values
  62149. * @param vertexCount Number of vertices to check for min and max values
  62150. * @returns min number array and max number array
  62151. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  62152. min: number[];
  62153. max: number[];
  62154. };
  62155. /**
  62156. * Converts a new right-handed Vector3
  62157. * @param vector vector3 array
  62158. * @returns right-handed Vector3
  62159. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  62160. /**
  62161. * Converts a Vector3 to right-handed
  62162. * @param vector Vector3 to convert to right-handed
  62163. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  62164. /**
  62165. * Converts a three element number array to right-handed
  62166. * @param vector number array to convert to right-handed
  62167. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  62168. /**
  62169. * Converts a new right-handed Vector3
  62170. * @param vector vector3 array
  62171. * @returns right-handed Vector3
  62172. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  62173. /**
  62174. * Converts a Vector3 to right-handed
  62175. * @param vector Vector3 to convert to right-handed
  62176. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  62177. /**
  62178. * Converts a three element number array to right-handed
  62179. * @param vector number array to convert to right-handed
  62180. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  62181. /**
  62182. * Converts a Vector4 to right-handed
  62183. * @param vector Vector4 to convert to right-handed
  62184. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  62185. /**
  62186. * Converts a Vector4 to right-handed
  62187. * @param vector Vector4 to convert to right-handed
  62188. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  62189. /**
  62190. * Converts a Quaternion to right-handed
  62191. * @param quaternion Source quaternion to convert to right-handed
  62192. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  62193. /**
  62194. * Converts a Quaternion to right-handed
  62195. * @param quaternion Source quaternion to convert to right-handed
  62196. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  62197. }
  62198. }
  62199. declare module BABYLON.GLTF2.Exporter {
  62200. /**
  62201. * Converts Babylon Scene into glTF 2.0.
  62202. * @hidden
  62203. */
  62204. export class _Exporter {
  62205. /**
  62206. * Stores the glTF to export
  62207. */ glTF: IGLTF;
  62208. /**
  62209. * Stores all generated buffer views, which represents views into the main glTF buffer data
  62210. */ bufferViews: IBufferView[];
  62211. /**
  62212. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  62213. */ accessors: IAccessor[];
  62214. /**
  62215. * Stores all the generated nodes, which contains transform and/or mesh information per node
  62216. */
  62217. private _nodes;
  62218. /**
  62219. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  62220. */
  62221. private _scenes;
  62222. /**
  62223. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  62224. */
  62225. private _meshes;
  62226. /**
  62227. * Stores all the generated material information, which represents the appearance of each primitive
  62228. */ materials: IMaterial[]; materialMap: {
  62229. [materialID: number]: number;
  62230. };
  62231. /**
  62232. * Stores all the generated texture information, which is referenced by glTF materials
  62233. */ textures: ITexture[];
  62234. /**
  62235. * Stores all the generated image information, which is referenced by glTF textures
  62236. */ images: IImage[];
  62237. /**
  62238. * Stores all the texture samplers
  62239. */ samplers: ISampler[];
  62240. /**
  62241. * Stores all the generated animation samplers, which is referenced by glTF animations
  62242. */
  62243. /**
  62244. * Stores the animations for glTF models
  62245. */
  62246. private _animations;
  62247. /**
  62248. * Stores the total amount of bytes stored in the glTF buffer
  62249. */
  62250. private _totalByteLength;
  62251. /**
  62252. * Stores a reference to the Babylon scene containing the source geometry and material information
  62253. */ babylonScene: Scene;
  62254. /**
  62255. * Stores a map of the image data, where the key is the file name and the value
  62256. * is the image data
  62257. */ imageData: {
  62258. [fileName: string]: {
  62259. data: Uint8Array;
  62260. mimeType: ImageMimeType;
  62261. };
  62262. };
  62263. /**
  62264. * Stores a map of the unique id of a node to its index in the node array
  62265. */
  62266. private _nodeMap;
  62267. /**
  62268. * Specifies if the Babylon scene should be converted to right-handed on export
  62269. */ convertToRightHandedSystem: boolean;
  62270. /**
  62271. * Baked animation sample rate
  62272. */
  62273. private _animationSampleRate;
  62274. /**
  62275. * Callback which specifies if a node should be exported or not
  62276. */
  62277. private _shouldExportNode;
  62278. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  62279. private _extensions;
  62280. private static _ExtensionNames;
  62281. private static _ExtensionFactories;
  62282. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62283. private _forEachExtensions;
  62284. private _extensionsOnExporting;
  62285. /**
  62286. * Load glTF serializer extensions
  62287. */
  62288. private _loadExtensions;
  62289. /**
  62290. * Creates a glTF Exporter instance, which can accept optional exporter options
  62291. * @param babylonScene Babylon scene object
  62292. * @param options Options to modify the behavior of the exporter
  62293. */
  62294. constructor(babylonScene: Scene, options?: IExportOptions);
  62295. /**
  62296. * Registers a glTF exporter extension
  62297. * @param name Name of the extension to export
  62298. * @param factory The factory function that creates the exporter extension
  62299. */
  62300. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  62301. /**
  62302. * Un-registers an exporter extension
  62303. * @param name The name fo the exporter extension
  62304. * @returns A boolean indicating whether the extension has been un-registered
  62305. */
  62306. static UnregisterExtension(name: string): boolean;
  62307. /**
  62308. * Lazy load a local engine with premultiplied alpha set to false
  62309. */ getLocalEngine(): Engine;
  62310. private reorderIndicesBasedOnPrimitiveMode;
  62311. /**
  62312. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  62313. * clock-wise during export to glTF
  62314. * @param submesh BabylonJS submesh
  62315. * @param primitiveMode Primitive mode of the mesh
  62316. * @param sideOrientation the winding order of the submesh
  62317. * @param vertexBufferKind The type of vertex attribute
  62318. * @param meshAttributeArray The vertex attribute data
  62319. * @param byteOffset The offset to the binary data
  62320. * @param binaryWriter The binary data for the glTF file
  62321. */
  62322. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  62323. /**
  62324. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  62325. * clock-wise during export to glTF
  62326. * @param submesh BabylonJS submesh
  62327. * @param primitiveMode Primitive mode of the mesh
  62328. * @param sideOrientation the winding order of the submesh
  62329. * @param vertexBufferKind The type of vertex attribute
  62330. * @param meshAttributeArray The vertex attribute data
  62331. * @param byteOffset The offset to the binary data
  62332. * @param binaryWriter The binary data for the glTF file
  62333. */
  62334. private reorderTriangleFillMode;
  62335. /**
  62336. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  62337. * clock-wise during export to glTF
  62338. * @param submesh BabylonJS submesh
  62339. * @param primitiveMode Primitive mode of the mesh
  62340. * @param sideOrientation the winding order of the submesh
  62341. * @param vertexBufferKind The type of vertex attribute
  62342. * @param meshAttributeArray The vertex attribute data
  62343. * @param byteOffset The offset to the binary data
  62344. * @param binaryWriter The binary data for the glTF file
  62345. */
  62346. private reorderTriangleStripDrawMode;
  62347. /**
  62348. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  62349. * clock-wise during export to glTF
  62350. * @param submesh BabylonJS submesh
  62351. * @param primitiveMode Primitive mode of the mesh
  62352. * @param sideOrientation the winding order of the submesh
  62353. * @param vertexBufferKind The type of vertex attribute
  62354. * @param meshAttributeArray The vertex attribute data
  62355. * @param byteOffset The offset to the binary data
  62356. * @param binaryWriter The binary data for the glTF file
  62357. */
  62358. private reorderTriangleFanMode;
  62359. /**
  62360. * Writes the vertex attribute data to binary
  62361. * @param vertices The vertices to write to the binary writer
  62362. * @param byteOffset The offset into the binary writer to overwrite binary data
  62363. * @param vertexAttributeKind The vertex attribute type
  62364. * @param meshAttributeArray The vertex attribute data
  62365. * @param binaryWriter The writer containing the binary data
  62366. */
  62367. private writeVertexAttributeData;
  62368. /**
  62369. * Writes mesh attribute data to a data buffer
  62370. * Returns the bytelength of the data
  62371. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  62372. * @param meshAttributeArray Array containing the attribute data
  62373. * @param binaryWriter The buffer to write the binary data to
  62374. * @param indices Used to specify the order of the vertex data
  62375. */
  62376. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  62377. /**
  62378. * Generates glTF json data
  62379. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  62380. * @param glTFPrefix Text to use when prefixing a glTF file
  62381. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  62382. * @returns json data as string
  62383. */
  62384. private generateJSON;
  62385. /**
  62386. * Generates data for .gltf and .bin files based on the glTF prefix string
  62387. * @param glTFPrefix Text to use when prefixing a glTF file
  62388. * @returns GLTFData with glTF file data
  62389. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  62390. /**
  62391. * Creates a binary buffer for glTF
  62392. * @returns array buffer for binary data
  62393. */
  62394. private _generateBinaryAsync;
  62395. /**
  62396. * Pads the number to a multiple of 4
  62397. * @param num number to pad
  62398. * @returns padded number
  62399. */
  62400. private _getPadding;
  62401. /**
  62402. * Generates a glb file from the json and binary data
  62403. * Returns an object with the glb file name as the key and data as the value
  62404. * @param glTFPrefix
  62405. * @returns object with glb filename as key and data as value
  62406. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  62407. /**
  62408. * Sets the TRS for each node
  62409. * @param node glTF Node for storing the transformation data
  62410. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  62411. */
  62412. private setNodeTransformation;
  62413. private getVertexBufferFromMesh;
  62414. /**
  62415. * Creates a bufferview based on the vertices type for the Babylon mesh
  62416. * @param kind Indicates the type of vertices data
  62417. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  62418. * @param binaryWriter The buffer to write the bufferview data to
  62419. */
  62420. private createBufferViewKind;
  62421. /**
  62422. * The primitive mode of the Babylon mesh
  62423. * @param babylonMesh The BabylonJS mesh
  62424. */
  62425. private getMeshPrimitiveMode;
  62426. /**
  62427. * Sets the primitive mode of the glTF mesh primitive
  62428. * @param meshPrimitive glTF mesh primitive
  62429. * @param primitiveMode The primitive mode
  62430. */
  62431. private setPrimitiveMode;
  62432. /**
  62433. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62434. * @param meshPrimitive glTF mesh primitive
  62435. * @param attributeKind vertex attribute
  62436. * @returns boolean specifying if uv coordinates are present
  62437. */
  62438. private setAttributeKind;
  62439. /**
  62440. * Sets data for the primitive attributes of each submesh
  62441. * @param mesh glTF Mesh object to store the primitive attribute information
  62442. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62443. * @param binaryWriter Buffer to write the attribute data to
  62444. */
  62445. private setPrimitiveAttributesAsync;
  62446. /**
  62447. * Creates a glTF scene based on the array of meshes
  62448. * Returns the the total byte offset
  62449. * @param babylonScene Babylon scene to get the mesh data from
  62450. * @param binaryWriter Buffer to write binary data to
  62451. */
  62452. private createSceneAsync;
  62453. /**
  62454. * Creates a mapping of Node unique id to node index and handles animations
  62455. * @param babylonScene Babylon Scene
  62456. * @param nodes Babylon transform nodes
  62457. * @param shouldExportNode Callback specifying if a transform node should be exported
  62458. * @param binaryWriter Buffer to write binary data to
  62459. * @returns Node mapping of unique id to index
  62460. */
  62461. private createNodeMapAndAnimationsAsync;
  62462. /**
  62463. * Creates a glTF node from a Babylon mesh
  62464. * @param babylonMesh Source Babylon mesh
  62465. * @param binaryWriter Buffer for storing geometry data
  62466. * @returns glTF node
  62467. */
  62468. private createNodeAsync;
  62469. }
  62470. /**
  62471. * @hidden
  62472. *
  62473. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62474. */
  62475. export class _BinaryWriter {
  62476. /**
  62477. * Array buffer which stores all binary data
  62478. */
  62479. private _arrayBuffer;
  62480. /**
  62481. * View of the array buffer
  62482. */
  62483. private _dataView;
  62484. /**
  62485. * byte offset of data in array buffer
  62486. */
  62487. private _byteOffset;
  62488. /**
  62489. * Initialize binary writer with an initial byte length
  62490. * @param byteLength Initial byte length of the array buffer
  62491. */
  62492. constructor(byteLength: number);
  62493. /**
  62494. * Resize the array buffer to the specified byte length
  62495. * @param byteLength
  62496. */
  62497. private resizeBuffer;
  62498. /**
  62499. * Get an array buffer with the length of the byte offset
  62500. * @returns ArrayBuffer resized to the byte offset
  62501. */
  62502. getArrayBuffer(): ArrayBuffer;
  62503. /**
  62504. * Get the byte offset of the array buffer
  62505. * @returns byte offset
  62506. */
  62507. getByteOffset(): number;
  62508. /**
  62509. * Stores an UInt8 in the array buffer
  62510. * @param entry
  62511. * @param byteOffset If defined, specifies where to set the value as an offset.
  62512. */
  62513. setUInt8(entry: number, byteOffset?: number): void;
  62514. /**
  62515. * Gets an UInt32 in the array buffer
  62516. * @param entry
  62517. * @param byteOffset If defined, specifies where to set the value as an offset.
  62518. */
  62519. getUInt32(byteOffset: number): number;
  62520. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62521. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62522. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62523. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62524. /**
  62525. * Stores a Float32 in the array buffer
  62526. * @param entry
  62527. */
  62528. setFloat32(entry: number, byteOffset?: number): void;
  62529. /**
  62530. * Stores an UInt32 in the array buffer
  62531. * @param entry
  62532. * @param byteOffset If defined, specifies where to set the value as an offset.
  62533. */
  62534. setUInt32(entry: number, byteOffset?: number): void;
  62535. }
  62536. }
  62537. declare module BABYLON.GLTF2.Exporter {
  62538. /**
  62539. * @hidden
  62540. * Interface to store animation data.
  62541. */
  62542. export interface _IAnimationData {
  62543. /**
  62544. * Keyframe data.
  62545. */
  62546. inputs: number[];
  62547. /**
  62548. * Value data.
  62549. */
  62550. outputs: number[][];
  62551. /**
  62552. * Animation interpolation data.
  62553. */
  62554. samplerInterpolation: AnimationSamplerInterpolation;
  62555. /**
  62556. * Minimum keyframe value.
  62557. */
  62558. inputsMin: number;
  62559. /**
  62560. * Maximum keyframe value.
  62561. */
  62562. inputsMax: number;
  62563. }
  62564. /**
  62565. * @hidden
  62566. */
  62567. export interface _IAnimationInfo {
  62568. /**
  62569. * The target channel for the animation
  62570. */
  62571. animationChannelTargetPath: AnimationChannelTargetPath;
  62572. /**
  62573. * The glTF accessor type for the data.
  62574. */
  62575. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62576. /**
  62577. * Specifies if quaternions should be used.
  62578. */
  62579. useQuaternion: boolean;
  62580. }
  62581. /**
  62582. * @hidden
  62583. * Utility class for generating glTF animation data from BabylonJS.
  62584. */
  62585. export class _GLTFAnimation {
  62586. /**
  62587. * @ignore
  62588. *
  62589. * Creates glTF channel animation from BabylonJS animation.
  62590. * @param babylonTransformNode - BabylonJS mesh.
  62591. * @param animation - animation.
  62592. * @param animationChannelTargetPath - The target animation channel.
  62593. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62594. * @param useQuaternion - Specifies if quaternions are used.
  62595. * @returns nullable IAnimationData
  62596. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62597. private static _DeduceAnimationInfo;
  62598. /**
  62599. * @ignore
  62600. * Create node animations from the transform node animations
  62601. * @param babylonNode
  62602. * @param runtimeGLTFAnimation
  62603. * @param idleGLTFAnimations
  62604. * @param nodeMap
  62605. * @param nodes
  62606. * @param binaryWriter
  62607. * @param bufferViews
  62608. * @param accessors
  62609. * @param convertToRightHandedSystem
  62610. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62611. [key: number]: number;
  62612. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62613. /**
  62614. * @ignore
  62615. * Create node animations from the animation groups
  62616. * @param babylonScene
  62617. * @param glTFAnimations
  62618. * @param nodeMap
  62619. * @param nodes
  62620. * @param binaryWriter
  62621. * @param bufferViews
  62622. * @param accessors
  62623. * @param convertToRightHandedSystem
  62624. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62625. [key: number]: number;
  62626. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62627. private static AddAnimation;
  62628. /**
  62629. * Create a baked animation
  62630. * @param babylonTransformNode BabylonJS mesh
  62631. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62632. * @param animationChannelTargetPath animation target channel
  62633. * @param minFrame minimum animation frame
  62634. * @param maxFrame maximum animation frame
  62635. * @param fps frames per second of the animation
  62636. * @param inputs input key frames of the animation
  62637. * @param outputs output key frame data of the animation
  62638. * @param convertToRightHandedSystem converts the values to right-handed
  62639. * @param useQuaternion specifies if quaternions should be used
  62640. */
  62641. private static _CreateBakedAnimation;
  62642. private static _ConvertFactorToVector3OrQuaternion;
  62643. private static _SetInterpolatedValue;
  62644. /**
  62645. * Creates linear animation from the animation key frames
  62646. * @param babylonTransformNode BabylonJS mesh
  62647. * @param animation BabylonJS animation
  62648. * @param animationChannelTargetPath The target animation channel
  62649. * @param frameDelta The difference between the last and first frame of the animation
  62650. * @param inputs Array to store the key frame times
  62651. * @param outputs Array to store the key frame data
  62652. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62653. * @param useQuaternion Specifies if quaternions are used in the animation
  62654. */
  62655. private static _CreateLinearOrStepAnimation;
  62656. /**
  62657. * Creates cubic spline animation from the animation key frames
  62658. * @param babylonTransformNode BabylonJS mesh
  62659. * @param animation BabylonJS animation
  62660. * @param animationChannelTargetPath The target animation channel
  62661. * @param frameDelta The difference between the last and first frame of the animation
  62662. * @param inputs Array to store the key frame times
  62663. * @param outputs Array to store the key frame data
  62664. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62665. * @param useQuaternion Specifies if quaternions are used in the animation
  62666. */
  62667. private static _CreateCubicSplineAnimation;
  62668. private static _GetBasePositionRotationOrScale;
  62669. /**
  62670. * Adds a key frame value
  62671. * @param keyFrame
  62672. * @param animation
  62673. * @param outputs
  62674. * @param animationChannelTargetPath
  62675. * @param basePositionRotationOrScale
  62676. * @param convertToRightHandedSystem
  62677. * @param useQuaternion
  62678. */
  62679. private static _AddKeyframeValue;
  62680. /**
  62681. * Determine the interpolation based on the key frames
  62682. * @param keyFrames
  62683. * @param animationChannelTargetPath
  62684. * @param useQuaternion
  62685. */
  62686. private static _DeduceInterpolation;
  62687. /**
  62688. * Adds an input tangent or output tangent to the output data
  62689. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62690. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62691. * @param outputs The animation data by keyframe
  62692. * @param animationChannelTargetPath The target animation channel
  62693. * @param interpolation The interpolation type
  62694. * @param keyFrame The key frame with the animation data
  62695. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62696. * @param useQuaternion Specifies if quaternions are used
  62697. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62698. */
  62699. private static AddSplineTangent;
  62700. /**
  62701. * Get the minimum and maximum key frames' frame values
  62702. * @param keyFrames animation key frames
  62703. * @returns the minimum and maximum key frame value
  62704. */
  62705. private static calculateMinMaxKeyFrames;
  62706. }
  62707. }
  62708. declare module BABYLON.GLTF2.Exporter {
  62709. /** @hidden */
  62710. export var textureTransformPixelShader: {
  62711. name: string;
  62712. shader: string;
  62713. };
  62714. }
  62715. declare module BABYLON.GLTF2.Exporter.Extensions {
  62716. /**
  62717. * @hidden
  62718. */
  62719. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62720. /** Name of this extension */
  62721. readonly name: string;
  62722. /** Defines whether this extension is enabled */
  62723. enabled: boolean;
  62724. /** Defines whether this extension is required */
  62725. required: boolean;
  62726. /** Reference to the glTF exporter */
  62727. private _exporter;
  62728. constructor(exporter: _Exporter);
  62729. dispose(): void;
  62730. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62731. /**
  62732. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62733. * @param babylonTexture
  62734. * @param offset
  62735. * @param rotation
  62736. * @param scale
  62737. * @param scene
  62738. */
  62739. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62740. }
  62741. }
  62742. declare module BABYLON.GLTF2.Exporter.Extensions {
  62743. /**
  62744. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62745. */
  62746. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62747. /** The name of this extension. */
  62748. readonly name: string;
  62749. /** Defines whether this extension is enabled. */
  62750. enabled: boolean;
  62751. /** Defines whether this extension is required */
  62752. required: boolean;
  62753. /** Reference to the glTF exporter */
  62754. private _exporter;
  62755. private _lights;
  62756. /** @hidden */
  62757. constructor(exporter: _Exporter);
  62758. /** @hidden */
  62759. dispose(): void;
  62760. /** @hidden */
  62761. onExporting(): void;
  62762. /**
  62763. * Define this method to modify the default behavior when exporting a node
  62764. * @param context The context when exporting the node
  62765. * @param node glTF node
  62766. * @param babylonNode BabylonJS node
  62767. * @returns nullable INode promise
  62768. */
  62769. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62770. }
  62771. }
  62772. declare module BABYLON {
  62773. /**
  62774. * Class for generating STL data from a Babylon scene.
  62775. */
  62776. export class STLExport {
  62777. /**
  62778. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62779. * @param meshes list defines the mesh to serialize
  62780. * @param download triggers the automatic download of the file.
  62781. * @param fileName changes the downloads fileName.
  62782. * @param binary changes the STL to a binary type.
  62783. * @param isLittleEndian toggle for binary type exporter.
  62784. * @returns the STL as UTF8 string
  62785. */
  62786. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62787. }
  62788. }
  62789. /**
  62790. * @ignoreChildren
  62791. * @ignore
  62792. */
  62793. declare module "babylonjs-gltf2interface" {
  62794. export = BABYLON.GLTF2;
  62795. }
  62796. /**
  62797. * Module for glTF 2.0 Interface
  62798. * @ignoreChildren
  62799. * @ignore
  62800. */
  62801. declare module BABYLON.GLTF2 {
  62802. /**
  62803. * The datatype of the components in the attribute
  62804. */
  62805. const enum AccessorComponentType {
  62806. /**
  62807. * Byte
  62808. */
  62809. BYTE = 5120,
  62810. /**
  62811. * Unsigned Byte
  62812. */
  62813. UNSIGNED_BYTE = 5121,
  62814. /**
  62815. * Short
  62816. */
  62817. SHORT = 5122,
  62818. /**
  62819. * Unsigned Short
  62820. */
  62821. UNSIGNED_SHORT = 5123,
  62822. /**
  62823. * Unsigned Int
  62824. */
  62825. UNSIGNED_INT = 5125,
  62826. /**
  62827. * Float
  62828. */
  62829. FLOAT = 5126,
  62830. }
  62831. /**
  62832. * Specifies if the attirbute is a scalar, vector, or matrix
  62833. */
  62834. const enum AccessorType {
  62835. /**
  62836. * Scalar
  62837. */
  62838. SCALAR = "SCALAR",
  62839. /**
  62840. * Vector2
  62841. */
  62842. VEC2 = "VEC2",
  62843. /**
  62844. * Vector3
  62845. */
  62846. VEC3 = "VEC3",
  62847. /**
  62848. * Vector4
  62849. */
  62850. VEC4 = "VEC4",
  62851. /**
  62852. * Matrix2x2
  62853. */
  62854. MAT2 = "MAT2",
  62855. /**
  62856. * Matrix3x3
  62857. */
  62858. MAT3 = "MAT3",
  62859. /**
  62860. * Matrix4x4
  62861. */
  62862. MAT4 = "MAT4",
  62863. }
  62864. /**
  62865. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62866. */
  62867. const enum AnimationChannelTargetPath {
  62868. /**
  62869. * Translation
  62870. */
  62871. TRANSLATION = "translation",
  62872. /**
  62873. * Rotation
  62874. */
  62875. ROTATION = "rotation",
  62876. /**
  62877. * Scale
  62878. */
  62879. SCALE = "scale",
  62880. /**
  62881. * Weights
  62882. */
  62883. WEIGHTS = "weights",
  62884. }
  62885. /**
  62886. * Interpolation algorithm
  62887. */
  62888. const enum AnimationSamplerInterpolation {
  62889. /**
  62890. * The animated values are linearly interpolated between keyframes
  62891. */
  62892. LINEAR = "LINEAR",
  62893. /**
  62894. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62895. */
  62896. STEP = "STEP",
  62897. /**
  62898. * The animation's interpolation is computed using a cubic spline with specified tangents
  62899. */
  62900. CUBICSPLINE = "CUBICSPLINE",
  62901. }
  62902. /**
  62903. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62904. */
  62905. const enum CameraType {
  62906. /**
  62907. * A perspective camera containing properties to create a perspective projection matrix
  62908. */
  62909. PERSPECTIVE = "perspective",
  62910. /**
  62911. * An orthographic camera containing properties to create an orthographic projection matrix
  62912. */
  62913. ORTHOGRAPHIC = "orthographic",
  62914. }
  62915. /**
  62916. * The mime-type of the image
  62917. */
  62918. const enum ImageMimeType {
  62919. /**
  62920. * JPEG Mime-type
  62921. */
  62922. JPEG = "image/jpeg",
  62923. /**
  62924. * PNG Mime-type
  62925. */
  62926. PNG = "image/png",
  62927. }
  62928. /**
  62929. * The alpha rendering mode of the material
  62930. */
  62931. const enum MaterialAlphaMode {
  62932. /**
  62933. * The alpha value is ignored and the rendered output is fully opaque
  62934. */
  62935. OPAQUE = "OPAQUE",
  62936. /**
  62937. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62938. */
  62939. MASK = "MASK",
  62940. /**
  62941. * 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)
  62942. */
  62943. BLEND = "BLEND",
  62944. }
  62945. /**
  62946. * The type of the primitives to render
  62947. */
  62948. const enum MeshPrimitiveMode {
  62949. /**
  62950. * Points
  62951. */
  62952. POINTS = 0,
  62953. /**
  62954. * Lines
  62955. */
  62956. LINES = 1,
  62957. /**
  62958. * Line Loop
  62959. */
  62960. LINE_LOOP = 2,
  62961. /**
  62962. * Line Strip
  62963. */
  62964. LINE_STRIP = 3,
  62965. /**
  62966. * Triangles
  62967. */
  62968. TRIANGLES = 4,
  62969. /**
  62970. * Triangle Strip
  62971. */
  62972. TRIANGLE_STRIP = 5,
  62973. /**
  62974. * Triangle Fan
  62975. */
  62976. TRIANGLE_FAN = 6,
  62977. }
  62978. /**
  62979. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62980. */
  62981. const enum TextureMagFilter {
  62982. /**
  62983. * Nearest
  62984. */
  62985. NEAREST = 9728,
  62986. /**
  62987. * Linear
  62988. */
  62989. LINEAR = 9729,
  62990. }
  62991. /**
  62992. * Minification filter. All valid values correspond to WebGL enums
  62993. */
  62994. const enum TextureMinFilter {
  62995. /**
  62996. * Nearest
  62997. */
  62998. NEAREST = 9728,
  62999. /**
  63000. * Linear
  63001. */
  63002. LINEAR = 9729,
  63003. /**
  63004. * Nearest Mip-Map Nearest
  63005. */
  63006. NEAREST_MIPMAP_NEAREST = 9984,
  63007. /**
  63008. * Linear Mipmap Nearest
  63009. */
  63010. LINEAR_MIPMAP_NEAREST = 9985,
  63011. /**
  63012. * Nearest Mipmap Linear
  63013. */
  63014. NEAREST_MIPMAP_LINEAR = 9986,
  63015. /**
  63016. * Linear Mipmap Linear
  63017. */
  63018. LINEAR_MIPMAP_LINEAR = 9987,
  63019. }
  63020. /**
  63021. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63022. */
  63023. const enum TextureWrapMode {
  63024. /**
  63025. * Clamp to Edge
  63026. */
  63027. CLAMP_TO_EDGE = 33071,
  63028. /**
  63029. * Mirrored Repeat
  63030. */
  63031. MIRRORED_REPEAT = 33648,
  63032. /**
  63033. * Repeat
  63034. */
  63035. REPEAT = 10497,
  63036. }
  63037. /**
  63038. * glTF Property
  63039. */
  63040. interface IProperty {
  63041. /**
  63042. * Dictionary object with extension-specific objects
  63043. */
  63044. extensions?: {
  63045. [key: string]: any;
  63046. };
  63047. /**
  63048. * Application-Specific data
  63049. */
  63050. extras?: any;
  63051. }
  63052. /**
  63053. * glTF Child of Root Property
  63054. */
  63055. interface IChildRootProperty extends IProperty {
  63056. /**
  63057. * The user-defined name of this object
  63058. */
  63059. name?: string;
  63060. }
  63061. /**
  63062. * Indices of those attributes that deviate from their initialization value
  63063. */
  63064. interface IAccessorSparseIndices extends IProperty {
  63065. /**
  63066. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63067. */
  63068. bufferView: number;
  63069. /**
  63070. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63071. */
  63072. byteOffset?: number;
  63073. /**
  63074. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  63075. */
  63076. componentType: AccessorComponentType;
  63077. }
  63078. /**
  63079. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  63080. */
  63081. interface IAccessorSparseValues extends IProperty {
  63082. /**
  63083. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63084. */
  63085. bufferView: number;
  63086. /**
  63087. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63088. */
  63089. byteOffset?: number;
  63090. }
  63091. /**
  63092. * Sparse storage of attributes that deviate from their initialization value
  63093. */
  63094. interface IAccessorSparse extends IProperty {
  63095. /**
  63096. * The number of attributes encoded in this sparse accessor
  63097. */
  63098. count: number;
  63099. /**
  63100. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  63101. */
  63102. indices: IAccessorSparseIndices;
  63103. /**
  63104. * 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
  63105. */
  63106. values: IAccessorSparseValues;
  63107. }
  63108. /**
  63109. * 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
  63110. */
  63111. interface IAccessor extends IChildRootProperty {
  63112. /**
  63113. * The index of the bufferview
  63114. */
  63115. bufferView?: number;
  63116. /**
  63117. * The offset relative to the start of the bufferView in bytes
  63118. */
  63119. byteOffset?: number;
  63120. /**
  63121. * The datatype of components in the attribute
  63122. */
  63123. componentType: AccessorComponentType;
  63124. /**
  63125. * Specifies whether integer data values should be normalized
  63126. */
  63127. normalized?: boolean;
  63128. /**
  63129. * The number of attributes referenced by this accessor
  63130. */
  63131. count: number;
  63132. /**
  63133. * Specifies if the attribute is a scalar, vector, or matrix
  63134. */
  63135. type: AccessorType;
  63136. /**
  63137. * Maximum value of each component in this attribute
  63138. */
  63139. max?: number[];
  63140. /**
  63141. * Minimum value of each component in this attribute
  63142. */
  63143. min?: number[];
  63144. /**
  63145. * Sparse storage of attributes that deviate from their initialization value
  63146. */
  63147. sparse?: IAccessorSparse;
  63148. }
  63149. /**
  63150. * Targets an animation's sampler at a node's property
  63151. */
  63152. interface IAnimationChannel extends IProperty {
  63153. /**
  63154. * The index of a sampler in this animation used to compute the value for the target
  63155. */
  63156. sampler: number;
  63157. /**
  63158. * The index of the node and TRS property to target
  63159. */
  63160. target: IAnimationChannelTarget;
  63161. }
  63162. /**
  63163. * The index of the node and TRS property that an animation channel targets
  63164. */
  63165. interface IAnimationChannelTarget extends IProperty {
  63166. /**
  63167. * The index of the node to target
  63168. */
  63169. node: number;
  63170. /**
  63171. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  63172. */
  63173. path: AnimationChannelTargetPath;
  63174. }
  63175. /**
  63176. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63177. */
  63178. interface IAnimationSampler extends IProperty {
  63179. /**
  63180. * The index of an accessor containing keyframe input values, e.g., time
  63181. */
  63182. input: number;
  63183. /**
  63184. * Interpolation algorithm
  63185. */
  63186. interpolation?: AnimationSamplerInterpolation;
  63187. /**
  63188. * The index of an accessor, containing keyframe output values
  63189. */
  63190. output: number;
  63191. }
  63192. /**
  63193. * A keyframe animation
  63194. */
  63195. interface IAnimation extends IChildRootProperty {
  63196. /**
  63197. * An array of channels, each of which targets an animation's sampler at a node's property
  63198. */
  63199. channels: IAnimationChannel[];
  63200. /**
  63201. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63202. */
  63203. samplers: IAnimationSampler[];
  63204. }
  63205. /**
  63206. * Metadata about the glTF asset
  63207. */
  63208. interface IAsset extends IChildRootProperty {
  63209. /**
  63210. * A copyright message suitable for display to credit the content creator
  63211. */
  63212. copyright?: string;
  63213. /**
  63214. * Tool that generated this glTF model. Useful for debugging
  63215. */
  63216. generator?: string;
  63217. /**
  63218. * The glTF version that this asset targets
  63219. */
  63220. version: string;
  63221. /**
  63222. * The minimum glTF version that this asset targets
  63223. */
  63224. minVersion?: string;
  63225. }
  63226. /**
  63227. * A buffer points to binary geometry, animation, or skins
  63228. */
  63229. interface IBuffer extends IChildRootProperty {
  63230. /**
  63231. * 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
  63232. */
  63233. uri?: string;
  63234. /**
  63235. * The length of the buffer in bytes
  63236. */
  63237. byteLength: number;
  63238. }
  63239. /**
  63240. * A view into a buffer generally representing a subset of the buffer
  63241. */
  63242. interface IBufferView extends IChildRootProperty {
  63243. /**
  63244. * The index of the buffer
  63245. */
  63246. buffer: number;
  63247. /**
  63248. * The offset into the buffer in bytes
  63249. */
  63250. byteOffset?: number;
  63251. /**
  63252. * The lenth of the bufferView in bytes
  63253. */
  63254. byteLength: number;
  63255. /**
  63256. * The stride, in bytes
  63257. */
  63258. byteStride?: number;
  63259. }
  63260. /**
  63261. * An orthographic camera containing properties to create an orthographic projection matrix
  63262. */
  63263. interface ICameraOrthographic extends IProperty {
  63264. /**
  63265. * The floating-point horizontal magnification of the view. Must not be zero
  63266. */
  63267. xmag: number;
  63268. /**
  63269. * The floating-point vertical magnification of the view. Must not be zero
  63270. */
  63271. ymag: number;
  63272. /**
  63273. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  63274. */
  63275. zfar: number;
  63276. /**
  63277. * The floating-point distance to the near clipping plane
  63278. */
  63279. znear: number;
  63280. }
  63281. /**
  63282. * A perspective camera containing properties to create a perspective projection matrix
  63283. */
  63284. interface ICameraPerspective extends IProperty {
  63285. /**
  63286. * The floating-point aspect ratio of the field of view
  63287. */
  63288. aspectRatio?: number;
  63289. /**
  63290. * The floating-point vertical field of view in radians
  63291. */
  63292. yfov: number;
  63293. /**
  63294. * The floating-point distance to the far clipping plane
  63295. */
  63296. zfar?: number;
  63297. /**
  63298. * The floating-point distance to the near clipping plane
  63299. */
  63300. znear: number;
  63301. }
  63302. /**
  63303. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  63304. */
  63305. interface ICamera extends IChildRootProperty {
  63306. /**
  63307. * An orthographic camera containing properties to create an orthographic projection matrix
  63308. */
  63309. orthographic?: ICameraOrthographic;
  63310. /**
  63311. * A perspective camera containing properties to create a perspective projection matrix
  63312. */
  63313. perspective?: ICameraPerspective;
  63314. /**
  63315. * Specifies if the camera uses a perspective or orthographic projection
  63316. */
  63317. type: CameraType;
  63318. }
  63319. /**
  63320. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  63321. */
  63322. interface IImage extends IChildRootProperty {
  63323. /**
  63324. * 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
  63325. */
  63326. uri?: string;
  63327. /**
  63328. * The image's MIME type
  63329. */
  63330. mimeType?: ImageMimeType;
  63331. /**
  63332. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  63333. */
  63334. bufferView?: number;
  63335. }
  63336. /**
  63337. * Material Normal Texture Info
  63338. */
  63339. interface IMaterialNormalTextureInfo extends ITextureInfo {
  63340. /**
  63341. * The scalar multiplier applied to each normal vector of the normal texture
  63342. */
  63343. scale?: number;
  63344. }
  63345. /**
  63346. * Material Occlusion Texture Info
  63347. */
  63348. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  63349. /**
  63350. * A scalar multiplier controlling the amount of occlusion applied
  63351. */
  63352. strength?: number;
  63353. }
  63354. /**
  63355. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  63356. */
  63357. interface IMaterialPbrMetallicRoughness {
  63358. /**
  63359. * The material's base color factor
  63360. */
  63361. baseColorFactor?: number[];
  63362. /**
  63363. * The base color texture
  63364. */
  63365. baseColorTexture?: ITextureInfo;
  63366. /**
  63367. * The metalness of the material
  63368. */
  63369. metallicFactor?: number;
  63370. /**
  63371. * The roughness of the material
  63372. */
  63373. roughnessFactor?: number;
  63374. /**
  63375. * The metallic-roughness texture
  63376. */
  63377. metallicRoughnessTexture?: ITextureInfo;
  63378. }
  63379. /**
  63380. * The material appearance of a primitive
  63381. */
  63382. interface IMaterial extends IChildRootProperty {
  63383. /**
  63384. * 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
  63385. */
  63386. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63387. /**
  63388. * The normal map texture
  63389. */
  63390. normalTexture?: IMaterialNormalTextureInfo;
  63391. /**
  63392. * The occlusion map texture
  63393. */
  63394. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63395. /**
  63396. * The emissive map texture
  63397. */
  63398. emissiveTexture?: ITextureInfo;
  63399. /**
  63400. * 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
  63401. */
  63402. emissiveFactor?: number[];
  63403. /**
  63404. * The alpha rendering mode of the material
  63405. */
  63406. alphaMode?: MaterialAlphaMode;
  63407. /**
  63408. * The alpha cutoff value of the material
  63409. */
  63410. alphaCutoff?: number;
  63411. /**
  63412. * Specifies whether the material is double sided
  63413. */
  63414. doubleSided?: boolean;
  63415. }
  63416. /**
  63417. * Geometry to be rendered with the given material
  63418. */
  63419. interface IMeshPrimitive extends IProperty {
  63420. /**
  63421. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  63422. */
  63423. attributes: {
  63424. [name: string]: number;
  63425. };
  63426. /**
  63427. * The index of the accessor that contains the indices
  63428. */
  63429. indices?: number;
  63430. /**
  63431. * The index of the material to apply to this primitive when rendering
  63432. */
  63433. material?: number;
  63434. /**
  63435. * The type of primitives to render. All valid values correspond to WebGL enums
  63436. */
  63437. mode?: MeshPrimitiveMode;
  63438. /**
  63439. * 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
  63440. */
  63441. targets?: {
  63442. [name: string]: number;
  63443. }[];
  63444. }
  63445. /**
  63446. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63447. */
  63448. interface IMesh extends IChildRootProperty {
  63449. /**
  63450. * An array of primitives, each defining geometry to be rendered with a material
  63451. */
  63452. primitives: IMeshPrimitive[];
  63453. /**
  63454. * Array of weights to be applied to the Morph Targets
  63455. */
  63456. weights?: number[];
  63457. }
  63458. /**
  63459. * A node in the node hierarchy
  63460. */
  63461. interface INode extends IChildRootProperty {
  63462. /**
  63463. * The index of the camera referenced by this node
  63464. */
  63465. camera?: number;
  63466. /**
  63467. * The indices of this node's children
  63468. */
  63469. children?: number[];
  63470. /**
  63471. * The index of the skin referenced by this node
  63472. */
  63473. skin?: number;
  63474. /**
  63475. * A floating-point 4x4 transformation matrix stored in column-major order
  63476. */
  63477. matrix?: number[];
  63478. /**
  63479. * The index of the mesh in this node
  63480. */
  63481. mesh?: number;
  63482. /**
  63483. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63484. */
  63485. rotation?: number[];
  63486. /**
  63487. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63488. */
  63489. scale?: number[];
  63490. /**
  63491. * The node's translation along the x, y, and z axes
  63492. */
  63493. translation?: number[];
  63494. /**
  63495. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63496. */
  63497. weights?: number[];
  63498. }
  63499. /**
  63500. * Texture sampler properties for filtering and wrapping modes
  63501. */
  63502. interface ISampler extends IChildRootProperty {
  63503. /**
  63504. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63505. */
  63506. magFilter?: TextureMagFilter;
  63507. /**
  63508. * Minification filter. All valid values correspond to WebGL enums
  63509. */
  63510. minFilter?: TextureMinFilter;
  63511. /**
  63512. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63513. */
  63514. wrapS?: TextureWrapMode;
  63515. /**
  63516. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63517. */
  63518. wrapT?: TextureWrapMode;
  63519. }
  63520. /**
  63521. * The root nodes of a scene
  63522. */
  63523. interface IScene extends IChildRootProperty {
  63524. /**
  63525. * The indices of each root node
  63526. */
  63527. nodes: number[];
  63528. }
  63529. /**
  63530. * Joints and matrices defining a skin
  63531. */
  63532. interface ISkin extends IChildRootProperty {
  63533. /**
  63534. * 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
  63535. */
  63536. inverseBindMatrices?: number;
  63537. /**
  63538. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63539. */
  63540. skeleton?: number;
  63541. /**
  63542. * 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)
  63543. */
  63544. joints: number[];
  63545. }
  63546. /**
  63547. * A texture and its sampler
  63548. */
  63549. interface ITexture extends IChildRootProperty {
  63550. /**
  63551. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63552. */
  63553. sampler?: number;
  63554. /**
  63555. * The index of the image used by this texture
  63556. */
  63557. source: number;
  63558. }
  63559. /**
  63560. * Reference to a texture
  63561. */
  63562. interface ITextureInfo extends IProperty {
  63563. /**
  63564. * The index of the texture
  63565. */
  63566. index: number;
  63567. /**
  63568. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63569. */
  63570. texCoord?: number;
  63571. }
  63572. /**
  63573. * The root object for a glTF asset
  63574. */
  63575. interface IGLTF extends IProperty {
  63576. /**
  63577. * An array of accessors. An accessor is a typed view into a bufferView
  63578. */
  63579. accessors?: IAccessor[];
  63580. /**
  63581. * An array of keyframe animations
  63582. */
  63583. animations?: IAnimation[];
  63584. /**
  63585. * Metadata about the glTF asset
  63586. */
  63587. asset: IAsset;
  63588. /**
  63589. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63590. */
  63591. buffers?: IBuffer[];
  63592. /**
  63593. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63594. */
  63595. bufferViews?: IBufferView[];
  63596. /**
  63597. * An array of cameras
  63598. */
  63599. cameras?: ICamera[];
  63600. /**
  63601. * Names of glTF extensions used somewhere in this asset
  63602. */
  63603. extensionsUsed?: string[];
  63604. /**
  63605. * Names of glTF extensions required to properly load this asset
  63606. */
  63607. extensionsRequired?: string[];
  63608. /**
  63609. * An array of images. An image defines data used to create a texture
  63610. */
  63611. images?: IImage[];
  63612. /**
  63613. * An array of materials. A material defines the appearance of a primitive
  63614. */
  63615. materials?: IMaterial[];
  63616. /**
  63617. * An array of meshes. A mesh is a set of primitives to be rendered
  63618. */
  63619. meshes?: IMesh[];
  63620. /**
  63621. * An array of nodes
  63622. */
  63623. nodes?: INode[];
  63624. /**
  63625. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63626. */
  63627. samplers?: ISampler[];
  63628. /**
  63629. * The index of the default scene
  63630. */
  63631. scene?: number;
  63632. /**
  63633. * An array of scenes
  63634. */
  63635. scenes?: IScene[];
  63636. /**
  63637. * An array of skins. A skin is defined by joints and matrices
  63638. */
  63639. skins?: ISkin[];
  63640. /**
  63641. * An array of textures
  63642. */
  63643. textures?: ITexture[];
  63644. }
  63645. /**
  63646. * Interface for glTF validation results
  63647. */
  63648. interface IGLTFValidationResults {
  63649. info: {
  63650. generator: string;
  63651. hasAnimations: boolean;
  63652. hasDefaultScene: boolean;
  63653. hasMaterials: boolean;
  63654. hasMorphTargets: boolean;
  63655. hasSkins: boolean;
  63656. hasTextures: boolean;
  63657. maxAttributesUsed: number;
  63658. primitivesCount: number
  63659. };
  63660. issues: {
  63661. messages: Array<string>;
  63662. numErrors: number;
  63663. numHints: number;
  63664. numInfos: number;
  63665. numWarnings: number;
  63666. truncated: boolean
  63667. };
  63668. mimeType: string;
  63669. uri: string;
  63670. validatedAt: string;
  63671. validatorVersion: string;
  63672. }
  63673. /**
  63674. * Interface for glTF validation options
  63675. */
  63676. interface IGLTFValidationOptions {
  63677. uri?: string;
  63678. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63679. validateAccessorData?: boolean;
  63680. maxIssues?: number;
  63681. ignoredIssues?: Array<string>;
  63682. severityOverrides?: Object;
  63683. }
  63684. /**
  63685. * glTF validator object Tyyings
  63686. */
  63687. interface IGLTFValidatorTypings {
  63688. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63689. }
  63690. }
  63691. /**
  63692. * Interface for glTF validation results
  63693. */
  63694. interface IGLTFValidationResults {
  63695. info: {
  63696. generator: string;
  63697. hasAnimations: boolean;
  63698. hasDefaultScene: boolean;
  63699. hasMaterials: boolean;
  63700. hasMorphTargets: boolean;
  63701. hasSkins: boolean;
  63702. hasTextures: boolean;
  63703. maxAttributesUsed: number;
  63704. primitivesCount: number
  63705. };
  63706. issues: {
  63707. messages: Array<string>;
  63708. numErrors: number;
  63709. numHints: number;
  63710. numInfos: number;
  63711. numWarnings: number;
  63712. truncated: boolean
  63713. };
  63714. mimeType: string;
  63715. uri: string;
  63716. validatedAt: string;
  63717. validatorVersion: string;
  63718. }
  63719. /**
  63720. * Interface for glTF validation options
  63721. */
  63722. interface IGLTFValidationOptions {
  63723. uri?: string;
  63724. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63725. validateAccessorData?: boolean;
  63726. maxIssues?: number;
  63727. ignoredIssues?: Array<string>;
  63728. severityOverrides?: Object;
  63729. }
  63730. /**
  63731. * glTF validator object Tyyings
  63732. */
  63733. interface IGLTFValidatorTypings {
  63734. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63735. }
  63736. declare module BABYLON {
  63737. /** @hidden */
  63738. export var cellPixelShader: {
  63739. name: string;
  63740. shader: string;
  63741. };
  63742. }
  63743. declare module BABYLON {
  63744. /** @hidden */
  63745. export var cellVertexShader: {
  63746. name: string;
  63747. shader: string;
  63748. };
  63749. }
  63750. declare module BABYLON {
  63751. export class CellMaterial extends BABYLON.PushMaterial {
  63752. private _diffuseTexture;
  63753. diffuseTexture: BABYLON.BaseTexture;
  63754. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63755. computeHighLevel: boolean;
  63756. private _disableLighting;
  63757. disableLighting: boolean;
  63758. private _maxSimultaneousLights;
  63759. maxSimultaneousLights: number;
  63760. private _renderId;
  63761. constructor(name: string, scene: BABYLON.Scene);
  63762. needAlphaBlending(): boolean;
  63763. needAlphaTesting(): boolean;
  63764. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63765. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63766. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63767. getAnimatables(): BABYLON.IAnimatable[];
  63768. getActiveTextures(): BABYLON.BaseTexture[];
  63769. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63770. dispose(forceDisposeEffect?: boolean): void;
  63771. getClassName(): string;
  63772. clone(name: string): CellMaterial;
  63773. serialize(): any;
  63774. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63775. }
  63776. }
  63777. declare module BABYLON {
  63778. export class CustomShaderStructure {
  63779. FragmentStore: string;
  63780. VertexStore: string;
  63781. constructor();
  63782. }
  63783. export class ShaderSpecialParts {
  63784. constructor();
  63785. Fragment_Begin: string;
  63786. Fragment_Definitions: string;
  63787. Fragment_MainBegin: string;
  63788. Fragment_Custom_Diffuse: string;
  63789. Fragment_Before_Lights: string;
  63790. Fragment_Before_Fog: string;
  63791. Fragment_Custom_Alpha: string;
  63792. Fragment_Before_FragColor: string;
  63793. Vertex_Begin: string;
  63794. Vertex_Definitions: string;
  63795. Vertex_MainBegin: string;
  63796. Vertex_Before_PositionUpdated: string;
  63797. Vertex_Before_NormalUpdated: string;
  63798. Vertex_MainEnd: string;
  63799. }
  63800. export class CustomMaterial extends BABYLON.StandardMaterial {
  63801. static ShaderIndexer: number;
  63802. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63803. FragmentShader: string;
  63804. VertexShader: string;
  63805. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63806. ReviewUniform(name: string, arr: string[]): string[];
  63807. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63808. constructor(name: string, scene: BABYLON.Scene);
  63809. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63810. Fragment_Begin(shaderPart: string): CustomMaterial;
  63811. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63812. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63813. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63814. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63815. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63816. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63817. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63818. Vertex_Begin(shaderPart: string): CustomMaterial;
  63819. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63820. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63821. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63822. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63823. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63824. }
  63825. }
  63826. declare module BABYLON {
  63827. export class ShaderAlebdoParts {
  63828. constructor();
  63829. Fragment_Begin: string;
  63830. Fragment_Definitions: string;
  63831. Fragment_MainBegin: string;
  63832. Fragment_Custom_Albedo: string;
  63833. Fragment_Before_Lights: string;
  63834. Fragment_Custom_MetallicRoughness: string;
  63835. Fragment_Custom_MicroSurface: string;
  63836. Fragment_Before_Fog: string;
  63837. Fragment_Custom_Alpha: string;
  63838. Fragment_Before_FragColor: string;
  63839. Vertex_Begin: string;
  63840. Vertex_Definitions: string;
  63841. Vertex_MainBegin: string;
  63842. Vertex_Before_PositionUpdated: string;
  63843. Vertex_Before_NormalUpdated: string;
  63844. Vertex_MainEnd: string;
  63845. }
  63846. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63847. static ShaderIndexer: number;
  63848. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63849. FragmentShader: string;
  63850. VertexShader: string;
  63851. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63852. ReviewUniform(name: string, arr: string[]): string[];
  63853. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63854. constructor(name: string, scene: BABYLON.Scene);
  63855. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63856. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63857. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63858. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63859. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63860. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63861. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63862. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  63863. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  63864. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63865. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63866. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63867. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63868. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63869. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63870. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63871. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63872. }
  63873. }
  63874. declare module BABYLON {
  63875. /** @hidden */
  63876. export var firePixelShader: {
  63877. name: string;
  63878. shader: string;
  63879. };
  63880. }
  63881. declare module BABYLON {
  63882. /** @hidden */
  63883. export var fireVertexShader: {
  63884. name: string;
  63885. shader: string;
  63886. };
  63887. }
  63888. declare module BABYLON {
  63889. export class FireMaterial extends BABYLON.PushMaterial {
  63890. private _diffuseTexture;
  63891. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63892. private _distortionTexture;
  63893. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63894. private _opacityTexture;
  63895. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63896. diffuseColor: BABYLON.Color3;
  63897. speed: number;
  63898. private _scaledDiffuse;
  63899. private _renderId;
  63900. private _lastTime;
  63901. constructor(name: string, scene: BABYLON.Scene);
  63902. needAlphaBlending(): boolean;
  63903. needAlphaTesting(): boolean;
  63904. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63905. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63906. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63907. getAnimatables(): BABYLON.IAnimatable[];
  63908. getActiveTextures(): BABYLON.BaseTexture[];
  63909. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63910. getClassName(): string;
  63911. dispose(forceDisposeEffect?: boolean): void;
  63912. clone(name: string): FireMaterial;
  63913. serialize(): any;
  63914. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. /** @hidden */
  63919. export var furPixelShader: {
  63920. name: string;
  63921. shader: string;
  63922. };
  63923. }
  63924. declare module BABYLON {
  63925. /** @hidden */
  63926. export var furVertexShader: {
  63927. name: string;
  63928. shader: string;
  63929. };
  63930. }
  63931. declare module BABYLON {
  63932. export class FurMaterial extends BABYLON.PushMaterial {
  63933. private _diffuseTexture;
  63934. diffuseTexture: BABYLON.BaseTexture;
  63935. private _heightTexture;
  63936. heightTexture: BABYLON.BaseTexture;
  63937. diffuseColor: BABYLON.Color3;
  63938. furLength: number;
  63939. furAngle: number;
  63940. furColor: BABYLON.Color3;
  63941. furOffset: number;
  63942. furSpacing: number;
  63943. furGravity: BABYLON.Vector3;
  63944. furSpeed: number;
  63945. furDensity: number;
  63946. furOcclusion: number;
  63947. furTexture: BABYLON.DynamicTexture;
  63948. private _disableLighting;
  63949. disableLighting: boolean;
  63950. private _maxSimultaneousLights;
  63951. maxSimultaneousLights: number;
  63952. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63953. private _renderId;
  63954. private _furTime;
  63955. constructor(name: string, scene: BABYLON.Scene);
  63956. furTime: number;
  63957. needAlphaBlending(): boolean;
  63958. needAlphaTesting(): boolean;
  63959. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63960. updateFur(): void;
  63961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63963. getAnimatables(): BABYLON.IAnimatable[];
  63964. getActiveTextures(): BABYLON.BaseTexture[];
  63965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63966. dispose(forceDisposeEffect?: boolean): void;
  63967. clone(name: string): FurMaterial;
  63968. serialize(): any;
  63969. getClassName(): string;
  63970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63971. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63972. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63973. }
  63974. }
  63975. declare module BABYLON {
  63976. /** @hidden */
  63977. export var gradientPixelShader: {
  63978. name: string;
  63979. shader: string;
  63980. };
  63981. }
  63982. declare module BABYLON {
  63983. /** @hidden */
  63984. export var gradientVertexShader: {
  63985. name: string;
  63986. shader: string;
  63987. };
  63988. }
  63989. declare module BABYLON {
  63990. export class GradientMaterial extends BABYLON.PushMaterial {
  63991. private _maxSimultaneousLights;
  63992. maxSimultaneousLights: number;
  63993. topColor: BABYLON.Color3;
  63994. topColorAlpha: number;
  63995. bottomColor: BABYLON.Color3;
  63996. bottomColorAlpha: number;
  63997. offset: number;
  63998. scale: number;
  63999. smoothness: number;
  64000. private _disableLighting;
  64001. disableLighting: boolean;
  64002. private _renderId;
  64003. constructor(name: string, scene: BABYLON.Scene);
  64004. needAlphaBlending(): boolean;
  64005. needAlphaTesting(): boolean;
  64006. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64007. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64008. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64009. getAnimatables(): BABYLON.IAnimatable[];
  64010. dispose(forceDisposeEffect?: boolean): void;
  64011. clone(name: string): GradientMaterial;
  64012. serialize(): any;
  64013. getClassName(): string;
  64014. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  64015. }
  64016. }
  64017. declare module BABYLON {
  64018. /** @hidden */
  64019. export var gridPixelShader: {
  64020. name: string;
  64021. shader: string;
  64022. };
  64023. }
  64024. declare module BABYLON {
  64025. /** @hidden */
  64026. export var gridVertexShader: {
  64027. name: string;
  64028. shader: string;
  64029. };
  64030. }
  64031. declare module BABYLON {
  64032. /**
  64033. * The grid materials allows you to wrap any shape with a grid.
  64034. * Colors are customizable.
  64035. */
  64036. export class GridMaterial extends BABYLON.PushMaterial {
  64037. /**
  64038. * Main color of the grid (e.g. between lines)
  64039. */
  64040. mainColor: BABYLON.Color3;
  64041. /**
  64042. * Color of the grid lines.
  64043. */
  64044. lineColor: BABYLON.Color3;
  64045. /**
  64046. * The scale of the grid compared to unit.
  64047. */
  64048. gridRatio: number;
  64049. /**
  64050. * Allows setting an offset for the grid lines.
  64051. */
  64052. gridOffset: BABYLON.Vector3;
  64053. /**
  64054. * The frequency of thicker lines.
  64055. */
  64056. majorUnitFrequency: number;
  64057. /**
  64058. * The visibility of minor units in the grid.
  64059. */
  64060. minorUnitVisibility: number;
  64061. /**
  64062. * The grid opacity outside of the lines.
  64063. */
  64064. opacity: number;
  64065. /**
  64066. * Determine RBG output is premultiplied by alpha value.
  64067. */
  64068. preMultiplyAlpha: boolean;
  64069. private _opacityTexture;
  64070. opacityTexture: BABYLON.BaseTexture;
  64071. private _gridControl;
  64072. private _renderId;
  64073. /**
  64074. * constructor
  64075. * @param name The name given to the material in order to identify it afterwards.
  64076. * @param scene The scene the material is used in.
  64077. */
  64078. constructor(name: string, scene: BABYLON.Scene);
  64079. /**
  64080. * Returns wehter or not the grid requires alpha blending.
  64081. */
  64082. needAlphaBlending(): boolean;
  64083. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64084. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64085. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64086. /**
  64087. * Dispose the material and its associated resources.
  64088. * @param forceDisposeEffect will also dispose the used effect when true
  64089. */
  64090. dispose(forceDisposeEffect?: boolean): void;
  64091. clone(name: string): GridMaterial;
  64092. serialize(): any;
  64093. getClassName(): string;
  64094. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /** @hidden */
  64099. export var lavaPixelShader: {
  64100. name: string;
  64101. shader: string;
  64102. };
  64103. }
  64104. declare module BABYLON {
  64105. /** @hidden */
  64106. export var lavaVertexShader: {
  64107. name: string;
  64108. shader: string;
  64109. };
  64110. }
  64111. declare module BABYLON {
  64112. export class LavaMaterial extends BABYLON.PushMaterial {
  64113. private _diffuseTexture;
  64114. diffuseTexture: BABYLON.BaseTexture;
  64115. noiseTexture: BABYLON.BaseTexture;
  64116. fogColor: BABYLON.Color3;
  64117. speed: number;
  64118. movingSpeed: number;
  64119. lowFrequencySpeed: number;
  64120. fogDensity: number;
  64121. private _lastTime;
  64122. diffuseColor: BABYLON.Color3;
  64123. private _disableLighting;
  64124. disableLighting: boolean;
  64125. private _unlit;
  64126. unlit: boolean;
  64127. private _maxSimultaneousLights;
  64128. maxSimultaneousLights: number;
  64129. private _scaledDiffuse;
  64130. private _renderId;
  64131. constructor(name: string, scene: BABYLON.Scene);
  64132. needAlphaBlending(): boolean;
  64133. needAlphaTesting(): boolean;
  64134. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64135. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64136. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64137. getAnimatables(): BABYLON.IAnimatable[];
  64138. getActiveTextures(): BABYLON.BaseTexture[];
  64139. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64140. dispose(forceDisposeEffect?: boolean): void;
  64141. clone(name: string): LavaMaterial;
  64142. serialize(): any;
  64143. getClassName(): string;
  64144. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  64145. }
  64146. }
  64147. declare module BABYLON {
  64148. /** @hidden */
  64149. export var mixPixelShader: {
  64150. name: string;
  64151. shader: string;
  64152. };
  64153. }
  64154. declare module BABYLON {
  64155. /** @hidden */
  64156. export var mixVertexShader: {
  64157. name: string;
  64158. shader: string;
  64159. };
  64160. }
  64161. declare module BABYLON {
  64162. export class MixMaterial extends BABYLON.PushMaterial {
  64163. /**
  64164. * Mix textures
  64165. */
  64166. private _mixTexture1;
  64167. mixTexture1: BABYLON.BaseTexture;
  64168. private _mixTexture2;
  64169. mixTexture2: BABYLON.BaseTexture;
  64170. /**
  64171. * Diffuse textures
  64172. */
  64173. private _diffuseTexture1;
  64174. diffuseTexture1: BABYLON.Texture;
  64175. private _diffuseTexture2;
  64176. diffuseTexture2: BABYLON.Texture;
  64177. private _diffuseTexture3;
  64178. diffuseTexture3: BABYLON.Texture;
  64179. private _diffuseTexture4;
  64180. diffuseTexture4: BABYLON.Texture;
  64181. private _diffuseTexture5;
  64182. diffuseTexture5: BABYLON.Texture;
  64183. private _diffuseTexture6;
  64184. diffuseTexture6: BABYLON.Texture;
  64185. private _diffuseTexture7;
  64186. diffuseTexture7: BABYLON.Texture;
  64187. private _diffuseTexture8;
  64188. diffuseTexture8: BABYLON.Texture;
  64189. /**
  64190. * Uniforms
  64191. */
  64192. diffuseColor: BABYLON.Color3;
  64193. specularColor: BABYLON.Color3;
  64194. specularPower: number;
  64195. private _disableLighting;
  64196. disableLighting: boolean;
  64197. private _maxSimultaneousLights;
  64198. maxSimultaneousLights: number;
  64199. private _renderId;
  64200. constructor(name: string, scene: BABYLON.Scene);
  64201. needAlphaBlending(): boolean;
  64202. needAlphaTesting(): boolean;
  64203. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64204. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64205. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64206. getAnimatables(): BABYLON.IAnimatable[];
  64207. getActiveTextures(): BABYLON.BaseTexture[];
  64208. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64209. dispose(forceDisposeEffect?: boolean): void;
  64210. clone(name: string): MixMaterial;
  64211. serialize(): any;
  64212. getClassName(): string;
  64213. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  64214. }
  64215. }
  64216. declare module BABYLON {
  64217. /** @hidden */
  64218. export var normalPixelShader: {
  64219. name: string;
  64220. shader: string;
  64221. };
  64222. }
  64223. declare module BABYLON {
  64224. /** @hidden */
  64225. export var normalVertexShader: {
  64226. name: string;
  64227. shader: string;
  64228. };
  64229. }
  64230. declare module BABYLON {
  64231. export class NormalMaterial extends BABYLON.PushMaterial {
  64232. private _diffuseTexture;
  64233. diffuseTexture: BABYLON.BaseTexture;
  64234. diffuseColor: BABYLON.Color3;
  64235. private _disableLighting;
  64236. disableLighting: boolean;
  64237. private _maxSimultaneousLights;
  64238. maxSimultaneousLights: number;
  64239. private _renderId;
  64240. constructor(name: string, scene: BABYLON.Scene);
  64241. needAlphaBlending(): boolean;
  64242. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64243. needAlphaTesting(): boolean;
  64244. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64245. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64246. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64247. getAnimatables(): BABYLON.IAnimatable[];
  64248. getActiveTextures(): BABYLON.BaseTexture[];
  64249. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64250. dispose(forceDisposeEffect?: boolean): void;
  64251. clone(name: string): NormalMaterial;
  64252. serialize(): any;
  64253. getClassName(): string;
  64254. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  64255. }
  64256. }
  64257. declare module BABYLON {
  64258. /** @hidden */
  64259. export var shadowOnlyPixelShader: {
  64260. name: string;
  64261. shader: string;
  64262. };
  64263. }
  64264. declare module BABYLON {
  64265. /** @hidden */
  64266. export var shadowOnlyVertexShader: {
  64267. name: string;
  64268. shader: string;
  64269. };
  64270. }
  64271. declare module BABYLON {
  64272. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  64273. private _renderId;
  64274. private _activeLight;
  64275. constructor(name: string, scene: BABYLON.Scene);
  64276. shadowColor: BABYLON.Color3;
  64277. needAlphaBlending(): boolean;
  64278. needAlphaTesting(): boolean;
  64279. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64280. activeLight: BABYLON.IShadowLight;
  64281. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64282. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64283. clone(name: string): ShadowOnlyMaterial;
  64284. serialize(): any;
  64285. getClassName(): string;
  64286. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  64287. }
  64288. }
  64289. declare module BABYLON {
  64290. /** @hidden */
  64291. export var simplePixelShader: {
  64292. name: string;
  64293. shader: string;
  64294. };
  64295. }
  64296. declare module BABYLON {
  64297. /** @hidden */
  64298. export var simpleVertexShader: {
  64299. name: string;
  64300. shader: string;
  64301. };
  64302. }
  64303. declare module BABYLON {
  64304. export class SimpleMaterial extends BABYLON.PushMaterial {
  64305. private _diffuseTexture;
  64306. diffuseTexture: BABYLON.BaseTexture;
  64307. diffuseColor: BABYLON.Color3;
  64308. private _disableLighting;
  64309. disableLighting: boolean;
  64310. private _maxSimultaneousLights;
  64311. maxSimultaneousLights: number;
  64312. private _renderId;
  64313. constructor(name: string, scene: BABYLON.Scene);
  64314. needAlphaBlending(): boolean;
  64315. needAlphaTesting(): boolean;
  64316. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64317. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64318. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64319. getAnimatables(): BABYLON.IAnimatable[];
  64320. getActiveTextures(): BABYLON.BaseTexture[];
  64321. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64322. dispose(forceDisposeEffect?: boolean): void;
  64323. clone(name: string): SimpleMaterial;
  64324. serialize(): any;
  64325. getClassName(): string;
  64326. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  64327. }
  64328. }
  64329. declare module BABYLON {
  64330. /** @hidden */
  64331. export var skyPixelShader: {
  64332. name: string;
  64333. shader: string;
  64334. };
  64335. }
  64336. declare module BABYLON {
  64337. /** @hidden */
  64338. export var skyVertexShader: {
  64339. name: string;
  64340. shader: string;
  64341. };
  64342. }
  64343. declare module BABYLON {
  64344. /**
  64345. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  64346. * @see https://doc.babylonjs.com/extensions/sky
  64347. */
  64348. export class SkyMaterial extends BABYLON.PushMaterial {
  64349. /**
  64350. * Defines the overall luminance of sky in interval ]0, 1[.
  64351. */
  64352. luminance: number;
  64353. /**
  64354. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  64355. */
  64356. turbidity: number;
  64357. /**
  64358. * Defines the sky appearance (light intensity).
  64359. */
  64360. rayleigh: number;
  64361. /**
  64362. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  64363. */
  64364. mieCoefficient: number;
  64365. /**
  64366. * Defines the amount of haze particles following the Mie scattering theory.
  64367. */
  64368. mieDirectionalG: number;
  64369. /**
  64370. * Defines the distance of the sun according to the active scene camera.
  64371. */
  64372. distance: number;
  64373. /**
  64374. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  64375. * "inclined".
  64376. */
  64377. inclination: number;
  64378. /**
  64379. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  64380. * an object direction and a reference direction.
  64381. */
  64382. azimuth: number;
  64383. /**
  64384. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  64385. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  64386. */
  64387. sunPosition: BABYLON.Vector3;
  64388. /**
  64389. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  64390. * .sunPosition property.
  64391. */
  64392. useSunPosition: boolean;
  64393. /**
  64394. * Defines an offset vector used to get a horizon offset.
  64395. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  64396. */
  64397. cameraOffset: BABYLON.Vector3;
  64398. private _cameraPosition;
  64399. private _renderId;
  64400. /**
  64401. * Instantiates a new sky material.
  64402. * This material allows to create dynamic and texture free
  64403. * effects for skyboxes by taking care of the atmosphere state.
  64404. * @see https://doc.babylonjs.com/extensions/sky
  64405. * @param name Define the name of the material in the scene
  64406. * @param scene Define the scene the material belong to
  64407. */
  64408. constructor(name: string, scene: BABYLON.Scene);
  64409. /**
  64410. * Specifies if the material will require alpha blending
  64411. * @returns a boolean specifying if alpha blending is needed
  64412. */
  64413. needAlphaBlending(): boolean;
  64414. /**
  64415. * Specifies if this material should be rendered in alpha test mode
  64416. * @returns false as the sky material doesn't need alpha testing.
  64417. */
  64418. needAlphaTesting(): boolean;
  64419. /**
  64420. * Get the texture used for alpha test purpose.
  64421. * @returns null as the sky material has no texture.
  64422. */
  64423. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64424. /**
  64425. * Get if the submesh is ready to be used and all its information available.
  64426. * Child classes can use it to update shaders
  64427. * @param mesh defines the mesh to check
  64428. * @param subMesh defines which submesh to check
  64429. * @param useInstances specifies that instances should be used
  64430. * @returns a boolean indicating that the submesh is ready or not
  64431. */
  64432. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64433. /**
  64434. * Binds the submesh to this material by preparing the effect and shader to draw
  64435. * @param world defines the world transformation matrix
  64436. * @param mesh defines the mesh containing the submesh
  64437. * @param subMesh defines the submesh to bind the material to
  64438. */
  64439. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64440. /**
  64441. * Get the list of animatables in the material.
  64442. * @returns the list of animatables object used in the material
  64443. */
  64444. getAnimatables(): BABYLON.IAnimatable[];
  64445. /**
  64446. * Disposes the material
  64447. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64448. */
  64449. dispose(forceDisposeEffect?: boolean): void;
  64450. /**
  64451. * Makes a duplicate of the material, and gives it a new name
  64452. * @param name defines the new name for the duplicated material
  64453. * @returns the cloned material
  64454. */
  64455. clone(name: string): SkyMaterial;
  64456. /**
  64457. * Serializes this material in a JSON representation
  64458. * @returns the serialized material object
  64459. */
  64460. serialize(): any;
  64461. /**
  64462. * Gets the current class name of the material e.g. "SkyMaterial"
  64463. * Mainly use in serialization.
  64464. * @returns the class name
  64465. */
  64466. getClassName(): string;
  64467. /**
  64468. * Creates a sky material from parsed material data
  64469. * @param source defines the JSON representation of the material
  64470. * @param scene defines the hosting scene
  64471. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64472. * @returns a new sky material
  64473. */
  64474. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64475. }
  64476. }
  64477. declare module BABYLON {
  64478. /** @hidden */
  64479. export var terrainPixelShader: {
  64480. name: string;
  64481. shader: string;
  64482. };
  64483. }
  64484. declare module BABYLON {
  64485. /** @hidden */
  64486. export var terrainVertexShader: {
  64487. name: string;
  64488. shader: string;
  64489. };
  64490. }
  64491. declare module BABYLON {
  64492. export class TerrainMaterial extends BABYLON.PushMaterial {
  64493. private _mixTexture;
  64494. mixTexture: BABYLON.BaseTexture;
  64495. private _diffuseTexture1;
  64496. diffuseTexture1: BABYLON.Texture;
  64497. private _diffuseTexture2;
  64498. diffuseTexture2: BABYLON.Texture;
  64499. private _diffuseTexture3;
  64500. diffuseTexture3: BABYLON.Texture;
  64501. private _bumpTexture1;
  64502. bumpTexture1: BABYLON.Texture;
  64503. private _bumpTexture2;
  64504. bumpTexture2: BABYLON.Texture;
  64505. private _bumpTexture3;
  64506. bumpTexture3: BABYLON.Texture;
  64507. diffuseColor: BABYLON.Color3;
  64508. specularColor: BABYLON.Color3;
  64509. specularPower: number;
  64510. private _disableLighting;
  64511. disableLighting: boolean;
  64512. private _maxSimultaneousLights;
  64513. maxSimultaneousLights: number;
  64514. private _renderId;
  64515. constructor(name: string, scene: BABYLON.Scene);
  64516. needAlphaBlending(): boolean;
  64517. needAlphaTesting(): boolean;
  64518. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64519. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64520. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64521. getAnimatables(): BABYLON.IAnimatable[];
  64522. getActiveTextures(): BABYLON.BaseTexture[];
  64523. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64524. dispose(forceDisposeEffect?: boolean): void;
  64525. clone(name: string): TerrainMaterial;
  64526. serialize(): any;
  64527. getClassName(): string;
  64528. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64529. }
  64530. }
  64531. declare module BABYLON {
  64532. /** @hidden */
  64533. export var triplanarPixelShader: {
  64534. name: string;
  64535. shader: string;
  64536. };
  64537. }
  64538. declare module BABYLON {
  64539. /** @hidden */
  64540. export var triplanarVertexShader: {
  64541. name: string;
  64542. shader: string;
  64543. };
  64544. }
  64545. declare module BABYLON {
  64546. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64547. mixTexture: BABYLON.BaseTexture;
  64548. private _diffuseTextureX;
  64549. diffuseTextureX: BABYLON.BaseTexture;
  64550. private _diffuseTextureY;
  64551. diffuseTextureY: BABYLON.BaseTexture;
  64552. private _diffuseTextureZ;
  64553. diffuseTextureZ: BABYLON.BaseTexture;
  64554. private _normalTextureX;
  64555. normalTextureX: BABYLON.BaseTexture;
  64556. private _normalTextureY;
  64557. normalTextureY: BABYLON.BaseTexture;
  64558. private _normalTextureZ;
  64559. normalTextureZ: BABYLON.BaseTexture;
  64560. tileSize: number;
  64561. diffuseColor: BABYLON.Color3;
  64562. specularColor: BABYLON.Color3;
  64563. specularPower: number;
  64564. private _disableLighting;
  64565. disableLighting: boolean;
  64566. private _maxSimultaneousLights;
  64567. maxSimultaneousLights: number;
  64568. private _renderId;
  64569. constructor(name: string, scene: BABYLON.Scene);
  64570. needAlphaBlending(): boolean;
  64571. needAlphaTesting(): boolean;
  64572. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64573. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64574. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64575. getAnimatables(): BABYLON.IAnimatable[];
  64576. getActiveTextures(): BABYLON.BaseTexture[];
  64577. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64578. dispose(forceDisposeEffect?: boolean): void;
  64579. clone(name: string): TriPlanarMaterial;
  64580. serialize(): any;
  64581. getClassName(): string;
  64582. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64583. }
  64584. }
  64585. declare module BABYLON {
  64586. /** @hidden */
  64587. export var waterPixelShader: {
  64588. name: string;
  64589. shader: string;
  64590. };
  64591. }
  64592. declare module BABYLON {
  64593. /** @hidden */
  64594. export var waterVertexShader: {
  64595. name: string;
  64596. shader: string;
  64597. };
  64598. }
  64599. declare module BABYLON {
  64600. export class WaterMaterial extends BABYLON.PushMaterial {
  64601. renderTargetSize: BABYLON.Vector2;
  64602. private _bumpTexture;
  64603. bumpTexture: BABYLON.BaseTexture;
  64604. diffuseColor: BABYLON.Color3;
  64605. specularColor: BABYLON.Color3;
  64606. specularPower: number;
  64607. private _disableLighting;
  64608. disableLighting: boolean;
  64609. private _maxSimultaneousLights;
  64610. maxSimultaneousLights: number;
  64611. /**
  64612. * @param {number}: Represents the wind force
  64613. */
  64614. windForce: number;
  64615. /**
  64616. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64617. */
  64618. windDirection: BABYLON.Vector2;
  64619. /**
  64620. * @param {number}: Wave height, represents the height of the waves
  64621. */
  64622. waveHeight: number;
  64623. /**
  64624. * @param {number}: Bump height, represents the bump height related to the bump map
  64625. */
  64626. bumpHeight: number;
  64627. /**
  64628. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64629. */
  64630. private _bumpSuperimpose;
  64631. bumpSuperimpose: boolean;
  64632. /**
  64633. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64634. */
  64635. private _fresnelSeparate;
  64636. fresnelSeparate: boolean;
  64637. /**
  64638. * @param {boolean}: bump Waves modify the reflection.
  64639. */
  64640. private _bumpAffectsReflection;
  64641. bumpAffectsReflection: boolean;
  64642. /**
  64643. * @param {number}: The water color blended with the refraction (near)
  64644. */
  64645. waterColor: BABYLON.Color3;
  64646. /**
  64647. * @param {number}: The blend factor related to the water color
  64648. */
  64649. colorBlendFactor: number;
  64650. /**
  64651. * @param {number}: The water color blended with the reflection (far)
  64652. */
  64653. waterColor2: BABYLON.Color3;
  64654. /**
  64655. * @param {number}: The blend factor related to the water color (reflection, far)
  64656. */
  64657. colorBlendFactor2: number;
  64658. /**
  64659. * @param {number}: Represents the maximum length of a wave
  64660. */
  64661. waveLength: number;
  64662. /**
  64663. * @param {number}: Defines the waves speed
  64664. */
  64665. waveSpeed: number;
  64666. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64667. private _mesh;
  64668. private _refractionRTT;
  64669. private _reflectionRTT;
  64670. private _reflectionTransform;
  64671. private _lastTime;
  64672. private _lastDeltaTime;
  64673. private _renderId;
  64674. private _useLogarithmicDepth;
  64675. private _waitingRenderList;
  64676. /**
  64677. * Gets a boolean indicating that current material needs to register RTT
  64678. */
  64679. readonly hasRenderTargetTextures: boolean;
  64680. /**
  64681. * Constructor
  64682. */
  64683. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64684. useLogarithmicDepth: boolean;
  64685. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64686. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64687. addToRenderList(node: any): void;
  64688. enableRenderTargets(enable: boolean): void;
  64689. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64690. readonly renderTargetsEnabled: boolean;
  64691. needAlphaBlending(): boolean;
  64692. needAlphaTesting(): boolean;
  64693. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64694. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64695. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64696. private _createRenderTargets;
  64697. getAnimatables(): BABYLON.IAnimatable[];
  64698. getActiveTextures(): BABYLON.BaseTexture[];
  64699. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64700. dispose(forceDisposeEffect?: boolean): void;
  64701. clone(name: string): WaterMaterial;
  64702. serialize(): any;
  64703. getClassName(): string;
  64704. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64705. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64706. }
  64707. }
  64708. declare module BABYLON {
  64709. /** @hidden */
  64710. export var asciiartPixelShader: {
  64711. name: string;
  64712. shader: string;
  64713. };
  64714. }
  64715. declare module BABYLON {
  64716. /**
  64717. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64718. *
  64719. * It basically takes care rendering the font front the given font size to a texture.
  64720. * This is used later on in the postprocess.
  64721. */
  64722. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64723. private _font;
  64724. private _text;
  64725. private _charSize;
  64726. /**
  64727. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64728. */
  64729. readonly charSize: number;
  64730. /**
  64731. * Create a new instance of the Ascii Art FontTexture class
  64732. * @param name the name of the texture
  64733. * @param font the font to use, use the W3C CSS notation
  64734. * @param text the caracter set to use in the rendering.
  64735. * @param scene the scene that owns the texture
  64736. */
  64737. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64738. /**
  64739. * Gets the max char width of a font.
  64740. * @param font the font to use, use the W3C CSS notation
  64741. * @return the max char width
  64742. */
  64743. private getFontWidth;
  64744. /**
  64745. * Gets the max char height of a font.
  64746. * @param font the font to use, use the W3C CSS notation
  64747. * @return the max char height
  64748. */
  64749. private getFontHeight;
  64750. /**
  64751. * Clones the current AsciiArtTexture.
  64752. * @return the clone of the texture.
  64753. */
  64754. clone(): AsciiArtFontTexture;
  64755. /**
  64756. * Parses a json object representing the texture and returns an instance of it.
  64757. * @param source the source JSON representation
  64758. * @param scene the scene to create the texture for
  64759. * @return the parsed texture
  64760. */
  64761. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64762. }
  64763. /**
  64764. * Option available in the Ascii Art Post Process.
  64765. */
  64766. export interface IAsciiArtPostProcessOptions {
  64767. /**
  64768. * The font to use following the w3c font definition.
  64769. */
  64770. font?: string;
  64771. /**
  64772. * The character set to use in the postprocess.
  64773. */
  64774. characterSet?: string;
  64775. /**
  64776. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64777. * This number is defined between 0 and 1;
  64778. */
  64779. mixToTile?: number;
  64780. /**
  64781. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64782. * This number is defined between 0 and 1;
  64783. */
  64784. mixToNormal?: number;
  64785. }
  64786. /**
  64787. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64788. *
  64789. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64790. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64791. */
  64792. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64793. /**
  64794. * The font texture used to render the char in the post process.
  64795. */
  64796. private _asciiArtFontTexture;
  64797. /**
  64798. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64799. * This number is defined between 0 and 1;
  64800. */
  64801. mixToTile: number;
  64802. /**
  64803. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64804. * This number is defined between 0 and 1;
  64805. */
  64806. mixToNormal: number;
  64807. /**
  64808. * Instantiates a new Ascii Art Post Process.
  64809. * @param name the name to give to the postprocess
  64810. * @camera the camera to apply the post process to.
  64811. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64812. */
  64813. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64814. }
  64815. }
  64816. declare module BABYLON {
  64817. /** @hidden */
  64818. export var digitalrainPixelShader: {
  64819. name: string;
  64820. shader: string;
  64821. };
  64822. }
  64823. declare module BABYLON {
  64824. /**
  64825. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64826. *
  64827. * It basically takes care rendering the font front the given font size to a texture.
  64828. * This is used later on in the postprocess.
  64829. */
  64830. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64831. private _font;
  64832. private _text;
  64833. private _charSize;
  64834. /**
  64835. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64836. */
  64837. readonly charSize: number;
  64838. /**
  64839. * Create a new instance of the Digital Rain FontTexture class
  64840. * @param name the name of the texture
  64841. * @param font the font to use, use the W3C CSS notation
  64842. * @param text the caracter set to use in the rendering.
  64843. * @param scene the scene that owns the texture
  64844. */
  64845. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64846. /**
  64847. * Gets the max char width of a font.
  64848. * @param font the font to use, use the W3C CSS notation
  64849. * @return the max char width
  64850. */
  64851. private getFontWidth;
  64852. /**
  64853. * Gets the max char height of a font.
  64854. * @param font the font to use, use the W3C CSS notation
  64855. * @return the max char height
  64856. */
  64857. private getFontHeight;
  64858. /**
  64859. * Clones the current DigitalRainFontTexture.
  64860. * @return the clone of the texture.
  64861. */
  64862. clone(): DigitalRainFontTexture;
  64863. /**
  64864. * Parses a json object representing the texture and returns an instance of it.
  64865. * @param source the source JSON representation
  64866. * @param scene the scene to create the texture for
  64867. * @return the parsed texture
  64868. */
  64869. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64870. }
  64871. /**
  64872. * Option available in the Digital Rain Post Process.
  64873. */
  64874. export interface IDigitalRainPostProcessOptions {
  64875. /**
  64876. * The font to use following the w3c font definition.
  64877. */
  64878. font?: string;
  64879. /**
  64880. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64881. * This number is defined between 0 and 1;
  64882. */
  64883. mixToTile?: number;
  64884. /**
  64885. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64886. * This number is defined between 0 and 1;
  64887. */
  64888. mixToNormal?: number;
  64889. }
  64890. /**
  64891. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64892. *
  64893. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64894. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64895. */
  64896. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64897. /**
  64898. * The font texture used to render the char in the post process.
  64899. */
  64900. private _digitalRainFontTexture;
  64901. /**
  64902. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64903. * This number is defined between 0 and 1;
  64904. */
  64905. mixToTile: number;
  64906. /**
  64907. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64908. * This number is defined between 0 and 1;
  64909. */
  64910. mixToNormal: number;
  64911. /**
  64912. * Instantiates a new Digital Rain Post Process.
  64913. * @param name the name to give to the postprocess
  64914. * @camera the camera to apply the post process to.
  64915. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64916. */
  64917. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64918. }
  64919. }
  64920. declare module BABYLON {
  64921. /** @hidden */
  64922. export var oceanPostProcessPixelShader: {
  64923. name: string;
  64924. shader: string;
  64925. };
  64926. }
  64927. declare module BABYLON {
  64928. /**
  64929. * Option available in the Ocean Post Process.
  64930. */
  64931. export interface IOceanPostProcessOptions {
  64932. /**
  64933. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64934. */
  64935. reflectionSize?: number | {
  64936. width: number;
  64937. height: number;
  64938. } | {
  64939. ratio: number;
  64940. };
  64941. /**
  64942. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64943. */
  64944. refractionSize?: number | {
  64945. width: number;
  64946. height: number;
  64947. } | {
  64948. ratio: number;
  64949. };
  64950. }
  64951. /**
  64952. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64953. *
  64954. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64955. * Example usage:
  64956. * var pp = new OceanPostProcess("myOcean", camera);
  64957. * pp.reflectionEnabled = true;
  64958. * pp.refractionEnabled = true;
  64959. */
  64960. export class OceanPostProcess extends BABYLON.PostProcess {
  64961. /**
  64962. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64963. */
  64964. /**
  64965. * Sets weither or not the real-time reflection is enabled on the ocean.
  64966. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64967. */
  64968. reflectionEnabled: boolean;
  64969. /**
  64970. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64971. */
  64972. /**
  64973. * Sets weither or not the real-time refraction is enabled on the ocean.
  64974. * Is set to true, the refraction render target texture will be used as refraction texture.
  64975. */
  64976. refractionEnabled: boolean;
  64977. /**
  64978. * Gets wether or not the post-processes is supported by the running hardware.
  64979. * This requires draw buffer supports.
  64980. */
  64981. readonly isSupported: boolean;
  64982. /**
  64983. * This is the reflection mirror texture used to display reflections on the ocean.
  64984. * By default, render list is empty.
  64985. */
  64986. reflectionTexture: BABYLON.MirrorTexture;
  64987. /**
  64988. * This is the refraction render target texture used to display refraction on the ocean.
  64989. * By default, render list is empty.
  64990. */
  64991. refractionTexture: BABYLON.RenderTargetTexture;
  64992. private _time;
  64993. private _cameraRotation;
  64994. private _cameraViewMatrix;
  64995. private _reflectionEnabled;
  64996. private _refractionEnabled;
  64997. private _geometryRenderer;
  64998. /**
  64999. * Instantiates a new Ocean Post Process.
  65000. * @param name the name to give to the postprocess.
  65001. * @camera the camera to apply the post process to.
  65002. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  65003. */
  65004. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  65005. /**
  65006. * Returns the appropriate defines according to the current configuration.
  65007. */
  65008. private _getDefines;
  65009. /**
  65010. * Computes the current camera rotation as the shader requires a camera rotation.
  65011. */
  65012. private _computeCameraRotation;
  65013. }
  65014. }
  65015. declare module BABYLON {
  65016. /** @hidden */
  65017. export var brickProceduralTexturePixelShader: {
  65018. name: string;
  65019. shader: string;
  65020. };
  65021. }
  65022. declare module BABYLON {
  65023. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  65024. private _numberOfBricksHeight;
  65025. private _numberOfBricksWidth;
  65026. private _jointColor;
  65027. private _brickColor;
  65028. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65029. updateShaderUniforms(): void;
  65030. numberOfBricksHeight: number;
  65031. numberOfBricksWidth: number;
  65032. jointColor: BABYLON.Color3;
  65033. brickColor: BABYLON.Color3;
  65034. /**
  65035. * Serializes this brick procedural texture
  65036. * @returns a serialized brick procedural texture object
  65037. */
  65038. serialize(): any;
  65039. /**
  65040. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  65041. * @param parsedTexture defines parsed texture data
  65042. * @param scene defines the current scene
  65043. * @param rootUrl defines the root URL containing brick procedural texture information
  65044. * @returns a parsed Brick Procedural BABYLON.Texture
  65045. */
  65046. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  65047. }
  65048. }
  65049. declare module BABYLON {
  65050. /** @hidden */
  65051. export var cloudProceduralTexturePixelShader: {
  65052. name: string;
  65053. shader: string;
  65054. };
  65055. }
  65056. declare module BABYLON {
  65057. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  65058. private _skyColor;
  65059. private _cloudColor;
  65060. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65061. updateShaderUniforms(): void;
  65062. skyColor: BABYLON.Color4;
  65063. cloudColor: BABYLON.Color4;
  65064. /**
  65065. * Serializes this cloud procedural texture
  65066. * @returns a serialized cloud procedural texture object
  65067. */
  65068. serialize(): any;
  65069. /**
  65070. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  65071. * @param parsedTexture defines parsed texture data
  65072. * @param scene defines the current scene
  65073. * @param rootUrl defines the root URL containing cloud procedural texture information
  65074. * @returns a parsed Cloud Procedural BABYLON.Texture
  65075. */
  65076. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  65077. }
  65078. }
  65079. declare module BABYLON {
  65080. /** @hidden */
  65081. export var fireProceduralTexturePixelShader: {
  65082. name: string;
  65083. shader: string;
  65084. };
  65085. }
  65086. declare module BABYLON {
  65087. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  65088. private _time;
  65089. private _speed;
  65090. private _autoGenerateTime;
  65091. private _fireColors;
  65092. private _alphaThreshold;
  65093. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65094. updateShaderUniforms(): void;
  65095. render(useCameraPostProcess?: boolean): void;
  65096. static readonly PurpleFireColors: BABYLON.Color3[];
  65097. static readonly GreenFireColors: BABYLON.Color3[];
  65098. static readonly RedFireColors: BABYLON.Color3[];
  65099. static readonly BlueFireColors: BABYLON.Color3[];
  65100. autoGenerateTime: boolean;
  65101. fireColors: BABYLON.Color3[];
  65102. time: number;
  65103. speed: BABYLON.Vector2;
  65104. alphaThreshold: number;
  65105. /**
  65106. * Serializes this fire procedural texture
  65107. * @returns a serialized fire procedural texture object
  65108. */
  65109. serialize(): any;
  65110. /**
  65111. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  65112. * @param parsedTexture defines parsed texture data
  65113. * @param scene defines the current scene
  65114. * @param rootUrl defines the root URL containing fire procedural texture information
  65115. * @returns a parsed Fire Procedural BABYLON.Texture
  65116. */
  65117. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  65118. }
  65119. }
  65120. declare module BABYLON {
  65121. /** @hidden */
  65122. export var grassProceduralTexturePixelShader: {
  65123. name: string;
  65124. shader: string;
  65125. };
  65126. }
  65127. declare module BABYLON {
  65128. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  65129. private _grassColors;
  65130. private _groundColor;
  65131. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65132. updateShaderUniforms(): void;
  65133. grassColors: BABYLON.Color3[];
  65134. groundColor: BABYLON.Color3;
  65135. /**
  65136. * Serializes this grass procedural texture
  65137. * @returns a serialized grass procedural texture object
  65138. */
  65139. serialize(): any;
  65140. /**
  65141. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  65142. * @param parsedTexture defines parsed texture data
  65143. * @param scene defines the current scene
  65144. * @param rootUrl defines the root URL containing grass procedural texture information
  65145. * @returns a parsed Grass Procedural BABYLON.Texture
  65146. */
  65147. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  65148. }
  65149. }
  65150. declare module BABYLON {
  65151. /** @hidden */
  65152. export var marbleProceduralTexturePixelShader: {
  65153. name: string;
  65154. shader: string;
  65155. };
  65156. }
  65157. declare module BABYLON {
  65158. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  65159. private _numberOfTilesHeight;
  65160. private _numberOfTilesWidth;
  65161. private _amplitude;
  65162. private _jointColor;
  65163. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65164. updateShaderUniforms(): void;
  65165. numberOfTilesHeight: number;
  65166. amplitude: number;
  65167. numberOfTilesWidth: number;
  65168. jointColor: BABYLON.Color3;
  65169. /**
  65170. * Serializes this marble procedural texture
  65171. * @returns a serialized marble procedural texture object
  65172. */
  65173. serialize(): any;
  65174. /**
  65175. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  65176. * @param parsedTexture defines parsed texture data
  65177. * @param scene defines the current scene
  65178. * @param rootUrl defines the root URL containing marble procedural texture information
  65179. * @returns a parsed Marble Procedural BABYLON.Texture
  65180. */
  65181. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  65182. }
  65183. }
  65184. declare module BABYLON {
  65185. /** @hidden */
  65186. export var normalMapProceduralTexturePixelShader: {
  65187. name: string;
  65188. shader: string;
  65189. };
  65190. }
  65191. declare module BABYLON {
  65192. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  65193. private _baseTexture;
  65194. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65195. updateShaderUniforms(): void;
  65196. render(useCameraPostProcess?: boolean): void;
  65197. resize(size: any, generateMipMaps: any): void;
  65198. baseTexture: BABYLON.Texture;
  65199. /**
  65200. * Serializes this normal map procedural texture
  65201. * @returns a serialized normal map procedural texture object
  65202. */
  65203. serialize(): any;
  65204. /**
  65205. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  65206. * @param parsedTexture defines parsed texture data
  65207. * @param scene defines the current scene
  65208. * @param rootUrl defines the root URL containing normal map procedural texture information
  65209. * @returns a parsed Normal Map Procedural BABYLON.Texture
  65210. */
  65211. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /** @hidden */
  65216. export var perlinNoiseProceduralTexturePixelShader: {
  65217. name: string;
  65218. shader: string;
  65219. };
  65220. }
  65221. declare module BABYLON {
  65222. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  65223. time: number;
  65224. timeScale: number;
  65225. translationSpeed: number;
  65226. private _currentTranslation;
  65227. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65228. updateShaderUniforms(): void;
  65229. render(useCameraPostProcess?: boolean): void;
  65230. resize(size: any, generateMipMaps: any): void;
  65231. /**
  65232. * Serializes this perlin noise procedural texture
  65233. * @returns a serialized perlin noise procedural texture object
  65234. */
  65235. serialize(): any;
  65236. /**
  65237. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  65238. * @param parsedTexture defines parsed texture data
  65239. * @param scene defines the current scene
  65240. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  65241. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  65242. */
  65243. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  65244. }
  65245. }
  65246. declare module BABYLON {
  65247. /** @hidden */
  65248. export var roadProceduralTexturePixelShader: {
  65249. name: string;
  65250. shader: string;
  65251. };
  65252. }
  65253. declare module BABYLON {
  65254. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  65255. private _roadColor;
  65256. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65257. updateShaderUniforms(): void;
  65258. roadColor: BABYLON.Color3;
  65259. /**
  65260. * Serializes this road procedural texture
  65261. * @returns a serialized road procedural texture object
  65262. */
  65263. serialize(): any;
  65264. /**
  65265. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  65266. * @param parsedTexture defines parsed texture data
  65267. * @param scene defines the current scene
  65268. * @param rootUrl defines the root URL containing road procedural texture information
  65269. * @returns a parsed Road Procedural BABYLON.Texture
  65270. */
  65271. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  65272. }
  65273. }
  65274. declare module BABYLON {
  65275. /** @hidden */
  65276. export var starfieldProceduralTexturePixelShader: {
  65277. name: string;
  65278. shader: string;
  65279. };
  65280. }
  65281. declare module BABYLON {
  65282. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  65283. private _time;
  65284. private _alpha;
  65285. private _beta;
  65286. private _zoom;
  65287. private _formuparam;
  65288. private _stepsize;
  65289. private _tile;
  65290. private _brightness;
  65291. private _darkmatter;
  65292. private _distfading;
  65293. private _saturation;
  65294. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65295. updateShaderUniforms(): void;
  65296. time: number;
  65297. alpha: number;
  65298. beta: number;
  65299. formuparam: number;
  65300. stepsize: number;
  65301. zoom: number;
  65302. tile: number;
  65303. brightness: number;
  65304. darkmatter: number;
  65305. distfading: number;
  65306. saturation: number;
  65307. /**
  65308. * Serializes this starfield procedural texture
  65309. * @returns a serialized starfield procedural texture object
  65310. */
  65311. serialize(): any;
  65312. /**
  65313. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  65314. * @param parsedTexture defines parsed texture data
  65315. * @param scene defines the current scene
  65316. * @param rootUrl defines the root URL containing startfield procedural texture information
  65317. * @returns a parsed Starfield Procedural BABYLON.Texture
  65318. */
  65319. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  65320. }
  65321. }
  65322. declare module BABYLON {
  65323. /** @hidden */
  65324. export var woodProceduralTexturePixelShader: {
  65325. name: string;
  65326. shader: string;
  65327. };
  65328. }
  65329. declare module BABYLON {
  65330. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  65331. private _ampScale;
  65332. private _woodColor;
  65333. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65334. updateShaderUniforms(): void;
  65335. ampScale: number;
  65336. woodColor: BABYLON.Color3;
  65337. /**
  65338. * Serializes this wood procedural texture
  65339. * @returns a serialized wood procedural texture object
  65340. */
  65341. serialize(): any;
  65342. /**
  65343. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  65344. * @param parsedTexture defines parsed texture data
  65345. * @param scene defines the current scene
  65346. * @param rootUrl defines the root URL containing wood procedural texture information
  65347. * @returns a parsed Wood Procedural BABYLON.Texture
  65348. */
  65349. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  65350. }
  65351. }